Commit 0f24bd291228aadaa07d5230a99710f2074f2eb0

Authored by deaflynx
1 parent cc7bd63b

Edge code cleaning. Not stable Default edges

... ... @@ -67,29 +67,6 @@ export default function AssetRoutes($stateProvider, types) {
67 67 ncyBreadcrumb: {
68 68 label: '{"icon": "domain", "label": "{{ vm.customerAssetsTitle }}", "translate": "false"}'
69 69 }
70   - })
71   - .state('home.edges.assets', {
72   - url: '/:edgeId/assets',
73   - params: {'topIndex': 0},
74   - module: 'private',
75   - auth: ['TENANT_ADMIN'],
76   - views: {
77   - "content@home": {
78   - templateUrl: assetsTemplate,
79   - controllerAs: 'vm',
80   - controller: 'AssetController'
81   - }
82   - },
83   - data: {
84   - assetsType: 'edge',
85   - searchEnabled: true,
86   - searchByEntitySubtype: true,
87   - searchEntityType: types.entityType.asset,
88   - pageTitle: 'edge.assets'
89   - },
90   - ncyBreadcrumb: {
91   - label: '{"icon": "domain", "label": "edge.assets"}'
92   - }
93 70 });
94 71
95 72 }
... ...
... ... @@ -124,47 +124,4 @@ export default function DashboardRoutes($stateProvider) {
124 124 label: '{"icon": "dashboard", "label": "customer.dashboard"}'
125 125 }
126 126 })
127   - .state('home.edges.dashboards', {
128   - url: '/:edgeId/dashboards',
129   - params: {'topIndex': 0},
130   - module: 'private',
131   - auth: ['TENANT_ADMIN'],
132   - views: {
133   - "content@home": {
134   - templateUrl: dashboardsTemplate,
135   - controllerAs: 'vm',
136   - controller: 'DashboardsController'
137   - }
138   - },
139   - data: {
140   - dashboardsType: 'edge',
141   - searchEnabled: true,
142   - pageTitle: 'edge.dashboards'
143   - },
144   - ncyBreadcrumb: {
145   - label: '{"icon": "dashboard", "label": "edge.dashboards"}'
146   - }
147   - })
148   - .state('home.edges.dashboards.dashboard', {
149   - url: '/:dashboardId?state',
150   - reloadOnSearch: false,
151   - module: 'private',
152   - auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
153   - views: {
154   - "content@home": {
155   - templateUrl: dashboardTemplate,
156   - controller: 'DashboardController',
157   - controllerAs: 'vm'
158   - }
159   - },
160   - data: {
161   - widgetEditMode: false,
162   - searchEnabled: false,
163   - pageTitle: 'dashboard.dashboard',
164   - dashboardsType: 'edge',
165   - },
166   - ncyBreadcrumb: {
167   - label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}'
168   - }
169   - })
170 127 }
... ...
... ... @@ -222,20 +222,6 @@ export function DeviceController($rootScope, userService, deviceService, custome
222 222 deviceActionsList.push(
223 223 {
224 224 onAction: function ($event, item) {
225   - unassignFromEdge($event, item, false);
226   - },
227   - name: function() { return $translate.instant('action.unassign') },
228   - details: function() { return $translate.instant('device.unassign-from-edge') },
229   - icon: "portable_wifi_off",
230   - isEnabled: function(device) {
231   - return device && device.edgeId && device.edgeId.id !== types.id.nullUid;
232   - }
233   - }
234   - );
235   -
236   - deviceActionsList.push(
237   - {
238   - onAction: function ($event, item) {
239 225 manageCredentials($event, item);
240 226 },
241 227 name: function() { return $translate.instant('device.credentials') },
... ...
... ... @@ -67,29 +67,6 @@ export default function DeviceRoutes($stateProvider, types) {
67 67 ncyBreadcrumb: {
68 68 label: '{"icon": "devices_other", "label": "{{ vm.customerDevicesTitle }}", "translate": "false"}'
69 69 }
70   - })
71   - .state('home.edges.devices', {
72   - url: '/:edgeId/devices',
73   - params: {'topIndex': 0},
74   - module: 'private',
75   - auth: ['TENANT_ADMIN'],
76   - views: {
77   - "content@home": {
78   - templateUrl: devicesTemplate,
79   - controllerAs: 'vm',
80   - controller: 'DeviceController'
81   - }
82   - },
83   - data: {
84   - devicesType: 'edge',
85   - searchEnabled: true,
86   - searchByEntitySubtype: true,
87   - searchEntityType: types.entityType.device,
88   - pageTitle: 'edge.devices'
89   - },
90   - ncyBreadcrumb: {
91   - label: '{"icon": "devices_other", "label": "edge.devices"}'
92   - }
93 70 });
94 71
95 72 }
... ...
... ... @@ -577,7 +577,6 @@ export function EdgeController($rootScope, userService, edgeService, customerSer
577 577 });
578 578 }
579 579
580   -
581 580 function assignEdgesToCustomer($event, items) {
582 581 var edgeIds = [];
583 582 for (var id in items.selections) {
... ... @@ -667,7 +666,6 @@ export function EdgeController($rootScope, userService, edgeService, customerSer
667 666 $state.go('home.edges.ruleChains', {edgeId: edge.id.id});
668 667 }
669 668
670   -
671 669 function openEdgeAssets($event, edge) {
672 670 if ($event) {
673 671 $event.stopPropagation();
... ...
... ... @@ -16,6 +16,11 @@
16 16 /* eslint-disable import/no-unresolved, import/default */
17 17
18 18 import edgesTemplate from './edges.tpl.html';
  19 +import entityViewsTemplate from "../entity-view/entity-views.tpl.html";
  20 +import devicesTemplate from "../device/devices.tpl.html";
  21 +import assetsTemplate from "../asset/assets.tpl.html";
  22 +import dashboardsTemplate from "../dashboard/dashboards.tpl.html";
  23 +import dashboardTemplate from "../dashboard/dashboard.tpl.html";
19 24
20 25 /* eslint-enable import/no-unresolved, import/default */
21 26
... ... @@ -45,27 +50,116 @@ export default function EdgeRoutes($stateProvider, types) {
45 50 label: '{"icon": "transform", "label": "edge.edges"}'
46 51 }
47 52 })
48   - .state('home.customers.edges', {
49   - url: '/:customerId/edges',
  53 + .state('home.edges.entityViews', {
  54 + url: '/:edgeId/entityViews',
50 55 params: {'topIndex': 0},
51 56 module: 'private',
52 57 auth: ['TENANT_ADMIN'],
53 58 views: {
54 59 "content@home": {
55   - templateUrl: edgesTemplate,
  60 + templateUrl: entityViewsTemplate,
56 61 controllerAs: 'vm',
57   - controller: 'EdgeController'
  62 + controller: 'EntityViewController'
58 63 }
59 64 },
60 65 data: {
61   - edgesType: 'customer',
  66 + entityViewsType: 'edge',
62 67 searchEnabled: true,
63 68 searchByEntitySubtype: true,
64   - searchEntityType: types.entityType.edge,
65   - pageTitle: 'customer.edges'
  69 + searchEntityType: types.entityType.entityView,
  70 + pageTitle: 'edge.entity-views'
  71 + },
  72 + ncyBreadcrumb: {
  73 + label: '{"icon": "view_quilt", "label": "edge.entity-views"}'
  74 + }
  75 + })
  76 + .state('home.edges.devices', {
  77 + url: '/:edgeId/devices',
  78 + params: {'topIndex': 0},
  79 + module: 'private',
  80 + auth: ['TENANT_ADMIN'],
  81 + views: {
  82 + "content@home": {
  83 + templateUrl: devicesTemplate,
  84 + controllerAs: 'vm',
  85 + controller: 'DeviceController'
  86 + }
  87 + },
  88 + data: {
  89 + devicesType: 'edge',
  90 + searchEnabled: true,
  91 + searchByEntitySubtype: true,
  92 + searchEntityType: types.entityType.device,
  93 + pageTitle: 'edge.devices'
  94 + },
  95 + ncyBreadcrumb: {
  96 + label: '{"icon": "devices_other", "label": "edge.devices"}'
  97 + }
  98 + })
  99 + .state('home.edges.assets', {
  100 + url: '/:edgeId/assets',
  101 + params: {'topIndex': 0},
  102 + module: 'private',
  103 + auth: ['TENANT_ADMIN'],
  104 + views: {
  105 + "content@home": {
  106 + templateUrl: assetsTemplate,
  107 + controllerAs: 'vm',
  108 + controller: 'AssetController'
  109 + }
  110 + },
  111 + data: {
  112 + assetsType: 'edge',
  113 + searchEnabled: true,
  114 + searchByEntitySubtype: true,
  115 + searchEntityType: types.entityType.asset,
  116 + pageTitle: 'edge.assets'
  117 + },
  118 + ncyBreadcrumb: {
  119 + label: '{"icon": "domain", "label": "edge.assets"}'
  120 + }
  121 + })
  122 + .state('home.edges.dashboards', {
  123 + url: '/:edgeId/dashboards',
  124 + params: {'topIndex': 0},
  125 + module: 'private',
  126 + auth: ['TENANT_ADMIN'],
  127 + views: {
  128 + "content@home": {
  129 + templateUrl: dashboardsTemplate,
  130 + controllerAs: 'vm',
  131 + controller: 'DashboardsController'
  132 + }
  133 + },
  134 + data: {
  135 + dashboardsType: 'edge',
  136 + searchEnabled: true,
  137 + pageTitle: 'edge.dashboards'
  138 + },
  139 + ncyBreadcrumb: {
  140 + label: '{"icon": "dashboard", "label": "edge.dashboards"}'
  141 + }
  142 + })
  143 + .state('home.edges.dashboards.dashboard', {
  144 + url: '/:dashboardId?state',
  145 + reloadOnSearch: false,
  146 + module: 'private',
  147 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
  148 + views: {
  149 + "content@home": {
  150 + templateUrl: dashboardTemplate,
  151 + controller: 'DashboardController',
  152 + controllerAs: 'vm'
  153 + }
  154 + },
  155 + data: {
  156 + widgetEditMode: false,
  157 + searchEnabled: false,
  158 + pageTitle: 'dashboard.dashboard',
  159 + dashboardsType: 'edge',
66 160 },
67 161 ncyBreadcrumb: {
68   - label: '{"icon": "transform", "label": "{{ vm.customerEdgesTitle }}", "translate": "false"}'
  162 + label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}'
69 163 }
70 164 });
71 165 }
... ...
... ... @@ -294,6 +294,19 @@ export function EntityViewController($rootScope, userService, entityViewService,
294 294 return {"edgeId": edgeId, "topIndex": vm.topIndex};
295 295 };
296 296
  297 + entityViewActionsList.push({
  298 + onAction: function ($event, item) {
  299 + unassignFromEdge($event, item, false);
  300 + },
  301 + name: function() { return $translate.instant('action.unassign') },
  302 + details: function() { return $translate.instant('entity-view.unassign-from-edge') },
  303 + icon: "assignment_return",
  304 + isEnabled: function(entityView) {
  305 + return entityView && entityView.edgeId && entityView.edgeId.id !== types.id.nullUid;
  306 + }
  307 + }
  308 + );
  309 +
297 310 entityViewGroupActionsList.push(
298 311 {
299 312 onAction: function ($event, items) {
... ... @@ -583,4 +596,25 @@ export function EntityViewController($rootScope, userService, entityViewService,
583 596 });
584 597 });
585 598 }
  599 +
  600 + function unassignFromEdge($event, entityView) {
  601 + if ($event) {
  602 + $event.stopPropagation();
  603 + }
  604 + var title = $translate.instant('entity-view.unassign-entity-view-from-edge-title', {entityViewName: entityView.name});
  605 + var content = $translate.instant('entity-view.unassign-entity-view-from-edge-text');
  606 + var label = $translate.instant('entity-view.unassign-entity-view');
  607 + var confirm = $mdDialog.confirm()
  608 + .targetEvent($event)
  609 + .title(title)
  610 + .htmlContent(content)
  611 + .ariaLabel(label)
  612 + .cancel($translate.instant('action.no'))
  613 + .ok($translate.instant('action.yes'));
  614 + $mdDialog.show(confirm).then(function () {
  615 + entityViewService.unassignEntityViewFromEdge(entityView.id.id).then(function success() {
  616 + vm.grid.refreshList();
  617 + });
  618 + });
  619 + }
586 620 }
... ...
... ... @@ -67,29 +67,5 @@ export default function EntityViewRoutes($stateProvider, types) {
67 67 ncyBreadcrumb: {
68 68 label: '{"icon": "view_quilt", "label": "{{ vm.customerEntityViewsTitle }}", "translate": "false"}'
69 69 }
70   - })
71   - .state('home.edges.entityViews', {
72   - url: '/:edgeId/entityViews',
73   - params: {'topIndex': 0},
74   - module: 'private',
75   - auth: ['TENANT_ADMIN'],
76   - views: {
77   - "content@home": {
78   - templateUrl: entityViewsTemplate,
79   - controllerAs: 'vm',
80   - controller: 'EntityViewController'
81   - }
82   - },
83   - data: {
84   - entityViewsType: 'edge',
85   - searchEnabled: true,
86   - searchByEntitySubtype: true,
87   - searchEntityType: types.entityType.entityView,
88   - pageTitle: 'edge.entity-views'
89   - },
90   - ncyBreadcrumb: {
91   - label: '{"icon": "view_quilt", "label": "edge.entity-views"}'
92   - }
93 70 });
94   -
95 71 }
... ...
1   -/**
2   - * Copyright © 2016-2020 The Thingsboard Authors
3   - *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
14   - * limitations under the License.
15   - */
16   -.tb-rule-chain-assigned-edges {
17   - display: block;
18   - display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
19   - height: 34px;
20   - margin-bottom: 4px;
21   - overflow: hidden;
22   - text-overflow: ellipsis;
23   - -webkit-line-clamp: 2;
24   - -webkit-box-orient: vertical; /* stylelint-disable-line property-no-vendor-prefix */
25   -}
... ... @@ -17,9 +17,6 @@
17 17 -->
18 18 <div ng-if="(vm.parentCtl.ruleChainsScope === 'tenant' && item && item.root) ||
19 19 (vm.parentCtl.ruleChainsScope === 'edge' && vm.parentCtl.isRootRuleChain(item)) ||
20   - (vm.parentCtl.ruleChainsScope === 'edges' && vm.parentCtl.isRootRuleChain(item))"
21   - translate>rulechain.root
22   -</div>
23   -<div ng-if="(vm.parentCtl.ruleChainsScope === 'edge' && vm.parentCtl.isDefaultEdgeRuleChain(item))"
24   - translate>rulechain.default
25   -</div>
  20 + (vm.parentCtl.ruleChainsScope === 'edges' && vm.parentCtl.isRootRuleChain(item))" translate>rulechain.root </div>
  21 +
  22 +<div ng-if="(vm.parentCtl.ruleChainsScope === 'edge' && vm.parentCtl.isDefaultEdgeRuleChain(item))" translate>rulechain.default </div>
