diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.html
new file mode 100644
index 0000000000..4c2db19345
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.html
@@ -0,0 +1,86 @@
+
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts
new file mode 100644
index 0000000000..d980bed4a7
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts
@@ -0,0 +1,129 @@
+///
+/// Copyright © 2016-2024 The Thingsboard Authors
+///
+/// Licensed under the Apache License, Version 2.0 (the "License");
+/// you may not use this file except in compliance with the License.
+/// You may obtain a copy of the License at
+///
+/// http://www.apache.org/licenses/LICENSE-2.0
+///
+/// Unless required by applicable law or agreed to in writing, software
+/// distributed under the License is distributed on an "AS IS" BASIS,
+/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+/// See the License for the specific language governing permissions and
+/// limitations under the License.
+///
+
+import {
+ ChangeDetectionStrategy,
+ Component,
+ forwardRef,
+ inject,
+ Input,
+ OnDestroy,
+ OnInit
+} from '@angular/core';
+import {
+ ControlContainer,
+ ControlValueAccessor,
+ FormBuilder,
+ FormGroup,
+ NG_VALUE_ACCESSOR,
+ UntypedFormGroup,
+ Validators
+} from '@angular/forms';
+import {
+ MqttVersions,
+ noLeadTrailSpacesRegex,
+ PortLimits,
+} from '@home/components/widget/lib/gateway/gateway-widget.models';
+import { SharedModule } from '@shared/shared.module';
+import { CommonModule } from '@angular/common';
+import { TranslateService } from '@ngx-translate/core';
+import { generateSecret } from '@core/utils';
+import { SecurityConfigComponent } from '@home/components/widget/lib/gateway/connectors-configuration';
+
+@Component({
+ selector: 'tb-broker-config-control',
+ templateUrl: './broker-config-control.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ standalone: true,
+ imports: [
+ CommonModule,
+ SharedModule,
+ SecurityConfigComponent,
+ ],
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => BrokerConfigControlComponent),
+ multi: true
+ }
+ ]
+})
+export class BrokerConfigControlComponent implements ControlValueAccessor, OnInit, OnDestroy {
+ @Input() controlKey = 'broker';
+
+ brokerConfigFormGroup: UntypedFormGroup;
+ mqttVersions = MqttVersions;
+ portLimits = PortLimits;
+
+ get parentFormGroup(): FormGroup {
+ return this.parentContainer.control as FormGroup;
+ }
+
+ private parentContainer = inject(ControlContainer);
+ private translate = inject(TranslateService);
+
+ constructor(private fb: FormBuilder) {
+ this.brokerConfigFormGroup = this.fb.group({
+ name: ['', []],
+ host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]],
+ port: [null, [Validators.required, Validators.min(PortLimits.MIN), Validators.max(PortLimits.MAX)]],
+ version: [5, []],
+ clientId: ['', [Validators.pattern(noLeadTrailSpacesRegex)]],
+ maxNumberOfWorkers: [100, [Validators.required, Validators.min(1)]],
+ maxMessageNumberPerWorker: [10, [Validators.required, Validators.min(1)]],
+ security: [{}, [Validators.required]]
+ });
+ }
+
+ get portErrorTooltip(): string {
+ if (this.brokerConfigFormGroup.get('port').hasError('required')) {
+ return this.translate.instant('gateway.port-required');
+ } else if (
+ this.brokerConfigFormGroup.get('port').hasError('min') ||
+ this.brokerConfigFormGroup.get('port').hasError('max')
+ ) {
+ return this.translate.instant('gateway.port-limits-error',
+ {min: PortLimits.MIN, max: PortLimits.MAX});
+ }
+ return '';
+ }
+
+ ngOnInit(): void {
+ this.addSelfControl();
+ }
+
+ ngOnDestroy(): void {
+ this.removeSelfControl();
+ }
+
+ generate(formControlName: string): void {
+ this.brokerConfigFormGroup.get(formControlName)?.patchValue('tb_gw_' + generateSecret(5));
+ }
+
+ registerOnChange(fn: any): void {}
+
+ registerOnTouched(fn: any): void {}
+
+ writeValue(obj: any): void {}
+
+ private addSelfControl(): void {
+ this.parentFormGroup.addControl(this.controlKey, this.brokerConfigFormGroup);
+ }
+
+ private removeSelfControl(): void {
+ this.parentFormGroup.removeControl(this.controlKey);
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.html
similarity index 88%
rename from ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.html
rename to ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.html
index 2a3108b8b4..0a33f5b885 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.html
@@ -50,9 +50,10 @@
class="tb-error">
warning
-
@@ -83,9 +84,10 @@
class="tb-error">
warning
-
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.scss
similarity index 100%
rename from ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.scss
rename to ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.scss
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.ts
similarity index 83%
rename from ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.ts
rename to ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.ts
index 8a40f25430..569f40b185 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/device-info-table/device-info-table.component.ts
@@ -16,27 +16,19 @@
import {
ChangeDetectionStrategy,
- ChangeDetectorRef,
Component,
- ElementRef,
forwardRef,
Input,
- NgZone,
OnDestroy,
OnInit,
- ViewContainerRef
} from '@angular/core';
import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { TranslateService } from '@ngx-translate/core';
import { MatDialog } from '@angular/material/dialog';
-import { DialogService } from '@core/services/dialog.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
-import { Overlay } from '@angular/cdk/overlay';
-import { UtilsService } from '@core/services/utils.service';
-import { EntityService } from '@core/http/entity.service';
import {
ControlValueAccessor,
FormBuilder,
@@ -50,6 +42,7 @@ import {
import {
DeviceInfoType,
noLeadTrailSpacesRegex,
+ OPCUaSourceTypes,
SourceTypes,
SourceTypeTranslationsMap
} from '@home/components/widget/lib/gateway/gateway-widget.models';
@@ -88,7 +81,7 @@ export class DeviceInfoTableComponent extends PageComponent implements ControlVa
required = false;
@Input()
- sourceTypes: Array = Object.values(SourceTypes);
+ sourceTypes: Array = Object.values(SourceTypes);
deviceInfoTypeValue: any;
@@ -111,14 +104,6 @@ export class DeviceInfoTableComponent extends PageComponent implements ControlVa
constructor(protected store: Store,
public translate: TranslateService,
public dialog: MatDialog,
- private overlay: Overlay,
- private viewContainerRef: ViewContainerRef,
- private dialogService: DialogService,
- private entityService: EntityService,
- private utils: UtilsService,
- private zone: NgZone,
- private cd: ChangeDetectorRef,
- private elementRef: ElementRef,
private fb: FormBuilder) {
super(store);
}
@@ -131,13 +116,13 @@ export class DeviceInfoTableComponent extends PageComponent implements ControlVa
if (this.useSource) {
this.mappingFormGroup.addControl('deviceNameExpressionSource',
- this.fb.control(SourceTypes.MSG, []));
+ this.fb.control(this.sourceTypes[0], []));
}
if (this.deviceInfoType === DeviceInfoType.FULL) {
if (this.useSource) {
this.mappingFormGroup.addControl('deviceProfileExpressionSource',
- this.fb.control(SourceTypes.MSG, []));
+ this.fb.control(this.sourceTypes[0], []));
}
this.mappingFormGroup.addControl('deviceProfileExpression',
this.fb.control('', this.required ?
@@ -154,6 +139,7 @@ export class DeviceInfoTableComponent extends PageComponent implements ControlVa
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
+ super.ngOnDestroy();
}
registerOnChange(fn: any): void {
@@ -175,5 +161,4 @@ export class DeviceInfoTableComponent extends PageComponent implements ControlVa
updateView(value: any) {
this.propagateChange(value);
}
-
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/index.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/index.ts
new file mode 100644
index 0000000000..bd0d4787d6
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/index.ts
@@ -0,0 +1,24 @@
+///
+/// Copyright © 2016-2024 The Thingsboard Authors
+///
+/// Licensed under the Apache License, Version 2.0 (the "License");
+/// you may not use this file except in compliance with the License.
+/// You may obtain a copy of the License at
+///
+/// http://www.apache.org/licenses/LICENSE-2.0
+///
+/// Unless required by applicable law or agreed to in writing, software
+/// distributed under the License is distributed on an "AS IS" BASIS,
+/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+/// See the License for the specific language governing permissions and
+/// limitations under the License.
+///
+
+export * from './mapping-table/mapping-table.component';
+export * from './device-info-table/device-info-table.component';
+export * from './security-config/security-config.component';
+export * from './server-config/server-config.component';
+export * from './mapping-data-keys-panel/mapping-data-keys-panel.component';
+export * from './type-value-panel/type-value-panel.component';
+export * from './broker-config-control/broker-config-control.component';
+export * from './workers-config-control/workers-config-control.component';
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel/mapping-data-keys-panel.component.html
similarity index 71%
rename from ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel.component.html
rename to ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel/mapping-data-keys-panel.component.html
index 4c3a6434fd..8b95c0bd3a 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-data-keys-panel/mapping-data-keys-panel.component.html
@@ -26,14 +26,15 @@
- {{ keyControl.get('key').value }}
- {{ '-' }}
- {{ valueTitle(keyControl.get('value').value) }}
+
+ {{ keyControl.get('key').value }}{{ '-' }}
+
+ {{ valueTitle(keyControl) }}
-
+