From b0e66be049e19fc4009f4cc9e4f21d365a9a0fdc Mon Sep 17 00:00:00 2001 From: Bri Prebilic Cole Date: Tue, 10 Feb 2015 10:53:15 -0800 Subject: [PATCH] GUI -- Table scrolling fixed header directive no longer depends on a timeout function. - Added a general directive that emits when ng-repeat is completed. Change-Id: I23131adecded9f0393334d003812845ac6b4f031 --- web/gui/src/main/webapp/app/directives.js | 9 +++++++++ web/gui/src/main/webapp/app/fw/widget/table.js | 14 ++++++++++---- .../src/main/webapp/app/view/device/device.html | 3 ++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/web/gui/src/main/webapp/app/directives.js b/web/gui/src/main/webapp/app/directives.js index 29e555d2e7..8bd31e2f73 100644 --- a/web/gui/src/main/webapp/app/directives.js +++ b/web/gui/src/main/webapp/app/directives.js @@ -70,5 +70,14 @@ } }; + }]) + + // create a general ng-repeat complete notifier directive + .directive('ngRepeatDone', [function () { + return function (scope, element, attrs) { + if(scope.$last) { + scope.$emit('LastElement'); + } + } }]); }()); 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 062318fd72..5cf283ea6d 100644 --- a/web/gui/src/main/webapp/app/fw/widget/table.js +++ b/web/gui/src/main/webapp/app/fw/widget/table.js @@ -113,7 +113,6 @@ }; }]) - // TODO: find another solution other than timeout for waiting for ng-repeat to end .directive('onosFixedHeader', ['$window', '$timeout', 'MastService', 'FnService', function (_$window_, $timeout, mast, _fs_) { @@ -121,7 +120,8 @@ $window = _$window_; fs = _fs_; var w = angular.element($window), - table = d3.select(element[0]); + table = d3.select(element[0]), + shouldResize = false; scope.$watch(function () { return { @@ -136,10 +136,16 @@ scope.windowWidth = newVal.w; scope.setTableHW = function () { - $timeout(function () { + scope.$on('LastElement', function (event) { fixTable(table, thead, tbody); - }, 250); + shouldResize = true; + }); }; + + if (shouldResize) { + fixTable(table, thead, tbody); + } + }, true); w.bind('onos-fixed-header', function () { 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 1ef4556b3e..aef1228f1a 100644 --- a/web/gui/src/main/webapp/app/view/device/device.html +++ b/web/gui/src/main/webapp/app/view/device/device.html @@ -18,7 +18,8 @@ - +
{{dev.id}} {{dev.mfr}}