Browse Source

Fixed default & root edge rule chains

pull/3811/head
Artem Babak 6 years ago
parent
commit
e764042fe2
  1. 96
      ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts
  2. 2
      ui-ngx/src/assets/locale/locale.constant-de_DE.json
  3. 23
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  4. 2
      ui-ngx/src/assets/locale/locale.constant-es_ES.json
  5. 2
      ui-ngx/src/assets/locale/locale.constant-fr_FR.json
  6. 6
      ui/src/app/rulechain/add-rulechains-to-edge.tpl.html

96
ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts

@ -16,7 +16,7 @@
import { Injectable } from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router} from '@angular/router';
import {ActivatedRouteSnapshot, Resolve, Route, Router} from '@angular/router';
import {
CellActionDescriptor,
checkBoxCell,
@ -75,52 +75,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
entity => {
return checkBoxCell(entity.root);
}),
})
);
// this.config.addActionDescriptors.push(
// {
// name: this.translate.instant('rulechain.create-new-rulechain'),
// icon: 'insert_drive_file',
// isEnabled: () => true,
// onAction: ($event) => this.config.table.addEntity($event)
// },
// {
// name: this.translate.instant('rulechain.import'),
// icon: 'file_upload',
// isEnabled: () => true,
// onAction: ($event) => this.importRuleChain($event)
// }
// );
// this.config.cellActionDescriptors.push(
// {
// name: this.translate.instant('rulechain.open-rulechain'),
// icon: 'settings_ethernet',
// isEnabled: () => true,
// onAction: ($event, entity) => this.openRuleChain($event, entity)
// },
// {
// name: this.translate.instant('rulechain.export'),
// icon: 'file_download',
// isEnabled: () => true,
// onAction: ($event, entity) => this.exportRuleChain($event, entity)
// },
// {
// name: this.translate.instant('rulechain.set-root'),
// icon: 'flag',
// isEnabled: (ruleChain) => !ruleChain.root,
// onAction: ($event, entity) => this.setRootRuleChain($event, entity)
// }
// );
this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
{ ruleChainName: ruleChain.name });
this.config.deleteEntityContent = () => this.translate.instant('rulechain.delete-rulechain-text');
this.config.deleteEntitiesTitle = count => this.translate.instant('rulechain.delete-rulechains-title', {count});
this.config.deleteEntitiesContent = () => this.translate.instant('rulechain.delete-rulechains-text');
// this.config.entitiesFetchFunction = pageLink => this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge);
this.config.loadEntity = id => this.ruleChainService.getRuleChain(id.id);
this.config.saveEntity = ruleChain => this.saveRuleChain(ruleChain);
this.config.deleteEntity = id => this.ruleChainService.deleteRuleChain(id.id);
@ -130,7 +91,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
}
resolve(route: ActivatedRouteSnapshot): EntityTableConfig<RuleChain> {
// this.config.tableTitle = this.translate.instant('rulechain.rulechains');
const routeParams = route.params;
this.config.componentsData = {
ruleChainScope: route.data.ruleChainScope,
@ -198,7 +158,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (ruleChainScope === 'edge') {
actions.push(
{
name: this.translate.instant('rulechain.unassign-rulechains-from-edge'),
name: this.translate.instant('rulechain.unassign-rulechains'),
icon: 'portable_wifi_off',
isEnabled: true,
onAction: ($event, entities) => this.unassignRuleChainsFromEdge($event, entities)
@ -223,17 +183,27 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
icon: 'file_download',
isEnabled: () => true,
onAction: ($event, entity) => this.exportRuleChain($event, entity)
},
}
)
}
if (ruleChainScope === 'tenant') {
actions.push(
{
name: this.translate.instant('rulechain.set-root'),
icon: 'flag',
isEnabled: (ruleChain) => !ruleChain.root,
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
}
)
}
if (ruleChainScope === 'edges') {
actions.push(
{
name: this.translate.instant('rulechain.set-default-root-edge'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setDefaultRootEdgeRuleChain($event, entity)
},
{
name: this.translate.instant('rulechain.set-default-edge'),
icon: 'bookmark_outline',
@ -250,6 +220,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
}
if (ruleChainScope === 'edge') {
actions.push(
{
name: this.translate.instant('edge.set-root'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
},
{
name: this.translate.instant('edge.unassign-from-edge'),
icon: 'portable_wifi_off',
@ -310,11 +286,19 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
true
).subscribe((res) => {
if (res) {
this.ruleChainService.setRootRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
}
);
if (this.edgeId) {
this.edgeService.setRootRuleChain(this.edgeId, ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
}
)
} else {
this.ruleChainService.setRootRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
}
)
}
}
}
);
@ -383,14 +367,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
$event.stopPropagation();
}
this.dialogService.confirm(
this.translate.instant('rulechain.unassign-from-edges'),
this.translate.instant('rulechain.unassign-from-edges-text'),
this.translate.instant('rulechain.unassign-rulechain-title', {ruleChainName: ruleChain.name}),
this.translate.instant('rulechain.unassign-rulechain-from-edge-text'),
this.translate.instant('action.no'),
this.translate.instant('action.yes'),
true
).subscribe((res) => {
if (res) {
this.ruleChainService.unassignRuleChainFromEdge(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
this.ruleChainService.unassignRuleChainFromEdge(this.edgeId, ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
}
@ -472,12 +456,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
);
}
isRootRuleChain(ruleChain: RuleChain) {
return (isDefined(ruleChain)) && !ruleChain.root && ruleChain.isDefault;
}
isNonRootRuleChain(ruleChain: RuleChain) {
return (isDefined(ruleChain)) && !ruleChain.root && !ruleChain.isDefault;
return (isDefined(ruleChain)) && !ruleChain.root;
}
isDefaultEdgeRuleChain(ruleChain) {

2
ui-ngx/src/assets/locale/locale.constant-de_DE.json

@ -1402,7 +1402,7 @@
"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.",
"unassign-rulechains-from-edge-action-title": "Zuordnung { count, plural, 1 {1 Regelkette} other {# Regelketten} } vom Rand aufheben",
"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.",
"assign-rulechain-to-edge": "Regelkette(n) dem Rand zuordnen",
"assign-rulechain-to-edge-title": "Regelkette(n) dem Rand zuordnen",
"assign-rulechain-to-edge-text": "Bitte wählen Sie die Regelketten aus, die Sie dem Rand zuordnen möchten",
"set-default-root-edge": "Machen Sie Randregelkette zur Wurzel Standard",
"set-default-root-edge-rulechain-title": "Sind Sie sicher, dass Sie die Randregelkette '{{ruleChainName}}' zur Wurzel machen Standard?",

23
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1789,11 +1789,6 @@
"no-relations-text": "No relations found"
},
"rulechain": {
"assign-new-rulechain": "Assign new rulechain",
"assign-rulechain-to-edge-title": "Assign Rule Chain(s) To Edge",
"assign-rulechain-to-edge-text": "Please select the rulechains to assign to the edge",
"edge-rulechains": "Edge Rule chains",
"core-rulechains": "Core Rule chains",
"rulechain": "Rule chain",
"rulechains": "Rule chains",
"root": "Root",
@ -1832,12 +1827,28 @@
"search": "Search rule chains",
"selected-rulechains": "{ count, plural, 1 {1 rule chain} other {# rule chains} } selected",
"open-rulechain": "Open rule chain",
"assign-new-rulechain": "Assign new rulechain",
"edge-rulechains": "Edge Rule chains",
"core-rulechains": "Core Rule chains",
"unassign-rulechain-from-edge-text": "After the confirmation the rulechain will be unassigned and won't be accessible by the edge.",
"unassign-rulechains-from-edge-title": "Unassign { count, plural, 1 {1 rulechain} other {# rulechains} } from edge",
"unassign-rulechains-from-edge-text": "After the confirmation all selected rulechains will be unassigned and won't be accessible by the edge.",
"assign-rulechain-to-edge-title": "Assign Rule Chain(s) To Edge",
"assign-rulechain-to-edge-text": "Please select the rulechains to assign to the edge",
"set-default-root-edge": "Make rule chain default root",
"set-default-root-edge-rulechain-title": "Are you sure you want to make the rule chain '{{ruleChainName}}' default edge root?",
"set-default-root-edge-rulechain-text": "After the confirmation the rule chain will become default edge root and will handle all incoming transport messages.",
"invalid-rulechain-type-error": "Unable to import rule chain: Invalid rule chain type. Expected type is {{expectedRuleChainType}}.",
"set-default-edge": "Make edge rule chain default",
"set-default-edge-title": "Are you sure you want to make the edge rule chain '{{ruleChainName}}' default?",
"set-default-edge-text": "After the confirmation the edge rule chain will be added to default list and assigned to newly created edge(s).",
"remove-default-edge": "Remove edge rule chain from defaults",
"remove-default-edge-title": "Are you sure you want to remove the edge rule chain '{{ruleChainName}}' from default list?",
"remove-default-edge-text": "After the confirmation the edge rule chain will not be assigned for a newly created edges."
"remove-default-edge-text": "After the confirmation the edge rule chain will not be assigned for a newly created edges.",
"unassign-rulechain-title": "Are you sure you want to unassign the rulechain '{{ruleChainName}}'?",
"unassign-rulechains-title": "Are you sure you want to unassign { count, plural, 1 {1 rulechain} other {# rulechains} }?",
"unassign-rulechains": "Unassign rulechains",
"default": "Default"
},
"rulenode": {
"details": "Details",

2
ui-ngx/src/assets/locale/locale.constant-es_ES.json

@ -1573,7 +1573,7 @@
"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",
"unassign-rulechains-from-edge-action-title": "Anular asignación {count, plural, 1 {1 cadena de reglas} other {# cadenas de reglas}} des bordes",
"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",
"assign-rulechain-to-edge": "Asignar cadena (s) de reglas a borde",
"assign-rulechain-to-edge-title": "Asignar cadena (s) de reglas a borde",
"assign-rulechain-to-edge-text": "Seleccione las cadenas de reglas para asignar al borde",
"set-default-root-edge": "Hacer que la cadena de reglas sea la raíz predeterminada",
"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?",

2
ui-ngx/src/assets/locale/locale.constant-fr_FR.json

@ -1447,7 +1447,7 @@
"unassign-rulechain-from-edge-text": "Après la confirmation, l'actif sera non attribué et ne sera pas accessible a la bordure.",
"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",
"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.",
"assign-rulechain-to-edge": "Attribuer les chaînes de règles a la bordure",
"assign-rulechain-to-edge-title": "Attribuer les chaînes de règles a la bordure",
"assign-rulechain-to-edge-text": "Veuillez sélectionner la bordure pour attribuer le ou les chaînes de règles",
"set-default-root-edge": "Définir la racine par défaut de la chaîne de règles",
"set-default-root-edge-rulechain-title": "AVoulez-vous vraiment créer de chaînes de règles par défaut '{{ruleChainName}}'?",

6
ui/src/app/rulechain/add-rulechains-to-edge.tpl.html

@ -15,11 +15,11 @@
limitations under the License.
-->
<md-dialog aria-label="{{ 'rulechain.assign-rulechain-to-edge' | translate }}">
<md-dialog aria-label="{{ 'rulechain.assign-rulechain-to-edge-title' | translate }}">
<form name="theForm" ng-submit="vm.assign()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>rulechain.assign-rulechain-to-edge</h2>
<h2 translate>rulechain.assign-rulechain-to-edge-title</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>
@ -74,4 +74,4 @@
</md-button>
</md-dialog-actions>
</form>
</md-dialog>
</md-dialog>

Loading…
Cancel
Save