Commit e764042fe2673303a92c9d1113afabbcb2adfbc6

Authored by Artem Babak
1 parent 848456fd

Fixed default & root edge rule chains

... ... @@ -16,7 +16,7 @@
16 16
17 17 import { Injectable } from '@angular/core';
18 18
19   -import {ActivatedRouteSnapshot, Resolve, Router} from '@angular/router';
  19 +import {ActivatedRouteSnapshot, Resolve, Route, Router} from '@angular/router';
20 20 import {
21 21 CellActionDescriptor,
22 22 checkBoxCell,
... ... @@ -75,52 +75,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
75 75 new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
76 76 entity => {
77 77 return checkBoxCell(entity.root);
78   - }),
  78 + })
79 79 );
80   -
81   - // this.config.addActionDescriptors.push(
82   - // {
83   - // name: this.translate.instant('rulechain.create-new-rulechain'),
84   - // icon: 'insert_drive_file',
85   - // isEnabled: () => true,
86   - // onAction: ($event) => this.config.table.addEntity($event)
87   - // },
88   - // {
89   - // name: this.translate.instant('rulechain.import'),
90   - // icon: 'file_upload',
91   - // isEnabled: () => true,
92   - // onAction: ($event) => this.importRuleChain($event)
93   - // }
94   - // );
95   -
96   - // this.config.cellActionDescriptors.push(
97   - // {
98   - // name: this.translate.instant('rulechain.open-rulechain'),
99   - // icon: 'settings_ethernet',
100   - // isEnabled: () => true,
101   - // onAction: ($event, entity) => this.openRuleChain($event, entity)
102   - // },
103   - // {
104   - // name: this.translate.instant('rulechain.export'),
105   - // icon: 'file_download',
106   - // isEnabled: () => true,
107   - // onAction: ($event, entity) => this.exportRuleChain($event, entity)
108   - // },
109   - // {
110   - // name: this.translate.instant('rulechain.set-root'),
111   - // icon: 'flag',
112   - // isEnabled: (ruleChain) => !ruleChain.root,
113   - // onAction: ($event, entity) => this.setRootRuleChain($event, entity)
114   - // }
115   - // );
116   -
117 80 this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
118 81 { ruleChainName: ruleChain.name });
119 82 this.config.deleteEntityContent = () => this.translate.instant('rulechain.delete-rulechain-text');
120 83 this.config.deleteEntitiesTitle = count => this.translate.instant('rulechain.delete-rulechains-title', {count});
121 84 this.config.deleteEntitiesContent = () => this.translate.instant('rulechain.delete-rulechains-text');
122   -
123   - // this.config.entitiesFetchFunction = pageLink => this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge);
124 85 this.config.loadEntity = id => this.ruleChainService.getRuleChain(id.id);
125 86 this.config.saveEntity = ruleChain => this.saveRuleChain(ruleChain);
126 87 this.config.deleteEntity = id => this.ruleChainService.deleteRuleChain(id.id);
... ... @@ -130,7 +91,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
130 91 }
131 92
132 93 resolve(route: ActivatedRouteSnapshot): EntityTableConfig<RuleChain> {
133   - // this.config.tableTitle = this.translate.instant('rulechain.rulechains');
134 94 const routeParams = route.params;
135 95 this.config.componentsData = {
136 96 ruleChainScope: route.data.ruleChainScope,
... ... @@ -198,7 +158,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
198 158 if (ruleChainScope === 'edge') {
199 159 actions.push(
200 160 {
201   - name: this.translate.instant('rulechain.unassign-rulechains-from-edge'),
  161 + name: this.translate.instant('rulechain.unassign-rulechains'),
202 162 icon: 'portable_wifi_off',
203 163 isEnabled: true,
204 164 onAction: ($event, entities) => this.unassignRuleChainsFromEdge($event, entities)
... ... @@ -223,11 +183,15 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
223 183 icon: 'file_download',
224 184 isEnabled: () => true,
225 185 onAction: ($event, entity) => this.exportRuleChain($event, entity)
226   - },
  186 + }
  187 + )
  188 + }
  189 + if (ruleChainScope === 'tenant') {
  190 + actions.push(
227 191 {
228 192 name: this.translate.instant('rulechain.set-root'),
229 193 icon: 'flag',
230   - isEnabled: (ruleChain) => !ruleChain.root,
  194 + isEnabled: (entity) => this.isNonRootRuleChain(entity),
231 195 onAction: ($event, entity) => this.setRootRuleChain($event, entity)
232 196 }
233 197 )
... ... @@ -235,6 +199,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
235 199 if (ruleChainScope === 'edges') {
236 200 actions.push(
237 201 {
  202 + name: this.translate.instant('rulechain.set-default-root-edge'),
  203 + icon: 'flag',
  204 + isEnabled: (entity) => this.isNonRootRuleChain(entity),
  205 + onAction: ($event, entity) => this.setDefaultRootEdgeRuleChain($event, entity)
  206 + },
  207 + {
238 208 name: this.translate.instant('rulechain.set-default-edge'),
239 209 icon: 'bookmark_outline',
240 210 isEnabled: (entity) => this.isNonDefaultEdgeRuleChain(entity),
... ... @@ -251,6 +221,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
251 221 if (ruleChainScope === 'edge') {
252 222 actions.push(
253 223 {
  224 + name: this.translate.instant('edge.set-root'),
  225 + icon: 'flag',
  226 + isEnabled: (entity) => this.isNonRootRuleChain(entity),
  227 + onAction: ($event, entity) => this.setRootRuleChain($event, entity)
  228 + },
  229 + {
254 230 name: this.translate.instant('edge.unassign-from-edge'),
255 231 icon: 'portable_wifi_off',
256 232 isEnabled: () => true,
... ... @@ -310,11 +286,19 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
310 286 true
311 287 ).subscribe((res) => {
312 288 if (res) {
313   - this.ruleChainService.setRootRuleChain(ruleChain.id.id).subscribe(
314   - () => {
315   - this.config.table.updateData();
316   - }
317   - );
  289 + if (this.edgeId) {
  290 + this.edgeService.setRootRuleChain(this.edgeId, ruleChain.id.id).subscribe(
  291 + () => {
  292 + this.config.table.updateData();
  293 + }
  294 + )
  295 + } else {
  296 + this.ruleChainService.setRootRuleChain(ruleChain.id.id).subscribe(
  297 + () => {
  298 + this.config.table.updateData();
  299 + }
  300 + )
  301 + }
318 302 }
319 303 }
320 304 );
... ... @@ -383,14 +367,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
383 367 $event.stopPropagation();
384 368 }
385 369 this.dialogService.confirm(
386   - this.translate.instant('rulechain.unassign-from-edges'),
387   - this.translate.instant('rulechain.unassign-from-edges-text'),
  370 + this.translate.instant('rulechain.unassign-rulechain-title', {ruleChainName: ruleChain.name}),
  371 + this.translate.instant('rulechain.unassign-rulechain-from-edge-text'),
388 372 this.translate.instant('action.no'),
389 373 this.translate.instant('action.yes'),
390 374 true
391 375 ).subscribe((res) => {
392 376 if (res) {
393   - this.ruleChainService.unassignRuleChainFromEdge(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
  377 + this.ruleChainService.unassignRuleChainFromEdge(this.edgeId, ruleChain.id.id).subscribe(
394 378 () => {
395 379 this.config.table.updateData();
396 380 }
... ... @@ -472,12 +456,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
472 456 );
473 457 }
474 458
475   - isRootRuleChain(ruleChain: RuleChain) {
476   - return (isDefined(ruleChain)) && !ruleChain.root && ruleChain.isDefault;
477   - }
478   -
479 459 isNonRootRuleChain(ruleChain: RuleChain) {
480   - return (isDefined(ruleChain)) && !ruleChain.root && !ruleChain.isDefault;
  460 + return (isDefined(ruleChain)) && !ruleChain.root;
481 461 }
482 462
483 463 isDefaultEdgeRuleChain(ruleChain) {
... ...
... ... @@ -1402,7 +1402,7 @@
1402 1402 "unassign-rulechain-from-edge-text": "Nach der Bestätigung wird die Zuordnung aller ausgewählten Regelkette aufgehoben und sie sind für den Rand nicht mehr zugänglich.",
1403 1403 "unassign-rulechains-from-edge-action-title": "Zuordnung { count, plural, 1 {1 Regelkette} other {# Regelketten} } vom Rand aufheben",
1404 1404 "unassign-rulechains-from-edge-text": "Nach der Bestätigung wird die Zuordnung aller ausgewählten Regelketten aufgehoben und sie sind für den Rand nicht mehr zugänglich.",
1405   - "assign-rulechain-to-edge": "Regelkette(n) dem Rand zuordnen",
  1405 + "assign-rulechain-to-edge-title": "Regelkette(n) dem Rand zuordnen",
1406 1406 "assign-rulechain-to-edge-text": "Bitte wählen Sie die Regelketten aus, die Sie dem Rand zuordnen möchten",
1407 1407 "set-default-root-edge": "Machen Sie Randregelkette zur Wurzel Standard",
1408 1408 "set-default-root-edge-rulechain-title": "Sind Sie sicher, dass Sie die Randregelkette '{{ruleChainName}}' zur Wurzel machen Standard?",
... ...
... ... @@ -1789,11 +1789,6 @@
1789 1789 "no-relations-text": "No relations found"
1790 1790 },
1791 1791 "rulechain": {
1792   - "assign-new-rulechain": "Assign new rulechain",
1793   - "assign-rulechain-to-edge-title": "Assign Rule Chain(s) To Edge",
1794   - "assign-rulechain-to-edge-text": "Please select the rulechains to assign to the edge",
1795   - "edge-rulechains": "Edge Rule chains",
1796   - "core-rulechains": "Core Rule chains",
1797 1792 "rulechain": "Rule chain",
1798 1793 "rulechains": "Rule chains",
1799 1794 "root": "Root",
... ... @@ -1832,12 +1827,28 @@
1832 1827 "search": "Search rule chains",
1833 1828 "selected-rulechains": "{ count, plural, 1 {1 rule chain} other {# rule chains} } selected",
1834 1829 "open-rulechain": "Open rule chain",
  1830 + "assign-new-rulechain": "Assign new rulechain",
  1831 + "edge-rulechains": "Edge Rule chains",
  1832 + "core-rulechains": "Core Rule chains",
  1833 + "unassign-rulechain-from-edge-text": "After the confirmation the rulechain will be unassigned and won't be accessible by the edge.",
  1834 + "unassign-rulechains-from-edge-title": "Unassign { count, plural, 1 {1 rulechain} other {# rulechains} } from edge",
  1835 + "unassign-rulechains-from-edge-text": "After the confirmation all selected rulechains will be unassigned and won't be accessible by the edge.",
  1836 + "assign-rulechain-to-edge-title": "Assign Rule Chain(s) To Edge",
  1837 + "assign-rulechain-to-edge-text": "Please select the rulechains to assign to the edge",
  1838 + "set-default-root-edge": "Make rule chain default root",
  1839 + "set-default-root-edge-rulechain-title": "Are you sure you want to make the rule chain '{{ruleChainName}}' default edge root?",
  1840 + "set-default-root-edge-rulechain-text": "After the confirmation the rule chain will become default edge root and will handle all incoming transport messages.",
  1841 + "invalid-rulechain-type-error": "Unable to import rule chain: Invalid rule chain type. Expected type is {{expectedRuleChainType}}.",
1835 1842 "set-default-edge": "Make edge rule chain default",
1836 1843 "set-default-edge-title": "Are you sure you want to make the edge rule chain '{{ruleChainName}}' default?",
1837 1844 "set-default-edge-text": "After the confirmation the edge rule chain will be added to default list and assigned to newly created edge(s).",
1838 1845 "remove-default-edge": "Remove edge rule chain from defaults",
1839 1846 "remove-default-edge-title": "Are you sure you want to remove the edge rule chain '{{ruleChainName}}' from default list?",
1840   - "remove-default-edge-text": "After the confirmation the edge rule chain will not be assigned for a newly created edges."
  1847 + "remove-default-edge-text": "After the confirmation the edge rule chain will not be assigned for a newly created edges.",
  1848 + "unassign-rulechain-title": "Are you sure you want to unassign the rulechain '{{ruleChainName}}'?",
  1849 + "unassign-rulechains-title": "Are you sure you want to unassign { count, plural, 1 {1 rulechain} other {# rulechains} }?",
  1850 + "unassign-rulechains": "Unassign rulechains",
  1851 + "default": "Default"
1841 1852 },
1842 1853 "rulenode": {
1843 1854 "details": "Details",
... ...
... ... @@ -1573,7 +1573,7 @@
1573 1573 "unassign-rulechain-from-edge-text": "Después de la confirmación, la cadena de reglas quedará sin asignar y el borde no podrá acceder a ella",
1574 1574 "unassign-rulechains-from-edge-action-title": "Anular asignación {count, plural, 1 {1 cadena de reglas} other {# cadenas de reglas}} des bordes",
1575 1575 "unassign-rulechains-from-edge-text": "Después de la confirmación, todas las cadenas de reglas seleccionadas quedarán sin asignar y el borde no podrá acceder a ellas",
1576   - "assign-rulechain-to-edge": "Asignar cadena (s) de reglas a borde",
  1576 + "assign-rulechain-to-edge-title": "Asignar cadena (s) de reglas a borde",
1577 1577 "assign-rulechain-to-edge-text": "Seleccione las cadenas de reglas para asignar al borde",
1578 1578 "set-default-root-edge": "Hacer que la cadena de reglas sea la raíz predeterminada",
1579 1579 "set-default-root-edge-rulechain-title": "¿Está seguro de que desea hacer que la cadena de reglas '{{ruleChainName}}' sea la raíz de borde predeterminada?",
... ...
... ... @@ -1447,7 +1447,7 @@
1447 1447 "unassign-rulechain-from-edge-text": "Après la confirmation, l'actif sera non attribué et ne sera pas accessible a la bordure.",
1448 1448 "unassign-rulechains-from-edge-action-title": "Retirer {count, plural, 1 {1 chaîne de règles} other {# chaînes de règles}} de la bordure",
1449 1449 "unassign-rulechains-from-edge-text": "Après la confirmation, tous les chaînes de règles sélectionnés ne seront pas attribués et ne seront pas accessibles a la bordure.",
1450   - "assign-rulechain-to-edge": "Attribuer les chaînes de règles a la bordure",
  1450 + "assign-rulechain-to-edge-title": "Attribuer les chaînes de règles a la bordure",
1451 1451 "assign-rulechain-to-edge-text": "Veuillez sélectionner la bordure pour attribuer le ou les chaînes de règles",
1452 1452 "set-default-root-edge": "Définir la racine par défaut de la chaîne de règles",
1453 1453 "set-default-root-edge-rulechain-title": "AVoulez-vous vraiment créer de chaînes de règles par défaut '{{ruleChainName}}'?",
... ...
... ... @@ -15,11 +15,11 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<md-dialog aria-label="{{ 'rulechain.assign-rulechain-to-edge' | translate }}">
  18 +<md-dialog aria-label="{{ 'rulechain.assign-rulechain-to-edge-title' | translate }}">
19 19 <form name="theForm" ng-submit="vm.assign()">
20 20 <md-toolbar>
21 21 <div class="md-toolbar-tools">
22   - <h2 translate>rulechain.assign-rulechain-to-edge</h2>
  22 + <h2 translate>rulechain.assign-rulechain-to-edge-title</h2>
23 23 <span flex></span>
24 24 <md-button class="md-icon-button" ng-click="vm.cancel()">
25 25 <ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
... ... @@ -74,4 +74,4 @@
74 74 </md-button>
75 75 </md-dialog-actions>
76 76 </form>
77   -</md-dialog>
\ No newline at end of file
  77 +</md-dialog>
... ...