X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fquerytable%2Fstatic%2Fjs%2Fquerytable.js;h=c22dbd2cbd175e6cce8173f8da6fc617f514e0df;hb=e283fe2eb8fc83942da4c7e5055f0d3969fefa22;hp=3c1aab2ae192ca2a5a573bae7831c065abc775f6;hpb=3b39e97b04f9333fd58978120f00c1b4ffffbc41;p=myslice.git diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 3c1aab2a..c22dbd2c 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -10,14 +10,6 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; (function($){ - - var QUERYTABLE_MAP = { - 'Facility': 'facility_name', - 'Testbed': 'testbed_name', - 'Resource name': 'hostname', - 'Type': 'type', - }; - var debug=false; // debug=true @@ -98,7 +90,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; sPaginationType: 'bootstrap', // Handle the null values & the error : Datatables warning Requested unknown parameter // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2 - aoColumnDefs: [{sDefaultContent: '', aTargets: [ '_all' ]}], + aoColumnDefs: [{sDefaultContent: '', aTargets: [ '_all' ], "sType": "mysort"}], // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty // sScrollX: '100%', /* Horizontal scrolling */ bProcessing: true, /* Loading */ @@ -166,23 +158,37 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; // resource info var sTable = this.table; + var oSettings = this.table.fnSettings(); + var cols = oSettings.aoColumns; + var self = this; $('table.dataTable').delegate('a.resource-info','click',function() { var aPos = sTable.fnGetPosition( this.parentNode ); var aData = sTable.fnGetData( aPos[0] ); - //console.log(aData); - - var network_hrn = aData[18]; + console.log(aData); + + var index = {} + // XXX Loic @ Hardcoded !!! Maybe a loop over all fields would be better + index['network_hrn'] = self.getColIndex('network_hrn',cols); + var network_hrn = aData[index['network_hrn']]; + + index['hostname'] = self.getColIndex('hostname',cols); + index['urn'] = self.getColIndex('urn',cols); + index['type'] = self.getColIndex('type',cols); + //index['status'] = self.getColIndex('boot_state',cols); + index['available'] = self.getColIndex('available',cols); + index['testbed'] = self.getColIndex('testbed_name',cols); + index['facility'] = self.getColIndex('facility_name',cols); var resourceData = { - 'hostname' : strip(aData[2]), - 'urn' : aData[6], - 'type' : aData[3], - 'status' : aData[10], - 'testbed' : aData[4], - 'facility' : aData[5], + 'hostname' : strip(aData[index['hostname']]), + 'urn' : aData[index['urn']], + 'type' : aData[index['type']], + //'status' : aData[index['status']], + 'available' : aData[index['available']], + 'testbed' : aData[index['testbed']], + 'facility' : aData[index['facility']], }; - - console.log(network_hrn); + /* //Greece: 37.6687092,22.2282404 if (network_hrn == 'omf.nitos') { var logo = 'nitos'; @@ -192,24 +198,27 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; }; var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude']; } else if (network_hrn == 'iotlab') { + */ + if (network_hrn == 'iotlab') { var logo = network_hrn; var s = resourceData['hostname'].split("."); var n = s[0].split("-"); resourceData['type'] = 'node ( Hardware: '+n[0]+' )'; var coordinates = resourceData['testbed']; } else { - var logo = network_hrn; + var logo = resourceData['testbed']; var resourceLocation = { - 'longitude' : aData[13], - 'latitude' : aData[23], + 'longitude' : aData[20], + 'latitude' : aData[17], }; var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude']; + console.log(coordinates); } var modal = $('#resource-info-modal'); modal.find('.modal-title').text(resourceData['testbed'] + ': ' +resourceData['hostname']); table = modal.find('.modal-resource-info'); - table.html('