diff --git a/ui/src/app/dashboard/add-dashboards-to-edge.controller.js b/ui/src/app/dashboard/add-dashboards-to-edge.controller.js index ff579d492f..e5dcc00b33 100644 --- a/ui/src/app/dashboard/add-dashboards-to-edge.controller.js +++ b/ui/src/app/dashboard/add-dashboards-to-edge.controller.js @@ -53,13 +53,7 @@ export default function AddDashboardsToEdgeController(dashboardService, types, $ fetchMoreItems_: function () { if (vm.dashboards.hasNext && !vm.dashboards.pending) { vm.dashboards.pending = true; - var fetchDashboardsPromise; - if (edgeCustomerId === vm.types.id.nullUid) { - fetchDashboardsPromise = dashboardService.getTenantDashboards(vm.dashboards.nextPageLink); - } else { - fetchDashboardsPromise = dashboardService.getCustomerDashboards(edgeCustomerId, vm.dashboards.nextPageLink); - } - fetchDashboardsPromise.then( + dashboardService.getTenantDashboards(vm.dashboards.nextPageLink).then( function success(dashboards) { vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); vm.dashboards.nextPageLink = dashboards.nextPageLink; diff --git a/ui/src/app/dashboard/dashboards.controller.js b/ui/src/app/dashboard/dashboards.controller.js index 6d61029b84..12a4d1cee0 100644 --- a/ui/src/app/dashboard/dashboards.controller.js +++ b/ui/src/app/dashboard/dashboards.controller.js @@ -708,14 +708,7 @@ export function DashboardsController(userService, dashboardService, customerServ $event.stopPropagation(); } var pageSize = 10; - var fetchDashboardsPromise; - if (vm.edgeCustomerId.id === vm.types.id.nullUid) { - fetchDashboardsPromise = dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}); - } else { - fetchDashboardsPromise = dashboardService.getCustomerDashboards(vm.edgeCustomerId.id, {limit: pageSize, textSearch: ''}); - } - - fetchDashboardsPromise.then( + dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}).then( function success(_dashboards) { var dashboards = { pageSize: pageSize, diff --git a/ui/src/app/edge/edge.routes.js b/ui/src/app/edge/edge.routes.js index e3443d1211..bcba2cffe1 100644 --- a/ui/src/app/edge/edge.routes.js +++ b/ui/src/app/edge/edge.routes.js @@ -21,6 +21,8 @@ import devicesTemplate from "../device/devices.tpl.html"; import assetsTemplate from "../asset/assets.tpl.html"; import dashboardsTemplate from "../dashboard/dashboards.tpl.html"; import dashboardTemplate from "../dashboard/dashboard.tpl.html"; +import ruleChainsTemplate from "../rulechain/rulechains.tpl.html"; +import ruleChainTemplate from "../rulechain/rulechain.tpl.html"; /* eslint-enable import/no-unresolved, import/default */ @@ -49,8 +51,7 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "transform", "label": "edge.edges"}' } - }) - .state('home.edges.entityViews', { + }).state('home.edges.entityViews', { url: '/:edgeId/entityViews', params: {'topIndex': 0}, module: 'private', @@ -72,8 +73,7 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "view_quilt", "label": "edge.entity-views"}' } - }) - .state('home.edges.devices', { + }).state('home.edges.devices', { url: '/:edgeId/devices', params: {'topIndex': 0}, module: 'private', @@ -95,8 +95,7 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "devices_other", "label": "edge.devices"}' } - }) - .state('home.edges.assets', { + }).state('home.edges.assets', { url: '/:edgeId/assets', params: {'topIndex': 0}, module: 'private', @@ -118,29 +117,27 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "domain", "label": "edge.assets"}' } - }) - .state('home.edges.dashboards', { - url: '/:edgeId/dashboards', - params: {'topIndex': 0}, - module: 'private', - auth: ['TENANT_ADMIN'], - views: { - "content@home": { - templateUrl: dashboardsTemplate, - controllerAs: 'vm', - controller: 'DashboardsController' + }).state('home.edges.dashboards', { + url: '/:edgeId/dashboards', + params: {'topIndex': 0}, + module: 'private', + auth: ['TENANT_ADMIN'], + views: { + "content@home": { + templateUrl: dashboardsTemplate, + controllerAs: 'vm', + controller: 'DashboardsController' + } + }, + data: { + dashboardsType: 'edge', + searchEnabled: true, + pageTitle: 'edge.dashboards' + }, + ncyBreadcrumb: { + label: '{"icon": "dashboard", "label": "edge.dashboards"}' } - }, - data: { - dashboardsType: 'edge', - searchEnabled: true, - pageTitle: 'edge.dashboards' - }, - ncyBreadcrumb: { - label: '{"icon": "dashboard", "label": "edge.dashboards"}' - } - }) - .state('home.edges.dashboards.dashboard', { + }).state('home.edges.dashboards.dashboard', { url: '/:dashboardId?state', reloadOnSearch: false, module: 'private', @@ -161,8 +158,7 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}' } - }) - .state('home.customers.edges', { + }).state('home.customers.edges', { url: '/:customerId/edges', params: {'topIndex': 0}, module: 'private', @@ -184,5 +180,62 @@ export default function EdgeRoutes($stateProvider, types) { ncyBreadcrumb: { label: '{"icon": "router", "label": "{{ vm.customerEdgesTitle }}", "translate": "false"}' } + }).state('home.edges.ruleChains', { + url: '/:edgeId/ruleChains', + params: {'topIndex': 0}, + module: 'private', + auth: ['TENANT_ADMIN'], + views: { + "content@home": { + templateUrl: ruleChainsTemplate, + controllerAs: 'vm', + controller: 'RuleChainsController' + } + }, + data: { + searchEnabled: true, + pageTitle: 'edge.rulechains', + ruleChainsType: 'edge' + }, + ncyBreadcrumb: { + label: '{"icon": "settings_ethernet", "label": "rulechain.edge-rulechains"}' + } + }).state('home.edges.ruleChains.ruleChain', { + url: '/:ruleChainId', + reloadOnSearch: false, + module: 'private', + auth: ['SYS_ADMIN', 'TENANT_ADMIN'], + views: { + "content@home": { + templateUrl: ruleChainTemplate, + controller: 'RuleChainController', + controllerAs: 'vm' + } + }, + resolve: { + ruleChain: + /*@ngInject*/ + function($stateParams, ruleChainService) { + return ruleChainService.getRuleChain($stateParams.ruleChainId); + }, + ruleChainMetaData: + /*@ngInject*/ + function($stateParams, ruleChainService) { + return ruleChainService.getRuleChainMetaData($stateParams.ruleChainId); + }, + ruleNodeComponents: + /*@ngInject*/ + function($stateParams, ruleChainService) { + return ruleChainService.getRuleNodeComponents(types.ruleChainType.edge); + } + }, + data: { + import: false, + searchEnabled: false, + pageTitle: 'edge.rulechain' + }, + ncyBreadcrumb: { + label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' + } }); } diff --git a/ui/src/app/event/event-row-edge-event.tpl.html b/ui/src/app/event/event-row-edge-event.tpl.html index d47ca55b81..6cc06d0cc3 100644 --- a/ui/src/app/event/event-row-edge-event.tpl.html +++ b/ui/src/app/event/event-row-edge-event.tpl.html @@ -16,12 +16,12 @@ -->
{{ event.createdTime | date : 'yyyy-MM-dd HH:mm:ss' }}
-
{{ event.edgeEventType }}
-
{{ event.edgeEventAction }}
+
{{ event.type }}
+
{{ event.action }}
{{ event.entityId }}
{{ updateStatus(event.createdTime) | translate }}
- diff --git a/ui/src/app/event/event-row.directive.js b/ui/src/app/event/event-row.directive.js index e1266323ed..c08048379e 100644 --- a/ui/src/app/event/event-row.directive.js +++ b/ui/src/app/event/event-row.directive.js @@ -1,184 +1,193 @@ -/* - * Copyright © 2016-2020 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* eslint-disable import/no-unresolved, import/default */ - -import eventErrorDialogTemplate from './event-content-dialog.tpl.html'; - -import eventRowLcEventTemplate from './event-row-lc-event.tpl.html'; -import eventRowStatsTemplate from './event-row-stats.tpl.html'; -import eventRowErrorTemplate from './event-row-error.tpl.html'; -import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html'; -import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html'; - -/* eslint-enable import/no-unresolved, import/default */ - -/*@ngInject*/ -export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, - types, utils, toast, entityService, ruleChainService) { - - var linker = function (scope, element, attrs) { - - var getTemplate = function(eventType) { - var template = ''; - switch(eventType) { - case types.eventType.lcEvent.value: - template = eventRowLcEventTemplate; - break; - case types.eventType.stats.value: - template = eventRowStatsTemplate; - break; - case types.eventType.error.value: - template = eventRowErrorTemplate; - break; - case types.debugEventType.debugRuleNode.value: - template = eventRowDebugRuleNodeTemplate; - break; - case types.debugEventType.debugRuleChain.value: - template = eventRowDebugRuleNodeTemplate; - break; - case types.eventType.edgeEvent.value: - template = eventRowEdgeEventTemplate; - break; - } - return $templateCache.get(template); - } - - scope.loadTemplate = function() { - element.html(getTemplate(attrs.eventType)); - $compile(element.contents())(scope); - } - - attrs.$observe('eventType', function() { - scope.loadTemplate(); - }); - - scope.types = types; - - scope.event = attrs.event; - - scope.showContent = function($event, content, title, contentType) { - var onShowingCallback = { - onShowing: function(){} - } - if (!contentType) { - contentType = null; - } - var sortedContent; - try { - sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content))); - } - catch(err) { - sortedContent = content; - } - $mdDialog.show({ - controller: 'EventContentDialogController', - controllerAs: 'vm', - templateUrl: eventErrorDialogTemplate, - locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback}, - parent: angular.element($document[0].body), - fullscreen: true, - targetEvent: $event, - multiple: true, - onShowing: function(scope, element) { - onShowingCallback.onShowing(scope, element); - } - }); - } - - scope.showEdgeEntityContent = function($event, title, contentType) { - var onShowingCallback = { - onShowing: function(){} - } - if (!contentType) { - contentType = null; - } - var content = ''; - switch(scope.event.edgeEventType) { - case types.edgeEventType.relation: - content = angular.toJson(scope.event.entityBody); - showDialog(); - break; - case types.edgeEventType.ruleChainMetaData: - content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {ignoreErrors: true}).then( - function success(info) { - showDialog(); - return angular.toJson(info); - }, function fail() { - showError(); - }); - break; - default: - content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {ignoreErrors: true}).then( - function success(info) { - showDialog(); - return angular.toJson(info); - }, function fail() { - showError(); - }); - break; - } - function showDialog() { - $mdDialog.show({ - controller: 'EventContentDialogController', - controllerAs: 'vm', - templateUrl: eventErrorDialogTemplate, - locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback}, - parent: angular.element($document[0].body), - fullscreen: true, - targetEvent: $event, - multiple: true, - onShowing: function(scope, element) { - onShowingCallback.onShowing(scope, element); - } - }); - } - function showError() { - toast.showError($translate.instant('edge.load-entity-error')); - } - } - - scope.checkTooltip = function($event) { - var el = $event.target; - var $el = angular.element(el); - if(el.offsetWidth < el.scrollWidth && !$el.attr('title')){ - $el.attr('title', $el.text()); - } - } - - $compile(element.contents())(scope); - - scope.updateStatus = function(eventCreatedTime) { - if (scope.queueStartTs) { - var status; - if (eventCreatedTime < scope.queueStartTs) { - status = $translate.instant('edge.success'); - scope.isPending = false; - } else { - status = $translate.instant('edge.failed'); - scope.isPending = true; - } - return status; - } - } - } - - return { - restrict: "A", - replace: false, - link: linker, - scope: false - }; -} +/* + * Copyright © 2016-2020 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* eslint-disable import/no-unresolved, import/default */ + +import eventErrorDialogTemplate from './event-content-dialog.tpl.html'; + +import eventRowLcEventTemplate from './event-row-lc-event.tpl.html'; +import eventRowStatsTemplate from './event-row-stats.tpl.html'; +import eventRowErrorTemplate from './event-row-error.tpl.html'; +import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html'; +import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html'; + +/* eslint-enable import/no-unresolved, import/default */ + +/*@ngInject*/ +export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, + types, utils, toast, entityService, ruleChainService) { + + var linker = function (scope, element, attrs) { + + var getTemplate = function(eventType) { + var template = ''; + switch(eventType) { + case types.eventType.lcEvent.value: + template = eventRowLcEventTemplate; + break; + case types.eventType.stats.value: + template = eventRowStatsTemplate; + break; + case types.eventType.error.value: + template = eventRowErrorTemplate; + break; + case types.debugEventType.debugRuleNode.value: + template = eventRowDebugRuleNodeTemplate; + break; + case types.debugEventType.debugRuleChain.value: + template = eventRowDebugRuleNodeTemplate; + break; + case types.eventType.edgeEvent.value: + template = eventRowEdgeEventTemplate; + break; + } + return $templateCache.get(template); + } + + scope.loadTemplate = function() { + element.html(getTemplate(attrs.eventType)); + $compile(element.contents())(scope); + } + + attrs.$observe('eventType', function() { + scope.loadTemplate(); + }); + + scope.types = types; + + scope.event = attrs.event; + + scope.showContent = function($event, content, title, contentType) { + var onShowingCallback = { + onShowing: function(){} + } + if (!contentType) { + contentType = null; + } + var sortedContent; + try { + sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content))); + } + catch(err) { + sortedContent = content; + } + $mdDialog.show({ + controller: 'EventContentDialogController', + controllerAs: 'vm', + templateUrl: eventErrorDialogTemplate, + locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback}, + parent: angular.element($document[0].body), + fullscreen: true, + targetEvent: $event, + multiple: true, + onShowing: function(scope, element) { + onShowingCallback.onShowing(scope, element); + } + }); + } + + scope.showEdgeEntityContent = function($event, title, contentType) { + var onShowingCallback = { + onShowing: function(){} + } + if (!contentType) { + contentType = null; + } + var content = ''; + switch(scope.event.type) { + case types.edgeEventType.relation: + case types.edgeEventType.whiteLabeling: + case types.edgeEventType.loginWhiteLabeling: + case types.edgeEventType.customTranslation: + content = angular.toJson(scope.event.body); + showDialog(); + break; + case types.edgeEventType.ruleChainMetaData: + content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {ignoreErrors: true}).then( + function success(info) { + showDialog(); + return angular.toJson(info); + }, function fail() { + showError(); + }); + break; + default: + content = entityService.getEntity(scope.event.type, scope.event.entityId, {ignoreErrors: true}).then( + function success(info) { + showDialog(); + return angular.toJson(info); + }, function fail() { + showError(); + }); + break; + } + function showDialog() { + $mdDialog.show({ + controller: 'EventContentDialogController', + controllerAs: 'vm', + templateUrl: eventErrorDialogTemplate, + locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback}, + parent: angular.element($document[0].body), + fullscreen: true, + targetEvent: $event, + multiple: true, + onShowing: function(scope, element) { + onShowingCallback.onShowing(scope, element); + } + }); + } + function showError() { + toast.showError($translate.instant('edge.load-entity-error')); + } + } + + scope.checkEdgeEventType = function (edgeEventType) { + return !(edgeEventType === types.edgeEventType.widgetType || + edgeEventType === types.edgeEventType.adminSettings || + edgeEventType === types.edgeEventType.widgetsBundle ); + } + + scope.checkTooltip = function($event) { + var el = $event.target; + var $el = angular.element(el); + if(el.offsetWidth < el.scrollWidth && !$el.attr('title')){ + $el.attr('title', $el.text()); + } + } + + $compile(element.contents())(scope); + + scope.updateStatus = function(eventCreatedTime) { + if (scope.queueStartTs) { + var status; + if (eventCreatedTime < scope.queueStartTs) { + status = $translate.instant('edge.success'); + scope.isPending = false; + } else { + status = $translate.instant('edge.failed'); + scope.isPending = true; + } + return status; + } + } + } + + return { + restrict: "A", + replace: false, + link: linker, + scope: false + }; +} diff --git a/ui/src/app/rulechain/add-rulechains-to-edge.controller.js b/ui/src/app/rulechain/add-rulechains-to-edge.controller.js index 236c44b091..df05c47eee 100644 --- a/ui/src/app/rulechain/add-rulechains-to-edge.controller.js +++ b/ui/src/app/rulechain/add-rulechains-to-edge.controller.js @@ -54,7 +54,7 @@ export default function AddRuleChainsToEdgeController(ruleChainService, $mdDialo vm.ruleChains.pending = true; ruleChainService.getEdgesRuleChains(vm.ruleChains.nextPageLink).then( function success(ruleChains) { - vm.ruleChains.data = ruleChains.data; + vm.ruleChains.data = vm.ruleChains.data.concat(ruleChains.data); vm.ruleChains.nextPageLink = ruleChains.nextPageLink; vm.ruleChains.hasNext = ruleChains.hasNext; if (vm.ruleChains.hasNext) { diff --git a/ui/src/app/rulechain/rulechain.routes.js b/ui/src/app/rulechain/rulechain.routes.js index 7489091665..faad077e79 100644 --- a/ui/src/app/rulechain/rulechain.routes.js +++ b/ui/src/app/rulechain/rulechain.routes.js @@ -191,62 +191,5 @@ export default function RuleChainRoutes($stateProvider, NodeTemplatePathProvider ncyBreadcrumb: { label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' } - }).state('home.edges.ruleChains', { - url: '/:edgeId/ruleChains', - params: {'topIndex': 0}, - module: 'private', - auth: ['TENANT_ADMIN'], - views: { - "content@home": { - templateUrl: ruleChainsTemplate, - controllerAs: 'vm', - controller: 'RuleChainsController' - } - }, - data: { - searchEnabled: true, - pageTitle: 'edge.rulechains', - ruleChainsType: 'edge' - }, - ncyBreadcrumb: { - label: '{"icon": "settings_ethernet", "label": "rulechain.edge-rulechains"}' - } - }).state('home.edges.ruleChains.ruleChain', { - url: '/:ruleChainId', - reloadOnSearch: false, - module: 'private', - auth: ['SYS_ADMIN', 'TENANT_ADMIN'], - views: { - "content@home": { - templateUrl: ruleChainTemplate, - controller: 'RuleChainController', - controllerAs: 'vm' - } - }, - resolve: { - ruleChain: - /*@ngInject*/ - function($stateParams, ruleChainService) { - return ruleChainService.getRuleChain($stateParams.ruleChainId); - }, - ruleChainMetaData: - /*@ngInject*/ - function($stateParams, ruleChainService) { - return ruleChainService.getRuleChainMetaData($stateParams.ruleChainId); - }, - ruleNodeComponents: - /*@ngInject*/ - function($stateParams, ruleChainService) { - return ruleChainService.getRuleNodeComponents(types.ruleChainType.edge); - } - }, - data: { - import: false, - searchEnabled: false, - pageTitle: 'edge.rulechain' - }, - ncyBreadcrumb: { - label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' - } }); } diff --git a/ui/src/app/rulechain/rulechains.controller.js b/ui/src/app/rulechain/rulechains.controller.js index fe19cad5ca..16ee29bd1a 100644 --- a/ui/src/app/rulechain/rulechains.controller.js +++ b/ui/src/app/rulechain/rulechains.controller.js @@ -397,7 +397,7 @@ export default function RuleChainsController(ruleChainService, userService, impo } var ruleChainParams = {ruleChainId: ruleChain.id.id}; if (vm.ruleChainsScope === 'edge') { - $state.go('home.edges.ruleChains.ruleChain', {...ruleChainParams, edgeId: vm.edge.id.id}); + $state.go('home.edges.ruleChains.ruleChain', Object.assign(ruleChainParams, edgeId = vm.edge.id.id)); } else if (vm.ruleChainsScope === 'edges') { $state.go('home.ruleChains.edge.ruleChain', ruleChainParams); } else {