Browse Source

Edge assignment cleaned all over CE entities, except Edge page. Fixed some locals for Unassign edge

pull/2436/head
deaflynx 6 years ago
parent
commit
7ec2b8d310
  1. 1386
      msa/js-executor/package-lock.json
  2. 12
      msa/web-ui/package-lock.json
  3. 2
      ui/package-lock.json
  4. 85
      ui/src/app/asset/asset.controller.js
  5. 123
      ui/src/app/asset/assign-to-edge.controller.js
  6. 76
      ui/src/app/asset/assign-to-edge.tpl.html
  7. 2
      ui/src/app/asset/index.js
  8. 20
      ui/src/app/customer/customer.controller.js
  9. 73
      ui/src/app/dashboard/dashboards.controller.js
  10. 3
      ui/src/app/dashboard/dashboards.tpl.html
  11. 2
      ui/src/app/dashboard/index.js
  12. 69
      ui/src/app/dashboard/manage-assigned-edges.controller.js
  13. 51
      ui/src/app/dashboard/manage-assigned-edges.tpl.html
  14. 123
      ui/src/app/device/assign-to-edge.controller.js
  15. 76
      ui/src/app/device/assign-to-edge.tpl.html
  16. 75
      ui/src/app/device/device.controller.js
  17. 2
      ui/src/app/device/index.js
  18. 123
      ui/src/app/entity-view/assign-to-edge.controller.js
  19. 76
      ui/src/app/entity-view/assign-to-edge.tpl.html
  20. 115
      ui/src/app/entity-view/entity-view.controller.js
  21. 2
      ui/src/app/entity-view/index.js
  22. 9
      ui/src/app/locale/locale.constant-en_US.json
  23. 2
      ui/src/app/rulechain/index.js
  24. 69
      ui/src/app/rulechain/manage-assigned-edges.controller.js
  25. 51
      ui/src/app/rulechain/manage-assigned-edges.tpl.html
  26. 74
      ui/src/app/rulechain/rulechains.controller.js

1386
msa/js-executor/package-lock.json

File diff suppressed because it is too large

12
msa/web-ui/package-lock.json

@ -1,6 +1,6 @@
{ {
"name": "thingsboard-web-ui", "name": "thingsboard-web-ui",
"version": "2.4.3", "version": "2.5.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1149,7 +1149,7 @@
}, },
"fecha": { "fecha": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", "resolved": "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz",
"integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
}, },
"file-stream-rotator": { "file-stream-rotator": {
@ -2354,7 +2354,7 @@
}, },
"json5": { "json5": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "http://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"requires": { "requires": {
"minimist": "^1.2.0" "minimist": "^1.2.0"
@ -2581,7 +2581,7 @@
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -2590,7 +2590,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true "dev": true
} }
@ -2859,7 +2859,7 @@
}, },
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },

2
ui/package-lock.json

@ -1,6 +1,6 @@
{ {
"name": "thingsboard", "name": "thingsboard",
"version": "2.4.3", "version": "2.5.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

85
ui/src/app/asset/asset.controller.js

@ -19,7 +19,6 @@ import addAssetTemplate from './add-asset.tpl.html';
import assetCard from './asset-card.tpl.html'; import assetCard from './asset-card.tpl.html';
import assignToCustomerTemplate from './assign-to-customer.tpl.html'; import assignToCustomerTemplate from './assign-to-customer.tpl.html';
import addAssetsToCustomerTemplate from './add-assets-to-customer.tpl.html'; import addAssetsToCustomerTemplate from './add-assets-to-customer.tpl.html';
import assignToEdgeTemplate from './assign-to-edge.tpl.html';
import addAssetsToEdgeTemplate from './add-assets-to-edge.tpl.html'; import addAssetsToEdgeTemplate from './add-assets-to-edge.tpl.html';
/* eslint-enable import/no-unresolved, import/default */ /* eslint-enable import/no-unresolved, import/default */
@ -219,32 +218,6 @@ export function AssetController($rootScope, userService, assetService, customerS
} }
}); });
assetActionsList.push({
onAction: function ($event, item) {
assignToEdge($event, [ item.id.id ]);
},
name: function() { return $translate.instant('action.assign') },
details: function() { return $translate.instant('asset.assign-to-edge') },
icon: "wifi_tethering",
isEnabled: function(asset) {
return asset && (!asset.edgeId || asset.edgeId.id === types.id.nullUid);
}
}
);
assetActionsList.push({
onAction: function ($event, item) {
unassignFromEdge($event, item, false);
},
name: function() { return $translate.instant('action.unassign') },
details: function() { return $translate.instant('asset.unassign-from-edge') },
icon: "portable_wifi_off",
isEnabled: function(asset) {
return asset && asset.edgeId && asset.edgeId.id !== types.id.nullUid;
}
}
);
assetActionsList.push( assetActionsList.push(
{ {
onAction: function ($event, item) { onAction: function ($event, item) {
@ -269,19 +242,6 @@ export function AssetController($rootScope, userService, assetService, customerS
} }
); );
assetGroupActionsList.push(
{
onAction: function ($event, items) {
assignAssetsToEdge($event, items);
},
name: function() { return $translate.instant('asset.assign-assets') },
details: function(selectedCount) {
return $translate.instant('asset.assign-assets-text', {count: selectedCount}, "messageformat");
},
icon: "wifi_tethering"
}
);
assetGroupActionsList.push( assetGroupActionsList.push(
{ {
onAction: function ($event) { onAction: function ($event) {
@ -391,7 +351,7 @@ export function AssetController($rootScope, userService, assetService, customerS
}, },
name: function() { return $translate.instant('asset.unassign-assets') }, name: function() { return $translate.instant('asset.unassign-assets') },
details: function(selectedCount) { details: function(selectedCount) {
return $translate.instant('asset.unassign-assets-action-title', {count: selectedCount}, "messageformat"); return $translate.instant('asset.unassign-assets-from-edge-action-title', {count: selectedCount}, "messageformat");
}, },
icon: "assignment_return" icon: "assignment_return"
} }
@ -619,41 +579,6 @@ export function AssetController($rootScope, userService, assetService, customerS
}); });
} }
function assignToEdge($event, assetIds) {
if ($event) {
$event.stopPropagation();
}
var pageSize = 10;
edgeService.getEdges({limit: pageSize, textSearch: ''}).then(
function success(_edges) {
var edges = {
pageSize: pageSize,
data: _edges.data,
nextPageLink: _edges.nextPageLink,
selection: null,
hasNext: _edges.hasNext,
pending: false
};
if (edges.hasNext) {
edges.nextPageLink.limit = pageSize;
}
$mdDialog.show({
controller: 'AssignAssetToEdgeController',
controllerAs: 'vm',
templateUrl: assignToEdgeTemplate,
locals: {assetIds: assetIds, edges: edges},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
}, function () {
});
},
function fail() {
});
}
function addAssetsToEdge($event) { function addAssetsToEdge($event) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();
@ -690,14 +615,6 @@ export function AssetController($rootScope, userService, assetService, customerS
}); });
} }
function assignAssetsToEdge($event, items) {
var assetIds = [];
for (var id in items.selections) {
assetIds.push(id);
}
assignToEdge($event, assetIds);
}
function unassignFromEdge($event, asset) { function unassignFromEdge($event, asset) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();

123
ui/src/app/asset/assign-to-edge.controller.js

@ -1,123 +0,0 @@
/*
* 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.
*/
/*@ngInject*/
export default function AssignAssetToEdgeController(edgeService, assetService, $mdDialog, $q, assetIds, edges) {
var vm = this;
vm.edges = edges;
vm.searchText = '';
vm.assign = assign;
vm.cancel = cancel;
vm.isEdgeSelected = isEdgeSelected;
vm.hasData = hasData;
vm.noData = noData;
vm.searchEdgeTextUpdated = searchEdgeTextUpdated;
vm.toggleEdgeSelection = toggleEdgeSelection;
vm.theEdges = {
getItemAtIndex: function (index) {
if (index > vm.edges.data.length) {
vm.theEdges.fetchMoreItems_(index);
return null;
}
var item = vm.edges.data[index];
if (item) {
item.indexNumber = index + 1;
}
return item;
},
getLength: function () {
if (vm.edges.hasNext) {
return vm.edges.data.length + vm.edges.nextPageLink.limit;
} else {
return vm.edges.data.length;
}
},
fetchMoreItems_: function () {
if (vm.edges.hasNext && !vm.edges.pending) {
vm.edges.pending = true;
edgeService.getEdges(vm.edges.nextPageLink).then(
function success(edges) {
vm.edges.data = vm.edges.data.concat(edges.data);
vm.edges.nextPageLink = edges.nextPageLink;
vm.edges.hasNext = edges.hasNext;
if (vm.edges.hasNext) {
vm.edges.nextPageLink.limit = vm.edges.pageSize;
}
vm.edges.pending = false;
},
function fail() {
vm.edges.hasNext = false;
vm.edges.pending = false;
});
}
}
};
function cancel() {
$mdDialog.cancel();
}
function assign() {
var tasks = [];
for (var i=0;i<assetIds.length;i++) {
tasks.push(assetService.assignAssetToEdge(vm.edges.selection.id.id, assetIds[i]));
}
$q.all(tasks).then(function () {
$mdDialog.hide();
});
}
function noData() {
return vm.edges.data.length == 0 && !vm.edges.hasNext;
}
function hasData() {
return vm.edges.data.length > 0;
}
function toggleEdgeSelection($event, edge) {
$event.stopPropagation();
if (vm.isEdgeSelected(edge)) {
vm.edges.selection = null;
} else {
vm.edges.selection = edge;
}
}
function isEdgeSelected(edge) {
return vm.edges.selection != null && edge &&
edge.id.id === vm.edges.selection.id.id;
}
function searchEdgeTextUpdated() {
vm.edges = {
pageSize: vm.edges.pageSize,
data: [],
nextPageLink: {
limit: vm.edges.pageSize,
textSearch: vm.searchText
},
selection: null,
hasNext: true,
pending: false
};
}
}

76
ui/src/app/asset/assign-to-edge.tpl.html

@ -1,76 +0,0 @@
<!--
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.
-->
<md-dialog aria-label="{{ 'asset.assign-asset-to-edge' | translate }}">
<form name="theForm" ng-submit="vm.assign()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>asset.assign-asset-to-edge</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="vm.cancel()">
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>asset.assign-to-edge-text</span>
<md-input-container class="md-block" style='margin-bottom: 0px;'>
<label>&nbsp;</label>
<md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons">
search
</md-icon>
<input id="edge-search" autofocus ng-model="vm.searchText"
ng-change="vm.searchEdgeTextUpdated()"
placeholder="{{ 'common.enter-search' | translate }}"/>
</md-input-container>
<div style='min-height: 150px;'>
<span translate layout-align="center center"
style="text-transform: uppercase; display: flex; height: 150px;"
class="md-subhead"
ng-show="vm.noData()">edge.no-edges-text</span>
<md-virtual-repeat-container ng-show="vm.hasData()"
tb-scope-element="repeatContainer" md-top-index="vm.topIndex" flex
style='min-height: 150px; width: 100%;'>
<md-list>
<md-list-item md-virtual-repeat="edge in vm.theEdges" md-on-demand
class="repeated-item" flex>
<md-checkbox ng-click="vm.toggleEdgeSelection($event, edge)"
aria-label="{{ 'item.selected' | translate }}"
ng-checked="vm.isEdgeSelected(edge)"></md-checkbox>
<span> {{ edge.name }} </span>
</md-list-item>
</md-list>
</md-virtual-repeat-container>
</div>
</fieldset>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading || vm.edges.selection==null" type="submit" class="md-raised md-primary">
{{ 'action.assign' | translate }}
</md-button>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' |
translate }}
</md-button>
</md-dialog-actions>
</form>
</md-dialog>

