X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fquerytable%2Fstatic%2Fjs%2Fquerytable.js;h=76934e79b49ab90b7c5881e9b843d9f852071f0c;hb=d035a1f93e4acbeee79b7c8200264687d940ccc2;hp=15477a424e645d4b413b367908129f0d2a0b5579;hpb=3a4d4c9c68d6e4fcf6cac26a9d7a78b2bddb89c5;p=myslice.git
diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js
index 15477a42..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
@@ -97,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' ]}],
// 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 */
@@ -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(' |
');
+ 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 = '';
- msg += '- '
+ msg += '
- ';
msg += '⚠';
msg += '