ONOS-1783 - GUI -- Refresh buttons for tabular views added. Minor table.js refactor.

Change-Id: Iee6c65fa8477b367e40a556c3c820ca454601a5f
This commit is contained in:
Bri Prebilic Cole 2015-04-30 13:48:36 -07:00 committed by Gerrit Code Review
parent 35fa3d4169
commit 3d4d01cb74
25 changed files with 288 additions and 134 deletions

View File

@ -24,3 +24,63 @@
padding-top: 20px; padding-top: 20px;
padding-bottom: 20px; padding-bottom: 20px;
} }
/* Tabular view upper right control buttons */
div.ctrl-btns {
display: inline-block;
float: right;
height: 44px;
margin-right: 24px;
margin-top: 7px;
}
div.ctrl-btns div {
display: inline-block;
padding: 4px;
cursor: pointer;
}
/* Inactive */
.light .ctrl-btns div g.icon rect,
.light .ctrl-btns div:hover g.icon rect {
fill: #eee;
}
.dark .ctrl-btns div g.icon rect,
.dark .ctrl-btns div:hover g.icon rect {
fill: #222;
}
.light .ctrl-btns div g.icon use {
fill: #ddd;
}
.dark .ctrl-btns div g.icon use {
fill: #333;
}
/* Active hover */
.light .ctrl-btns div.active:hover g.icon rect {
fill: #800;
}
.dark .ctrl-btns div.active:hover g.icon rect {
fill: #CE5650;
}
/* Active */
.light .ctrl-btns div.active g.icon use {
fill: #fff;
}
.dark .ctrl-btns div.active g.icon use {
fill: #eee;
}
.light .ctrl-btns div.active g.icon rect {
fill: #bbb;
}
.dark .ctrl-btns div.active g.icon rect {
fill: #444;
}

View File

@ -37,6 +37,8 @@
play: 'play', play: 'play',
stop: 'stop', stop: 'stop',
crown: 'crown',
upArrow: 'triangleUp', upArrow: 'triangleUp',
downArrow: 'triangleDown', downArrow: 'triangleDown',
@ -191,7 +193,7 @@
return g; return g;
} }
function createSortIcon() { function sortIcons() {
function sortAsc(div) { function sortAsc(div) {
div.style('display', 'inline-block'); div.style('display', 'inline-block');
loadEmbeddedIcon(div, 'upArrow', 10); loadEmbeddedIcon(div, 'upArrow', 10);
@ -236,7 +238,7 @@
addDeviceIcon: addDeviceIcon, addDeviceIcon: addDeviceIcon,
addHostIcon: addHostIcon, addHostIcon: addHostIcon,
iconConfig: function () { return config; }, iconConfig: function () { return config; },
createSortIcon: createSortIcon sortIcons: sortIcons
}; };
}]); }]);

View File

