// When document is ready jQuery(document).ready(function() { // Prepare for setup the datatable. var dataTableOptions = { "sAjaxSource": sAjaxSource, "bSort": true, "aaSorting": [[10, 'desc']], "aoColumnDefs": [ { "bSortable": false, "aTargets": [1, 4, 7, 8, 9, 11, 12] }, // turn off sorting { "bVisible": false, "aTargets": [11] }, // turn off visibility { "sClass": "center", "aTargets": [12] } ], "bAutoWidth": false, "aoColumns": [ { "sWidth": "3%"}, // Id { "sWidth": "7%"}, // Server { "sWidth": "4%"}, // Pid { "sWidth": "12%"}, // Queued Time { "sWidth": "25%"}, // Title { "sWidth": "11%"}, // Started At { "sWidth": "11%"}, // Finished At { "sWidth": "7%"}, // Run Time { "sWidth": "12%"}, // Affinities { "sWidth": "8%"}, // Tags { "asSorting": [ "desc" ], "sWidth": "6%" }, // Status null, // Application URL { "sWidth": "6%"} // Actions ], "fnInitComplete" : function() { initPageSelect(); setPageOrder(); }, "fnServerData": function ( sSource, aoData, fnCallback ) { _.each(jQuery('.datatable_variable').serializeArray(), function(dv) { aoData.push(dv); }); jQuery.getJSON( sSource, aoData, function (json) { fnCallback(json); initPaging(); addTitles(); }); }, "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { addLinkToJob(nRow, aData); addLinkToTitle(nRow, aData); alignmentButtons(nRow, aData); colorizationStatus(nRow, aData); checkTimeFormat(nRow, aData); return nRow; }, "sDom": "Rlfrtip" }; // Setup the datatable. jQuery('#datatable').addDataTable(dataTableOptions); // Action: Terminate Job jQuery(document).delegate('.terminate', "click", function(){ var answer = confirm("You are terminating this job. Are you sure you want to do this?"); if (!answer) { return false; } var id = jQuery(this).attr('id'); var url = 'job_system/historical_jobs/' + id; jQuery.ajax({ url: url, type: 'POST', dataType: 'json', data: { "historical_job[request_to_terminate]": 1, "historical_job_id": id, "_method": "put" }, success:function (data) { if (data.success) { var title = data.title ? data.title : data.command jQuery("
A Job " + title + " was terminated!
"). appendTo('#flash_message').slideDown().delay(5000).slideUp(); jQuery('#datatable').dataTable().fnDraw(); } } }); }); jQuery(document).delegate('.re-enqueue', "click", function(){ var url = jQuery(this).attr('content'); var new_params = { data: jQuery(this).attr('data') }; new_params['job_id'] = jQuery(this).attr('id'); if (jQuery(this).attr('app_id')) { new_params['app_id'] = jQuery(this).attr('app_id'); } if (jQuery(this).attr('link')) { new_params['link'] = jQuery(this).attr('link'); } if (jQuery(this).attr('title_name')) { new_params['title_name'] = jQuery(this).attr('title_name'); } var answer = confirm("Would you like to enqueue this job?"); if (!answer) { return false; } jQuery.post(url, new_params, function (data) { if (data.success) { jQuery("Congratulations, a Job " + data.title + " was added!
"). appendTo('#flash_message').slideDown().delay(5000).slideUp(); setTimeout('window.location.reload()', 5600); } else { jQuery("