From 2bd819ebd4eb3a0e83b1feed248370b4a6fd592b Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Sun, 10 Jan 2021 01:27:49 +0200 Subject: [PATCH] Added rule chain type to edge dialog. Update default edge root rule chain --- .../rule_chains/edge_root_rule_chain.json | 53 +++++++++++++------ ...add-entities-to-edge-dialog.component.html | 3 +- .../add-entities-to-edge-dialog.component.ts | 4 ++ .../entity/entity-list.component.ts | 6 ++- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/application/src/main/data/json/demo/edge_management/rule_chains/edge_root_rule_chain.json b/application/src/main/data/json/demo/edge_management/rule_chains/edge_root_rule_chain.json index 0d777f029f..740d64627e 100644 --- a/application/src/main/data/json/demo/edge_management/rule_chains/edge_root_rule_chain.json +++ b/application/src/main/data/json/demo/edge_management/rule_chains/edge_root_rule_chain.json @@ -9,8 +9,22 @@ "configuration": null }, "metadata": { - "firstNodeIndex": 2, + "firstNodeIndex": 0, "nodes": [ + { + "additionalInfo": { + "description": "Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \"Success\" relation type.", + "layoutX": 203, + "layoutY": 259 + }, + "type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode", + "name": "Device Profile Node", + "debugMode": false, + "configuration": { + "persistAlarmRulesState": false, + "fetchAlarmRulesStateOnStart": false + } + }, { "additionalInfo": { "layoutX": 823, @@ -99,42 +113,47 @@ "connections": [ { "fromIndex": 0, - "toIndex": 6, + "toIndex": 3, "type": "Success" }, { "fromIndex": 1, - "toIndex": 6, + "toIndex": 7, "type": "Success" }, { "fromIndex": 2, - "toIndex": 4, + "toIndex": 7, + "type": "Success" + }, + { + "fromIndex": 3, + "toIndex": 6, + "type": "RPC Request to Device" + }, + { + "fromIndex": 3, + "toIndex": 5, "type": "Other" }, { - "fromIndex": 2, - "toIndex": 1, + "fromIndex": 3, + "toIndex": 2, "type": "Post attributes" }, { - "fromIndex": 2, - "toIndex": 0, + "fromIndex": 3, + "toIndex": 1, "type": "Post telemetry" }, { - "fromIndex": 2, - "toIndex": 3, + "fromIndex": 3, + "toIndex": 4, "type": "RPC Request from Device" }, { - "fromIndex": 2, - "toIndex": 5, - "type": "RPC Request to Device" - }, - { - "fromIndex": 3, - "toIndex": 6, + "fromIndex": 4, + "toIndex": 7, "type": "Success" } ], diff --git a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html index ad45c32de0..d890ad7a21 100644 --- a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html +++ b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html @@ -34,7 +34,8 @@ + [entityType]="entityType" + [subType]="subType"> diff --git a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts index a179c05286..6a01d08f3f 100644 --- a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts @@ -30,6 +30,7 @@ import { DashboardService } from '@core/http/dashboard.service'; import { DialogComponent } from '@shared/components/dialog.component'; import { Router } from '@angular/router'; import { RuleChainService } from "@core/http/rule-chain.service"; +import { ruleChainType } from "@shared/models/rule-chain.models"; export interface AddEntitiesToEdgeDialogData { edgeId: string; @@ -50,6 +51,7 @@ export class AddEntitiesToEdgeDialogComponent extends submitted = false; entityType: EntityType; + subType: string; assignToEdgeTitle: string; assignToEdgeText: string; @@ -74,6 +76,7 @@ export class AddEntitiesToEdgeDialogComponent extends this.addEntitiesToEdgeFormGroup = this.fb.group({ entityIds: [null, [Validators.required]] }); + this.subType = ''; switch (this.data.entityType) { case EntityType.DEVICE: this.assignToEdgeTitle = 'device.assign-device-to-edge-title'; @@ -82,6 +85,7 @@ export class AddEntitiesToEdgeDialogComponent extends case EntityType.RULE_CHAIN: this.assignToEdgeTitle = 'rulechain.assign-rulechain-to-edge-title'; this.assignToEdgeText = 'rulechain.assign-rulechain-to-edge-text'; + this.subType = ruleChainType.edge; break; case EntityType.ASSET: this.assignToEdgeTitle = 'asset.assign-asset-to-edge-title'; diff --git a/ui-ngx/src/app/shared/components/entity/entity-list.component.ts b/ui-ngx/src/app/shared/components/entity/entity-list.component.ts index 5595708b96..17708730df 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-list.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-list.component.ts @@ -60,6 +60,9 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV @Input() entityType: EntityType; + @Input() + subType: string; + private requiredValue: boolean; get required(): boolean { return this.requiredValue; @@ -216,8 +219,9 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV fetchEntities(searchText?: string): Observable>> { this.searchText = searchText; + return this.entityService.getEntitiesByNameFilter(this.entityType, searchText, - 50, '', {ignoreLoading: true}).pipe( + 50, this.subType ? this.subType : '', {ignoreLoading: true}).pipe( map((data) => data ? data : [])); }