X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fquerytable%2Fstatic%2Fjs%2Fquerytable.js;h=76934e79b49ab90b7c5881e9b843d9f852071f0c;hb=d035a1f93e4acbeee79b7c8200264687d940ccc2;hp=4b9e5461a51a89c81c1f0e6819e4f2a42675a797;hpb=e05236fa7fc990e54389b6255c5f9232c9260159;p=myslice.git diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 4b9e5461..76934e79 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -10,13 +10,6 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; (function($){ - - var QUERYTABLE_MAP = { - 'Testbed': 'network_hrn', - 'Resource name': 'hostname', - 'Type': 'type', - }; - var debug=false; // debug=true @@ -162,6 +155,79 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; }); $(".dataTables_filter").append("
"); $(".dataTables_filter input").css("width","100%"); + + // 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 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[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']], + }; + + /* + //Greece: 37.6687092,22.2282404 + if (network_hrn == 'omf.nitos') { + var logo = 'nitos'; + var resourceLocation = { + 'longitude' : '22.2282404', + 'latitude' : '37.6687092', + }; + 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 = resourceData['testbed']; + var resourceLocation = { + '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('
'+resourceData['facility']+' - '+resourceData['testbed']+'
'); + for (var j in resourceData) { + table.append('' + j + '' + resourceData[j] + ''); + } + if (coordinates != '') { + table.append(''); + } + modal.modal(); + }); + }, // initialize_table /** @@ -231,7 +297,8 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; //TODO: we need to add source/destination for links line.push(''); else - line.push(record['hostname']); + //line.push(record['hostname']); + line.push('' + record['hostname'] + ''); } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') { obj = this.object @@ -336,7 +403,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; } } else { msg = '