... ...
... ... @@ -21,8 +21,6 @@ import addRuleChainsToEdgeTemplate from "./add-rulechains-to-edge.tpl.html";
21 21
22 22 /* eslint-enable import/no-unresolved, import/default */
23 23
24   -import './rulechain-card.scss';
25   -
26 24 /*@ngInject*/
27 25 export default function RuleChainsController(ruleChainService, userService, edgeService, importExport, $state,
28 26 $stateParams, $filter, $translate, $mdDialog, $document, $q, types) {
... ... @@ -342,6 +340,7 @@ export default function RuleChainsController(ruleChainService, userService, edge
342 340 var deferred = $q.defer();
343 341 ruleChainService.getDefaultEdgeRuleChains(null).then(
344 342 function success(response) {
  343 + defaultEdgeRuleChainIds = [];
345 344 response.map(function (ruleChain) {
346 345 defaultEdgeRuleChainIds.push(ruleChain.id.id)
347 346 });
... ... @@ -368,7 +367,7 @@ export default function RuleChainsController(ruleChainService, userService, edge
368 367
369 368 function fetchEdgeRuleChains(edgeId, pageLink) {
370 369 var deferred = $q.defer();
371   - ruleChainService.getRuleChains(pageLink, null, types.edgeRuleChainType).then(
  370 + ruleChainService.getEdgeRuleChains(edgeId, pageLink, null).then(
372 371 function success(ruleChains) {
373 372 getDefaultEdges(ruleChains).then(
374 373 function success(response) {
... ... @@ -377,7 +376,6 @@ export default function RuleChainsController(ruleChainService, userService, edge
377 376 deferred.reject();
378 377 }
379 378 );
380   - // deferred.resolve(response);
381 379 }, function fail() {
382 380 deferred.reject();
383 381 }
... ...