2
ui/src/app/asset/index.js

@ -24,7 +24,6 @@ import {AssetController, AssetCardController} from './asset.controller';
import AssignAssetToCustomerController from './assign-to-customer.controller'; import AssignAssetToCustomerController from './assign-to-customer.controller';
import AddAssetsToCustomerController from './add-assets-to-customer.controller'; import AddAssetsToCustomerController from './add-assets-to-customer.controller';
import AssetDirective from './asset.directive'; import AssetDirective from './asset.directive';
import AssignAssetToEdgeController from './assign-to-edge.controller';
import AddAssetsToEdgeController from './add-assets-to-edge.controller'; import AddAssetsToEdgeController from './add-assets-to-edge.controller';
export default angular.module('thingsboard.asset', [ export default angular.module('thingsboard.asset', [
@ -39,7 +38,6 @@ export default angular.module('thingsboard.asset', [
.controller('AssetCardController', AssetCardController) .controller('AssetCardController', AssetCardController)
.controller('AssignAssetToCustomerController', AssignAssetToCustomerController) .controller('AssignAssetToCustomerController', AssignAssetToCustomerController)
.controller('AddAssetsToCustomerController', AddAssetsToCustomerController) .controller('AddAssetsToCustomerController', AddAssetsToCustomerController)
.controller('AssignAssetToEdgeController', AssignAssetToEdgeController)
.controller('AddAssetsToEdgeController', AddAssetsToEdgeController) .controller('AddAssetsToEdgeController', AddAssetsToEdgeController)
.directive('tbAsset', AssetDirective) .directive('tbAsset', AssetDirective)
.name; .name;

20
ui/src/app/customer/customer.controller.js

@ -77,20 +77,6 @@ export default function CustomerController(customerService, $state, $stateParams
}, },
icon: "dashboard" icon: "dashboard"
}, },
{
onAction: function ($event, item) {
openCustomerEdges($event, item);
},
name: function() { return $translate.instant('edge.edges') },
details: function(customer) {
if (customer && customer.additionalInfo && customer.additionalInfo.isPublic) {
return $translate.instant('customer.manage-public-edges')
} else {
return $translate.instant('customer.manage-customer-edges')
}
},
icon: "wifi_tethering"
},
{ {
onAction: function ($event, item) { onAction: function ($event, item) {
vm.grid.deleteItem($event, item); vm.grid.deleteItem($event, item);
@ -230,10 +216,4 @@ export default function CustomerController(customerService, $state, $stateParams
$state.go('home.customers.dashboards', {customerId: customer.id.id}); $state.go('home.customers.dashboards', {customerId: customer.id.id});
} }
function openCustomerEdges($event, customer) {
if ($event) {
$event.stopPropagation();
}
$state.go('home.customers.edges', {customerId: customer.id.id});
}
} }

73
ui/src/app/dashboard/dashboards.controller.js

@ -20,7 +20,6 @@ import dashboardCard from './dashboard-card.tpl.html';
import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.html'; import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.html';
import makeDashboardPublicDialogTemplate from './make-dashboard-public-dialog.tpl.html'; import makeDashboardPublicDialogTemplate from './make-dashboard-public-dialog.tpl.html';
import manageAssignedCustomersTemplate from './manage-assigned-customers.tpl.html'; import manageAssignedCustomersTemplate from './manage-assigned-customers.tpl.html';
import manageAssignedEdgesTemplate from './manage-assigned-edges.tpl.html';
import addDashboardsToEdgeTemplate from './add-dashboards-to-edge.tpl.html'; import addDashboardsToEdgeTemplate from './add-dashboards-to-edge.tpl.html';
/* eslint-enable import/no-unresolved, import/default */ /* eslint-enable import/no-unresolved, import/default */
@ -222,14 +221,6 @@ export function DashboardsController(userService, dashboardService, customerServ
return dashboard; return dashboard;
} }
}); });
dashboardActionsList.push({
onAction: function ($event, item) {
manageAssignedEdges($event, item);
},
name: function() { return $translate.instant('action.assign') },
details: function() { return $translate.instant('dashboard.manage-assigned-edges') },
icon: "wifi_tethering"
});
/*dashboardActionsList.push({ /*dashboardActionsList.push({
onAction: function ($event, item) { onAction: function ($event, item) {
@ -265,32 +256,6 @@ export function DashboardsController(userService, dashboardService, customerServ
} }
); );
dashboardGroupActionsList.push(
{
onAction: function ($event, items) {
assignDashboardsToEdges($event, items);
},
name: function() { return $translate.instant('dashboard.assign-dashboards') },
details: function(selectedCount) {
return $translate.instant('dashboard.assign-dashboards-to-edge-text', {count: selectedCount}, "messageformat");
},
icon: "wifi_tethering"
}
);
dashboardGroupActionsList.push(
{
onAction: function ($event, items) {
unassignDashboardsFromEdges($event, items);
},
name: function() { return $translate.instant('dashboard.unassign-dashboards') },
details: function(selectedCount) {
return $translate.instant('dashboard.unassign-dashboards-from-edge-action-text', {count: selectedCount}, "messageformat");
},
icon: "portable_wifi_off"
}
);
dashboardGroupActionsList.push( dashboardGroupActionsList.push(
{ {
onAction: function ($event, items) { onAction: function ($event, items) {
@ -714,26 +679,6 @@ export function DashboardsController(userService, dashboardService, customerServ
} }
} }
function manageAssignedEdges($event, dashboard) {
showManageAssignedEdgesDialog($event, [dashboard.id.id], 'manage', dashboard.assignedEdgesIds);
}
function assignDashboardsToEdges($event, items) {
var dashboardIds = [];
for (var id in items.selections) {
dashboardIds.push(id);
}
showManageAssignedEdgesDialog($event, dashboardIds, 'assign');
}
function unassignDashboardsFromEdges($event, items) {
var dashboardIds = [];
for (var id in items.selections) {
dashboardIds.push(id);
}
showManageAssignedEdgesDialog($event, dashboardIds, 'unassign');
}
function unassignDashboardsFromEdge($event, items, edgeId) { function unassignDashboardsFromEdge($event, items, edgeId) {
var confirm = $mdDialog.confirm() var confirm = $mdDialog.confirm()
.targetEvent($event) .targetEvent($event)
@ -753,24 +698,6 @@ export function DashboardsController(userService, dashboardService, customerServ
}); });
} }
function showManageAssignedEdgesDialog($event, dashboardIds, actionType, assignedEdges) {
if ($event) {
$event.stopPropagation();
}
$mdDialog.show({
controller: 'ManageAssignedEdgesToDashboardController',
controllerAs: 'vm',
templateUrl: manageAssignedEdgesTemplate,
locals: {actionType: actionType, dashboardIds: dashboardIds, assignedEdges: assignedEdges},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
}, function () {
});
}
function addDashboardsToEdge($event) { function addDashboardsToEdge($event) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();

3
ui/src/app/dashboard/dashboards.tpl.html

@ -32,8 +32,7 @@
on-manage-assigned-customers="vm.manageAssignedCustomers(event, vm.grid.detailsConfig.currentItem)" on-manage-assigned-customers="vm.manageAssignedCustomers(event, vm.grid.detailsConfig.currentItem)"
on-unassign-from-customer="vm.unassignFromCustomer(event, vm.grid.detailsConfig.currentItem, vm.customerId)" on-unassign-from-customer="vm.unassignFromCustomer(event, vm.grid.detailsConfig.currentItem, vm.customerId)"
on-export-dashboard="vm.exportDashboard(event, vm.grid.detailsConfig.currentItem)" on-export-dashboard="vm.exportDashboard(event, vm.grid.detailsConfig.currentItem)"
on-delete-dashboard="vm.grid.deleteItem(event, vm.grid.detailsConfig.currentItem)" on-delete-dashboard="vm.grid.deleteItem(event, vm.grid.detailsConfig.currentItem)"></tb-dashboard-details>
on-manage-assigned-edges="vm.manageAssignedEdges(event, vm.grid.detailsConfig.currentItem)"></tb-dashboard-details>
</md-tab> </md-tab>
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.grid.isTenantAdmin()" md-on-select="vm.grid.triggerResize()" label="{{ 'audit-log.audit-logs' | translate }}"> <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.grid.isTenantAdmin()" md-on-select="vm.grid.triggerResize()" label="{{ 'audit-log.audit-logs' | translate }}">
<tb-audit-log-table flex entity-type="vm.types.entityType.dashboard" <tb-audit-log-table flex entity-type="vm.types.entityType.dashboard"

2
ui/src/app/dashboard/index.js

@ -42,7 +42,6 @@ import DashboardController from './dashboard.controller';
import DashboardSettingsController from './dashboard-settings.controller'; import DashboardSettingsController from './dashboard-settings.controller';
import AddDashboardsToCustomerController from './add-dashboards-to-customer.controller'; import AddDashboardsToCustomerController from './add-dashboards-to-customer.controller';
import ManageAssignedCustomersController from './manage-assigned-customers.controller'; import ManageAssignedCustomersController from './manage-assigned-customers.controller';
import ManageAssignedEdgesToDashboardController from './manage-assigned-edges.controller';
import AddWidgetController from './add-widget.controller'; import AddWidgetController from './add-widget.controller';
import DashboardDirective from './dashboard.directive'; import DashboardDirective from './dashboard.directive';
import EditWidgetDirective from './edit-widget.directive'; import EditWidgetDirective from './edit-widget.directive';
@ -78,7 +77,6 @@ export default angular.module('thingsboard.dashboard', [
.controller('DashboardSettingsController', DashboardSettingsController) .controller('DashboardSettingsController', DashboardSettingsController)
.controller('AddDashboardsToCustomerController', AddDashboardsToCustomerController) .controller('AddDashboardsToCustomerController', AddDashboardsToCustomerController)
.controller('ManageAssignedCustomersController', ManageAssignedCustomersController) .controller('ManageAssignedCustomersController', ManageAssignedCustomersController)
.controller('ManageAssignedEdgesToDashboardController', ManageAssignedEdgesToDashboardController)
.controller('AddWidgetController', AddWidgetController) .controller('AddWidgetController', AddWidgetController)
.controller('AddDashboardsToEdgeController', AddDashboardsToEdgeController) .controller('AddDashboardsToEdgeController', AddDashboardsToEdgeController)
.directive('tbDashboardDetails', DashboardDirective) .directive('tbDashboardDetails', DashboardDirective)

69
ui/src/app/dashboard/manage-assigned-edges.controller.js

@ -1,69 +0,0 @@
/*
* 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.
*/
/*@ngInject*/
export default function ManageAssignedEdgesToDashboardController($mdDialog, $q, types, dashboardService, actionType, dashboardIds, assignedEdges) {
var vm = this;
vm.types = types;
vm.actionType = actionType;
vm.dashboardIds = dashboardIds;
vm.assignedEdges = assignedEdges;
if (actionType != 'manage') {
vm.assignedEdges = [];
}
if (actionType == 'manage') {
vm.titleText = 'dashboard.manage-assigned-edges';
vm.labelText = 'dashboard.assigned-edges';
vm.actionName = 'action.update';
} else if (actionType == 'assign') {
vm.titleText = 'dashboard.assign-to-edges';
vm.labelText = 'dashboard.assign-to-edges-text';
vm.actionName = 'action.assign';
} else if (actionType == 'unassign') {
vm.titleText = 'dashboard.unassign-from-edges';
vm.labelText = 'dashboard.unassign-from-edges-text';
vm.actionName = 'action.unassign';
}
vm.submit = submit;
vm.cancel = cancel;
function cancel () {
$mdDialog.cancel();
}
function submit () {
var tasks = [];
for (var i=0;i<vm.dashboardIds.length;i++) {
var dashboardId = vm.dashboardIds[i];
var promise;
if (vm.actionType == 'manage') {
promise = dashboardService.updateDashboardEdges(dashboardId, vm.assignedEdges);
} else if (vm.actionType == 'assign') {
promise = dashboardService.addDashboardEdges(dashboardId, vm.assignedEdges);
} else if (vm.actionType == 'unassign') {
promise = dashboardService.removeDashboardEdges(dashboardId, vm.assignedEdges);
}
tasks.push(promise);
}
$q.all(tasks).then(function () {
$mdDialog.hide();
});
}
}

