|
|
@ -25,6 +25,7 @@ import extensionDialogTemplate from './extension-dialog.tpl.html'; |
|
|
/* eslint-enable import/no-unresolved, import/default */ |
|
|
/* eslint-enable import/no-unresolved, import/default */ |
|
|
|
|
|
|
|
|
import ExtensionDialogController from './extension-dialog.controller' |
|
|
import ExtensionDialogController from './extension-dialog.controller' |
|
|
|
|
|
import $ from 'jquery'; |
|
|
|
|
|
|
|
|
/*@ngInject*/ |
|
|
/*@ngInject*/ |
|
|
export default function ExtensionTableDirective() { |
|
|
export default function ExtensionTableDirective() { |
|
|
@ -72,6 +73,15 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
|
|
|
|
|
|
|
|
$scope.$watch("vm.entityId", function(newVal) { |
|
|
$scope.$watch("vm.entityId", function(newVal) { |
|
|
if (newVal) { |
|
|
if (newVal) { |
|
|
|
|
|
if ($scope.subscriber) { |
|
|
|
|
|
telemetryWebsocketService.unsubscribe($scope.subscriber); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vm.subscribed = false; |
|
|
|
|
|
vm.syncLastTime = $translate.instant('extension.sync.not-available'); |
|
|
|
|
|
|
|
|
|
|
|
subscribeForClientAttributes(); |
|
|
|
|
|
|
|
|
reloadExtensions(); |
|
|
reloadExtensions(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
@ -205,12 +215,18 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function reloadExtensions() { |
|
|
function reloadExtensions() { |
|
|
|
|
|
vm.subscribed = false; |
|
|
vm.allExtensions.length = 0; |
|
|
vm.allExtensions.length = 0; |
|
|
vm.extensions.length = 0; |
|
|
vm.extensions.length = 0; |
|
|
vm.extensionsPromise = attributeService.getEntityAttributesValues(vm.entityType, vm.entityId, types.attributesScope.shared.value, ["configuration"]); |
|
|
vm.extensionsPromise = attributeService.getEntityAttributesValues(vm.entityType, vm.entityId, types.attributesScope.shared.value, ["configuration"]); |
|
|
vm.extensionsPromise.then( |
|
|
vm.extensionsPromise.then( |
|
|
function success(data) { |
|
|
function success(data) { |
|
|
vm.allExtensions = angular.fromJson(data[0].value); |
|
|
if (data.length) { |
|
|
|
|
|
vm.allExtensions = angular.fromJson(data[0].value); |
|
|
|
|
|
} else { |
|
|
|
|
|
vm.allExtensions = []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
vm.selectedExtensions = []; |
|
|
vm.selectedExtensions = []; |
|
|
updateExtensions(); |
|
|
updateExtensions(); |
|
|
vm.extensionsPromise = null; |
|
|
vm.extensionsPromise = null; |
|
|
@ -238,52 +254,58 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
|
|
vm.extensionsCount = result.length; |
|
|
vm.extensionsCount = result.length; |
|
|
var startIndex = vm.query.limit * (vm.query.page - 1); |
|
|
var startIndex = vm.query.limit * (vm.query.page - 1); |
|
|
vm.extensions = result.slice(startIndex, startIndex + vm.query.limit); |
|
|
vm.extensions = result.slice(startIndex, startIndex + vm.query.limit); |
|
|
vm.extensionsJSON = angular.toJson(vm.extensions); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vm.extensionsJSON = angular.toJson(vm.extensions); |
|
|
|
|
|
checkForSync() |
|
|
|
|
|
|
|
|
if (vm.entityId && vm.entityType) { |
|
|
|
|
|
$scope.subscriber = { |
|
|
|
|
|
subscriptionCommands: [{ |
|
|
|
|
|
entityType: vm.entityType, |
|
|
|
|
|
entityId: vm.entityId, |
|
|
|
|
|
scope: 'CLIENT_SCOPE' |
|
|
|
|
|
}], |
|
|
|
|
|
type: 'attribute', |
|
|
|
|
|
onData: function (data) { |
|
|
|
|
|
if (data.data) { |
|
|
|
|
|
onSubscriptionData(data.data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
} |
|
|
telemetryWebsocketService.subscribe($scope.subscriber); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('$destroy', function() { |
|
|
|
|
|
telemetryWebsocketService.unsubscribe($scope.subscriber); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function subscribeForClientAttributes() { |
|
|
|
|
|
if (!vm.subscribed) { |
|
|
|
|
|
if (vm.entityId && vm.entityType) { |
|
|
|
|
|
$scope.subscriber = { |
|
|
|
|
|
subscriptionCommands: [{ |
|
|
|
|
|
entityType: vm.entityType, |
|
|
|
|
|
entityId: vm.entityId, |
|
|
|
|
|
scope: 'CLIENT_SCOPE' |
|
|
|
|
|
}], |
|
|
|
|
|
type: 'attribute', |
|
|
|
|
|
onData: function (data) { |
|
|
|
|
|
if (data.data) { |
|
|
|
|
|
onSubscriptionData(data.data); |
|
|
|
|
|
} |
|
|
|
|
|
vm.subscribed = true; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
telemetryWebsocketService.subscribe($scope.subscriber); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
function onSubscriptionData(data) { |
|
|
function onSubscriptionData(data) { |
|
|
if (data.appliedConfiguration && data.appliedConfiguration[0] && data.appliedConfiguration[0][1]) { |
|
|
|
|
|
vm.appliedConfiguration = data.appliedConfiguration[0][1]; |
|
|
if ($.isEmptyObject(data)) { |
|
|
checkForSync(); |
|
|
vm.appliedConfiguration = undefined; |
|
|
$scope.$digest(); |
|
|
} else { |
|
|
|
|
|
if (data.appliedConfiguration && data.appliedConfiguration[0] && data.appliedConfiguration[0][1]) { |
|
|
|
|
|
vm.appliedConfiguration = data.appliedConfiguration[0][1]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateExtensions(); |
|
|
|
|
|
$scope.$digest(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkForSync(); |
|
|
|
|
|
function checkForSync() { |
|
|
function checkForSync() { |
|
|
if (vm.appliedConfiguration === vm.extensionsJSON) { |
|
|
if (vm.appliedConfiguration && vm.extensionsJSON && vm.appliedConfiguration === vm.extensionsJSON) { |
|
|
vm.syncStatus = $translate.instant('extension.sync.sync'); |
|
|
vm.syncStatus = $translate.instant('extension.sync.sync'); |
|
|
vm.syncLastTime = formatDate(); |
|
|
vm.syncLastTime = formatDate(); |
|
|
|
|
|
$scope.isSync = true; |
|
|
} else { |
|
|
} else { |
|
|
vm.syncStatus = $translate.instant('extension.sync.not-sync'); |
|
|
vm.syncStatus = $translate.instant('extension.sync.not-sync'); |
|
|
|
|
|
|
|
|
|
|
|
$scope.isSync = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -306,7 +328,4 @@ function ExtensionTableController($scope, $filter, $document, $translate, types, |
|
|
return num; |
|
|
return num; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//telemetryWebsocketService.subscribe(subscriber);
|
|
|
|
|
|
} |
|
|
} |