From d0c6d7729c79f7761c2f8b5aa8a967490aecf92e Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Fri, 19 Dec 2014 20:16:07 +0100 Subject: [PATCH] Popup resource info: fields orderd by name index retrieved by getColIndex function --- plugins/querytable/static/js/querytable.js | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 7e72f2ae..ab208109 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -158,19 +158,32 @@ 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]; + + 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['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']], + 'testbed' : aData[index['testbed']], + 'facility' : aData[index['facility']], }; /* -- 2.43.0