diff --git a/ui/src/app/entity/attribute/attribute-table.tpl.html b/ui/src/app/entity/attribute/attribute-table.tpl.html index 6f862ba71f..3b19e9d8d7 100644 --- a/ui/src/app/entity/attribute/attribute-table.tpl.html +++ b/ui/src/app/entity/attribute/attribute-table.tpl.html @@ -16,7 +16,7 @@ --> -
+
@@ -26,7 +26,7 @@
-
+
diff --git a/ui/src/app/extension/extension-table.directive.js b/ui/src/app/extension/extension-table.directive.js index 21d716bdb7..e109ad954d 100644 --- a/ui/src/app/extension/extension-table.directive.js +++ b/ui/src/app/extension/extension-table.directive.js @@ -33,7 +33,8 @@ export default function ExtensionTableDirective() { scope: true, bindToController: { entityId: '=', - entityType: '@' + entityType: '@', + transferredAttributes: '<' }, controller: ExtensionTableController, controllerAs: 'vm', @@ -82,6 +83,51 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, } }); + $scope.$watch('vm.transferredAttributes', function () { + if (vm.transferredAttributes && vm.transferredAttributes.data && vm.transferredAttributes.data.length) { + vm.transferredAttributes.data + .some(attribute=>{ + if (attribute.key === "appliedConfiguration") { + vm.appliedConfiguration = attribute.value; + } + }); + + checkForSync(); + } + }); + + + checkForSync(); + function checkForSync() { + if (vm.appliedConfiguration === vm.extensionsJSON) { + vm.syncStatus = $translate.instant('extension.sync.sync'); + vm.syncLastTime = formatDate(); + } else { + vm.syncStatus = $translate.instant('extension.sync.not-sync'); + } + } + + + function formatDate(date) { + let d; + if (date) { + d = date; + } else { + d = new Date(); + } + + d = d.getFullYear() +'/'+ addZero(d.getMonth()+1) +'/'+ addZero(d.getDate()) + ' ' + addZero(d.getHours()) + ':' + addZero(d.getMinutes()) +':'+ addZero(d.getSeconds()); + return d; + + + function addZero(num) { + if ((angular.isNumber(num) && num < 10) || (angular.isString(num) && num.length === 1)) { + num = '0' + num; + } + return num; + } + } + function enterFilterMode() { vm.query.search = ''; } @@ -238,5 +284,61 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, vm.extensionsCount = result.length; var startIndex = vm.query.limit * (vm.query.page - 1); vm.extensions = result.slice(startIndex, startIndex + vm.query.limit); + vm.extensionsJSON = angular.toJson(vm.extensions); } + + + // vm.subscriptionId = null; + // $scope.checkSubscription = function() { + // var newSubscriptionId = null; + // if (vm.entityId && vm.entityType) { + // newSubscriptionId = attributeService.subscribeForEntityAttributes(vm.entityType, vm.entityId, 'extension/SHARED_SCOPE'); + // } + // if (vm.subscriptionId && vm.subscriptionId != newSubscriptionId) { + // attributeService.unsubscribeForEntityAttributes(vm.subscriptionId); + // } + // vm.subscriptionId = newSubscriptionId; + // } + // + // + // // $scope.attributesData = {}; + // // var entityAttributesSubscriptionMap = []; + // // + // $scope.subscribeForEntityAttributes = function (entityType=vm.entityType, entityId=vm.entityId, attributeScope="SHARED_SCOPE") { + // var subscriptionId = entityType + entityId + attributeScope; + // var entityAttributesSubscription = entityAttributesSubscriptionMap[subscriptionId]; + // if (!entityAttributesSubscription) { + // var subscriptionCommand = { + // entityType: entityType, + // entityId: entityId, + // scope: attributeScope + // }; + // + // var type = attributeScope === types.latestTelemetry.value ? + // types.dataKeyType.timeseries : types.dataKeyType.attribute; + // + // var subscriber = { + // subscriptionCommands: [subscriptionCommand], + // type: type, + // onData: function (data) { + // if (data.data) { + // onSubscriptionData(data.data, subscriptionId); + // } + // } + // }; + // entityAttributesSubscription = { + // subscriber: subscriber, + // attributes: null + // }; + // entityAttributesSubscriptionMap[subscriptionId] = entityAttributesSubscription; + // telemetryWebsocketService.subscribe(subscriber); + // } + // return subscriptionId; + // }; + // + // function onSubscriptionData(data/*, subscriptionId*/) { + // $scope.attributesData = data; + // } + + // telemetryWebsocketService.subscribe(subscriber); } \ No newline at end of file diff --git a/ui/src/app/extension/extension-table.scss b/ui/src/app/extension/extension-table.scss index c6c19a5978..ee2a57016d 100644 --- a/ui/src/app/extension/extension-table.scss +++ b/ui/src/app/extension/extension-table.scss @@ -13,4 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@import '../../scss/constants'; \ No newline at end of file +@import '../../scss/constants'; + + +.extension-table md-input-container .md-errors-spacer { + min-height: 0; +} + +.extension__syncStatus--black { + color: #000000!important; +} +.extension__syncStatus--green { + color: #228634!important; +} +.extension__syncStatus--red { + color: #862222!important; +} \ No newline at end of file diff --git a/ui/src/app/extension/extension-table.tpl.html b/ui/src/app/extension/extension-table.tpl.html index 558b9c2a03..3a425768eb 100644 --- a/ui/src/app/extension/extension-table.tpl.html +++ b/ui/src/app/extension/extension-table.tpl.html @@ -16,7 +16,7 @@ --> - +
@@ -78,6 +78,25 @@
+ +
+ + + + + + + + + +
+ diff --git a/ui/src/app/locale/locale.constant.js b/ui/src/app/locale/locale.constant.js index 6f626b5ed8..8272fbbbfa 100644 --- a/ui/src/app/locale/locale.constant.js +++ b/ui/src/app/locale/locale.constant.js @@ -777,6 +777,14 @@ export default angular.module('thingsboard.locale', []) "timeseries": "Timeseries", "add-timeseries": "Add timeseries", + + "sync": { + "status": "Status", + "sync": "Sync", + "not-sync": "Not sync", + "last-sync-time": "Last sync time", + }, + "opc-field-required": "Field is required", "opc-server": "Servers", "opc-add-server-hint": "Add server",