@ -27,11 +27,15 @@
var tableIconTdSize = 33, var tableIconTdSize = 33,
pdg = 12, pdg = 12,
colWidth = 'col-width', colWidth = 'col-width',
tableIcon = 'table-icon'; tableIcon = 'table-icon',
asc = 'asc',
desc = 'desc',
none = 'none';
// internal state // internal state
var currCol = {}, var currCol = {},
prevCol = {}; prevCol = {},
sortIconAPI;
// Functions for creating a fixed header on a table (Angular Directive) // Functions for creating a fixed header on a table (Angular Directive)
@ -115,48 +119,49 @@
setTableHeight(th, tb); setTableHeight(th, tb);
} }
// Functions for sorting table rows by header and choosing appropriate icon // Functions for sorting table rows by header
function updateSortingIcons(thElem, api) { function updateSortDirection(thElem) {
var div; sortIconAPI.sortNone(thElem.select('div'));
currCol.div = thElem.append('div');
currCol.colId = thElem.attr('colId'); currCol.colId = thElem.attr('colId');
if (currCol.colId === prevCol.colId) { if (currCol.colId === prevCol.colId) {
(currCol.icon === 'downArrow') ? (currCol.dir === desc) ? currCol.dir = asc : currCol.dir = desc;
currCol.icon = 'upArrow' : prevCol.dir = currCol.dir;
currCol.icon = 'downArrow';
prevCol.icon = currCol.icon;
} else { } else {
currCol.icon = 'upArrow'; currCol.dir = asc;
prevCol.icon = 'tableColSortNone'; prevCol.dir = none;
} }
(currCol.dir === asc) ?
sortIconAPI.sortAsc(currCol.div) : sortIconAPI.sortDesc(currCol.div);
div = thElem.select('div'); if (prevCol.colId && prevCol.dir === none) {
api.sortNone(div); sortIconAPI.sortNone(prevCol.div);
div = thElem.append('div');
if (currCol.icon === 'upArrow') {
api.sortAsc(div);
} else {
api.sortDesc(div);
}
if (prevCol.colId !== undefined &&
prevCol.icon === 'tableColSortNone') {
api.sortNone(prevCol.elem.select('div'));
} }
prevCol.colId = currCol.colId; prevCol.colId = currCol.colId;
prevCol.elem = thElem; prevCol.div = currCol.div;
} }
function sortRequestParams() { function sortRequestParams() {
return { return {
sortCol: currCol.colId, sortCol: currCol.colId,
sortDir: (currCol.icon === 'upArrow' ? 'asc' : 'desc') sortDir: currCol.dir
}; };
} }
function resetSortIcons() {
if (currCol.div) {
sortIconAPI.sortNone(currCol.div);
}
if (prevCol.div) {
sortIconAPI.sortNone(prevCol.div);
}
currCol = {};
prevCol = {};
}
angular.module('onosWidget') angular.module('onosWidget')
.directive('onosFixedHeader', ['$window', 'FnService', 'MastService', .directive('onosFixedHeader', ['$window', 'FnService', 'MastService',
function (_$window_, _fs_, _mast_) { function (_$window_, _fs_, _mast_) {
@ -210,8 +215,8 @@
link: function (scope, element) { link: function (scope, element) {
$log = _$log_; $log = _$log_;
is = _is_; is = _is_;
var table = d3.select(element[0]), var table = d3.select(element[0]);
sortIconAPI = is.createSortIcon(); sortIconAPI = is.sortIcons();
// when a header is clicked, change its icon tag // when a header is clicked, change its icon tag
// and get sorting order to send to the server. // and get sorting order to send to the server.
@ -219,7 +224,7 @@
var thElem = d3.select(this); var thElem = d3.select(this);
if (thElem.attr('sortable') === '') { if (thElem.attr('sortable') === '') {
updateSortingIcons(thElem, sortIconAPI); updateSortDirection(thElem);
scope.ctrlCallback({ scope.ctrlCallback({
requestParams: sortRequestParams() requestParams: sortRequestParams()
}); });
@ -227,6 +232,16 @@
}); });
} }
}; };
}])
.factory('TableService', ['$log', 'IconService',
function ($log, is) {
sortIconAPI = is.sortIcons();
return {
resetSortIcons: resetSortIcons
};
}]); }]);
}()); }());

View File

@ -23,59 +23,11 @@
} }
#ov-app div.ctrl-btns { #ov-app div.ctrl-btns {
display:inline-block; width: 290px;
float: right;
width: 200px;
height: 44px;
margin-right: 24px;
margin-top: 7px;
} }
div.ctrl-btns div { #ov-app div.ctrl-btns div.separator {
display: inline-block; cursor: auto;
padding: 4px; width: 24px;
cursor: pointer; border: none;
} }
/* Inactive */
.light .ctrl-btns div g.icon rect,
.light .ctrl-btns div:hover g.icon rect {
fill: #eee;
}
.dark .ctrl-btns div g.icon rect,
.dark .ctrl-btns div:hover g.icon rect {
fill: #222;
}
.light .ctrl-btns div g.icon use {
fill: #ddd;
}
.dark .ctrl-btns div g.icon use {
fill: #333;
}
/* Active hover */
.light .ctrl-btns div.active:hover g.icon rect {
fill: #800;
}
.dark .ctrl-btns div.active:hover g.icon rect {
fill: #CE5650;
}
/* Active */
.light .ctrl-btns div.active g.icon use {
fill: #fff;
}
.dark .ctrl-btns div.active g.icon use {
fill: #eee;
}
.light .ctrl-btns div.active g.icon rect {
fill: #bbb;
}
.dark .ctrl-btns div.active g.icon rect {
fill: #444;
}

View File

