Showing
9 changed files
with
50 additions
and
31 deletions
@@ -73,7 +73,7 @@ export class EdgeService { | @@ -73,7 +73,7 @@ export class EdgeService { | ||
73 | } | 73 | } |
74 | 74 | ||
75 | public assignEdgeToCustomer(customerId: string, edgeId: string, config?: RequestConfig): Observable<Edge> { | 75 | public assignEdgeToCustomer(customerId: string, edgeId: string, config?: RequestConfig): Observable<Edge> { |
76 | - return this.http.post<Edge>(`/api/customer/${customerId}/edge/${edgeId}`, null, defaultHttpOptionsFromConfig(config)); | 76 | + return this.http.post<Edge>(`/api/customer/${customerId}/edge/${edgeId}`, defaultHttpOptionsFromConfig(config)); |
77 | } | 77 | } |
78 | 78 | ||
79 | public unassignEdgeFromCustomer(edgeId: string, config?: RequestConfig) { | 79 | public unassignEdgeFromCustomer(edgeId: string, config?: RequestConfig) { |
@@ -81,11 +81,11 @@ export class EdgeService { | @@ -81,11 +81,11 @@ export class EdgeService { | ||
81 | } | 81 | } |
82 | 82 | ||
83 | public makeEdgePublic(edgeId: string, config?: RequestConfig): Observable<Edge> { | 83 | public makeEdgePublic(edgeId: string, config?: RequestConfig): Observable<Edge> { |
84 | - return this.http.post<Edge>(`/api/customer/public/edge/${edgeId}`, null, defaultHttpOptionsFromConfig(config)); | 84 | + return this.http.post<Edge>(`/api/customer/public/edge/${edgeId}`, defaultHttpOptionsFromConfig(config)); |
85 | } | 85 | } |
86 | 86 | ||
87 | public setRootRuleChain(edgeId: string, ruleChainId: string, config?: RequestConfig): Observable<Edge> { | 87 | public setRootRuleChain(edgeId: string, ruleChainId: string, config?: RequestConfig): Observable<Edge> { |
88 | - return this.http.post<Edge>(`/api/edge/${edgeId}/${ruleChainId}/root`, null, defaultHttpOptionsFromConfig(config)); | 88 | + return this.http.post<Edge>(`/api/edge/${edgeId}/${ruleChainId}/root`, defaultHttpOptionsFromConfig(config)); |
89 | } | 89 | } |
90 | 90 | ||
91 | public getTenantEdgeInfos(pageLink: PageLink, type: string = '', | 91 | public getTenantEdgeInfos(pageLink: PageLink, type: string = '', |
@@ -46,12 +46,14 @@ import { | @@ -46,12 +46,14 @@ import { | ||
46 | import { MatDialog } from "@angular/material/dialog"; | 46 | import { MatDialog } from "@angular/material/dialog"; |
47 | import { isDefined, isUndefined } from "@core/utils"; | 47 | import { isDefined, isUndefined } from "@core/utils"; |
48 | import { PageLink } from "@shared/models/page/page-link"; | 48 | import { PageLink } from "@shared/models/page/page-link"; |
49 | +import { Edge } from "@shared/models/edge.models"; | ||
49 | 50 | ||
50 | @Injectable() | 51 | @Injectable() |
51 | export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<RuleChain>> { | 52 | export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<RuleChain>> { |
52 | 53 | ||
53 | private readonly config: EntityTableConfig<RuleChain> = new EntityTableConfig<RuleChain>(); | 54 | private readonly config: EntityTableConfig<RuleChain> = new EntityTableConfig<RuleChain>(); |
54 | private edgeId: string; | 55 | private edgeId: string; |
56 | + private edge: Edge; | ||
55 | 57 | ||
56 | constructor(private ruleChainService: RuleChainService, | 58 | constructor(private ruleChainService: RuleChainService, |
57 | private dialogService: DialogService, | 59 | private dialogService: DialogService, |
@@ -62,7 +64,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -62,7 +64,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
62 | private translate: TranslateService, | 64 | private translate: TranslateService, |
63 | private datePipe: DatePipe, | 65 | private datePipe: DatePipe, |
64 | private router: Router) { | 66 | private router: Router) { |
65 | - | ||
66 | this.config.entityType = EntityType.RULE_CHAIN; | 67 | this.config.entityType = EntityType.RULE_CHAIN; |
67 | this.config.entityComponent = RuleChainComponent; | 68 | this.config.entityComponent = RuleChainComponent; |
68 | this.config.entityTabsComponent = RuleChainTabsComponent; | 69 | this.config.entityTabsComponent = RuleChainTabsComponent; |
@@ -74,7 +75,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -74,7 +75,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
74 | new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'), | 75 | new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'), |
75 | new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px', | 76 | new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px', |
76 | entity => { | 77 | entity => { |
78 | + if (isDefined(this.edgeId) && this.edgeId != null) { | ||
79 | + return checkBoxCell((this.edge.rootRuleChainId.id == entity.id.id)); | ||
80 | + } else { | ||
77 | return checkBoxCell(entity.root); | 81 | return checkBoxCell(entity.root); |
82 | + } | ||
78 | }) | 83 | }) |
79 | ); | 84 | ); |
80 | this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title', | 85 | this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title', |
@@ -87,7 +92,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -87,7 +92,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
87 | this.config.deleteEntity = id => this.ruleChainService.deleteRuleChain(id.id); | 92 | this.config.deleteEntity = id => this.ruleChainService.deleteRuleChain(id.id); |
88 | this.config.onEntityAction = action => this.onRuleChainAction(action); | 93 | this.config.onEntityAction = action => this.onRuleChainAction(action); |
89 | this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; | 94 | this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; |
90 | - this.config.entitySelectionEnabled = (ruleChain) => ruleChain && !ruleChain.root; | 95 | + this.config.entitySelectionEnabled = (ruleChain) => { |
96 | + if (isDefined(this.edgeId) && this.edgeId != null) { | ||
97 | + return this.edge.rootRuleChainId.id != ruleChain.id.id; | ||
98 | + } else { | ||
99 | + return ruleChain && !ruleChain.root; | ||
100 | + } | ||
101 | + } | ||
91 | } | 102 | } |
92 | 103 | ||
93 | resolve(route: ActivatedRouteSnapshot): EntityTableConfig<RuleChain> { | 104 | resolve(route: ActivatedRouteSnapshot): EntityTableConfig<RuleChain> { |
@@ -143,13 +154,15 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -143,13 +154,15 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
143 | this.config.tableTitle = this.translate.instant('rulechain.edge-rulechains'); | 154 | this.config.tableTitle = this.translate.instant('rulechain.edge-rulechains'); |
144 | this.config.entitiesFetchFunction = pageLink => this.fetchEdgeRuleChains(pageLink); | 155 | this.config.entitiesFetchFunction = pageLink => this.fetchEdgeRuleChains(pageLink); |
145 | } else if (ruleChainScope === 'edge') { | 156 | } else if (ruleChainScope === 'edge') { |
146 | - if (this.edgeId) { | 157 | + if (isDefined(this.edgeId) && this.edgeId != null) { |
147 | this.edgeService.getEdge(this.edgeId) | 158 | this.edgeService.getEdge(this.edgeId) |
148 | - .pipe(map(edge => this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains'))) | ||
149 | - .subscribe(); | 159 | + .pipe(map(edge => { |
160 | + this.edge = edge; | ||
161 | + this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains') | ||
162 | + })).subscribe(); | ||
150 | } | 163 | } |
151 | this.config.entitiesFetchFunction = pageLink => this.ruleChainService.getEdgeRuleChains(this.edgeId, pageLink); | 164 | this.config.entitiesFetchFunction = pageLink => this.ruleChainService.getEdgeRuleChains(this.edgeId, pageLink); |
152 | - this.config.deleteEnabled = () => false; | 165 | + this.config.entitiesDeleteEnabled = false; |
153 | } | 166 | } |
154 | } | 167 | } |
155 | 168 | ||
@@ -221,7 +234,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -221,7 +234,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
221 | if (ruleChainScope === 'edge') { | 234 | if (ruleChainScope === 'edge') { |
222 | actions.push( | 235 | actions.push( |
223 | { | 236 | { |
224 | - name: this.translate.instant('edge.set-root'), | 237 | + name: this.translate.instant('rulechain.set-root'), |
225 | icon: 'flag', | 238 | icon: 'flag', |
226 | isEnabled: (entity) => this.isNonRootRuleChain(entity), | 239 | isEnabled: (entity) => this.isNonRootRuleChain(entity), |
227 | onAction: ($event, entity) => this.setRootRuleChain($event, entity) | 240 | onAction: ($event, entity) => this.setRootRuleChain($event, entity) |
@@ -229,7 +242,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -229,7 +242,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
229 | { | 242 | { |
230 | name: this.translate.instant('edge.unassign-from-edge'), | 243 | name: this.translate.instant('edge.unassign-from-edge'), |
231 | icon: 'portable_wifi_off', | 244 | icon: 'portable_wifi_off', |
232 | - isEnabled: () => true, | 245 | + isEnabled: (entity) => entity.id.id != this.edge.rootRuleChainId.id, |
233 | onAction: ($event, entity) => this.unassignFromEdge($event, entity) | 246 | onAction: ($event, entity) => this.unassignFromEdge($event, entity) |
234 | } | 247 | } |
235 | ) | 248 | ) |
@@ -286,9 +299,10 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -286,9 +299,10 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
286 | true | 299 | true |
287 | ).subscribe((res) => { | 300 | ).subscribe((res) => { |
288 | if (res) { | 301 | if (res) { |
289 | - if (this.edgeId) { | 302 | + if (isDefined(this.edgeId) && this.edgeId != null) { |
290 | this.edgeService.setRootRuleChain(this.edgeId, ruleChain.id.id).subscribe( | 303 | this.edgeService.setRootRuleChain(this.edgeId, ruleChain.id.id).subscribe( |
291 | - () => { | 304 | + (edge) => { |
305 | + this.edge = edge; | ||
292 | this.config.table.updateData(); | 306 | this.config.table.updateData(); |
293 | } | 307 | } |
294 | ) | 308 | ) |
@@ -457,6 +471,9 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | @@ -457,6 +471,9 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< | ||
457 | } | 471 | } |
458 | 472 | ||
459 | isNonRootRuleChain(ruleChain: RuleChain) { | 473 | isNonRootRuleChain(ruleChain: RuleChain) { |
474 | + if (isDefined(this.edgeId) && this.edgeId != null) { | ||
475 | + return (isDefined(this.edge.rootRuleChainId) && this.edge.rootRuleChainId != null && this.edge.rootRuleChainId.id != ruleChain.id.id); | ||
476 | + } | ||
460 | return (isDefined(ruleChain)) && !ruleChain.root; | 477 | return (isDefined(ruleChain)) && !ruleChain.root; |
461 | } | 478 | } |
462 | 479 |
@@ -19,6 +19,7 @@ import { TenantId } from '@shared/models/id/tenant-id'; | @@ -19,6 +19,7 @@ import { TenantId } from '@shared/models/id/tenant-id'; | ||
19 | import { CustomerId } from '@shared/models/id/customer-id'; | 19 | import { CustomerId } from '@shared/models/id/customer-id'; |
20 | import { EdgeId } from '@shared/models/id/edge-id'; | 20 | import { EdgeId } from '@shared/models/id/edge-id'; |
21 | import { EntitySearchQuery } from '@shared/models/relation.models'; | 21 | import { EntitySearchQuery } from '@shared/models/relation.models'; |
22 | +import { RuleChainId } from "@shared/models/id/rule-chain-id"; | ||
22 | 23 | ||
23 | export interface Edge extends BaseData<EdgeId> { | 24 | export interface Edge extends BaseData<EdgeId> { |
24 | tenantId?: TenantId; | 25 | tenantId?: TenantId; |
@@ -31,6 +32,7 @@ export interface Edge extends BaseData<EdgeId> { | @@ -31,6 +32,7 @@ export interface Edge extends BaseData<EdgeId> { | ||
31 | edgeLicenseKey: string; | 32 | edgeLicenseKey: string; |
32 | label?: string; | 33 | label?: string; |
33 | additionalInfo?: any; | 34 | additionalInfo?: any; |
35 | + rootRuleChainId?: RuleChainId; | ||
34 | } | 36 | } |
35 | 37 | ||
36 | export interface EdgeInfo extends Edge { | 38 | export interface EdgeInfo extends Edge { |
@@ -802,9 +802,9 @@ | @@ -802,9 +802,9 @@ | ||
802 | "assets": "Rand Objekte", | 802 | "assets": "Rand Objekte", |
803 | "devices": "Objekte Geräte", | 803 | "devices": "Objekte Geräte", |
804 | "entity-views": "Objekte Entitätsansichten", | 804 | "entity-views": "Objekte Entitätsansichten", |
805 | - "set-root-rule-chain-text": "Bitte wählen Sie die Regelkette zur Wurzel rule chain für die Rand", | ||
806 | - "set-root-rule-chain-to-edges": "Regelkette zur Wurzel machen für die Rand", | ||
807 | - "set-root-rule-chain-to-edges-text": "Die Regelkette zur Wurzel für { count, plural, 1 {1 Rand} other {# Rand} } machen", | 805 | + "set-root-rulechain-text": "Bitte wählen Sie die Regelkette zur Wurzel rule chain für die Rand", |
806 | + "set-root-rulechain-to-edges": "Regelkette zur Wurzel machen für die Rand", | ||
807 | + "set-root-rulechain-to-edges-text": "Die Regelkette zur Wurzel für { count, plural, 1 {1 Rand} other {# Rand} } machen", | ||
808 | "status": "Von Rand empfangen", | 808 | "status": "Von Rand empfangen", |
809 | "success": "Bereitgestellt", | 809 | "success": "Bereitgestellt", |
810 | "failed": "Steht aus", | 810 | "failed": "Steht aus", |
@@ -994,9 +994,9 @@ | @@ -994,9 +994,9 @@ | ||
994 | "assets": "Edge assets", | 994 | "assets": "Edge assets", |
995 | "devices": "Edge devices", | 995 | "devices": "Edge devices", |
996 | "entity-views": "Edge entity views", | 996 | "entity-views": "Edge entity views", |
997 | - "set-root-rule-chain-text": "Please select root rule chain for edge(s)", | ||
998 | - "set-root-rule-chain-to-edges": "Set root rule chain for Edge(s)", | ||
999 | - "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }", | 997 | + "set-root-rulechain-text": "Please select root rule chain for edge(s)", |
998 | + "set-root-rulechain-to-edges": "Set root rule chain for Edge(s)", | ||
999 | + "set-root-rulechain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }", | ||
1000 | "status": "Received by edge", | 1000 | "status": "Received by edge", |
1001 | "success": "Deployed", | 1001 | "success": "Deployed", |
1002 | "failed": "Pending", | 1002 | "failed": "Pending", |
@@ -824,9 +824,9 @@ | @@ -824,9 +824,9 @@ | ||
824 | "assets": "Activos de borde", | 824 | "assets": "Activos de borde", |
825 | "devices": "Dispositivos de borde", | 825 | "devices": "Dispositivos de borde", |
826 | "entity-views": "Vistas de entidad de borde", | 826 | "entity-views": "Vistas de entidad de borde", |
827 | - "set-root-rule-chain-text": "Seleccione la cadena de reglas raíz para los bordes", | ||
828 | - "set-root-rule-chain-to-edges": "Establecer la cadena de reglas raíz para Edge (s)", | ||
829 | - "set-root-rule-chain-to-edges-text": "Establecer la cadena de la regla raíz para {count, plural, 1 {1 borde} other {# bordes}}", | 827 | + "set-root-rulechain-text": "Seleccione la cadena de reglas raíz para los bordes", |
828 | + "set-root-rulechain-to-edges": "Establecer la cadena de reglas raíz para Edge (s)", | ||
829 | + "set-root-rulechain-to-edges-text": "Establecer la cadena de la regla raíz para {count, plural, 1 {1 borde} other {# bordes}}", | ||
830 | "status": "Recibido por borde", | 830 | "status": "Recibido por borde", |
831 | "success": "Desplegada", | 831 | "success": "Desplegada", |
832 | "failed": "Pendiente", | 832 | "failed": "Pendiente", |
@@ -820,9 +820,9 @@ | @@ -820,9 +820,9 @@ | ||
820 | "assets": "Actifs de la bordure", | 820 | "assets": "Actifs de la bordure", |
821 | "devices": "Dispositifs de la bordure", | 821 | "devices": "Dispositifs de la bordure", |
822 | "entity-views": "Vues de l'entité bordure", | 822 | "entity-views": "Vues de l'entité bordure", |
823 | - "set-root-rule-chain-text": "Veuillez sélectionner la chaîne de règles racine pour les bordure(s)", | ||
824 | - "set-root-rule-chain-to-edges": "Définir la chaîne de règles racine pour bordure(s)", | ||
825 | - "set-root-rule-chain-to-edges-text": "Définir la chaîne de règles racine pour {count, plural, 1 {1 bordure} other {# bordures} }", | 823 | + "set-root-rulechain-text": "Veuillez sélectionner la chaîne de règles racine pour les bordure(s)", |
824 | + "set-rootrule-chain-to-edges": "Définir la chaîne de règles racine pour bordure(s)", | ||
825 | + "set-root-rulechain-to-edges-text": "Définir la chaîne de règles racine pour {count, plural, 1 {1 bordure} other {# bordures} }", | ||
826 | "status": "Reçu par bord", | 826 | "status": "Reçu par bord", |
827 | "success": "Déployée", | 827 | "success": "Déployée", |
828 | "failed": "En attente", | 828 | "failed": "En attente", |
@@ -19,7 +19,7 @@ import addEdgeTemplate from './add-edge.tpl.html'; | @@ -19,7 +19,7 @@ import addEdgeTemplate from './add-edge.tpl.html'; | ||
19 | import edgeCard from './edge-card.tpl.html'; | 19 | import edgeCard from './edge-card.tpl.html'; |
20 | import assignToCustomerTemplate from './assign-to-customer.tpl.html'; | 20 | import assignToCustomerTemplate from './assign-to-customer.tpl.html'; |
21 | import addEdgesToCustomerTemplate from './add-edges-to-customer.tpl.html'; | 21 | import addEdgesToCustomerTemplate from './add-edges-to-customer.tpl.html'; |
22 | -import setRootRuleChainToEdgesTemplate from './set-root-rule-chain-to-edges.tpl.html'; | 22 | +import setRootRuleChainToEdgesTemplate from './set-root-rulechain-to-edges.tpl.html'; |
23 | 23 | ||
24 | /* eslint-enable import/no-unresolved, import/default */ | 24 | /* eslint-enable import/no-unresolved, import/default */ |
25 | 25 | ||
@@ -303,9 +303,9 @@ export function EdgeController($rootScope, userService, edgeService, customerSer | @@ -303,9 +303,9 @@ export function EdgeController($rootScope, userService, edgeService, customerSer | ||
303 | onAction: function ($event, items) { | 303 | onAction: function ($event, items) { |
304 | setRootRuleChainToEdges($event, items); | 304 | setRootRuleChainToEdges($event, items); |
305 | }, | 305 | }, |
306 | - name: function() { return $translate.instant('edge.set-root-rule-chain-to-edges') }, | 306 | + name: function() { return $translate.instant('edge.set-rootrule-chain-to-edges') }, |
307 | details: function(selectedCount) { | 307 | details: function(selectedCount) { |
308 | - return $translate.instant('edge.set-root-rule-chain-to-edges-text', {count: selectedCount}, "messageformat"); | 308 | + return $translate.instant('edge.set-root-rulechain-to-edges-text', {count: selectedCount}, "messageformat"); |
309 | }, | 309 | }, |
310 | icon: "flag" | 310 | icon: "flag" |
311 | } | 311 | } |
@@ -15,11 +15,11 @@ | @@ -15,11 +15,11 @@ | ||
15 | limitations under the License. | 15 | limitations under the License. |
16 | 16 | ||
17 | --> | 17 | --> |
18 | -<md-dialog aria-label="{{ 'edge.set-root-rule-chain-to-edges' | translate }}"> | 18 | +<md-dialog aria-label="{{ 'edge.set-root-rulechain-to-edges' | translate }}"> |
19 | <form name="theForm" ng-submit="vm.assign()"> | 19 | <form name="theForm" ng-submit="vm.assign()"> |
20 | <md-toolbar> | 20 | <md-toolbar> |
21 | <div class="md-toolbar-tools"> | 21 | <div class="md-toolbar-tools"> |
22 | - <h2 translate>edge.set-root-rule-chain-to-edges</h2> | 22 | + <h2 translate>edge.set-root-rulechain-to-edges</h2> |
23 | <span flex></span> | 23 | <span flex></span> |
24 | <md-button class="md-icon-button" ng-click="vm.cancel()"> | 24 | <md-button class="md-icon-button" ng-click="vm.cancel()"> |
25 | <ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon> | 25 | <ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon> |
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | <md-dialog-content> | 31 | <md-dialog-content> |
32 | <div class="md-dialog-content"> | 32 | <div class="md-dialog-content"> |
33 | <fieldset> | 33 | <fieldset> |
34 | - <span translate>edge.set-root-rule-chain-text</span> | 34 | + <span translate>edge.set-root-rulechain-text</span> |
35 | <md-input-container class="md-block" style='margin-bottom: 0px;'> | 35 | <md-input-container class="md-block" style='margin-bottom: 0px;'> |
36 | <label> </label> | 36 | <label> </label> |
37 | <md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons"> | 37 | <md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons"> |