Commit 585f60fe15ab3912ab428cc9e93c31014584540c
1 parent
29f64d93
Edge rulechains: open/export from 'edge' scope
Showing
3 changed files
with
89 additions
and
66 deletions
@@ -59,21 +59,6 @@ const routes: Routes = [ | @@ -59,21 +59,6 @@ const routes: Routes = [ | ||
59 | } | 59 | } |
60 | }, | 60 | }, |
61 | { | 61 | { |
62 | - path: ':edgeId/ruleChains', | ||
63 | - component: EntitiesTableComponent, | ||
64 | - data: { | ||
65 | - auth: [Authority.TENANT_ADMIN], | ||
66 | - ruleChainsType: 'edge', | ||
67 | - breadcrumb: { | ||
68 | - label: 'edge.edge-rulechains', | ||
69 | - icon: 'settings_ethernet' | ||
70 | - }, | ||
71 | - }, | ||
72 | - resolve: { | ||
73 | - entitiesTableConfig: RuleChainsTableConfigResolver | ||
74 | - } | ||
75 | - }, | ||
76 | - { | ||
77 | path: ':edgeId/assets', | 62 | path: ':edgeId/assets', |
78 | component: EntitiesTableComponent, | 63 | component: EntitiesTableComponent, |
79 | data: { | 64 | data: { |
@@ -157,6 +142,50 @@ const routes: Routes = [ | @@ -157,6 +142,50 @@ const routes: Routes = [ | ||
157 | ] | 142 | ] |
158 | }, | 143 | }, |
159 | { | 144 | { |
145 | + path: ':edgeId/ruleChains', | ||
146 | + data: { | ||
147 | + breadcrumb: { | ||
148 | + label: 'edge.edge-rulechains', | ||
149 | + icon: 'settings_ethernet' | ||
150 | + } | ||
151 | + }, | ||
152 | + children: [ | ||
153 | + { | ||
154 | + path: '', | ||
155 | + component: EntitiesTableComponent, | ||
156 | + data: { | ||
157 | + auth: [Authority.TENANT_ADMIN], | ||
158 | + title: 'edge.rulechains', | ||
159 | + ruleChainsType: 'edge' | ||
160 | + }, | ||
161 | + resolve: { | ||
162 | + entitiesTableConfig: RuleChainsTableConfigResolver | ||
163 | + } | ||
164 | + }, | ||
165 | + { | ||
166 | + path: ':ruleChainId', | ||
167 | + component: RuleChainPageComponent, | ||
168 | + canDeactivate: [ConfirmOnExitGuard], | ||
169 | + data: { | ||
170 | + breadcrumb: { | ||
171 | + labelFunction: ruleChainBreadcumbLabelFunction, | ||
172 | + icon: 'settings_ethernet' | ||
173 | + } as BreadCrumbConfig<RuleChainPageComponent>, | ||
174 | + auth: [Authority.TENANT_ADMIN], | ||
175 | + title: 'rulechain.edge-rulechain', | ||
176 | + import: false, | ||
177 | + ruleChainType: RuleChainType.EDGE | ||
178 | + }, | ||
179 | + resolve: { | ||
180 | + ruleChain: RuleChainResolver, | ||
181 | + ruleChainMetaData: ResolvedRuleChainMetaDataResolver, | ||
182 | + ruleNodeComponents: RuleNodeComponentsResolver, | ||
183 | + tooltipster: TooltipsterResolver | ||
184 | + } | ||
185 | + } | ||
186 | + ] | ||
187 | + }, | ||
188 | + { | ||
160 | path: 'ruleChains', | 189 | path: 'ruleChains', |
161 | data: { | 190 | data: { |
162 | breadcrumb: { | 191 | breadcrumb: { |
@@ -19,19 +19,19 @@ | @@ -19,19 +19,19 @@ | ||
19 | <button mat-raised-button color="primary" | 19 | <button mat-raised-button color="primary" |
20 | [disabled]="(isLoading$ | async)" | 20 | [disabled]="(isLoading$ | async)" |
21 | (click)="onEntityAction($event, 'open')" | 21 | (click)="onEntityAction($event, 'open')" |
22 | - [fxShow]="!isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')"> | 22 | + [fxShow]="!isEdit"> |
23 | {{'rulechain.open-rulechain' | translate }} | 23 | {{'rulechain.open-rulechain' | translate }} |
24 | </button> | 24 | </button> |
25 | <button mat-raised-button color="primary" | 25 | <button mat-raised-button color="primary" |
26 | [disabled]="(isLoading$ | async)" | 26 | [disabled]="(isLoading$ | async)" |
27 | (click)="onEntityAction($event, 'export')" | 27 | (click)="onEntityAction($event, 'export')" |
28 | - [fxShow]="!isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')"> | 28 | + [fxShow]="!isEdit"> |
29 | {{'rulechain.export' | translate }} | 29 | {{'rulechain.export' | translate }} |
30 | </button> | 30 | </button> |
31 | <button mat-raised-button color="primary" | 31 | <button mat-raised-button color="primary" |
32 | [disabled]="(isLoading$ | async)" | 32 | [disabled]="(isLoading$ | async)" |
33 | (click)="onEntityAction($event, 'setRoot')" | 33 | (click)="onEntityAction($event, 'setRoot')" |
34 | - [fxShow]="!isEdit && !entity?.root && ruleChainScope === 'tenant'"> | 34 | + [fxShow]="!isEdit && ((!entity?.root && ruleChainScope === 'tenant') || (!isEdgeRootRuleChain() && ruleChainScope === 'edge'))"> |
35 | {{'rulechain.set-root' | translate }} | 35 | {{'rulechain.set-root' | translate }} |
36 | </button> | 36 | </button> |
37 | <button mat-raised-button color="primary" | 37 | <button mat-raised-button color="primary" |
@@ -54,12 +54,6 @@ | @@ -54,12 +54,6 @@ | ||
54 | </button> | 54 | </button> |
55 | <button mat-raised-button color="primary" | 55 | <button mat-raised-button color="primary" |
56 | [disabled]="(isLoading$ | async)" | 56 | [disabled]="(isLoading$ | async)" |
57 | - (click)="onEntityAction($event, 'setRoot')" | ||
58 | - [fxShow]="!isEdit && !isEdgeRootRuleChain() && ruleChainScope === 'edge'"> | ||
59 | - {{'rulechain.set-root' | translate }} | ||
60 | - </button> | ||
61 | - <button mat-raised-button color="primary" | ||
62 | - [disabled]="(isLoading$ | async)" | ||
63 | (click)="onEntityAction($event, 'unassignFromEdge')" | 57 | (click)="onEntityAction($event, 'unassignFromEdge')" |
64 | [fxShow]="!isEdit && !isEdgeRootRuleChain() && ruleChainScope === 'edge'"> | 58 | [fxShow]="!isEdit && !isEdgeRootRuleChain() && ruleChainScope === 'edge'"> |
65 | {{'edge.unassign-from-edge' | translate }} | 59 | {{'edge.unassign-from-edge' | translate }} |
@@ -67,7 +61,7 @@ | @@ -67,7 +61,7 @@ | ||
67 | <button mat-raised-button color="primary" | 61 | <button mat-raised-button color="primary" |
68 | [disabled]="(isLoading$ | async)" | 62 | [disabled]="(isLoading$ | async)" |
69 | (click)="onEntityAction($event, 'delete')" | 63 | (click)="onEntityAction($event, 'delete')" |
70 | - [fxShow]="!hideDelete() && !isEdit && (ruleChainScope === 'tenant' || ruleChainScope === 'edges')"> | 64 | + [fxShow]="!hideDelete() && !isEdit && ruleChainScope !== 'edge'"> |
71 | {{'rulechain.delete' | translate }} | 65 | {{'rulechain.delete' | translate }} |
72 | </button> | 66 | </button> |
73 | <div fxLayout="row"> | 67 | <div fxLayout="row"> |
@@ -211,53 +211,51 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -211,53 +211,51 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
211 | 211 | ||
212 | configureCellActions(ruleChainScope: string): Array<CellActionDescriptor<RuleChain>> { | 212 | configureCellActions(ruleChainScope: string): Array<CellActionDescriptor<RuleChain>> { |
213 | const actions: Array<CellActionDescriptor<RuleChain>> = []; | 213 | const actions: Array<CellActionDescriptor<RuleChain>> = []; |
214 | - if (ruleChainScope === 'tenant' || ruleChainScope === 'edges') { | 214 | + actions.push( |
215 | + { | ||
216 | + name: this.translate.instant('rulechain.open-rulechain'), | ||
217 | + icon: 'settings_ethernet', | ||
218 | + isEnabled: () => true, | ||
219 | + onAction: ($event, entity) => this.openRuleChain($event, entity) | ||
220 | + }, | ||
221 | + { | ||
222 | + name: this.translate.instant('rulechain.export'), | ||
223 | + icon: 'file_download', | ||
224 | + isEnabled: () => true, | ||
225 | + onAction: ($event, entity) => this.exportRuleChain($event, entity) | ||
226 | + } | ||
227 | + ); | ||
228 | + if (ruleChainScope === 'tenant') { | ||
215 | actions.push( | 229 | actions.push( |
216 | { | 230 | { |
217 | - name: this.translate.instant('rulechain.open-rulechain'), | ||
218 | - icon: 'settings_ethernet', | ||
219 | - isEnabled: () => true, | ||
220 | - onAction: ($event, entity) => this.openRuleChain($event, entity) | 231 | + name: this.translate.instant('rulechain.set-root'), |
232 | + icon: 'flag', | ||
233 | + isEnabled: (entity) => this.isNonRootRuleChain(entity), | ||
234 | + onAction: ($event, entity) => this.setRootRuleChain($event, entity) | ||
235 | + } | ||
236 | + ); | ||
237 | + } | ||
238 | + if (ruleChainScope === 'edges') { | ||
239 | + actions.push( | ||
240 | + { | ||
241 | + name: this.translate.instant('rulechain.set-edge-template-root-rulechain'), | ||
242 | + icon: 'flag', | ||
243 | + isEnabled: (entity) => this.isNonRootRuleChain(entity), | ||
244 | + onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($event, entity) | ||
221 | }, | 245 | }, |
222 | { | 246 | { |
223 | - name: this.translate.instant('rulechain.export'), | ||
224 | - icon: 'file_download', | ||
225 | - isEnabled: () => true, | ||
226 | - onAction: ($event, entity) => this.exportRuleChain($event, entity) | 247 | + name: this.translate.instant('rulechain.set-auto-assign-to-edge'), |
248 | + icon: 'bookmark_outline', | ||
249 | + isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity), | ||
250 | + onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity) | ||
251 | + }, | ||
252 | + { | ||
253 | + name: this.translate.instant('rulechain.unset-auto-assign-to-edge'), | ||
254 | + icon: 'bookmark', | ||
255 | + isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity), | ||
256 | + onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity) | ||
227 | } | 257 | } |
228 | ); | 258 | ); |
229 | - if (ruleChainScope === 'tenant') { | ||
230 | - actions.push( | ||
231 | - { | ||
232 | - name: this.translate.instant('rulechain.set-root'), | ||
233 | - icon: 'flag', | ||
234 | - isEnabled: (entity) => this.isNonRootRuleChain(entity), | ||
235 | - onAction: ($event, entity) => this.setRootRuleChain($event, entity) | ||
236 | - } | ||
237 | - ); | ||
238 | - } | ||
239 | - if (ruleChainScope === 'edges') { | ||
240 | - actions.push( | ||
241 | - { | ||
242 | - name: this.translate.instant('rulechain.set-edge-template-root-rulechain'), | ||
243 | - icon: 'flag', | ||
244 | - isEnabled: (entity) => this.isNonRootRuleChain(entity), | ||
245 | - onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($event, entity) | ||
246 | - }, | ||
247 | - { | ||
248 | - name: this.translate.instant('rulechain.set-auto-assign-to-edge'), | ||
249 | - icon: 'bookmark_outline', | ||
250 | - isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity), | ||
251 | - onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity) | ||
252 | - }, | ||
253 | - { | ||
254 | - name: this.translate.instant('rulechain.unset-auto-assign-to-edge'), | ||
255 | - icon: 'bookmark', | ||
256 | - isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity), | ||
257 | - onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity) | ||
258 | - } | ||
259 | - ); | ||
260 | - } | ||
261 | } | 259 | } |
262 | if (ruleChainScope === 'edge') { | 260 | if (ruleChainScope === 'edge') { |
263 | actions.push( | 261 | actions.push( |
@@ -301,6 +299,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -301,6 +299,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
301 | } | 299 | } |
302 | if (this.config.componentsData.ruleChainScope === 'edges') { | 300 | if (this.config.componentsData.ruleChainScope === 'edges') { |
303 | this.router.navigateByUrl(`edges/ruleChains/${ruleChain.id.id}`); | 301 | this.router.navigateByUrl(`edges/ruleChains/${ruleChain.id.id}`); |
302 | + } else if (this.config.componentsData.ruleChainScope === 'edge') { | ||
303 | + this.router.navigateByUrl(`edges/${this.config.componentsData.edgeId}/ruleChains/${ruleChain.id.id}`); | ||
304 | } else { | 304 | } else { |
305 | this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`); | 305 | this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`); |
306 | } | 306 | } |