@ -3,6 +3,10 @@
<div class="tabular-header"> <div class="tabular-header">
<h2>Applications ({{ctrl.tableData.length}} total)</h2> <h2>Applications ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns"> <div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
<div class="separator"></div>
<div id="app-install" icon icon-size="36" icon-id="plus" class="active"></div> <div id="app-install" icon icon-size="36" icon-id="plus" class="active"></div>
<div id="app-activate" icon icon-size="36" icon-id="play"></div> <div id="app-activate" icon icon-size="36" icon-id="play"></div>
<div id="app-deactivate" icon icon-size="36" icon-id="stop"></div> <div id="app-deactivate" icon icon-size="36" icon-id="stop"></div>

View File

@ -25,9 +25,9 @@
angular.module('ovApp', []) angular.module('ovApp', [])
.controller('OvAppCtrl', .controller('OvAppCtrl',
['$log', '$scope', 'TableBuilderService', 'WebSocketService', ['$log', '$scope', 'TableService', 'TableBuilderService', 'WebSocketService',
function ($log, $scope, tbs, wss) { function ($log, $scope, ts, tbs, wss) {
function selCb($event, row) { function selCb($event, row) {
selRow = angular.element($event.currentTarget); selRow = angular.element($event.currentTarget);
selection = row; selection = row;
@ -45,6 +45,12 @@
document.getElementById('file').dispatchEvent(evt); document.getElementById('file').dispatchEvent(evt);
}); });
$scope.refresh = function () {
$log.debug('Refreshing application page');
ts.resetSortIcons();
$scope.sortCallback();
};
function appAction(action) { function appAction(action) {
if (selection) { if (selection) {
$log.debug('Initiating uninstall of', selection); $log.debug('Initiating uninstall of', selection);

View File

@ -18,5 +18,10 @@
ONOS GUI -- Cluster View -- CSS file ONOS GUI -- Cluster View -- CSS file
*/ */
#ov-cluster td { #ov-cluster h2 {
display: inline-block;
}
#ov-cluster div.ctrl-btns {
width: 45px;
} }

View File

@ -18,6 +18,11 @@
<div id="ov-cluster"> <div id="ov-cluster">
<div class="tabular-header"> <div class="tabular-header">
<h2>Cluster Nodes ({{ctrl.tableData.length}} total)</h2> <h2>Cluster Nodes ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"

View File

@ -23,15 +23,21 @@
angular.module('ovCluster', []) angular.module('ovCluster', [])
.controller('OvClusterCtrl', .controller('OvClusterCtrl',
['$log', '$scope', 'TableBuilderService', ['$log', '$scope', 'TableService', 'TableBuilderService',
function ($log, $scope, tbs) { function ($log, $scope, ts, tbs) {
tbs.buildTable({ tbs.buildTable({
self: this, self: this,
scope: $scope, scope: $scope,
tag: 'cluster' tag: 'cluster'
}); });
$scope.refresh = function () {
$log.debug('Refreshing cluster nodes page');
ts.resetSortIcons();
$scope.sortCallback();
};
$log.log('OvClusterCtrl has been created'); $log.log('OvClusterCtrl has been created');
}]); }]);
}()); }());

View File

@ -18,6 +18,14 @@
ONOS GUI -- Device View -- CSS file ONOS GUI -- Device View -- CSS file
*/ */
#ov-device h2 {
display: inline-block;
}
#ov-device div.ctrl-btns {
width: 45px;
}
/* More in generic panel.css */ /* More in generic panel.css */
#device-details-panel.floatpanel { #device-details-panel.floatpanel {

View File

@ -2,6 +2,11 @@
<div id="ov-device"> <div id="ov-device">
<div class="tabular-header"> <div class="tabular-header">
<h2>Devices ({{ctrl.tableData.length}} total)</h2> <h2>Devices ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"

View File

