From dcefde00f0d44ef836c4e2fec08925eef3612473 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Wed, 26 Apr 2017 21:39:42 +0300 Subject: [PATCH] Improve devices attributes table. --- .../attribute/attribute-table.directive.js | 24 +++++++++++++------ .../device/attribute/attribute-table.tpl.html | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ui/src/app/device/attribute/attribute-table.directive.js b/ui/src/app/device/attribute/attribute-table.directive.js index 560a4dc10f..701fd37754 100644 --- a/ui/src/app/device/attribute/attribute-table.directive.js +++ b/ui/src/app/device/attribute/attribute-table.directive.js @@ -72,7 +72,7 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS scope.$watch("deviceId", function(newVal, prevVal) { if (newVal && !angular.equals(newVal, prevVal)) { scope.resetFilter(); - scope.getDeviceAttributes(); + scope.getDeviceAttributes(false, true); } }); @@ -81,7 +81,7 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS scope.mode = 'default'; scope.query.search = null; scope.selectedAttributes = []; - scope.getDeviceAttributes(); + scope.getDeviceAttributes(false, true); } }); @@ -117,15 +117,25 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS } } - scope.getDeviceAttributes = function(forceUpdate) { + scope.onReorder = function() { + scope.getDeviceAttributes(false, false); + } + + scope.onPaginate = function() { + scope.getDeviceAttributes(false, false); + } + + scope.getDeviceAttributes = function(forceUpdate, reset) { if (scope.attributesDeferred) { scope.attributesDeferred.resolve(); } if (scope.deviceId && scope.attributeScope) { - scope.attributes = { - count: 0, - data: [] - }; + if (reset) { + scope.attributes = { + count: 0, + data: [] + }; + } scope.checkSubscription(); scope.attributesDeferred = deviceService.getDeviceAttributes(scope.deviceId, scope.attributeScope.value, scope.query, function(attributes, update, apply) { diff --git a/ui/src/app/device/attribute/attribute-table.tpl.html b/ui/src/app/device/attribute/attribute-table.tpl.html index 915fbea861..b6099c4ffa 100644 --- a/ui/src/app/device/attribute/attribute-table.tpl.html +++ b/ui/src/app/device/attribute/attribute-table.tpl.html @@ -126,7 +126,7 @@ - + @@ -147,7 +147,7 @@ + md-on-paginate="onPaginate" md-page-select>
Last update time Key