Browse Source

Fixed edge rule chains

pull/3811/head
deaflynx 6 years ago
parent
commit
a75fc2ea0d
  1. 6
      ui-ngx/src/app/core/http/edge.service.ts
  2. 37
      ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts
  3. 2
      ui-ngx/src/app/shared/models/edge.models.ts
  4. 6
      ui-ngx/src/assets/locale/locale.constant-de_DE.json
  5. 6
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  6. 6
      ui-ngx/src/assets/locale/locale.constant-es_ES.json
  7. 6
      ui-ngx/src/assets/locale/locale.constant-fr_FR.json
  8. 6
      ui/src/app/edge/edge.controller.js
  9. 6
      ui/src/app/edge/set-root-rule-chain-to-edges.tpl.html

6
ui-ngx/src/app/core/http/edge.service.ts

@ -73,7 +73,7 @@ export class EdgeService {
}
public assignEdgeToCustomer(customerId: string, edgeId: string, config?: RequestConfig): Observable<Edge> {
return this.http.post<Edge>(`/api/customer/${customerId}/edge/${edgeId}`, null, defaultHttpOptionsFromConfig(config));
return this.http.post<Edge>(`/api/customer/${customerId}/edge/${edgeId}`, defaultHttpOptionsFromConfig(config));
}
public unassignEdgeFromCustomer(edgeId: string, config?: RequestConfig) {
@ -81,11 +81,11 @@ export class EdgeService {
}
public makeEdgePublic(edgeId: string, config?: RequestConfig): Observable<Edge> {
return this.http.post<Edge>(`/api/customer/public/edge/${edgeId}`, null, defaultHttpOptionsFromConfig(config));
return this.http.post<Edge>(`/api/customer/public/edge/${edgeId}`, defaultHttpOptionsFromConfig(config));
}
public setRootRuleChain(edgeId: string, ruleChainId: string, config?: RequestConfig): Observable<Edge> {
return this.http.post<Edge>(`/api/edge/${edgeId}/${ruleChainId}/root`, null, defaultHttpOptionsFromConfig(config));
return this.http.post<Edge>(`/api/edge/${edgeId}/${ruleChainId}/root`, defaultHttpOptionsFromConfig(config));
}
public getTenantEdgeInfos(pageLink: PageLink, type: string = '',

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

@ -46,12 +46,14 @@ import {
import { MatDialog } from "@angular/material/dialog";
import { isDefined, isUndefined } from "@core/utils";
import { PageLink } from "@shared/models/page/page-link";
import { Edge } from "@shared/models/edge.models";
@Injectable()
export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<RuleChain>> {
private readonly config: EntityTableConfig<RuleChain> = new EntityTableConfig<RuleChain>();
private edgeId: string;
private edge: Edge;
constructor(private ruleChainService: RuleChainService,
private dialogService: DialogService,
@ -62,7 +64,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
private translate: TranslateService,
private datePipe: DatePipe,
private router: Router) {
this.config.entityType = EntityType.RULE_CHAIN;
this.config.entityComponent = RuleChainComponent;
this.config.entityTabsComponent = RuleChainTabsComponent;
@ -74,7 +75,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'),
new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
entity => {
if (isDefined(this.edgeId) && this.edgeId != null) {
return checkBoxCell((this.edge.rootRuleChainId.id == entity.id.id));
} else {
return checkBoxCell(entity.root);
}
})
);
this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
@ -87,7 +92,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
this.config.deleteEntity = id => this.ruleChainService.deleteRuleChain(id.id);
this.config.onEntityAction = action => this.onRuleChainAction(action);
this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root;
this.config.entitySelectionEnabled = (ruleChain) => ruleChain && !ruleChain.root;
this.config.entitySelectionEnabled = (ruleChain) => {
if (isDefined(this.edgeId) && this.edgeId != null) {
return this.edge.rootRuleChainId.id != ruleChain.id.id;
} else {
return ruleChain && !ruleChain.root;
}
}
}
resolve(route: ActivatedRouteSnapshot): EntityTableConfig<RuleChain> {
@ -143,13 +154,15 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
this.config.tableTitle = this.translate.instant('rulechain.edge-rulechains');
this.config.entitiesFetchFunction = pageLink => this.fetchEdgeRuleChains(pageLink);
} else if (ruleChainScope === 'edge') {
if (this.edgeId) {
if (isDefined(this.edgeId) && this.edgeId != null) {
this.edgeService.getEdge(this.edgeId)
.pipe(map(edge => this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains')))
.subscribe();
.pipe(map(edge => {
this.edge = edge;
this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains')
})).subscribe();
}
this.config.entitiesFetchFunction = pageLink => this.ruleChainService.getEdgeRuleChains(this.edgeId, pageLink);
this.config.deleteEnabled = () => false;
this.config.entitiesDeleteEnabled = false;
}
}
@ -221,7 +234,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (ruleChainScope === 'edge') {
actions.push(
{
name: this.translate.instant('edge.set-root'),
name: this.translate.instant('rulechain.set-root'),
icon: 'flag',
isEnabled: (entity) => this.isNonRootRuleChain(entity),
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
@ -229,7 +242,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
{
name: this.translate.instant('edge.unassign-from-edge'),
icon: 'portable_wifi_off',
isEnabled: () => true,
isEnabled: (entity) => entity.id.id != this.edge.rootRuleChainId.id,
onAction: ($event, entity) => this.unassignFromEdge($event, entity)
}
)
@ -286,9 +299,10 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
true
).subscribe((res) => {
if (res) {
if (this.edgeId) {
if (isDefined(this.edgeId) && this.edgeId != null) {
this.edgeService.setRootRuleChain(this.edgeId, ruleChain.id.id).subscribe(
() => {
(edge) => {
this.edge = edge;
this.config.table.updateData();
}
)
@ -457,6 +471,9 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
}
isNonRootRuleChain(ruleChain: RuleChain) {
if (isDefined(this.edgeId) && this.edgeId != null) {
return (isDefined(this.edge.rootRuleChainId) && this.edge.rootRuleChainId != null && this.edge.rootRuleChainId.id != ruleChain.id.id);
}
return (isDefined(ruleChain)) && !ruleChain.root;
}

2
ui-ngx/src/app/shared/models/edge.models.ts

@ -19,6 +19,7 @@ import { TenantId } from '@shared/models/id/tenant-id';
import { CustomerId } from '@shared/models/id/customer-id';
import { EdgeId } from '@shared/models/id/edge-id';
import { EntitySearchQuery } from '@shared/models/relation.models';
import { RuleChainId } from "@shared/models/id/rule-chain-id";
export interface Edge extends BaseData<EdgeId> {
tenantId?: TenantId;
@ -31,6 +32,7 @@ export interface Edge extends BaseData<EdgeId> {
edgeLicenseKey: string;
label?: string;
additionalInfo?: any;
rootRuleChainId?: RuleChainId;
}
export interface EdgeInfo extends Edge {

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

@ -802,9 +802,9 @@
"assets": "Rand Objekte",
"devices": "Objekte Geräte",
"entity-views": "Objekte Entitätsansichten",
"set-root-rule-chain-text": "Bitte wählen Sie die Regelkette zur Wurzel rule chain für die Rand",
"set-root-rule-chain-to-edges": "Regelkette zur Wurzel machen für die Rand",
"set-root-rule-chain-to-edges-text": "Die Regelkette zur Wurzel für { count, plural, 1 {1 Rand} other {# Rand} } machen",
"set-root-rulechain-text": "Bitte wählen Sie die Regelkette zur Wurzel rule chain für die Rand",
"set-root-rulechain-to-edges": "Regelkette zur Wurzel machen für die Rand",
"set-root-rulechain-to-edges-text": "Die Regelkette zur Wurzel für { count, plural, 1 {1 Rand} other {# Rand} } machen",
"status": "Von Rand empfangen",
"success": "Bereitgestellt",
"failed": "Steht aus",

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

@ -994,9 +994,9 @@
"assets": "Edge assets",
"devices": "Edge devices",
"entity-views": "Edge entity views",
"set-root-rule-chain-text": "Please select root rule chain for edge(s)",
"set-root-rule-chain-to-edges": "Set root rule chain for Edge(s)",
"set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
"set-root-rulechain-text": "Please select root rule chain for edge(s)",
"set-root-rulechain-to-edges": "Set root rule chain for Edge(s)",
"set-root-rulechain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
"status": "Received by edge",
"success": "Deployed",
"failed": "Pending",

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

@ -824,9 +824,9 @@
"assets": "Activos de borde",
"devices": "Dispositivos de borde",
"entity-views": "Vistas de entidad de borde",
"set-root-rule-chain-text": "Seleccione la cadena de reglas raíz para los bordes",
"set-root-rule-chain-to-edges": "Establecer la cadena de reglas raíz para Edge (s)",
"set-root-rule-chain-to-edges-text": "Establecer la cadena de la regla raíz para {count, plural, 1 {1 borde} other {# bordes}}",
"set-root-rulechain-text": "Seleccione la cadena de reglas raíz para los bordes",
"set-root-rulechain-to-edges": "Establecer la cadena de reglas raíz para Edge (s)",
"set-root-rulechain-to-edges-text": "Establecer la cadena de la regla raíz para {count, plural, 1 {1 borde} other {# bordes}}",
"status": "Recibido por borde",
"success": "Desplegada",
"failed": "Pendiente",

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

@ -820,9 +820,9 @@
"assets": "Actifs de la bordure",
"devices": "Dispositifs de la bordure",
"entity-views": "Vues de l'entité bordure",
"set-root-rule-chain-text": "Veuillez sélectionner la chaîne de règles racine pour les bordure(s)",
"set-root-rule-chain-to-edges": "Définir la chaîne de règles racine pour bordure(s)",
"set-root-rule-chain-to-edges-text": "Définir la chaîne de règles racine pour {count, plural, 1 {1 bordure} other {# bordures} }",
"set-root-rulechain-text": "Veuillez sélectionner la chaîne de règles racine pour les bordure(s)",
"set-rootrule-chain-to-edges": "Définir la chaîne de règles racine pour bordure(s)",
"set-root-rulechain-to-edges-text": "Définir la chaîne de règles racine pour {count, plural, 1 {1 bordure} other {# bordures} }",
"status": "Reçu par bord",
"success": "Déployée",
"failed": "En attente",

6
ui/src/app/edge/edge.controller.js

@ -19,7 +19,7 @@ import addEdgeTemplate from './add-edge.tpl.html';
import edgeCard from './edge-card.tpl.html';
import assignToCustomerTemplate from './assign-to-customer.tpl.html';
import addEdgesToCustomerTemplate from './add-edges-to-customer.tpl.html';
import setRootRuleChainToEdgesTemplate from './set-root-rule-chain-to-edges.tpl.html';
import setRootRuleChainToEdgesTemplate from './set-root-rulechain-to-edges.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
@ -303,9 +303,9 @@ export function EdgeController($rootScope, userService, edgeService, customerSer
onAction: function ($event, items) {
setRootRuleChainToEdges($event, items);
},
name: function() { return $translate.instant('edge.set-root-rule-chain-to-edges') },
name: function() { return $translate.instant('edge.set-rootrule-chain-to-edges') },
details: function(selectedCount) {
return $translate.instant('edge.set-root-rule-chain-to-edges-text', {count: selectedCount}, "messageformat");
return $translate.instant('edge.set-root-rulechain-to-edges-text', {count: selectedCount}, "messageformat");
},
icon: "flag"
}

6
ui/src/app/edge/set-root-rule-chain-to-edges.tpl.html

@ -15,11 +15,11 @@
limitations under the License.
-->
<md-dialog aria-label="{{ 'edge.set-root-rule-chain-to-edges' | translate }}">
<md-dialog aria-label="{{ 'edge.set-root-rulechain-to-edges' | translate }}">
<form name="theForm" ng-submit="vm.assign()">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>edge.set-root-rule-chain-to-edges</h2>
<h2 translate>edge.set-root-rulechain-to-edges</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>
@ -31,7 +31,7 @@
<md-dialog-content>
<div class="md-dialog-content">
<fieldset>
<span translate>edge.set-root-rule-chain-text</span>
<span translate>edge.set-root-rulechain-text</span>
<md-input-container class="md-block" style='margin-bottom: 0px;'>
<label>&nbsp;</label>
<md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons">

Loading…
Cancel
Save