26 changed files with 1295 additions and 1406 deletions
File diff suppressed because it is too large
@ -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 |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
@ -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> </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> |
|
||||
@ -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(); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -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> |
|
||||
@ -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 |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
@ -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> </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> |
|
||||
@ -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 |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
@ -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> </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> |
|
||||
@ -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(); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -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> |
|
||||
Loading…
Reference in new issue