From c598b4fa9d19a899410188975defb5053900bb20 Mon Sep 17 00:00:00 2001 From: dudnikmaksim Date: Thu, 7 Dec 2023 16:58:19 +0200 Subject: [PATCH] default config --- .../lib/gateway/gateway-connectors.component.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts index 9fa1f7b5f2..cd54221e32 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts @@ -139,6 +139,21 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie this.cd.detectChanges(); }); + this.connectorForm.get('type').valueChanges.subscribe(type=> { + if(type && this.initialConnector === null) { + this.attributeService.getEntityAttributes(this.device, AttributeScope.CLIENT_SCOPE, + [`${type.toUpperCase()}_DEFAULT_CONFIG`], {ignoreErrors: true}).subscribe(defaultConfig=>{ + if (defaultConfig && defaultConfig.length) { + this.connectorForm.get('configurationJson').setValue( + isString(defaultConfig[0].value) ? + JSON.parse(defaultConfig[0].value) : + defaultConfig[0].value); + this.cd.detectChanges(); + } + }) + } + }); + this.dataSource.sort = this.sort; this.dataSource.sortingDataAccessor = (data: AttributeData, sortHeaderId: string) => { if (sortHeaderId === 'syncStatus') {