@ -203,12 +203,12 @@
angular.module('ovDevice', []) angular.module('ovDevice', [])
.controller('OvDeviceCtrl', .controller('OvDeviceCtrl',
['$log', '$scope', 'TableBuilderService', 'FnService', ['$log', '$scope', 'TableService', 'TableBuilderService', 'FnService',
'MastService', 'PanelService', 'WebSocketService', 'IconService', 'MastService', 'PanelService', 'WebSocketService', 'IconService',
'ButtonService', 'NavService', 'TooltipService', 'ButtonService', 'NavService', 'TooltipService',
function (_$log_, _$scope_, function (_$log_, _$scope_,
tbs, _fs_, _mast_, _ps_, _wss_, _is_, _bns_, _ns_, _ttip_) { ts, tbs, _fs_, _mast_, _ps_, _wss_, _is_, _bns_, _ns_, _ttip_) {
$log = _$log_; $log = _$log_;
$scope = _$scope_; $scope = _$scope_;
fs = _fs_; fs = _fs_;
@ -243,6 +243,12 @@
tag: 'device', tag: 'device',
selCb: selCb selCb: selCb
}); });
$scope.refresh = function () {
$log.debug('Refreshing devices page');
ts.resetSortIcons();
$scope.sortCallback();
};
createDetailsPane(); createDetailsPane();
// details panel handlers // details panel handlers

View File

@ -18,6 +18,14 @@
ONOS GUI -- Flow View -- CSS file ONOS GUI -- Flow View -- CSS file
*/ */
#ov-flow h2 {
display: inline-block;
}
#ov-flow div.ctrl-btns {
width: 45px;
}
.light #ov-flow tr:nth-child(6n + 2), .light #ov-flow tr:nth-child(6n + 2),
.light #ov-flow tr:nth-child(6n + 3), .light #ov-flow tr:nth-child(6n + 3),
.light #ov-flow tr:nth-child(6n + 4) { .light #ov-flow tr:nth-child(6n + 4) {

View File

@ -2,9 +2,14 @@
<div id="ov-flow"> <div id="ov-flow">
<div class="tabular-header"> <div class="tabular-header">
<h2> <h2>
Flows for Device {{ctrl.devId || "none"}} Flows for Device {{ctrl.devId || "(No device selected)"}}
({{ctrl.tableData.length}} total) ({{ctrl.tableData.length}} total)
</h2> </h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"

View File

@ -22,19 +22,21 @@
'use strict'; 'use strict';
// injected references // injected references
var $log, $scope, $location, fs, tbs; var $log, $scope, $location, fs, ts, tbs;
angular.module('ovFlow', []) angular.module('ovFlow', [])
.controller('OvFlowCtrl', .controller('OvFlowCtrl',
['$log', '$scope', '$location', 'FnService', 'TableBuilderService', ['$log', '$scope', '$location',
'FnService', 'TableService', 'TableBuilderService',
function (_$log_, _$scope_, _$location_, _fs_, _tbs_) { function (_$log_, _$scope_, _$location_, _fs_, _ts_, _tbs_) {
var self = this, var self = this,
params; params;
$log = _$log_; $log = _$log_;
$scope = _$scope_; $scope = _$scope_;
$location = _$location_; $location = _$location_;
fs = _fs_; fs = _fs_;
ts = _ts_;
tbs = _tbs_; tbs = _tbs_;
params = $location.search(); params = $location.search();
@ -49,6 +51,12 @@
query: params query: params
}); });
$scope.refresh = function () {
$log.debug('Refreshing flows page');
ts.resetSortIcons();
$scope.sortCallback();
};
$log.log('OvFlowCtrl has been created'); $log.log('OvFlowCtrl has been created');
}]); }]);
}()); }());

View File

@ -18,5 +18,10 @@
ONOS GUI -- Host View -- CSS file ONOS GUI -- Host View -- CSS file
*/ */
#ov-host td { #ov-host h2 {
display: inline-block;
}
#ov-host div.ctrl-btns {
width: 45px;
} }

View File

@ -2,6 +2,11 @@
<div id="ov-host"> <div id="ov-host">
<div class="tabular-header"> <div class="tabular-header">
<h2>Hosts ({{ctrl.tableData.length}} total)</h2> <h2>Hosts ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"

View File

@ -23,15 +23,21 @@
angular.module('ovHost', []) angular.module('ovHost', [])
.controller('OvHostCtrl', .controller('OvHostCtrl',
['$log', '$scope', 'TableBuilderService', ['$log', '$scope', 'TableService', 'TableBuilderService',
function ($log, $scope, tbs) { function ($log, $scope, ts, tbs) {
tbs.buildTable({ tbs.buildTable({
self: this, self: this,
scope: $scope, scope: $scope,
tag: 'host' tag: 'host'
}); });
$scope.refresh = function () {
$log.debug('Refreshing hosts page');
ts.resetSortIcons();
$scope.sortCallback();
};
$log.log('OvHostCtrl has been created'); $log.log('OvHostCtrl has been created');
}]); }]);
}()); }());

View File

