GUI -- Cycling through icons in table headers:
- An object is returned that has the current column ID and which icon/sorting needs to take place when sent to the server
- clicking on each header will display to the debug console which way it will be sorted
Change-Id: I686d417a5b9b0e5c9b591380b8a6166c70c3c401
diff --git a/web/gui/src/main/webapp/app/view/device/device.js b/web/gui/src/main/webapp/app/view/device/device.js
index c59944a..b97e9e7 100644
--- a/web/gui/src/main/webapp/app/view/device/device.js
+++ b/web/gui/src/main/webapp/app/view/device/device.js
@@ -15,11 +15,14 @@
*/
/*
- ONOS GUI -- Sample View Module
+ ONOS GUI -- Device View Module
*/
(function () {
'use strict';
+ var currCol = {},
+ prevCol = {};
+
angular.module('ovDevice', [])
.controller('OvDeviceCtrl', ['$log', '$location', 'RestService',
@@ -35,6 +38,31 @@
self.deviceData = data.devices;
});
+ d3.selectAll('th').on('click', function(d) {
+ var thElem = d3.select(this);
+ currCol.colId = thElem.attr('colId');
+
+ if(currCol.colId === prevCol.colId) {
+ (currCol.icon === 'tableColSortDesc') ?
+ currCol.icon = 'tableColSortAsc' :
+ currCol.icon = 'tableColSortDesc';
+ prevCol.icon = currCol.icon;
+ } else {
+ currCol.icon = 'tableColSortAsc';
+ prevCol.icon = 'tableColSortNone';
+ }
+
+ $log.debug('currCol clicked: ' + currCol.colId +
+ ', with sorting icon: ' + currCol.icon);
+ $log.debug('prevCol clicked: ' + prevCol.colId +
+ ', with its current sorting icon as ' + prevCol.icon);
+
+ // TODO: send the prev and currCol info to the server to use in sorting table here
+
+ prevCol.colId = currCol.colId;
+
+ });
+
$log.log('OvDeviceCtrl has been created');
}]);
}());