Browse Source

Merge pull request #4404 from deaflynx/improvement/edge/rule-chains-routes

UI: Edge rulechains: open from 'edge' scope
pull/4416/head
Igor Kulikov 5 years ago
committed by GitHub
parent
commit
c1e09038cf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts
  2. 14
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain.component.html
  3. 82
      ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts

59
ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts

@ -58,21 +58,6 @@ const routes: Routes = [
entitiesTableConfig: EdgesTableConfigResolver
}
},
{
path: ':edgeId/ruleChains',
component: EntitiesTableComponent,
data: {
auth: [Authority.TENANT_ADMIN],
ruleChainsType: 'edge',
breadcrumb: {
label: 'edge.edge-rulechains',
icon: 'settings_ethernet'
},
},
resolve: {
entitiesTableConfig: RuleChainsTableConfigResolver
}
},
{
path: ':edgeId/assets',
component: EntitiesTableComponent,
@ -156,6 +141,50 @@ const routes: Routes = [
}
]
},
{
path: ':edgeId/ruleChains',
data: {
breadcrumb: {
label: 'edge.edge-rulechains',
icon: 'settings_ethernet'
}
},
children: [
{
path: '',
component: EntitiesTableComponent,
data: {
auth: [Authority.TENANT_ADMIN],
title: 'edge.rulechains',
ruleChainsType: 'edge'
},
resolve: {
entitiesTableConfig: RuleChainsTableConfigResolver
}
},
{
path: ':ruleChainId',
component: RuleChainPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: {
breadcrumb: {
labelFunction: ruleChainBreadcumbLabelFunction,
icon: 'settings_ethernet'
} as BreadCrumbConfig<RuleChainPageComponent>,
auth: [Authority.TENANT_ADMIN],
title: 'rulechain.edge-rulechain',
import: false,
ruleChainType: RuleChainType.EDGE
},
resolve: {
ruleChain: RuleChainResolver,
ruleChainMetaData: ResolvedRuleChainMetaDataResolver,
ruleNodeComponents: RuleNodeComponentsResolver,
tooltipster: TooltipsterResolver
}
}
]
},
{
path: 'ruleChains',
data: {

14
ui-ngx/src/app/modules/home/pages/rulechain/rulechain.component.html

@ -19,19 +19,19 @@
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'open')"
[fxShow]="!isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')">
[fxShow]="!isEdit">
{{'rulechain.open-rulechain' | translate }}
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'export')"
[fxShow]="!isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')">
[fxShow]="!isEdit">
{{'rulechain.export' | translate }}
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'setRoot')"
[fxShow]="!isEdit && !entity?.root && ruleChainScope === 'tenant'">
[fxShow]="!isEdit && ((!entity?.root && ruleChainScope === 'tenant') || (!isEdgeRootRuleChain() && ruleChainScope === 'edge'))">
{{'rulechain.set-root' | translate }}
</button>
<button mat-raised-button color="primary"
@ -52,12 +52,6 @@
[fxShow]="!isEdit && isAutoAssignToEdgeRuleChain() && ruleChainScope === 'edges'">
{{'rulechain.unset-auto-assign-to-edge' | translate }}
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'setRoot')"
[fxShow]="!isEdit && !isEdgeRootRuleChain() && ruleChainScope === 'edge'">
{{'rulechain.set-root' | translate }}
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'unassignFromEdge')"
@ -67,7 +61,7 @@
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'delete')"
[fxShow]="!hideDelete() && !isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')">
[fxShow]="!hideDelete() && !isEdit && ruleChainScope !== 'edge'">
{{'rulechain.delete' | translate }}
</button>
<div fxLayout="row">

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

@ -211,53 +211,51 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
configureCellActions(ruleChainScope: string): Array<CellActionDescriptor<RuleChain>> {
const actions: Array<CellActionDescriptor<RuleChain>> = [];
if (ruleChainScope === 'tenant' || ruleChainScope === 'edges') {
actions.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)
}
);
if (ruleChainScope === 'tenant') {
actions.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.set-root'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
}
);
}
if (ruleChainScope === 'edges') {
actions.push(
{
name: this.translate.instant('rulechain.set-edge-template-root-rulechain'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($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-auto-assign-to-edge'),
icon: 'bookmark_outline',
isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity),
onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity)
},
{
name: this.translate.instant('rulechain.unset-auto-assign-to-edge'),
icon: 'bookmark',
isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity),
onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity)
}
);
if (ruleChainScope === 'tenant') {
actions.push(
{
name: this.translate.instant('rulechain.set-root'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
}
);
}
if (ruleChainScope === 'edges') {
actions.push(
{
name: this.translate.instant('rulechain.set-edge-template-root-rulechain'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($event, entity)
},
{
name: this.translate.instant('rulechain.set-auto-assign-to-edge'),
icon: 'bookmark_outline',
isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity),
onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity)
},
{
name: this.translate.instant('rulechain.unset-auto-assign-to-edge'),
icon: 'bookmark',
isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity),
onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity)
}
);
}
}
if (ruleChainScope === 'edge') {
actions.push(
@ -301,6 +299,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
}
if (this.config.componentsData.ruleChainScope === 'edges') {
this.router.navigateByUrl(`edges/ruleChains/${ruleChain.id.id}`);
} else if (this.config.componentsData.ruleChainScope === 'edge') {
this.router.navigateByUrl(`edges/${this.config.componentsData.edgeId}/ruleChains/${ruleChain.id.id}`);
} else {
this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`);
}

Loading…
Cancel
Save