From c9565719b719e6c5a12abf436173915997c86fd1 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Tue, 11 Jun 2024 15:52:05 +0300 Subject: [PATCH 1/7] [PROD-3481] [FIX] changed docker commands button and pop-up window title --- .../src/main/data/json/tenant/dashboards/gateways.json | 8 ++++---- ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/application/src/main/data/json/tenant/dashboards/gateways.json b/application/src/main/data/json/tenant/dashboards/gateways.json index d98daa3632..42c4f199b5 100644 --- a/application/src/main/data/json/tenant/dashboards/gateways.json +++ b/application/src/main/data/json/tenant/dashboards/gateways.json @@ -181,12 +181,12 @@ "actions": { "actionCellButton": [ { - "name": "Docker commands", + "name": "Launch command", "icon": "terminal", "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

Docker commands

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], @@ -1861,7 +1861,7 @@ "padding": "8px", "settings": { "useMarkdownTextFunction": false, - "markdownTextPattern": "
\r\n \r\n
", + "markdownTextPattern": "
\r\n \r\n
", "applyDefaultMarkdownStyle": false, "markdownCss": ".action-buttons-container {\r\n display: flex;\r\n flex-wrap: wrap;\r\n flex-direction: row;\r\n height: 100%;\r\n width: 100%;\r\n align-content: center;\r\n}\r\n\r\nbutton {\r\n flex-grow: 1;\r\n margin: 10px;\r\n min-width: 150px;\r\n height: auto;\r\n}" }, @@ -1887,7 +1887,7 @@ "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

Launch command

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 0fa09da5e4..d0270a5c87 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2835,6 +2835,7 @@ "enable-remote-logging": "Enable remote logging", "ellipsis-chips-text": "+ {{count}} more", "launch-gateway": "Launch gateway", + "launch-command": "Launch command", "launch-docker-compose": "Start the gateway using the following command in the terminal from folder with docker-compose.yml file", "logs-configuration": "Logs configuration", "create-new-gateway": "Create a new gateway", From 98f873f0b606f48acb0b2ba5ba61d6dbfa9e52e8 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 10:52:59 +0300 Subject: [PATCH 2/7] [PROD-3727] [FIX] made response topic expression required --- ...teway-service-rpc-connector.component.html | 2 +- ...gateway-service-rpc-connector.component.ts | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html index 2d992187f6..6f495984f5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html @@ -35,7 +35,7 @@ {{ 'gateway.rpc.withResponse' | translate }} - {{ 'gateway.rpc.responseTopicExpression' | translate }} + {{ 'gateway.rpc.responseTopicExpression' | translate }}* diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index 2ea5964b84..cbb11fc059 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, forwardRef, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { ControlValueAccessor, FormArray, @@ -22,6 +22,8 @@ import { FormControl, FormGroup, NG_VALUE_ACCESSOR, + UntypedFormControl, + ValidatorFn, Validators } from '@angular/forms'; import { @@ -53,6 +55,8 @@ import { } from '@shared/components/dialog/json-object-edit-dialog.component'; import { jsonRequired } from '@shared/components/json-object-edit.component'; import { deepClone } from '@core/utils'; +import { takeUntil, tap } from "rxjs/operators"; +import { Subject } from "rxjs"; @Component({ selector: 'tb-gateway-service-rpc-connector', @@ -66,7 +70,7 @@ import { deepClone } from '@core/utils'; } ] }) -export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValueAccessor { +export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, ControlValueAccessor { @Input() connectorType: ConnectorType; @@ -105,6 +109,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue private propagateChange = (v: any) => { } + private destroy$ = new Subject(); constructor(private fb: FormBuilder, private dialog: MatDialog,) { @@ -138,6 +143,17 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue } }); this.isMQTTWithResponse = this.fb.control(false); + this.isMQTTWithResponse.valueChanges.pipe( + tap(() => { + this.commandForm.get('responseTopicExpression').updateValueAndValidity(); + }), + takeUntil(this.destroy$), + ).subscribe(); + } + + ngOnDestroy(): void { + this.destroy$.next(); + this.destroy$.complete(); } connectorParamsFormGroupByType(type: ConnectorType): FormGroup { @@ -148,7 +164,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue formGroup = this.fb.group({ methodFilter: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], requestTopicExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], - responseTopicExpression: [null, [Validators.pattern(noLeadTrailSpacesRegex)]], + responseTopicExpression: [null, [this.requiredOnWithResponse(), Validators.pattern(noLeadTrailSpacesRegex)]], responseTimeout: [null, [Validators.min(10), Validators.pattern(this.numbersOnlyPattern)]], valueExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], }) @@ -424,4 +440,16 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue this.commandForm.patchValue(value, {onlySelf: false}); } } + + private requiredOnWithResponse(): ValidatorFn { + return (control: UntypedFormControl) => { + const withResponse: boolean = this.isMQTTWithResponse?.value; + + if (withResponse && !control.value) { + return { 'required': true }; + } + + return null; + }; + } } From 45472e64fde17fdb5eefeb595555f739996620e3 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 10:55:33 +0300 Subject: [PATCH 3/7] Revert "[PROD-3481] [FIX] changed docker commands button and pop-up window title" This reverts commit c9565719b719e6c5a12abf436173915997c86fd1. --- .../src/main/data/json/tenant/dashboards/gateways.json | 8 ++++---- ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/application/src/main/data/json/tenant/dashboards/gateways.json b/application/src/main/data/json/tenant/dashboards/gateways.json index 42c4f199b5..d98daa3632 100644 --- a/application/src/main/data/json/tenant/dashboards/gateways.json +++ b/application/src/main/data/json/tenant/dashboards/gateways.json @@ -181,12 +181,12 @@ "actions": { "actionCellButton": [ { - "name": "Launch command", + "name": "Docker commands", "icon": "terminal", "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

Docker commands

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], @@ -1861,7 +1861,7 @@ "padding": "8px", "settings": { "useMarkdownTextFunction": false, - "markdownTextPattern": "
\r\n \r\n
", + "markdownTextPattern": "
\r\n \r\n
", "applyDefaultMarkdownStyle": false, "markdownCss": ".action-buttons-container {\r\n display: flex;\r\n flex-wrap: wrap;\r\n flex-direction: row;\r\n height: 100%;\r\n width: 100%;\r\n align-content: center;\r\n}\r\n\r\nbutton {\r\n flex-grow: 1;\r\n margin: 10px;\r\n min-width: 150px;\r\n height: auto;\r\n}" }, @@ -1887,7 +1887,7 @@ "useShowWidgetActionFunction": null, "showWidgetActionFunction": "return true;", "type": "customPretty", - "customHtml": "
\n \n

{{ 'gateway.launch-command' | translate }}

\n \n
\n \n
\n \n
\n \n
\n
\n", + "customHtml": "
\n \n

Launch command

\n \n
\n \n
\n \n
\n \n
\n
\n", "customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}", "customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n", "customResources": [], diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index d0270a5c87..0fa09da5e4 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2835,7 +2835,6 @@ "enable-remote-logging": "Enable remote logging", "ellipsis-chips-text": "+ {{count}} more", "launch-gateway": "Launch gateway", - "launch-command": "Launch command", "launch-docker-compose": "Start the gateway using the following command in the terminal from folder with docker-compose.yml file", "logs-configuration": "Logs configuration", "create-new-gateway": "Create a new gateway", From 4990db2dc02e6cba89407dd63811c380a490c06b Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 10:58:42 +0300 Subject: [PATCH 4/7] [PROD-3727] [FIX] refactoring --- .../gateway-service-rpc-connector.component.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index cbb11fc059..6598b332ca 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -143,12 +143,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, C } }); this.isMQTTWithResponse = this.fb.control(false); - this.isMQTTWithResponse.valueChanges.pipe( - tap(() => { - this.commandForm.get('responseTopicExpression').updateValueAndValidity(); - }), - takeUntil(this.destroy$), - ).subscribe(); + this.observeMQTTWithResponse(); } ngOnDestroy(): void { @@ -452,4 +447,13 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, C return null; }; } + + private observeMQTTWithResponse(): void { + this.isMQTTWithResponse.valueChanges.pipe( + tap(() => { + this.commandForm.get('responseTopicExpression').updateValueAndValidity(); + }), + takeUntil(this.destroy$), + ).subscribe(); + } } From 58f677cd4fa2501376a8d9ed3ca8f64c7f2f567a Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 11:55:52 +0300 Subject: [PATCH 5/7] [PROD-3727] [FIX] refactoring --- ...teway-service-rpc-connector.component.html | 2 +- ...gateway-service-rpc-connector.component.ts | 20 +++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html index 6f495984f5..2d992187f6 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.html @@ -35,7 +35,7 @@ {{ 'gateway.rpc.withResponse' | translate }} - {{ 'gateway.rpc.responseTopicExpression' | translate }}* + {{ 'gateway.rpc.responseTopicExpression' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index 6598b332ca..fe3c600b50 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -159,7 +159,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, C formGroup = this.fb.group({ methodFilter: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], requestTopicExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], - responseTopicExpression: [null, [this.requiredOnWithResponse(), Validators.pattern(noLeadTrailSpacesRegex)]], + responseTopicExpression: [{ value: null, disabled: true }, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], responseTimeout: [null, [Validators.min(10), Validators.pattern(this.numbersOnlyPattern)]], valueExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], }) @@ -436,22 +436,12 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, C } } - private requiredOnWithResponse(): ValidatorFn { - return (control: UntypedFormControl) => { - const withResponse: boolean = this.isMQTTWithResponse?.value; - - if (withResponse && !control.value) { - return { 'required': true }; - } - - return null; - }; - } - private observeMQTTWithResponse(): void { this.isMQTTWithResponse.valueChanges.pipe( - tap(() => { - this.commandForm.get('responseTopicExpression').updateValueAndValidity(); + tap((isActive: boolean) => { + const responseControl = this.commandForm.get('responseTopicExpression'); + isActive ? responseControl.enable() : responseControl.disable(); + responseControl.updateValueAndValidity(); }), takeUntil(this.destroy$), ).subscribe(); From 25ce2d0800cfd4ae01895da0c937c26a9b983784 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 16:05:55 +0300 Subject: [PATCH 6/7] [PROD-3727] [FIX] refactoring --- .../lib/gateway/gateway-service-rpc-connector.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index fe3c600b50..0d9a8be239 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -22,8 +22,6 @@ import { FormControl, FormGroup, NG_VALUE_ACCESSOR, - UntypedFormControl, - ValidatorFn, Validators } from '@angular/forms'; import { From 3f01672284107bf1e25fd93650d65413274ef6df Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 12 Jun 2024 16:08:26 +0300 Subject: [PATCH 7/7] [PROD-3727] [FIX] refactoring --- .../lib/gateway/gateway-service-rpc-connector.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts index 0d9a8be239..77802935fb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector.component.ts @@ -439,7 +439,6 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, C tap((isActive: boolean) => { const responseControl = this.commandForm.get('responseTopicExpression'); isActive ? responseControl.enable() : responseControl.disable(); - responseControl.updateValueAndValidity(); }), takeUntil(this.destroy$), ).subscribe();