Commit dcefde00f0d44ef836c4e2fec08925eef3612473

Authored by Igor Kulikov
1 parent 02202c21

Improve devices attributes table.

... ... @@ -72,7 +72,7 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS
72 72 scope.$watch("deviceId", function(newVal, prevVal) {
73 73 if (newVal && !angular.equals(newVal, prevVal)) {
74 74 scope.resetFilter();
75   - scope.getDeviceAttributes();
  75 + scope.getDeviceAttributes(false, true);
76 76 }
77 77 });
78 78
... ... @@ -81,7 +81,7 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS
81 81 scope.mode = 'default';
82 82 scope.query.search = null;
83 83 scope.selectedAttributes = [];
84   - scope.getDeviceAttributes();
  84 + scope.getDeviceAttributes(false, true);
85 85 }
86 86 });
87 87
... ... @@ -117,15 +117,25 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS
117 117 }
118 118 }
119 119
120   - scope.getDeviceAttributes = function(forceUpdate) {
  120 + scope.onReorder = function() {
  121 + scope.getDeviceAttributes(false, false);
  122 + }
  123 +
  124 + scope.onPaginate = function() {
  125 + scope.getDeviceAttributes(false, false);
  126 + }
  127 +
  128 + scope.getDeviceAttributes = function(forceUpdate, reset) {
121 129 if (scope.attributesDeferred) {
122 130 scope.attributesDeferred.resolve();
123 131 }
124 132 if (scope.deviceId && scope.attributeScope) {
125   - scope.attributes = {
126   - count: 0,
127   - data: []
128   - };
  133 + if (reset) {
  134 + scope.attributes = {
  135 + count: 0,
  136 + data: []
  137 + };
  138 + }
129 139 scope.checkSubscription();
130 140 scope.attributesDeferred = deviceService.getDeviceAttributes(scope.deviceId, scope.attributeScope.value,
131 141 scope.query, function(attributes, update, apply) {
... ...
... ... @@ -126,7 +126,7 @@
126 126 </md-toolbar>
127 127 <md-table-container ng-show="mode!='widget'">
128 128 <table md-table md-row-select multiple="" ng-model="selectedAttributes" md-progress="attributesDeferred.promise">
129   - <thead md-head md-order="query.order" md-on-reorder="getDeviceAttributes">
  129 + <thead md-head md-order="query.order" md-on-reorder="onReorder">
130 130 <tr md-row>
131 131 <th md-column md-order-by="lastUpdateTs"><span>Last update time</span></th>
132 132 <th md-column md-order-by="key"><span>Key</span></th>
... ... @@ -147,7 +147,7 @@
147 147 </md-table-container>
148 148 <md-table-pagination ng-show="mode!='widget'" md-limit="query.limit" md-limit-options="[5, 10, 15]"
149 149 md-page="query.page" md-total="{{attributes.count}}"
150   - md-on-paginate="getDeviceAttributes" md-page-select>
  150 + md-on-paginate="onPaginate" md-page-select>
151 151 </md-table-pagination>
152 152 <ul flex rn-carousel ng-if="mode==='widget'" class="widgets-carousel"
153 153 rn-carousel-index="widgetsCarousel.index"
... ...