@ -18,6 +18,14 @@
ONOS GUI -- Intent View -- CSS file ONOS GUI -- Intent View -- CSS file
*/ */
#ov-intent h2 {
display: inline-block;
}
#ov-intent div.ctrl-btns {
width: 45px;
}
.light #ov-intent tr:nth-child(6n + 2), .light #ov-intent tr:nth-child(6n + 2),
.light #ov-intent tr:nth-child(6n + 3), .light #ov-intent tr:nth-child(6n + 3),
.light #ov-intent tr:nth-child(6n + 4) { .light #ov-intent tr:nth-child(6n + 4) {

View File

@ -18,6 +18,11 @@
<div id="ov-intent"> <div id="ov-intent">
<div class="tabular-header"> <div class="tabular-header">
<h2>Intents ({{ctrl.tableData.length}} total)</h2> <h2>Intents ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"
onos-fixed-header onos-fixed-header

View File

@ -23,15 +23,21 @@
angular.module('ovIntent', []) angular.module('ovIntent', [])
.controller('OvIntentCtrl', .controller('OvIntentCtrl',
['$log', '$scope', 'TableBuilderService', ['$log', '$scope', 'TableService', 'TableBuilderService',
function ($log, $scope, tbs) { function ($log, $scope, ts, tbs) {
tbs.buildTable({ tbs.buildTable({
self: this, self: this,
scope: $scope, scope: $scope,
tag: 'intent' tag: 'intent'
}); });
$scope.refresh = function () {
$log.debug('Refreshing intents page');
ts.resetSortIcons();
$scope.sortCallback();
};
$log.log('OvIntentCtrl has been created'); $log.log('OvIntentCtrl has been created');
}]); }]);
}()); }());

View File

@ -18,5 +18,10 @@
ONOS GUI -- Link View -- CSS file ONOS GUI -- Link View -- CSS file
*/ */
#ov-link td { #ov-link h2 {
display: inline-block;
}
#ov-link div.ctrl-btns {
width: 45px;
} }

View File

@ -18,6 +18,11 @@
<div id="ov-link"> <div id="ov-link">
<div class="tabular-header"> <div class="tabular-header">
<h2>Links ({{ctrl.tableData.length}} total)</h2> <h2>Links ({{ctrl.tableData.length}} total)</h2>
<div class="ctrl-btns">
<div class="refresh active"
icon icon-size="36" icon-id="crown"
ng-click="refresh()"></div>
</div>
</div> </div>
<table class="summary-list" <table class="summary-list"

View File

@ -23,15 +23,21 @@
angular.module('ovLink', []) angular.module('ovLink', [])
.controller('OvLinkCtrl', .controller('OvLinkCtrl',
['$log', '$scope', 'TableBuilderService', ['$log', '$scope', 'TableService', 'TableBuilderService',
function ($log, $scope, tbs) { function ($log, $scope, ts, tbs) {
tbs.buildTable({ tbs.buildTable({
self: this, self: this,
scope: $scope, scope: $scope,
tag: 'link' tag: 'link'
}); });
$scope.refresh = function () {
$log.debug('Refreshing links page');
ts.resetSortIcons();
$scope.sortCallback();
};
$log.log('OvLinkCtrl has been created'); $log.log('OvLinkCtrl has been created');
}]); }]);
}()); }());

View File

