From 72b02eb7d3bba8505e72b6b588cb426df5d92070 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 24 Dec 2019 16:27:09 +0200 Subject: [PATCH] Test script function dialog. --- .../script/node-script-test.service.ts | 22 ++++++-- .../node-script-test-dialog.component.html | 7 +-- .../node-script-test-dialog.component.scss | 28 +++++++---- .../node-script-test-dialog.component.ts | 50 +++++++------------ ui-ngx/src/app/shared/shared.module.ts | 6 ++- 5 files changed, 65 insertions(+), 48 deletions(-) rename ui-ngx/src/app/{core/services/script => shared/components/dialog}/node-script-test-dialog.component.html (95%) rename ui-ngx/src/app/{core/services/script => shared/components/dialog}/node-script-test-dialog.component.scss (69%) rename ui-ngx/src/app/{core/services/script => shared/components/dialog}/node-script-test-dialog.component.ts (81%) diff --git a/ui-ngx/src/app/core/services/script/node-script-test.service.ts b/ui-ngx/src/app/core/services/script/node-script-test.service.ts index 3efa935c2e..d946425698 100644 --- a/ui-ngx/src/app/core/services/script/node-script-test.service.ts +++ b/ui-ngx/src/app/core/services/script/node-script-test.service.ts @@ -18,13 +18,16 @@ import { Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; import { RuleChainService } from '@core/http/rule-chain.service'; import { map, switchMap } from 'rxjs/operators'; +import { MatDialog } from '@angular/material'; +import { NodeScriptTestDialogComponent, NodeScriptTestDialogData } from '@shared/components/dialog/node-script-test-dialog.component'; @Injectable({ providedIn: 'root' }) export class NodeScriptTestService { - constructor(private ruleChainService: RuleChainService) { + constructor(private ruleChainService: RuleChainService, + public dialog: MatDialog) { } testNodeScript(script: string, scriptType: string, functionTitle: string, @@ -73,8 +76,21 @@ export class NodeScriptTestService { if (!msgType) { msgType = 'POST_TELEMETRY_REQUEST'; } - console.log(`testNodeScript TODO: ${script}`); - return of(script); + return this.dialog.open(NodeScriptTestDialogComponent, + { + disableClose: true, + panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-fullscreen-dialog-gt-sm'], + data: { + msg, + metadata, + msgType, + functionTitle, + functionName, + script, + scriptType, + argNames + } + }).afterClosed(); } } diff --git a/ui-ngx/src/app/core/services/script/node-script-test-dialog.component.html b/ui-ngx/src/app/shared/components/dialog/node-script-test-dialog.component.html similarity index 95% rename from ui-ngx/src/app/core/services/script/node-script-test-dialog.component.html rename to ui-ngx/src/app/shared/components/dialog/node-script-test-dialog.component.html index 8a3e17247b..c1b20aef19 100644 --- a/ui-ngx/src/app/core/services/script/node-script-test-dialog.component.html +++ b/ui-ngx/src/app/shared/components/dialog/node-script-test-dialog.component.html @@ -15,7 +15,8 @@ limitations under the License. --> -
+

{{ 'rulenode.test-script-function' | translate }}

@@ -43,8 +44,8 @@
- TODO: metadataForm
+ TODO: metadataForm
@@ -72,7 +73,6 @@ @@ -85,6 +85,7 @@