51
ui/src/app/dashboard/manage-assigned-edges.tpl.html

@ -1,51 +0,0 @@
<!--
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.
-->
<md-dialog aria-label="{{ vm.titleText | translate }}" style="width: 600px;">
<form name="theForm" ng-submit="vm.submit()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>{{vm.titleText}}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="vm.cancel()">
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>{{vm.labelText}}</span>
<tb-entity-list ng-disabled="$root.loading"
ng-model="vm.assignedEdges"
entity-type="vm.types.entityType.edge"></tb-entity-list>
</fieldset>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading || !theForm.$dirty || !theForm.$valid" type="submit" class="md-raised md-primary">
{{ vm.actionName | translate }}
</md-button>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' |
translate }}
</md-button>
</md-dialog-actions>
</form>
</md-dialog>

123
ui/src/app/device/assign-to-edge.controller.js

@ -1,123 +0,0 @@
/*
* 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.
*/
/*@ngInject*/
export default function AssignDeviceToEdgeController(edgeService, deviceService, $mdDialog, $q, deviceIds, edges) {
var vm = this;
vm.edges = edges;
vm.searchText = '';
vm.assign = assign;
vm.cancel = cancel;
vm.isEdgeSelected = isEdgeSelected;
vm.hasData = hasData;
vm.noData = noData;
vm.searchEdgeTextUpdated = searchEdgeTextUpdated;
vm.toggleEdgeSelection = toggleEdgeSelection;
vm.theEdges = {
getItemAtIndex: function (index) {
if (index > vm.edges.data.length) {
vm.theEdges.fetchMoreItems_(index);
return null;
}
var item = vm.edges.data[index];
if (item) {
item.indexNumber = index + 1;
}
return item;
},
getLength: function () {
if (vm.edges.hasNext) {
return vm.edges.data.length + vm.edges.nextPageLink.limit;
} else {
return vm.edges.data.length;
}
},
fetchMoreItems_: function () {
if (vm.edges.hasNext && !vm.edges.pending) {
vm.edges.pending = true;
edgeService.getEdges(vm.edges.nextPageLink).then(
function success(edges) {
vm.edges.data = vm.edges.data.concat(edges.data);
vm.edges.nextPageLink = edges.nextPageLink;
vm.edges.hasNext = edges.hasNext;
if (vm.edges.hasNext) {
vm.edges.nextPageLink.limit = vm.edges.pageSize;
}
vm.edges.pending = false;
},
function fail() {
vm.edges.hasNext = false;
vm.edges.pending = false;
});
}
}
};
function cancel() {
$mdDialog.cancel();
}
function assign() {
var tasks = [];
for (var i=0;i<deviceIds.length;i++) {
tasks.push(deviceService.assignDeviceToEdge(vm.edges.selection.id.id, deviceIds[i]));
}
$q.all(tasks).then(function () {
$mdDialog.hide();
});
}
function noData() {
return vm.edges.data.length == 0 && !vm.edges.hasNext;
}
function hasData() {
return vm.edges.data.length > 0;
}
function toggleEdgeSelection($event, edge) {
$event.stopPropagation();
if (vm.isEdgeSelected(edge)) {
vm.edges.selection = null;
} else {
vm.edges.selection = edge;
}
}
function isEdgeSelected(edge) {
return vm.edges.selection != null && edge &&
edge.id.id === vm.edges.selection.id.id;
}
function searchEdgeTextUpdated() {
vm.edges = {
pageSize: vm.edges.pageSize,
data: [],
nextPageLink: {
limit: vm.edges.pageSize,
textSearch: vm.searchText
},
selection: null,
hasNext: true,
pending: false
};
}
}

