...
|
...
|
@@ -33,7 +33,8 @@ export default function ExtensionTableDirective() { |
33
|
33
|
scope: true,
|
34
|
34
|
bindToController: {
|
35
|
35
|
entityId: '=',
|
36
|
|
- entityType: '@'
|
|
36
|
+ entityType: '@',
|
|
37
|
+ transferredAttributes: '<'
|
37
|
38
|
},
|
38
|
39
|
controller: ExtensionTableController,
|
39
|
40
|
controllerAs: 'vm',
|
...
|
...
|
@@ -82,6 +83,51 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
82
|
83
|
}
|
83
|
84
|
});
|
84
|
85
|
|
|
86
|
+ $scope.$watch('vm.transferredAttributes', function () {
|
|
87
|
+ if (vm.transferredAttributes && vm.transferredAttributes.data && vm.transferredAttributes.data.length) {
|
|
88
|
+ vm.transferredAttributes.data
|
|
89
|
+ .some(attribute=>{
|
|
90
|
+ if (attribute.key === "appliedConfiguration") {
|
|
91
|
+ vm.appliedConfiguration = attribute.value;
|
|
92
|
+ }
|
|
93
|
+ });
|
|
94
|
+
|
|
95
|
+ checkForSync();
|
|
96
|
+ }
|
|
97
|
+ });
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+ checkForSync();
|
|
101
|
+ function checkForSync() {
|
|
102
|
+ if (vm.appliedConfiguration === vm.extensionsJSON) {
|
|
103
|
+ vm.syncStatus = $translate.instant('extension.sync.sync');
|
|
104
|
+ vm.syncLastTime = formatDate();
|
|
105
|
+ } else {
|
|
106
|
+ vm.syncStatus = $translate.instant('extension.sync.not-sync');
|
|
107
|
+ }
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+ function formatDate(date) {
|
|
112
|
+ let d;
|
|
113
|
+ if (date) {
|
|
114
|
+ d = date;
|
|
115
|
+ } else {
|
|
116
|
+ d = new Date();
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ d = d.getFullYear() +'/'+ addZero(d.getMonth()+1) +'/'+ addZero(d.getDate()) + ' ' + addZero(d.getHours()) + ':' + addZero(d.getMinutes()) +':'+ addZero(d.getSeconds());
|
|
120
|
+ return d;
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+ function addZero(num) {
|
|
124
|
+ if ((angular.isNumber(num) && num < 10) || (angular.isString(num) && num.length === 1)) {
|
|
125
|
+ num = '0' + num;
|
|
126
|
+ }
|
|
127
|
+ return num;
|
|
128
|
+ }
|
|
129
|
+ }
|
|
130
|
+
|
85
|
131
|
function enterFilterMode() {
|
86
|
132
|
vm.query.search = '';
|
87
|
133
|
}
|
...
|
...
|
@@ -238,5 +284,61 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
238
|
284
|
vm.extensionsCount = result.length;
|
239
|
285
|
var startIndex = vm.query.limit * (vm.query.page - 1);
|
240
|
286
|
vm.extensions = result.slice(startIndex, startIndex + vm.query.limit);
|
|
287
|
+ vm.extensionsJSON = angular.toJson(vm.extensions);
|
241
|
288
|
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+ // vm.subscriptionId = null;
|
|
292
|
+ // $scope.checkSubscription = function() {
|
|
293
|
+ // var newSubscriptionId = null;
|
|
294
|
+ // if (vm.entityId && vm.entityType) {
|
|
295
|
+ // newSubscriptionId = attributeService.subscribeForEntityAttributes(vm.entityType, vm.entityId, 'extension/SHARED_SCOPE');
|
|
296
|
+ // }
|
|
297
|
+ // if (vm.subscriptionId && vm.subscriptionId != newSubscriptionId) {
|
|
298
|
+ // attributeService.unsubscribeForEntityAttributes(vm.subscriptionId);
|
|
299
|
+ // }
|
|
300
|
+ // vm.subscriptionId = newSubscriptionId;
|
|
301
|
+ // }
|
|
302
|
+ //
|
|
303
|
+ //
|
|
304
|
+ // // $scope.attributesData = {};
|
|
305
|
+ // // var entityAttributesSubscriptionMap = [];
|
|
306
|
+ // //
|
|
307
|
+ // $scope.subscribeForEntityAttributes = function (entityType=vm.entityType, entityId=vm.entityId, attributeScope="SHARED_SCOPE") {
|
|
308
|
+ // var subscriptionId = entityType + entityId + attributeScope;
|
|
309
|
+ // var entityAttributesSubscription = entityAttributesSubscriptionMap[subscriptionId];
|
|
310
|
+ // if (!entityAttributesSubscription) {
|
|
311
|
+ // var subscriptionCommand = {
|
|
312
|
+ // entityType: entityType,
|
|
313
|
+ // entityId: entityId,
|
|
314
|
+ // scope: attributeScope
|
|
315
|
+ // };
|
|
316
|
+ //
|
|
317
|
+ // var type = attributeScope === types.latestTelemetry.value ?
|
|
318
|
+ // types.dataKeyType.timeseries : types.dataKeyType.attribute;
|
|
319
|
+ //
|
|
320
|
+ // var subscriber = {
|
|
321
|
+ // subscriptionCommands: [subscriptionCommand],
|
|
322
|
+ // type: type,
|
|
323
|
+ // onData: function (data) {
|
|
324
|
+ // if (data.data) {
|
|
325
|
+ // onSubscriptionData(data.data, subscriptionId);
|
|
326
|
+ // }
|
|
327
|
+ // }
|
|
328
|
+ // };
|
|
329
|
+ // entityAttributesSubscription = {
|
|
330
|
+ // subscriber: subscriber,
|
|
331
|
+ // attributes: null
|
|
332
|
+ // };
|
|
333
|
+ // entityAttributesSubscriptionMap[subscriptionId] = entityAttributesSubscription;
|
|
334
|
+ // telemetryWebsocketService.subscribe(subscriber);
|
|
335
|
+ // }
|
|
336
|
+ // return subscriptionId;
|
|
337
|
+ // };
|
|
338
|
+ //
|
|
339
|
+ // function onSubscriptionData(data/*, subscriptionId*/) {
|
|
340
|
+ // $scope.attributesData = data;
|
|
341
|
+ // }
|
|
342
|
+
|
|
343
|
+ // telemetryWebsocketService.subscribe(subscriber);
|
242
|
344
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|