Sha256: f4560a6bfce2060045d814e646548f14453e4f06d52c7fc51342cbea3308865b

Contents?: true

Size: 1.84 KB

Versions: 5

Compression:

Stored size: 1.84 KB

Contents

// When document is ready
jQuery(document).ready(function() {

  // Prepare for setup the datatable.
  var dataTableOptions = {
    "sAjaxSource": sAjaxSource,
    "bSort": true,
    "aaSorting": [[1, 'desc']],
    "bAutoWidth": false,
    "aoColumns": [
        { "sWidth": "5%"},              // Id
        { "sWidth": "15%"},             // Started At
        { "sWidth": "10%"},             // Machine Runner Id
        { "sWidth": "12%"},             // Server Name
        { "sWidth": "10%"},             // Pid
        { "sWidth": "10%"},             // Status
        { "sWidth": "25%"},             // Latest Commit
        { "sWidth": "10%"},             // Deployment Tag
    ],
    "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 ) {
      colorizationStatus(nRow, aData);
      return nRow;
    }
  };

   // Setup the datatable.
  jQuery('#datatable').addDataTable(dataTableOptions);
});

function setPageOrder(){
  jQuery('#datatable').dataTable().fnSort([ [1,'desc'] ]);
}

// Function that changes the color of the job status
function colorizationStatus(nRow, aData) {
  jQuery('td:nth-child(6)', nRow).wrapInner('<div class="">');
  switch(aData[5]) {
    case 'Running':
      jQuery('td:nth-child(6) div', nRow).addClass('running');
      break;
    case 'Winding Down':
      jQuery('td:nth-child(6) div', nRow).addClass('winding-down');
      break;
    case 'Dead':
      jQuery('td:nth-child(6) div', nRow).addClass('dead');
      break;
  }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
naf-1.1.4 app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js
naf-1.1.3 app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js
naf-1.1.2 app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js
naf-1.1.1 app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js
naf-1.1.0 app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js