76
ui/src/app/device/assign-to-edge.tpl.html

@ -1,76 +0,0 @@
<!--
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.
-->
<md-dialog aria-label="{{ 'device.assign-device-to-edge' | translate }}">
<form name="theForm" ng-submit="vm.assign()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>device.assign-device-to-edge</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="vm.cancel()">
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>device.assign-to-edge-text</span>
<md-input-container class="md-block" style='margin-bottom: 0px;'>
<label>&nbsp;</label>
<md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons">
search
</md-icon>
<input id="edge-search" autofocus ng-model="vm.searchText"
ng-change="vm.searchEdgeTextUpdated()"
placeholder="{{ 'common.enter-search' | translate }}"/>
</md-input-container>
<div style='min-height: 150px;'>
<span translate layout-align="center center"
style="text-transform: uppercase; display: flex; height: 150px;"
class="md-subhead"
ng-show="vm.noData()">edge.no-edges-text</span>
<md-virtual-repeat-container ng-show="vm.hasData()"
tb-scope-element="repeatContainer" md-top-index="vm.topIndex" flex
style='min-height: 150px; width: 100%;'>
<md-list>
<md-list-item md-virtual-repeat="edge in vm.theEdges" md-on-demand
class="repeated-item" flex>
<md-checkbox ng-click="vm.toggleEdgeSelection($event, edge)"
aria-label="{{ 'item.selected' | translate }}"
ng-checked="vm.isEdgeSelected(edge)"></md-checkbox>
<span> {{ edge.name }} </span>
</md-list-item>
</md-list>
</md-virtual-repeat-container>
</div>
</fieldset>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading || vm.edges.selection==null" type="submit" class="md-raised md-primary">
{{ 'action.assign' | translate }}
</md-button>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' |
translate }}
</md-button>
</md-dialog-actions>
</form>
</md-dialog>