@ -19,7 +19,7 @@
*/ */
describe('factory: fw/widget/table.js', function () { describe('factory: fw/widget/table.js', function () {
var $log, $compile, $rootScope, var $log, $compile, $rootScope,
fs, mast, is, fs, ts, mast, is,
scope, compiled, scope, compiled,
table, thead, tbody, mockHeader, table, thead, tbody, mockHeader,
mockH2Height = 20, mockH2Height = 20,
@ -99,11 +99,12 @@ describe('factory: fw/widget/table.js', function () {
}); });
beforeEach(inject(function (_$log_, _$compile_, _$rootScope_, beforeEach(inject(function (_$log_, _$compile_, _$rootScope_,
FnService, MastService, IconService) { FnService, TableService, MastService, IconService) {
$log = _$log_; $log = _$log_;
$compile = _$compile_; $compile = _$compile_;
$rootScope = _$rootScope_; $rootScope = _$rootScope_;
fs = FnService; fs = FnService;
ts = TableService;
mast = MastService; mast = MastService;
is = IconService; is = IconService;
})); }));
@ -127,6 +128,16 @@ describe('factory: fw/widget/table.js', function () {
mockHeader.remove(); mockHeader.remove();
}); });
it('should define TableBuilderService', function () {
expect(ts).toBeDefined();
});
it('should define api functions', function () {
expect(fs.areFunctions(ts, [
'resetSortIcons'
])).toBeTruthy();
});
function compileTable() { function compileTable() {
compiled = $compile(table); compiled = $compile(table);
compiled(scope); compiled(scope);
@ -204,26 +215,22 @@ describe('factory: fw/widget/table.js', function () {
thElems[1].click(); thElems[1].click();
currentTh = angular.element(thElems[1]); currentTh = angular.element(thElems[1]);
div = currentTh.find('div'); div = currentTh.find('div');
expect(div.html()).toBe('<svg class="embeddedIcon" ' + expect(div.html()).toBe(
'width="10" height="10" viewBox="0 0 50 50">' + '<svg class="embeddedIcon" width="10" height="10" viewBox="0 0 ' +
'<g class="icon upArrow">' + '50 50"><g class="icon upArrow"><rect width="50" height="50" ' +
'<rect width="50" height="50" rx="5"></rect>' + 'rx="5"></rect><use width="50" height="50" class="glyph" xmlns:' +
'<use width="50" height="50" class="glyph" ' + 'xlink="http://www.w3.org/1999/xlink" xlink:href="#triangleUp">' +
'xmlns:xlink="http://www.w3.org/1999/xlink" ' + '</use></g></svg>'
'xlink:href="#triangleUp">' + );
'</use>' +
'</g></svg>');
thElems[1].click(); thElems[1].click();
div = currentTh.find('div'); div = currentTh.find('div');
expect(div.html()).toBe('<svg class="embeddedIcon" ' + expect(div.html()).toBe(
'width="10" height="10" viewBox="0 0 50 50">' + '<svg class="embeddedIcon" width="10" height="10" viewBox="0 0 ' +
'<g class="icon downArrow">' + '50 50"><g class="icon downArrow"><rect width="50" height="50" ' +
'<rect width="50" height="50" rx="5"></rect>' + 'rx="5"></rect><use width="50" height="50" class="glyph" xmlns:' +
'<use width="50" height="50" class="glyph" ' + 'xlink="http://www.w3.org/1999/xlink" xlink:href="#triangleDown">' +
'xmlns:xlink="http://www.w3.org/1999/xlink" ' + '</use></g></svg>'
'xlink:href="#triangleDown">' + );
'</use>' +
'</g></svg>');
thElems[2].click(); thElems[2].click();
div = currentTh.children(); div = currentTh.children();
@ -233,15 +240,13 @@ describe('factory: fw/widget/table.js', function () {
// the new element should have the ascending icon // the new element should have the ascending icon
currentTh = angular.element(thElems[2]); currentTh = angular.element(thElems[2]);
div = currentTh.children(); div = currentTh.children();
expect(div.html()).toBe('<svg class="embeddedIcon" ' + expect(div.html()).toBe(
'width="10" height="10" viewBox="0 0 50 50">' + '<svg class="embeddedIcon" width="10" height="10" viewBox="0 0 ' +
'<g class="icon upArrow">' + '50 50"><g class="icon upArrow"><rect width="50" height="50" ' +
'<rect width="50" height="50" rx="5"></rect>' + 'rx="5"></rect><use width="50" height="50" class="glyph" xmlns:' +
'<use width="50" height="50" class="glyph" ' + 'xlink="http://www.w3.org/1999/xlink" xlink:href="#triangleUp">' +
'xmlns:xlink="http://www.w3.org/1999/xlink" ' + '</use></g></svg>'
'xlink:href="#triangleUp">' + );
'</use>' +
'</g></svg>');
} }
it('should affirm that onos-fixed-header is working', function () { it('should affirm that onos-fixed-header is working', function () {
@ -264,8 +269,7 @@ describe('factory: fw/widget/table.js', function () {
compileTable(); compileTable();
verifyGivenTags('onos-sortable-header'); verifyGivenTags('onos-sortable-header');
// ctrlCallback functionality is tested in device-spec
// only checking that it has been called correctly in the directive
scope.sortCallback = jasmine.createSpy('sortCallback'); scope.sortCallback = jasmine.createSpy('sortCallback');
thElems = thead.find('th'); thElems = thead.find('th');
@ -273,4 +277,8 @@ describe('factory: fw/widget/table.js', function () {
verifyIcons(thElems); verifyIcons(thElems);
}); });
// Note: testing resetSortIcons isn't feasible because due to the nature of
// directive compilation: they are jQuery elements, not d3 elements,
// so the function doesn't work.
}); });