GUI -- Cleaned up directives - onos-sortable-header and icon no longer use isolate scope. Icon directive moved to icon.js. Deleted unneeded TableService.
Change-Id: I53970176b9ca021d1aa7d844ccd961cbf6ac6b51
diff --git a/web/gui/src/main/webapp/app/directives.js b/web/gui/src/main/webapp/app/directives.js
index 98aef8e..b3c34ab 100644
--- a/web/gui/src/main/webapp/app/directives.js
+++ b/web/gui/src/main/webapp/app/directives.js
@@ -59,25 +59,5 @@
});
}
};
- }])
-
-
- // create icon directive, so that we can inject icons into
- // HTML tables etc.
- .directive('icon', ['IconService', function (is) {
- return {
- restrict: 'A',
- scope: {
- iconId: '@',
- iconSize: '@'
- },
- link: function (scope, element, attrs) {
- attrs.$observe('iconId', function () {
- var div = d3.select(element[0]);
- div.selectAll('*').remove();
- is.loadEmbeddedIcon(div, scope.iconId, scope.iconSize);
- });
- }
- };
}]);
}());
diff --git a/web/gui/src/main/webapp/app/fw/svg/icon.js b/web/gui/src/main/webapp/app/fw/svg/icon.js
index 164fc4c..c536a66 100644
--- a/web/gui/src/main/webapp/app/fw/svg/icon.js
+++ b/web/gui/src/main/webapp/app/fw/svg/icon.js
@@ -227,6 +227,19 @@
// === DEFINE THE MODULE
angular.module('onosSvg')
+ .directive('icon', ['IconService', function (is) {
+ return {
+ restrict: 'A',
+ link: function (scope, element, attrs) {
+ attrs.$observe('iconId', function () {
+ var div = d3.select(element[0]);
+ div.selectAll('*').remove();
+ is.loadEmbeddedIcon(div, attrs.iconId, attrs.iconSize);
+ });
+ }
+ };
+ }])
+
.factory('IconService', ['$log', 'FnService', 'GlyphService',
'SvgUtilService',
diff --git a/web/gui/src/main/webapp/app/fw/widget/table.js b/web/gui/src/main/webapp/app/fw/widget/table.js
index 9bdf1c1..21baaa3 100644
--- a/web/gui/src/main/webapp/app/fw/widget/table.js
+++ b/web/gui/src/main/webapp/app/fw/widget/table.js
@@ -189,44 +189,26 @@
.directive('onosSortableHeader', ['$log', 'IconService',
function (_$log_, _is_) {
- return {
- scope: {
- sortCallback: '&',
- sortParams: '='
- },
- link: function (scope, element) {
- $log = _$log_;
- is = _is_;
- var header = d3.select(element[0]);
- sortIconAPI = is.sortIcons();
+ return function (scope, element) {
+ $log = _$log_;
+ is = _is_;
+ var header = d3.select(element[0]);
+ sortIconAPI = is.sortIcons();
- // when a header is clicked, change its sort direction
- // and get sorting order to send to the server.
- header.selectAll('td').on('click', function () {
- var col = d3.select(this);
+ header.selectAll('td').on('click', function () {
+ var col = d3.select(this);
- if (col.attr('sortable') === '') {
- updateSortDirection(col);
- scope.$apply(function () {
- scope.sortParams = sortRequestParams();
- });
- scope.sortCallback({
- requestParams: scope.sortParams
- });
- }
- });
- }
- };
- }])
+ if (col.attr('sortable') === '') {
+ updateSortDirection(col);
+ scope.sortParams = sortRequestParams();
+ scope.sortCallback(scope.sortParams);
+ }
+ });
- .factory('TableService', ['IconService',
-
- function (is) {
- sortIconAPI = is.sortIcons();
-
- return {
- resetSort: resetSort
- };
+ scope.$on('$destroy', function () {
+ resetSort();
+ });
+ }
}]);
}());
diff --git a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
index 4f418e7..1196dee 100644
--- a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
+++ b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
@@ -21,7 +21,7 @@
'use strict';
// injected refs
- var $log, $interval, fs, wss, ts;
+ var $log, $interval, fs, wss;
// constants
var refreshInterval = 2000;
@@ -98,7 +98,6 @@
// Cleanup on destroyed scope
o.scope.$on('$destroy', function () {
wss.unbindHandlers(handlers);
- ts.resetSort();
stopRefresh();
});
@@ -108,14 +107,13 @@
angular.module('onosWidget')
.factory('TableBuilderService',
- ['$log', '$interval', 'FnService', 'WebSocketService', 'TableService',
+ ['$log', '$interval', 'FnService', 'WebSocketService',
- function (_$log_, _$interval_, _fs_, _wss_, _ts_) {
+ function (_$log_, _$interval_, _fs_, _wss_) {
$log = _$log_;
$interval = _$interval_;
fs = _fs_;
wss = _wss_;
- ts = _ts_;
return {
buildTable: buildTable
diff --git a/web/gui/src/main/webapp/app/view/app/app.html b/web/gui/src/main/webapp/app/view/app/app.html
index 9df05b8..4d202bf 100644
--- a/web/gui/src/main/webapp/app/view/app/app.html
+++ b/web/gui/src/main/webapp/app/view/app/app.html
@@ -38,10 +38,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="state" class="table-icon" sortable></td>
diff --git a/web/gui/src/main/webapp/app/view/cluster/cluster.html b/web/gui/src/main/webapp/app/view/cluster/cluster.html
index d51bb43..a7c84bf 100644
--- a/web/gui/src/main/webapp/app/view/cluster/cluster.html
+++ b/web/gui/src/main/webapp/app/view/cluster/cluster.html
@@ -28,10 +28,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="_iconid_state" class="table-icon" sortable></td>
diff --git a/web/gui/src/main/webapp/app/view/device/device.html b/web/gui/src/main/webapp/app/view/device/device.html
index b9adfea..6f09fe4 100644
--- a/web/gui/src/main/webapp/app/view/device/device.html
+++ b/web/gui/src/main/webapp/app/view/device/device.html
@@ -28,10 +28,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="available" class="table-icon" sortable></td>
diff --git a/web/gui/src/main/webapp/app/view/flow/flow.html b/web/gui/src/main/webapp/app/view/flow/flow.html
index 2003698..87109b6 100644
--- a/web/gui/src/main/webapp/app/view/flow/flow.html
+++ b/web/gui/src/main/webapp/app/view/flow/flow.html
@@ -30,10 +30,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="id" col-width="180px" sortable>Flow ID </td>
diff --git a/web/gui/src/main/webapp/app/view/group/group.html b/web/gui/src/main/webapp/app/view/group/group.html
index d5811fb..13bde14 100644
--- a/web/gui/src/main/webapp/app/view/group/group.html
+++ b/web/gui/src/main/webapp/app/view/group/group.html
@@ -46,10 +46,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="id" sortable>Group ID </td>
diff --git a/web/gui/src/main/webapp/app/view/host/host.html b/web/gui/src/main/webapp/app/view/host/host.html
index c5f98e7..7a32216 100644
--- a/web/gui/src/main/webapp/app/view/host/host.html
+++ b/web/gui/src/main/webapp/app/view/host/host.html
@@ -12,10 +12,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="type" class="table-icon" sortable></td>
diff --git a/web/gui/src/main/webapp/app/view/intent/intent.html b/web/gui/src/main/webapp/app/view/intent/intent.html
index c065285..4fcb453 100644
--- a/web/gui/src/main/webapp/app/view/intent/intent.html
+++ b/web/gui/src/main/webapp/app/view/intent/intent.html
@@ -28,10 +28,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="appId" sortable>Application ID </td>
diff --git a/web/gui/src/main/webapp/app/view/link/link.html b/web/gui/src/main/webapp/app/view/link/link.html
index 595a1f7..fa8306f 100644
--- a/web/gui/src/main/webapp/app/view/link/link.html
+++ b/web/gui/src/main/webapp/app/view/link/link.html
@@ -28,10 +28,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="_iconid_state" class="table-icon" sortable></td>
diff --git a/web/gui/src/main/webapp/app/view/port/port.html b/web/gui/src/main/webapp/app/view/port/port.html
index ebf5311..522abd5 100644
--- a/web/gui/src/main/webapp/app/view/port/port.html
+++ b/web/gui/src/main/webapp/app/view/port/port.html
@@ -46,10 +46,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="id" col-width="60px" sortable>Port ID </td>
diff --git a/web/gui/src/main/webapp/app/view/settings/settings.html b/web/gui/src/main/webapp/app/view/settings/settings.html
index ae909cd..a10dd1c 100644
--- a/web/gui/src/main/webapp/app/view/settings/settings.html
+++ b/web/gui/src/main/webapp/app/view/settings/settings.html
@@ -12,10 +12,7 @@
<div class="summary-list" onos-table-resize>
- <div class="table-header"
- onos-sortable-header
- sort-params="sortParams"
- sort-callback="sortCallback(sortParams)">
+ <div class="table-header" onos-sortable-header>
<table>
<tr>
<td colId="component" sortable col-width="200px">Component </td>