75
ui/src/app/device/device.controller.js

@ -20,7 +20,6 @@ import deviceCard from './device-card.tpl.html';
import assignToCustomerTemplate from './assign-to-customer.tpl.html'; import assignToCustomerTemplate from './assign-to-customer.tpl.html';
import addDevicesToCustomerTemplate from './add-devices-to-customer.tpl.html'; import addDevicesToCustomerTemplate from './add-devices-to-customer.tpl.html';
import deviceCredentialsTemplate from './device-credentials.tpl.html'; import deviceCredentialsTemplate from './device-credentials.tpl.html';
import assignToEdgeTemplate from './assign-to-edge.tpl.html';
import addDevicesToEdgeTemplate from './add-devices-to-edge.tpl.html'; import addDevicesToEdgeTemplate from './add-devices-to-edge.tpl.html';
/* eslint-enable import/no-unresolved, import/default */ /* eslint-enable import/no-unresolved, import/default */
@ -220,21 +219,6 @@ export function DeviceController($rootScope, userService, deviceService, custome
} }
}); });
deviceActionsList.push(
{
onAction: function ($event, item) {
assignToEdge($event, [ item.id.id ]);
},
name: function() { return $translate.instant('action.assign') },
details: function() { return $translate.instant('device.assign-to-edge') },
icon: "wifi_tethering",
isEnabled: function(device) {
return device && (!device.edgeId || device.edgeId.id === types.id.nullUid);
}
}
);
deviceActionsList.push( deviceActionsList.push(
{ {
onAction: function ($event, item) { onAction: function ($event, item) {
@ -284,20 +268,6 @@ export function DeviceController($rootScope, userService, deviceService, custome
} }
); );
deviceGroupActionsList.push(
{
onAction: function ($event, items) {
assignDevicesToEdge($event, items);
},
name: function() { return $translate.instant('device.assign-devices') },
details: function(selectedCount) {
return $translate.instant('device.assign-devices-text', {count: selectedCount}, "messageformat");
},
icon: "wifi_tethering"
}
);
deviceGroupActionsList.push( deviceGroupActionsList.push(
{ {
onAction: function ($event) { onAction: function ($event) {
@ -428,7 +398,7 @@ export function DeviceController($rootScope, userService, deviceService, custome
}, },
name: function() { return $translate.instant('device.unassign-devices') }, name: function() { return $translate.instant('device.unassign-devices') },
details: function(selectedCount) { details: function(selectedCount) {
return $translate.instant('device.unassign-devices-action-title', {count: selectedCount}, "messageformat"); return $translate.instant('device.unassign-devices-from-edge-action-title', {count: selectedCount}, "messageformat");
}, },
icon: "assignment_return" icon: "assignment_return"
} }
@ -672,41 +642,6 @@ export function DeviceController($rootScope, userService, deviceService, custome
}); });
} }
function assignToEdge($event, deviceIds) {
if ($event) {
$event.stopPropagation();
}
var pageSize = 10;
edgeService.getEdges({limit: pageSize, textSearch: ''}).then(
function success(_edges) {
var edges = {
pageSize: pageSize,
data: _edges.data,
nextPageLink: _edges.nextPageLink,
selection: null,
hasNext: _edges.hasNext,
pending: false
};
if (edges.hasNext) {
edges.nextPageLink.limit = pageSize;
}
$mdDialog.show({
controller: 'AssignDeviceToEdgeController',
controllerAs: 'vm',
templateUrl: assignToEdgeTemplate,
locals: {deviceIds: deviceIds, edges: edges},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
}, function () {
});
},
function fail() {
});
}
function addDevicesToEdge($event) { function addDevicesToEdge($event) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();
@ -743,14 +678,6 @@ export function DeviceController($rootScope, userService, deviceService, custome
}); });
} }
function assignDevicesToEdge($event, items) {
var deviceIds = [];
for (var id in items.selections) {
deviceIds.push(id);
}
assignToEdge($event, deviceIds);
}
function unassignFromEdge($event, device) { function unassignFromEdge($event, device) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();

2
ui/src/app/device/index.js

@ -25,7 +25,6 @@ import AssignDeviceToCustomerController from './assign-to-customer.controller';
import AddDevicesToCustomerController from './add-devices-to-customer.controller'; import AddDevicesToCustomerController from './add-devices-to-customer.controller';
import ManageDeviceCredentialsController from './device-credentials.controller'; import ManageDeviceCredentialsController from './device-credentials.controller';
import DeviceDirective from './device.directive'; import DeviceDirective from './device.directive';
import AssignDeviceToEdgeController from './assign-to-edge.controller';
import AddDevicesToEdgeController from './add-devices-to-edge.controller'; import AddDevicesToEdgeController from './add-devices-to-edge.controller';
export default angular.module('thingsboard.device', [ export default angular.module('thingsboard.device', [
@ -41,7 +40,6 @@ export default angular.module('thingsboard.device', [
.controller('AssignDeviceToCustomerController', AssignDeviceToCustomerController) .controller('AssignDeviceToCustomerController', AssignDeviceToCustomerController)
.controller('AddDevicesToCustomerController', AddDevicesToCustomerController) .controller('AddDevicesToCustomerController', AddDevicesToCustomerController)
.controller('ManageDeviceCredentialsController', ManageDeviceCredentialsController) .controller('ManageDeviceCredentialsController', ManageDeviceCredentialsController)
.controller('AssignDeviceToEdgeController', AssignDeviceToEdgeController)
.controller('AddDevicesToEdgeController', AddDevicesToEdgeController) .controller('AddDevicesToEdgeController', AddDevicesToEdgeController)
.directive('tbDevice', DeviceDirective) .directive('tbDevice', DeviceDirective)
.name; .name;

123
ui/src/app/entity-view/assign-to-edge.controller.js

@ -1,123 +0,0 @@
/*
* 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.
*/
/*@ngInject*/
export default function AssignEntityViewToEdgeController(edgeService, entityViewService, $mdDialog, $q, entityViewIds, edges) {
var vm = this;
vm.edges = edges;
vm.searchText = '';
vm.assign = assign;
vm.cancel = cancel;
vm.isEdgeSelected = isEdgeSelected;
vm.hasData = hasData;
vm.noData = noData;
vm.searchEdgeTextUpdated = searchEdgeTextUpdated;
vm.toggleEdgeSelection = toggleEdgeSelection;
vm.theEdges = {
getItemAtIndex: function (index) {
if (index > vm.edges.data.length) {
vm.theEdges.fetchMoreItems_(index);
return null;
}
var item = vm.edges.data[index];
if (item) {
item.indexNumber = index + 1;
}
return item;
},
getLength: function () {
if (vm.edges.hasNext) {
return vm.edges.data.length + vm.edges.nextPageLink.limit;
} else {
return vm.edges.data.length;
}
},
fetchMoreItems_: function () {
if (vm.edges.hasNext && !vm.edges.pending) {
vm.edges.pending = true;
edgeService.getEdges(vm.edges.nextPageLink).then(
function success(edges) {
vm.edges.data = vm.edges.data.concat(edges.data);
vm.edges.nextPageLink = edges.nextPageLink;
vm.edges.hasNext = edges.hasNext;
if (vm.edges.hasNext) {
vm.edges.nextPageLink.limit = vm.edges.pageSize;
}
vm.edges.pending = false;
},
function fail() {
vm.edges.hasNext = false;
vm.edges.pending = false;
});
}
}
};
function cancel() {
$mdDialog.cancel();
}
function assign() {
var tasks = [];
for (var i=0; i < entityViewIds.length;i++) {
tasks.push(entityViewService.assignEntityViewToEdge(vm.edges.selection.id.id, entityViewIds[i]));
}
$q.all(tasks).then(function () {
$mdDialog.hide();
});
}
function noData() {
return vm.edges.data.length == 0 && !vm.edges.hasNext;
}
function hasData() {
return vm.edges.data.length > 0;
}
function toggleEdgeSelection($event, edge) {
$event.stopPropagation();
if (vm.isEdgeSelected(edge)) {
vm.edges.selection = null;
} else {
vm.edges.selection = edge;
}
}
function isEdgeSelected(edge) {
return vm.edges.selection != null && edge &&
edge.id.id === vm.edges.selection.id.id;
}
function searchEdgeTextUpdated() {
vm.edges = {
pageSize: vm.edges.pageSize,
data: [],
nextPageLink: {
limit: vm.edges.pageSize,
textSearch: vm.searchText
},
selection: null,
hasNext: true,
pending: false
};
}
}

76
ui/src/app/entity-view/assign-to-edge.tpl.html

@ -1,76 +0,0 @@
<!--
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.
-->
<md-dialog aria-label="{{ 'entity-view.assign-entity-view-to-edge' | translate }}">
<form name="theForm" ng-submit="vm.assign()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>entity-view.assign-entity-view-to-edge</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="vm.cancel()">
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>entity-view.assign-to-edge-text</span>
<md-input-container class="md-block" style='margin-bottom: 0px;'>
<label>&nbsp;</label>
<md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons">
search
</md-icon>
<input id="edge-search" autofocus ng-model="vm.searchText"
ng-change="vm.searchEdgeTextUpdated()"
placeholder="{{ 'common.enter-search' | translate }}"/>
</md-input-container>
<div style='min-height: 150px;'>
<span translate layout-align="center center"
style="text-transform: uppercase; display: flex; height: 150px;"
class="md-subhead"
ng-show="vm.noData()">edge.no-edges-text</span>
<md-virtual-repeat-container ng-show="vm.hasData()"
tb-scope-element="repeatContainer" md-top-index="vm.topIndex" flex
style='min-height: 150px; width: 100%;'>
<md-list>
<md-list-item md-virtual-repeat="edge in vm.theEdges" md-on-demand
class="repeated-item" flex>
<md-checkbox ng-click="vm.toggleEdgeSelection($event, edge)"
aria-label="{{ 'item.selected' | translate }}"
ng-checked="vm.isEdgeSelected(edge)"></md-checkbox>
<span> {{ edge.name }} </span>
</md-list-item>
</md-list>
</md-virtual-repeat-container>
</div>
</fieldset>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading || vm.edges.selection==null" type="submit" class="md-raised md-primary">
{{ 'action.assign' | translate }}
</md-button>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' |
translate }}
</md-button>
</md-dialog-actions>
</form>
</md-dialog>

115
ui/src/app/entity-view/entity-view.controller.js

@ -19,7 +19,6 @@ import addEntityViewTemplate from './add-entity-view.tpl.html';
import entityViewCard from './entity-view-card.tpl.html'; import entityViewCard from './entity-view-card.tpl.html';
import assignToCustomerTemplate from './assign-to-customer.tpl.html'; import assignToCustomerTemplate from './assign-to-customer.tpl.html';
import addEntityViewsToCustomerTemplate from './add-entity-views-to-customer.tpl.html'; import addEntityViewsToCustomerTemplate from './add-entity-views-to-customer.tpl.html';
import assignToEdgeTemplate from './assign-to-edge.tpl.html';
import addEntityViewsToEdgeTemplate from './add-entity-views-to-edge.tpl.html'; import addEntityViewsToEdgeTemplate from './add-entity-views-to-edge.tpl.html';
/* eslint-enable import/no-unresolved, import/default */ /* eslint-enable import/no-unresolved, import/default */
@ -195,32 +194,6 @@ export function EntityViewController($rootScope, userService, entityViewService,
} }
}); });
entityViewActionsList.push({
onAction: function ($event, item) {
assignToEdge($event, [ item.id.id ]);
},
name: function() { return $translate.instant('action.assign') },
details: function() { return $translate.instant('entity-view.assign-to-edge') },
icon: "wifi_tethering",
isEnabled: function(entityView) {
return entityView && (!entityView.edgeId || entityView.edgeId.id === types.id.nullUid);
}
}
);
entityViewActionsList.push({
onAction: function ($event, item) {
unassignFromEdge($event, item, false);
},
name: function() { return $translate.instant('action.unassign') },
details: function() { return $translate.instant('entity-view.unassign-from-edge') },
icon: "portable_wifi_off",
isEnabled: function(entityView) {
return entityView && entityView.edgeId && entityView.edgeId.id !== types.id.nullUid;
}
}
);
entityViewActionsList.push( entityViewActionsList.push(
{ {
onAction: function ($event, item) { onAction: function ($event, item) {
@ -245,19 +218,6 @@ export function EntityViewController($rootScope, userService, entityViewService,
} }
); );
entityViewGroupActionsList.push(
{
onAction: function ($event, items) {
assignEntityViewsToEdge($event, items);
},
name: function() { return $translate.instant('entity-view.assign-assets') },
details: function(selectedCount) {
return $translate.instant('entity-view.assign-entity-views-text', {count: selectedCount}, "messageformat");
},
icon: "wifi_tethering"
}
);
entityViewGroupActionsList.push( entityViewGroupActionsList.push(
{ {
onAction: function ($event) { onAction: function ($event) {
@ -334,17 +294,6 @@ export function EntityViewController($rootScope, userService, entityViewService,
return {"edgeId": edgeId, "topIndex": vm.topIndex}; return {"edgeId": edgeId, "topIndex": vm.topIndex};
}; };
entityViewActionsList.push(
{
onAction: function ($event, item) {
unassignFromEdge($event, item, false);
},
name: function() { return $translate.instant('action.unassign') },
details: function() { return $translate.instant('entity-view.unassign-from-edge') },
icon: "assignment_return"
}
);
entityViewGroupActionsList.push( entityViewGroupActionsList.push(
{ {
onAction: function ($event, items) { onAction: function ($event, items) {
@ -580,41 +529,6 @@ export function EntityViewController($rootScope, userService, entityViewService,
}); });
} }
function assignToEdge($event, entityViewIds) {
if ($event) {
$event.stopPropagation();
}
var pageSize = 10;
edgeService.getEdges({limit: pageSize, textSearch: ''}).then(
function success(_edges) {
var edges = {
pageSize: pageSize,
data: _edges.data,
nextPageLink: _edges.nextPageLink,
selection: null,
hasNext: _edges.hasNext,
pending: false
};
if (edges.hasNext) {
edges.nextPageLink.limit = pageSize;
}
$mdDialog.show({
controller: 'AssignEntityViewToEdgeController',
controllerAs: 'vm',
templateUrl: assignToEdgeTemplate,
locals: {entityViewIds: entityViewIds, edges: edges},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
}, function () {
});
},
function fail() {
});
}
function addEntityViewsToEdge($event) { function addEntityViewsToEdge($event) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();
@ -651,35 +565,6 @@ export function EntityViewController($rootScope, userService, entityViewService,
}); });
} }
function assignEntityViewsToEdge($event, items) {
var entityViewIds = [];
for (var id in items.selections) {
entityViewIds.push(id);
}
assignToEdge($event, entityViewIds);
}
function unassignFromEdge($event, entityView) {
if ($event) {
$event.stopPropagation();
}
var title = $translate.instant('entity-view.unassign-entity-view-from-edge-title', {entityViewName: entityView.name});
var content = $translate.instant('entity-view.unassign-entity-view-from-edge-text');
var label = $translate.instant('entity-view.unassign-entity-view');
var confirm = $mdDialog.confirm()
.targetEvent($event)
.title(title)
.htmlContent(content)
.ariaLabel(label)
.cancel($translate.instant('action.no'))
.ok($translate.instant('action.yes'));
$mdDialog.show(confirm).then(function () {
entityViewService.unassignEntityViewFromEdge(entityView.id.id).then(function success() {
vm.grid.refreshList();
});
});
}
function unassignEntityViewsFromEdge($event, items) { function unassignEntityViewsFromEdge($event, items) {
var confirm = $mdDialog.confirm() var confirm = $mdDialog.confirm()
.targetEvent($event) .targetEvent($event)

2
ui/src/app/entity-view/index.js

@ -24,7 +24,6 @@ import {EntityViewController, EntityViewCardController} from './entity-view.cont
import AssignEntityViewToCustomerController from './assign-to-customer.controller'; import AssignEntityViewToCustomerController from './assign-to-customer.controller';
import AddEntityViewsToCustomerController from './add-entity-views-to-customer.controller'; import AddEntityViewsToCustomerController from './add-entity-views-to-customer.controller';
import EntityViewDirective from './entity-view.directive'; import EntityViewDirective from './entity-view.directive';
import AssignEntityViewToEdgeController from './assign-to-edge.controller';
import AddEntityViewsToEdgeController from './add-entity-views-to-edge.controller'; import AddEntityViewsToEdgeController from './add-entity-views-to-edge.controller';
export default angular.module('thingsboard.entityView', [ export default angular.module('thingsboard.entityView', [
@ -39,7 +38,6 @@ export default angular.module('thingsboard.entityView', [
.controller('EntityViewCardController', EntityViewCardController) .controller('EntityViewCardController', EntityViewCardController)
.controller('AssignEntityViewToCustomerController', AssignEntityViewToCustomerController) .controller('AssignEntityViewToCustomerController', AssignEntityViewToCustomerController)
.controller('AddEntityViewsToCustomerController', AddEntityViewsToCustomerController) .controller('AddEntityViewsToCustomerController', AddEntityViewsToCustomerController)
.controller('AssignEntityViewToEdgeController', AssignEntityViewToEdgeController)
.controller('AddEntityViewsToEdgeController', AddEntityViewsToEdgeController) .controller('AddEntityViewsToEdgeController', AddEntityViewsToEdgeController)
.directive('tbEntityView', EntityViewDirective) .directive('tbEntityView', EntityViewDirective)
.name; .name;

9
ui/src/app/locale/locale.constant-en_US.json

@ -292,7 +292,8 @@
"assign-to-edge": "Assign to edge", "assign-to-edge": "Assign to edge",
"assign-to-edge-text": "Please select the edge to assign the asset(s)", "assign-to-edge-text": "Please select the edge to assign the asset(s)",
"unassign-asset-from-edge-title": "Are you sure you want to unassign the asset '{{assetName}}'?", "unassign-asset-from-edge-title": "Are you sure you want to unassign the asset '{{assetName}}'?",
"unassign-asset-from-edge-text": "After the confirmation the asset will be unassigned and won't be accessible by the edge." "unassign-asset-from-edge-text": "After the confirmation the asset will be unassigned and won't be accessible by the edge.",
"unassign-assets-from-edge-action-title": "Unassign { count, plural, 1 {1 asset} other {# assets} } from edge"
}, },
"attribute": { "attribute": {
"attributes": "Attributes", "attributes": "Attributes",
@ -746,7 +747,8 @@
"assign-to-edge": "Assign to edge", "assign-to-edge": "Assign to edge",
"assign-to-edge-text": "Please select the edge to assign the device(s)", "assign-to-edge-text": "Please select the edge to assign the device(s)",
"unassign-device-from-edge-title": "Are you sure you want to unassign the device '{{deviceName}}'?", "unassign-device-from-edge-title": "Are you sure you want to unassign the device '{{deviceName}}'?",
"unassign-device-from-edge-text": "After the confirmation the device will be unassigned and won't be accessible by the edge." "unassign-device-from-edge-text": "After the confirmation the device will be unassigned and won't be accessible by the edge.",
"unassign-devices-from-edge-action-title": "Unassign { count, plural, 1 {1 device} other {# devices} } from edge"
}, },
"dialog": { "dialog": {
"close": "Close dialog" "close": "Close dialog"
@ -1051,7 +1053,8 @@
"assign-to-edge": "Assign to edge", "assign-to-edge": "Assign to edge",
"assign-to-edge-text": "Please select the edge to assign the entity view(s)", "assign-to-edge-text": "Please select the edge to assign the entity view(s)",
"unassign-entity-view-from-edge-title": "Are you sure you want to unassign the entity view '{{entityViewName}}'?", "unassign-entity-view-from-edge-title": "Are you sure you want to unassign the entity view '{{entityViewName}}'?",
"unassign-entity-view-from-edge-text": "After the confirmation the entity view will be unassigned and won't be accessible by the edge." "unassign-entity-view-from-edge-text": "After the confirmation the entity view will be unassigned and won't be accessible by the edge.",
"unassign-entity-views-from-edge-action-title": "Unassign { count, plural, 1 {1 entity view} other {# entity views} } from edge"
}, },
"event": { "event": {
"event-type": "Event type", "event-type": "Event type",

2
ui/src/app/rulechain/index.js

@ -25,7 +25,6 @@ import LinkDirective from './link.directive';
import MessageTypeAutocompleteDirective from './message-type-autocomplete.directive'; import MessageTypeAutocompleteDirective from './message-type-autocomplete.directive';
import NodeScriptTest from './script/node-script-test.service'; import NodeScriptTest from './script/node-script-test.service';
import AddRuleChainsToEdgeController from './add-rulechains-to-edge.controller'; import AddRuleChainsToEdgeController from './add-rulechains-to-edge.controller';
import ManageAssignedEdgesToRuleChainController from "./manage-assigned-edges.controller";
export default angular.module('thingsboard.ruleChain', []) export default angular.module('thingsboard.ruleChain', [])
.config(RuleChainRoutes) .config(RuleChainRoutes)
@ -34,7 +33,6 @@ export default angular.module('thingsboard.ruleChain', [])
.controller('AddRuleNodeController', AddRuleNodeController) .controller('AddRuleNodeController', AddRuleNodeController)
.controller('AddRuleNodeLinkController', AddRuleNodeLinkController) .controller('AddRuleNodeLinkController', AddRuleNodeLinkController)
.controller('NodeScriptTestController', NodeScriptTestController) .controller('NodeScriptTestController', NodeScriptTestController)
.controller('ManageAssignedEdgesToRuleChainController', ManageAssignedEdgesToRuleChainController)
.controller('AddRuleChainsToEdgeController', AddRuleChainsToEdgeController) .controller('AddRuleChainsToEdgeController', AddRuleChainsToEdgeController)
.directive('tbRuleChain', RuleChainDirective) .directive('tbRuleChain', RuleChainDirective)
.directive('tbRuleNodeDefinedConfig', RuleNodeDefinedConfigDirective) .directive('tbRuleNodeDefinedConfig', RuleNodeDefinedConfigDirective)

69
ui/src/app/rulechain/manage-assigned-edges.controller.js

@ -1,69 +0,0 @@
/*
* 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.
*/
/*@ngInject*/
export default function ManageAssignedEdgesToRuleChainController($mdDialog, $q, types, ruleChainService, actionType, ruleChainIds, assignedEdges) {
var vm = this;
vm.types = types;
vm.actionType = actionType;
vm.ruleChainIds = ruleChainIds;
vm.assignedEdges = assignedEdges;
if (actionType != 'manage') {
vm.assignedEdges = [];
}
if (actionType == 'manage') {
vm.titleText = 'rulechain.manage-assigned-edges';
vm.labelText = 'rulechain.assigned-edges';
vm.actionName = 'action.update';
} else if (actionType == 'assign') {
vm.titleText = 'rulechain.assign-to-edges';
vm.labelText = 'rulechain.assign-to-edges-text';
vm.actionName = 'action.assign';
} else if (actionType == 'unassign') {
vm.titleText = 'rulechain.unassign-from-edges';
vm.labelText = 'rulechain.unassign-from-edges-text';
vm.actionName = 'action.unassign';
}
vm.submit = submit;
vm.cancel = cancel;
function cancel () {
$mdDialog.cancel();
}
function submit () {
var tasks = [];
for (var i=0;i<vm.ruleChainIds.length;i++) {
var ruleChainId = vm.ruleChainIds[i];
var promise;
if (vm.actionType == 'manage') {
promise = ruleChainService.updateRuleChainEdges(ruleChainId, vm.assignedEdges);
} else if (vm.actionType == 'assign') {
promise = ruleChainService.addRuleChainEdges(ruleChainId, vm.assignedEdges);
} else if (vm.actionType == 'unassign') {
promise = ruleChainService.removeRuleChainEdges(ruleChainId, vm.assignedEdges);
}
tasks.push(promise);
}
$q.all(tasks).then(function () {
$mdDialog.hide();
});
}
}

51
ui/src/app/rulechain/manage-assigned-edges.tpl.html

@ -1,51 +0,0 @@
<!--
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.
-->
<md-dialog aria-label="{{ vm.titleText | translate }}" style="width: 600px;">
<form name="theForm" ng-submit="vm.submit()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>{{vm.titleText}}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="vm.cancel()">
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
</md-button>
</div>
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>{{vm.labelText}}</span>
<tb-entity-list ng-disabled="$root.loading"
ng-model="vm.assignedEdges"
entity-type="vm.types.entityType.edge"></tb-entity-list>
</fieldset>
</div>
</md-dialog-content>
<md-dialog-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading || !theForm.$dirty || !theForm.$valid" type="submit" class="md-raised md-primary">
{{ vm.actionName | translate }}
</md-button>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' |
translate }}
</md-button>
</md-dialog-actions>
</form>
</md-dialog>

74
ui/src/app/rulechain/rulechains.controller.js

@ -17,7 +17,6 @@
import addRuleChainTemplate from './add-rulechain.tpl.html'; import addRuleChainTemplate from './add-rulechain.tpl.html';
import ruleChainCard from './rulechain-card.tpl.html'; import ruleChainCard from './rulechain-card.tpl.html';
import manageAssignedEdgesTemplate from "./manage-assigned-edges.tpl.html";
import addRuleChainsToEdgeTemplate from "./add-rulechains-to-edge.tpl.html"; import addRuleChainsToEdgeTemplate from "./add-rulechains-to-edge.tpl.html";
/* eslint-enable import/no-unresolved, import/default */ /* eslint-enable import/no-unresolved, import/default */
@ -183,15 +182,6 @@ export default function RuleChainsController(ruleChainService, userService, edge
return deleteRuleChain(ruleChainId); return deleteRuleChain(ruleChainId);
}; };
ruleChainActionsList.push({
onAction: function ($event, item) {
manageAssignedEdges($event, item);
},
name: function() { return $translate.instant('action.assign') },
details: function() { return $translate.instant('rulechain.manage-assigned-edges') },
icon: "wifi_tethering"
});
ruleChainActionsList.push({ ruleChainActionsList.push({
onAction: function ($event, item) { onAction: function ($event, item) {
vm.grid.deleteItem($event, item); vm.grid.deleteItem($event, item);
@ -212,32 +202,6 @@ export default function RuleChainsController(ruleChainService, userService, edge
isEnabled: isNonRootRuleChain isEnabled: isNonRootRuleChain
}); });
ruleChainGroupActionsList.push(
{
onAction: function ($event, items) {
assignRuleChainsToEdges($event, items);
},
name: function() { return $translate.instant('rulechain.assign-rulechains') },
details: function(selectedCount) {
return $translate.instant('rulechain.assign-rulechains-to-edge-text', {count: selectedCount}, "messageformat");
},
icon: "wifi_tethering"
}
);
ruleChainGroupActionsList.push(
{
onAction: function ($event, items) {
unassignRuleChainsFromEdges($event, items);
},
name: function() { return $translate.instant('rulechain.unassign-rulechains') },
details: function(selectedCount) {
return $translate.instant('rulechain.unassign-rulechains-from-edge-action-text', {count: selectedCount}, "messageformat");
},
icon: "portable_wifi_off"
}
);
ruleChainGroupActionsList.push( ruleChainGroupActionsList.push(
{ {
onAction: function ($event) { onAction: function ($event) {
@ -454,26 +418,6 @@ export default function RuleChainsController(ruleChainService, userService, edge
}); });
} }
function manageAssignedEdges($event, ruleChain) {
showManageAssignedEdgesDialog($event, [ruleChain.id.id], 'manage', ruleChain.assignedEdgesIds);
}
function assignRuleChainsToEdges($event, items) {
var ruleChainIds = [];
for (var id in items.selections) {
ruleChainIds.push(id);
}
showManageAssignedEdgesDialog($event, ruleChainIds, 'assign');
}
function unassignRuleChainsFromEdges($event, items) {
var ruleChainIds = [];
for (var id in items.selections) {
ruleChainIds.push(id);
}
showManageAssignedEdgesDialog($event, ruleChainIds, 'unassign');
}
function unassignRuleChainsFromEdge($event, items, edgeId) { function unassignRuleChainsFromEdge($event, items, edgeId) {
var confirm = $mdDialog.confirm() var confirm = $mdDialog.confirm()
.targetEvent($event) .targetEvent($event)
@ -493,24 +437,6 @@ export default function RuleChainsController(ruleChainService, userService, edge
}); });
} }
function showManageAssignedEdgesDialog($event, ruleChainIds, actionType, assignedEdges) {
if ($event) {
$event.stopPropagation();
}
$mdDialog.show({
controller: 'ManageAssignedEdgesToRuleChainController',
controllerAs: 'vm',
templateUrl: manageAssignedEdgesTemplate,
locals: {actionType: actionType, ruleChainIds: ruleChainIds, assignedEdges: assignedEdges},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
}, function () {
});
}
function addRuleChainsToEdge($event) { function addRuleChainsToEdge($event) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();

Loading…
Cancel
Save