23 changed files with 865 additions and 6 deletions
@ -0,0 +1,150 @@ |
|||||
|
/* |
||||
|
* Copyright © 2016-2018 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. |
||||
|
*/ |
||||
|
export default angular.module('thingsboard.api.ruleChain', []) |
||||
|
.factory('ruleChainService', RuleChainService).name; |
||||
|
|
||||
|
/*@ngInject*/ |
||||
|
function RuleChainService($http, $q) { |
||||
|
|
||||
|
var service = { |
||||
|
getSystemRuleChains: getSystemRuleChains, |
||||
|
getTenantRuleChains: getTenantRuleChains, |
||||
|
getRuleChains: getRuleChains, |
||||
|
getRuleChain: getRuleChain, |
||||
|
saveRuleChain: saveRuleChain, |
||||
|
deleteRuleChain: deleteRuleChain, |
||||
|
getRuleChainMetaData: getRuleChainMetaData, |
||||
|
saveRuleChainMetaData: saveRuleChainMetaData |
||||
|
}; |
||||
|
|
||||
|
return service; |
||||
|
|
||||
|
function getSystemRuleChains (pageLink, config) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/system/ruleChains?limit=' + pageLink.limit; |
||||
|
if (angular.isDefined(pageLink.textSearch)) { |
||||
|
url += '&textSearch=' + pageLink.textSearch; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.idOffset)) { |
||||
|
url += '&idOffset=' + pageLink.idOffset; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.textOffset)) { |
||||
|
url += '&textOffset=' + pageLink.textOffset; |
||||
|
} |
||||
|
$http.get(url, config).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function getTenantRuleChains (pageLink, config) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/tenant/ruleChains?limit=' + pageLink.limit; |
||||
|
if (angular.isDefined(pageLink.textSearch)) { |
||||
|
url += '&textSearch=' + pageLink.textSearch; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.idOffset)) { |
||||
|
url += '&idOffset=' + pageLink.idOffset; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.textOffset)) { |
||||
|
url += '&textOffset=' + pageLink.textOffset; |
||||
|
} |
||||
|
$http.get(url, config).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function getRuleChains (pageLink, config) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChains?limit=' + pageLink.limit; |
||||
|
if (angular.isDefined(pageLink.textSearch)) { |
||||
|
url += '&textSearch=' + pageLink.textSearch; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.idOffset)) { |
||||
|
url += '&idOffset=' + pageLink.idOffset; |
||||
|
} |
||||
|
if (angular.isDefined(pageLink.textOffset)) { |
||||
|
url += '&textOffset=' + pageLink.textOffset; |
||||
|
} |
||||
|
$http.get(url, config).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function getRuleChain(ruleChainId, config) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChain/' + ruleChainId; |
||||
|
$http.get(url, config).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function saveRuleChain(ruleChain) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChain'; |
||||
|
$http.post(url, ruleChain).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChain(ruleChainId) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChain/' + ruleChainId; |
||||
|
$http.delete(url).then(function success() { |
||||
|
deferred.resolve(); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function getRuleChainMetaData(ruleChainId, config) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChain/' + ruleChainId + '/metadata'; |
||||
|
$http.get(url, config).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
function saveRuleChainMetaData(ruleChainMetaData) { |
||||
|
var deferred = $q.defer(); |
||||
|
var url = '/api/ruleChain/metadata'; |
||||
|
$http.post(url, ruleChainMetaData).then(function success(response) { |
||||
|
deferred.resolve(response.data); |
||||
|
}, function fail() { |
||||
|
deferred.reject(); |
||||
|
}); |
||||
|
return deferred.promise; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2018 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="{{ 'rulechain.add' | translate }}" tb-help="'rulechains'" help-container-id="help-container"> |
||||
|
<form name="theForm" ng-submit="vm.add()"> |
||||
|
<md-toolbar> |
||||
|
<div class="md-toolbar-tools"> |
||||
|
<h2 translate>rulechain.add</h2> |
||||
|
<span flex></span> |
||||
|
<div id="help-container"></div> |
||||
|
<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"> |
||||
|
<tb-rule-chain rule-chain="vm.item" is-edit="true" the-form="theForm"></tb-rule-chain> |
||||
|
</div> |
||||
|
</md-dialog-content> |
||||
|
<md-dialog-actions layout="row"> |
||||
|
<span flex></span> |
||||
|
<md-button ng-disabled="$root.loading || theForm.$invalid || !theForm.$dirty" type="submit" |
||||
|
class="md-raised md-primary"> |
||||
|
{{ 'action.add' | 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> |
||||
@ -0,0 +1,25 @@ |
|||||
|
/* |
||||
|
* Copyright © 2016-2018 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. |
||||
|
*/ |
||||
|
|
||||
|
import RuleChainRoutes from './rulechain.routes'; |
||||
|
import RuleChainController from './rulechain.controller'; |
||||
|
import RuleChainDirective from './rulechain.directive'; |
||||
|
|
||||
|
export default angular.module('thingsboard.ruleChain', []) |
||||
|
.config(RuleChainRoutes) |
||||
|
.controller('RuleChainController', RuleChainController) |
||||
|
.directive('tbRuleChain', RuleChainDirective) |
||||
|
.name; |
||||
@ -0,0 +1,18 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2018 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. |
||||
|
|
||||
|
--> |
||||
|
<div class="tb-uppercase" ng-if="item && parentCtl.types.id.nullUid === item.tenantId.id" translate>rulechain.system</div> |
||||
@ -0,0 +1,49 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2018 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-button ng-click="onExportRuleChain({event: $event})" |
||||
|
ng-show="!isEdit" |
||||
|
class="md-raised md-primary">{{ 'rulechain.export' | translate }}</md-button> |
||||
|
<md-button ng-click="onDeleteRuleChain({event: $event})" |
||||
|
ng-show="!isEdit && !isReadOnly" |
||||
|
class="md-raised md-primary">{{ 'rulechain.delete' | translate }}</md-button> |
||||
|
|
||||
|
<div layout="row"> |
||||
|
<md-button ngclipboard data-clipboard-action="copy" |
||||
|
ngclipboard-success="onRuleChainIdCopied(e)" |
||||
|
data-clipboard-text="{{ruleChain.id.id}}" ng-show="!isEdit" |
||||
|
class="md-raised"> |
||||
|
<md-icon md-svg-icon="mdi:clipboard-arrow-left"></md-icon> |
||||
|
<span translate>rulechain.copyId</span> |
||||
|
</md-button> |
||||
|
</div> |
||||
|
|
||||
|
<md-content class="md-padding tb-rulechain" layout="column"> |
||||
|
<fieldset ng-disabled="$root.loading || !isEdit || isReadOnly"> |
||||
|
<md-input-container class="md-block"> |
||||
|
<label translate>rulechain.name</label> |
||||
|
<input required name="name" ng-model="ruleChain.name"> |
||||
|
<div ng-messages="theForm.name.$error"> |
||||
|
<div translate ng-message="required">rulechain.name-required</div> |
||||
|
</div> |
||||
|
</md-input-container> |
||||
|
<md-input-container class="md-block"> |
||||
|
<label translate>rulechain.description</label> |
||||
|
<textarea ng-model="ruleChain.additionalInfo.description" rows="2"></textarea> |
||||
|
</md-input-container> |
||||
|
</fieldset> |
||||
|
</md-content> |
||||
@ -0,0 +1,172 @@ |
|||||
|
/* |
||||
|
* Copyright © 2016-2018 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
/* eslint-disable import/no-unresolved, import/default */ |
||||
|
|
||||
|
import addRuleChainTemplate from './add-rulechain.tpl.html'; |
||||
|
import ruleChainCard from './rulechain-card.tpl.html'; |
||||
|
|
||||
|
/* eslint-enable import/no-unresolved, import/default */ |
||||
|
|
||||
|
/*@ngInject*/ |
||||
|
export default function RuleChainController(ruleChainService, userService, importExport, $state, $stateParams, $filter, $translate, types) { |
||||
|
|
||||
|
var ruleChainActionsList = [ |
||||
|
{ |
||||
|
onAction: function ($event, item) { |
||||
|
exportRuleChain($event, item); |
||||
|
}, |
||||
|
name: function() { $translate.instant('action.export') }, |
||||
|
details: function() { return $translate.instant('rulechain.export') }, |
||||
|
icon: "file_download" |
||||
|
}, |
||||
|
{ |
||||
|
onAction: function ($event, item) { |
||||
|
vm.grid.deleteItem($event, item); |
||||
|
}, |
||||
|
name: function() { return $translate.instant('action.delete') }, |
||||
|
details: function() { return $translate.instant('rulechain.delete') }, |
||||
|
icon: "delete", |
||||
|
isEnabled: isRuleChainEditable |
||||
|
} |
||||
|
]; |
||||
|
|
||||
|
var ruleChainAddItemActionsList = [ |
||||
|
{ |
||||
|
onAction: function ($event) { |
||||
|
vm.grid.addItem($event); |
||||
|
}, |
||||
|
name: function() { return $translate.instant('action.create') }, |
||||
|
details: function() { return $translate.instant('rulechain.create-new-rulechain') }, |
||||
|
icon: "insert_drive_file" |
||||
|
}, |
||||
|
{ |
||||
|
onAction: function ($event) { |
||||
|
importExport.importRuleChain($event).then( |
||||
|
function() { |
||||
|
vm.grid.refreshList(); |
||||
|
} |
||||
|
); |
||||
|
}, |
||||
|
name: function() { return $translate.instant('action.import') }, |
||||
|
details: function() { return $translate.instant('rulechain.import') }, |
||||
|
icon: "file_upload" |
||||
|
} |
||||
|
]; |
||||
|
|
||||
|
var vm = this; |
||||
|
|
||||
|
vm.types = types; |
||||
|
|
||||
|
vm.ruleChainGridConfig = { |
||||
|
|
||||
|
refreshParamsFunc: null, |
||||
|
|
||||
|
deleteItemTitleFunc: deleteRuleChainTitle, |
||||
|
deleteItemContentFunc: deleteRuleChainText, |
||||
|
deleteItemsTitleFunc: deleteRuleChainsTitle, |
||||
|
deleteItemsActionTitleFunc: deleteRuleChainsActionTitle, |
||||
|
deleteItemsContentFunc: deleteRuleChainsText, |
||||
|
|
||||
|
fetchItemsFunc: fetchRuleChains, |
||||
|
saveItemFunc: saveRuleChain, |
||||
|
deleteItemFunc: deleteRuleChain, |
||||
|
|
||||
|
getItemTitleFunc: getRuleChainTitle, |
||||
|
itemCardTemplateUrl: ruleChainCard, |
||||
|
parentCtl: vm, |
||||
|
|
||||
|
actionsList: ruleChainActionsList, |
||||
|
addItemActions: ruleChainAddItemActionsList, |
||||
|
|
||||
|
onGridInited: gridInited, |
||||
|
|
||||
|
addItemTemplateUrl: addRuleChainTemplate, |
||||
|
|
||||
|
addItemText: function() { return $translate.instant('rulechain.add-rulechain-text') }, |
||||
|
noItemsText: function() { return $translate.instant('rulechain.no-rulechains-text') }, |
||||
|
itemDetailsText: function() { return $translate.instant('rulechain.rulechain-details') }, |
||||
|
isSelectionEnabled: isRuleChainEditable, |
||||
|
isDetailsReadOnly: function(ruleChain) { |
||||
|
return !isRuleChainEditable(ruleChain); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
if (angular.isDefined($stateParams.items) && $stateParams.items !== null) { |
||||
|
vm.ruleChainGridConfig.items = $stateParams.items; |
||||
|
} |
||||
|
|
||||
|
if (angular.isDefined($stateParams.topIndex) && $stateParams.topIndex > 0) { |
||||
|
vm.ruleChainGridConfig.topIndex = $stateParams.topIndex; |
||||
|
} |
||||
|
|
||||
|
vm.isRuleChainEditable = isRuleChainEditable; |
||||
|
|
||||
|
vm.exportRuleChain = exportRuleChain; |
||||
|
|
||||
|
function deleteRuleChainTitle(ruleChain) { |
||||
|
return $translate.instant('rulechain.delete-rulechain-title', {ruleChainName: ruleChain.name}); |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChainText() { |
||||
|
return $translate.instant('rulechain.delete-rulechain-text'); |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChainsTitle(selectedCount) { |
||||
|
return $translate.instant('rulechain.delete-rulechains-title', {count: selectedCount}, 'messageformat'); |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChainsActionTitle(selectedCount) { |
||||
|
return $translate.instant('rulechain.delete-rulechains-action-title', {count: selectedCount}, 'messageformat'); |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChainsText() { |
||||
|
return $translate.instant('rulechain.delete-rulechains-text'); |
||||
|
} |
||||
|
|
||||
|
function gridInited(grid) { |
||||
|
vm.grid = grid; |
||||
|
} |
||||
|
|
||||
|
function fetchRuleChains(pageLink) { |
||||
|
return ruleChainService.getRuleChains(pageLink); |
||||
|
} |
||||
|
|
||||
|
function saveRuleChain(ruleChain) { |
||||
|
return ruleChainService.saveRuleChain(ruleChain); |
||||
|
} |
||||
|
|
||||
|
function deleteRuleChain(ruleChainId) { |
||||
|
return ruleChainService.deleteRuleChain(ruleChainId); |
||||
|
} |
||||
|
|
||||
|
function getRuleChainTitle(ruleChain) { |
||||
|
return ruleChain ? ruleChain.name : ''; |
||||
|
} |
||||
|
|
||||
|
function isRuleChainEditable(ruleChain) { |
||||
|
if (userService.getAuthority() === 'TENANT_ADMIN') { |
||||
|
return ruleChain && ruleChain.tenantId.id != types.id.nullUid; |
||||
|
} else { |
||||
|
return userService.getAuthority() === 'SYS_ADMIN'; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function exportRuleChain($event, ruleChain) { |
||||
|
$event.stopPropagation(); |
||||
|
importExport.exportRuleChain(ruleChain.id.id); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
/* |
||||
|
* Copyright © 2016-2018 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
|
||||
|
/* eslint-disable import/no-unresolved, import/default */ |
||||
|
|
||||
|
import ruleChainFieldsetTemplate from './rulechain-fieldset.tpl.html'; |
||||
|
|
||||
|
/* eslint-enable import/no-unresolved, import/default */ |
||||
|
|
||||
|
/*@ngInject*/ |
||||
|
export default function RuleChainDirective($compile, $templateCache, $mdDialog, $document, $q, $translate, types, toast) { |
||||
|
var linker = function (scope, element) { |
||||
|
var template = $templateCache.get(ruleChainFieldsetTemplate); |
||||
|
element.html(template); |
||||
|
|
||||
|
scope.onRuleChainIdCopied = function() { |
||||
|
toast.showSuccess($translate.instant('rulechain.idCopiedMessage'), 750, angular.element(element).parent().parent(), 'bottom left'); |
||||
|
}; |
||||
|
|
||||
|
$compile(element.contents())(scope); |
||||
|
} |
||||
|
return { |
||||
|
restrict: "E", |
||||
|
link: linker, |
||||
|
scope: { |
||||
|
ruleChain: '=', |
||||
|
isEdit: '=', |
||||
|
isReadOnly: '=', |
||||
|
theForm: '=', |
||||
|
onExportRuleChain: '&', |
||||
|
onDeleteRuleChain: '&' |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
/* |
||||
|
* Copyright © 2016-2018 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
/* eslint-disable import/no-unresolved, import/default */ |
||||
|
|
||||
|
import ruleChainsTemplate from './rulechains.tpl.html'; |
||||
|
|
||||
|
/* eslint-enable import/no-unresolved, import/default */ |
||||
|
|
||||
|
/*@ngInject*/ |
||||
|
export default function RuleChainRoutes($stateProvider) { |
||||
|
|
||||
|
$stateProvider |
||||
|
.state('home.ruleChains', { |
||||
|
url: '/ruleChains', |
||||
|
params: {'topIndex': 0}, |
||||
|
module: 'private', |
||||
|
auth: ['SYS_ADMIN', 'TENANT_ADMIN'], |
||||
|
views: { |
||||
|
"content@home": { |
||||
|
templateUrl: ruleChainsTemplate, |
||||
|
controllerAs: 'vm', |
||||
|
controller: 'RuleChainController' |
||||
|
} |
||||
|
}, |
||||
|
data: { |
||||
|
searchEnabled: true, |
||||
|
pageTitle: 'rulechain.rulechains' |
||||
|
}, |
||||
|
ncyBreadcrumb: { |
||||
|
label: '{"icon": "settings_ethernet", "label": "rulechain.rulechains"}' |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
@ -0,0 +1,75 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2018 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. |
||||
|
|
||||
|
--> |
||||
|
<tb-grid grid-configuration="vm.ruleChainGridConfig"> |
||||
|
<details-buttons tb-help="'rulechains'" help-container-id="help-container"> |
||||
|
<div id="help-container"></div> |
||||
|
</details-buttons> |
||||
|
<md-tabs ng-class="{'tb-headless': (vm.grid.detailsConfig.isDetailsEditMode || !vm.isRuleChainEditable(vm.grid.operatingItem()))}" |
||||
|
id="tabs" md-border-bottom flex class="tb-absolute-fill"> |
||||
|
<md-tab label="{{ 'rulechain.details' | translate }}"> |
||||
|
<tb-rule-chain rule-chain="vm.grid.operatingItem()" |
||||
|
is-edit="vm.grid.detailsConfig.isDetailsEditMode" |
||||
|
is-read-only="vm.grid.isDetailsReadOnly(vm.grid.operatingItem())" |
||||
|
the-form="vm.grid.detailsForm" |
||||
|
on-export-rule-chain="vm.exportRuleChain(event, vm.grid.detailsConfig.currentItem)" |
||||
|
on-delete-rule-chain="vm.grid.deleteItem(event, vm.grid.detailsConfig.currentItem)"></tb-rule-chain> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem())" md-on-select="vm.grid.triggerResize()" label="{{ 'attribute.attributes' | translate }}"> |
||||
|
<tb-attribute-table flex |
||||
|
entity-id="vm.grid.operatingItem().id.id" |
||||
|
entity-type="{{vm.types.entityType.rulechain}}" |
||||
|
entity-name="vm.grid.operatingItem().name" |
||||
|
default-attribute-scope="{{vm.types.attributesScope.server.value}}"> |
||||
|
</tb-attribute-table> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem())" md-on-select="vm.grid.triggerResize()" label="{{ 'attribute.latest-telemetry' | translate }}"> |
||||
|
<tb-attribute-table flex |
||||
|
entity-id="vm.grid.operatingItem().id.id" |
||||
|
entity-type="{{vm.types.entityType.rulechain}}" |
||||
|
entity-name="vm.grid.operatingItem().name" |
||||
|
default-attribute-scope="{{vm.types.latestTelemetry.value}}" |
||||
|
disable-attribute-scope-selection="true"> |
||||
|
</tb-attribute-table> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem())" md-on-select="vm.grid.triggerResize()" label="{{ 'alarm.alarms' | translate }}"> |
||||
|
<tb-alarm-table flex entity-type="vm.types.entityType.rulechain" |
||||
|
entity-id="vm.grid.operatingItem().id.id"> |
||||
|
</tb-alarm-table> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem())" md-on-select="vm.grid.triggerResize()" label="{{ 'rulechain.events' | translate }}"> |
||||
|
<tb-event-table flex entity-type="vm.types.entityType.rulechain" |
||||
|
entity-id="vm.grid.operatingItem().id.id" |
||||
|
tenant-id="vm.grid.operatingItem().tenantId.id" |
||||
|
default-event-type="{{vm.types.eventType.lcEvent.value}}"> |
||||
|
</tb-event-table> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem())" md-on-select="vm.grid.triggerResize()" label="{{ 'relation.relations' | translate }}"> |
||||
|
<tb-relation-table flex |
||||
|
entity-id="vm.grid.operatingItem().id.id" |
||||
|
entity-type="{{vm.types.entityType.rulechain}}"> |
||||
|
</tb-relation-table> |
||||
|
</md-tab> |
||||
|
<md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleChainEditable(vm.grid.operatingItem()) && 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.rulechain" |
||||
|
entity-id="vm.grid.operatingItem().id.id" |
||||
|
audit-log-mode="{{vm.types.auditLogMode.entity}}"> |
||||
|
</tb-audit-log-table> |
||||
|
</md-tab> |
||||
|
</md-tabs> |
||||
|
</tb-grid> |
||||
Loading…
Reference in new issue