Browse Source

UI: Refactoring gateway connectors configuration

pull/11101/head
Vladyslav_Prykhodko 2 years ago
parent
commit
5813ce515d
  1. 120
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.html
  2. 16
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts
  3. 80
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/general-config/general-config.component.html
  4. 52
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/general-config/general-config.component.ts
  5. 48
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts
  6. 25
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt-basic-config/mqtt-basic-config.component.ts
  7. 15
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/opc-ua-basic-config/opc-ua-basic-config.component.ts
  8. 1
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/public-api.ts
  9. 9
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/security-config/security-config.component.ts
  10. 4
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.html
  11. 18
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.ts
  12. 5
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/workers-config-control/workers-config-control.component.ts
  13. 86
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.html
  14. 53
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts
  15. 83
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-widget.models.ts
  16. 2
      ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts

120
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.html

@ -15,72 +15,72 @@
limitations under the License. limitations under the License.
--> -->
<div class="tb-form-panel no-border no-padding padding-top" [formGroup]="brokerConfigFormGroup"> <div class="tb-form-panel no-border no-padding padding-top" [formGroup]="brokerConfigFormGroup">
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center"> <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width tb-required" translate>gateway.host</div> <div class="fixed-title-width tb-required" translate>gateway.host</div>
<div class="tb-flex no-gap"> <div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic"> <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput name="value" formControlName="host" placeholder="{{ 'gateway.set' | translate }}"/> <input matInput name="value" formControlName="host" placeholder="{{ 'gateway.set' | translate }}"/>
<mat-icon matSuffix <mat-icon matSuffix
matTooltipPosition="above" matTooltipPosition="above"
matTooltipClass="tb-error-tooltip" matTooltipClass="tb-error-tooltip"
[matTooltip]="('gateway.host-required') | translate" [matTooltip]="('gateway.host-required') | translate"
*ngIf="brokerConfigFormGroup.get('host').hasError('required') *ngIf="brokerConfigFormGroup.get('host').hasError('required')
&& brokerConfigFormGroup.get('host').touched" && brokerConfigFormGroup.get('host').touched"
class="tb-error"> class="tb-error">
warning warning
</mat-icon> </mat-icon>
</mat-form-field> </mat-form-field>
</div>
</div> </div>
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center"> </div>
<div class="fixed-title-width tb-required" translate>gateway.port</div> <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="tb-flex no-gap"> <div class="fixed-title-width tb-required" translate>gateway.port</div>
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic"> <div class="tb-flex no-gap">
<input matInput type="number" min="{{portLimits.MIN}}" max="{{portLimits.MAX}}" <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
name="value" formControlName="port" placeholder="{{ 'gateway.set' | translate }}"/> <input matInput type="number" min="{{portLimits.MIN}}" max="{{portLimits.MAX}}"
<mat-icon matSuffix name="value" formControlName="port" placeholder="{{ 'gateway.set' | translate }}"/>
matTooltipPosition="above" <mat-icon matSuffix
matTooltipClass="tb-error-tooltip" matTooltipPosition="above"
[matTooltip]="portErrorTooltip" matTooltipClass="tb-error-tooltip"
*ngIf="(brokerConfigFormGroup.get('port').hasError('required') || [matTooltip]="portErrorTooltip"
*ngIf="(brokerConfigFormGroup.get('port').hasError('required') ||
brokerConfigFormGroup.get('port').hasError('min') || brokerConfigFormGroup.get('port').hasError('min') ||
brokerConfigFormGroup.get('port').hasError('max')) && brokerConfigFormGroup.get('port').hasError('max')) &&
brokerConfigFormGroup.get('port').touched" brokerConfigFormGroup.get('port').touched"
class="tb-error"> class="tb-error">
warning warning
</mat-icon> </mat-icon>
</mat-form-field> </mat-form-field>
</div>
</div> </div>
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center"> </div>
<div class="fixed-title-width" translate>gateway.mqtt-version</div> <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="tb-flex no-gap"> <div class="fixed-title-width" translate>gateway.mqtt-version</div>
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic"> <div class="tb-flex no-gap">
<mat-select formControlName="version"> <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<mat-option *ngFor="let version of mqttVersions" [value]="version.value">{{ version.name }}</mat-option> <mat-select formControlName="version">
</mat-select> <mat-option *ngFor="let version of mqttVersions" [value]="version.value">{{ version.name }}</mat-option>
</mat-form-field> </mat-select>
</div> </mat-form-field>
</div> </div>
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center"> </div>
<div class="fixed-title-width" translate>gateway.client-id</div> <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="tb-flex no-gap"> <div class="fixed-title-width" translate>gateway.client-id</div>
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic"> <div class="tb-flex no-gap">
<input matInput name="value" formControlName="clientId" placeholder="{{ 'gateway.set' | translate }}"/> <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<button type="button" <input matInput name="value" formControlName="clientId" placeholder="{{ 'gateway.set' | translate }}"/>
matSuffix <button type="button"
mat-icon-button matSuffix
aria-label="Generate" mat-icon-button
matTooltip="{{ 'gateway.generate-client-id' | translate }}" aria-label="Generate"
matTooltipPosition="above" matTooltip="{{ 'gateway.generate-client-id' | translate }}"
(click)="generate('clientId')" matTooltipPosition="above"
*ngIf="!brokerConfigFormGroup.get('clientId').value"> (click)="generate('clientId')"
<mat-icon>autorenew</mat-icon> *ngIf="!brokerConfigFormGroup.get('clientId').value">
</button> <mat-icon>autorenew</mat-icon>
</mat-form-field> </button>
</div> </mat-form-field>
</div> </div>
<tb-security-config formControlName="security">
</tb-security-config>
</div> </div>
<tb-security-config formControlName="security">
</tb-security-config>
</div>

16
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts

@ -14,13 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
ChangeDetectionStrategy,
Component,
forwardRef,
inject,
OnDestroy,
} from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
FormBuilder, FormBuilder,
@ -72,13 +66,13 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
mqttVersions = MqttVersions; mqttVersions = MqttVersions;
portLimits = PortLimits; portLimits = PortLimits;
onChange!: (value: string) => void; private onChange: (value: string) => void;
onTouched!: () => void; private onTouched: () => void;
private translate = inject(TranslateService);
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
constructor(private fb: FormBuilder) { constructor(private fb: FormBuilder,
private translate: TranslateService) {
this.brokerConfigFormGroup = this.fb.group({ this.brokerConfigFormGroup = this.fb.group({
name: ['', []], name: ['', []],
host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]],

80
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/general-config/general-config.component.html

@ -1,80 +0,0 @@
<!--
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.
-->
<div class="tb-form-panel no-border no-padding padding-top" [formGroup]="parentFormGroup">
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width tb-required" translate>gateway.name</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput autocomplete="off" name="value" formControlName="name" placeholder="{{ 'gateway.set' | translate }}"/>
<mat-icon matSuffix
matTooltipPosition="above"
matTooltipClass="tb-error-tooltip"
[matTooltip]="(parentFormGroup.get('name').hasError('duplicateName') ?
'gateway.connector-duplicate-name' : 'gateway.name-required') | translate"
*ngIf="(parentFormGroup.get('name').hasError('required') && parentFormGroup.get('name').touched) ||
parentFormGroup.get('name').hasError('duplicateName')"
class="tb-error">
warning
</mat-icon>
</mat-form-field>
</div>
</div>
<div *ngIf="parentFormGroup.get('type').value === connectorType.CUSTOM" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.connectors-table-class</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput name="value" formControlName="class" placeholder="{{ 'gateway.set' | translate }}"/>
</mat-form-field>
</div>
</div>
<div *ngIf="parentFormGroup.get('type').value === connectorType.GRPC" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.connectors-table-key</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput name="value" formControlName="key" placeholder="{{ 'gateway.set' | translate }}"/>
</mat-form-field>
</div>
</div>
<div class="tb-form-panel stroked">
<div class="tb-form-panel-title" translate>gateway.logs-configuration</div>
<div class="tb-form-row" fxLayoutAlign="space-between center">
<mat-slide-toggle class="mat-slide" formControlName="enableRemoteLogging">
<mat-label>
{{ 'gateway.enable-remote-logging' | translate }}
</mat-label>
</mat-slide-toggle>
</div>
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.remote-logging-level</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="logLevel">
<mat-option *ngFor="let logLevel of gatewayLogLevel" [value]="logLevel">{{ logLevel }}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div *ngIf="parentFormGroup.get('type').value === connectorType.MQTT" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<mat-slide-toggle class="mat-slide" formControlName="sendDataOnlyOnChange">
<mat-label tb-hint-tooltip-icon="{{ 'gateway.send-change-data-hint' | translate }}">
{{ 'gateway.send-change-data' | translate }}
</mat-label>
</mat-slide-toggle>
</div>
</div>

52
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/general-config/general-config.component.ts

@ -1,52 +0,0 @@
///
/// 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,
inject,
} from '@angular/core';
import {
ControlContainer,
FormGroup,
} from '@angular/forms';
import {
ConnectorType,
GatewayLogLevel,
} from '@home/components/widget/lib/gateway/gateway-widget.models';
import { SharedModule } from '@shared/shared.module';
import { CommonModule } from '@angular/common';
@Component({
selector: 'tb-general-config',
templateUrl: './general-config.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
CommonModule,
SharedModule,
],
})
export class GeneralConfigComponent {
gatewayLogLevel = Object.values(GatewayLogLevel);
connectorType = ConnectorType;
get parentFormGroup(): FormGroup {
return this.parentContainer.control as FormGroup;
}
private parentContainer = inject(ControlContainer);
}

48
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts

@ -25,7 +25,6 @@ import {
OnInit, OnInit,
ViewChild, ViewChild,
} from '@angular/core'; } from '@angular/core';
import { PageLink } from '@shared/models/page/page-link';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { DialogService } from '@core/services/dialog.service'; import { DialogService } from '@core/services/dialog.service';
@ -33,7 +32,6 @@ import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, take, takeUntil } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged, map, take, takeUntil } from 'rxjs/operators';
import { import {
ControlValueAccessor, ControlValueAccessor,
FormArray,
FormBuilder, FormBuilder,
NG_VALIDATORS, NG_VALIDATORS,
NG_VALUE_ACCESSOR, NG_VALUE_ACCESSOR,
@ -54,7 +52,7 @@ import {
RequestType, RequestType,
RequestTypesTranslationsMap RequestTypesTranslationsMap
} from '@home/components/widget/lib/gateway/gateway-widget.models'; } from '@home/components/widget/lib/gateway/gateway-widget.models';
import { CollectionViewer, DataSource } from '@angular/cdk/collections'; import { DataSource } from '@angular/cdk/collections';
import { MappingDialogComponent } from '@home/components/widget/lib/gateway/dialog/mapping-dialog.component'; import { MappingDialogComponent } from '@home/components/widget/lib/gateway/dialog/mapping-dialog.component';
import { isDefinedAndNotNull, isUndefinedOrNull } from '@core/utils'; import { isDefinedAndNotNull, isUndefinedOrNull } from '@core/utils';
import { coerceBoolean } from '@shared/decorators/coercion'; import { coerceBoolean } from '@shared/decorators/coercion';
@ -82,8 +80,10 @@ import { CommonModule } from '@angular/common';
imports: [CommonModule, SharedModule] imports: [CommonModule, SharedModule]
}) })
export class MappingTableComponent implements ControlValueAccessor, Validator, AfterViewInit, OnInit, OnDestroy { export class MappingTableComponent implements ControlValueAccessor, Validator, AfterViewInit, OnInit, OnDestroy {
@Input()
@coerceBoolean() @coerceBoolean()
@Input() required = false; required = false;
@Input() @Input()
set mappingType(value: MappingType) { set mappingType(value: MappingType) {
@ -92,6 +92,10 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
} }
} }
get mappingType(): MappingType {
return this.mappingTypeValue;
}
@ViewChild('searchInput') searchInputField: ElementRef; @ViewChild('searchInput') searchInputField: ElementRef;
mappingTypeTranslationsMap = MappingTypeTranslationsMap; mappingTypeTranslationsMap = MappingTypeTranslationsMap;
@ -107,12 +111,8 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
mappingFormGroup: UntypedFormArray; mappingFormGroup: UntypedFormArray;
textSearch = this.fb.control('', {nonNullable: true}); textSearch = this.fb.control('', {nonNullable: true});
get mappingType(): MappingType { private onChange: (value: string) => void = () => {};
return this.mappingTypeValue; private onTouched: () => void = () => {};
}
onChange: (value: string) => void = () => {};
onTouched: () => void = () => {};
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
@ -149,7 +149,7 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe((text) => { ).subscribe((text) => {
const searchText = text.trim(); const searchText = text.trim();
this.updateTableData(this.mappingFormGroup.value, searchText.trim()) this.updateTableData(this.mappingFormGroup.value, searchText.trim());
}); });
} }
@ -162,8 +162,8 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
} }
writeValue(connectorMappings: ConnectorMapping[]): void { writeValue(connectorMappings: ConnectorMapping[]): void {
(this.mappingFormGroup as FormArray).clear(); this.mappingFormGroup.clear();
this.pushDataAsFormArrays(connectorMappings) this.pushDataAsFormArrays(connectorMappings);
} }
validate(): ValidationErrors | null { validate(): ValidationErrors | null {
@ -213,12 +213,11 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
}); });
} }
updateTableData(value: ConnectorMapping[], textSearch?: string): void { private updateTableData(value: ConnectorMapping[], textSearch?: string): void {
let tableValue = let tableValue = value.map(mappingValue => this.getMappingValue(mappingValue));
value.map((value: ConnectorMapping) => this.getMappingValue(value));
if (textSearch) { if (textSearch) {
tableValue = tableValue.filter(value => tableValue = tableValue.filter(mappingValue =>
Object.values(value).some(val => Object.values(mappingValue).some(val =>
val.toString().toLowerCase().includes(textSearch.toLowerCase()) val.toString().toLowerCase().includes(textSearch.toLowerCase())
) )
); );
@ -259,7 +258,7 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
converter: this.translate.instant(ConvertorTypeTranslationsMap.get((value as ConverterConnectorMapping).converter?.type) || '') converter: this.translate.instant(ConvertorTypeTranslationsMap.get((value as ConverterConnectorMapping).converter?.type) || '')
}; };
case MappingType.REQUESTS: case MappingType.REQUESTS:
let details; let details: string;
if ((value as RequestMappingData).requestType === RequestType.ATTRIBUTE_UPDATE) { if ((value as RequestMappingData).requestType === RequestType.ATTRIBUTE_UPDATE) {
details = (value as RequestMappingData).requestValue.attributeFilter; details = (value as RequestMappingData).requestValue.attributeFilter;
} else if ((value as RequestMappingData).requestType === RequestType.SERVER_SIDE_RPC) { } else if ((value as RequestMappingData).requestType === RequestType.SERVER_SIDE_RPC) {
@ -315,22 +314,17 @@ export class MappingDatasource implements DataSource<{[key: string]: any}> {
private mappingSubject = new BehaviorSubject<Array<{[key: string]: any}>>([]); private mappingSubject = new BehaviorSubject<Array<{[key: string]: any}>>([]);
private allMappings: Observable<Array<{[key: string]: any}>>;
constructor() {} constructor() {}
connect(collectionViewer: CollectionViewer): Observable<Array<{[key: string]: any}>> { connect(): Observable<Array<{[key: string]: any}>> {
return this.mappingSubject.asObservable(); return this.mappingSubject.asObservable();
} }
disconnect(collectionViewer: CollectionViewer): void { disconnect(): void {
this.mappingSubject.complete(); this.mappingSubject.complete();
} }
loadMappings(mappings: Array<{[key: string]: any}>, pageLink?: PageLink, reload: boolean = false): void { loadMappings(mappings: Array<{[key: string]: any}>): void {
if (reload) {
this.allMappings = null;
}
this.mappingSubject.next(mappings); this.mappingSubject.next(mappings);
} }

25
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt-basic-config/mqtt-basic-config.component.ts

@ -14,14 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { import { ChangeDetectionStrategy, Component, forwardRef, Input, OnDestroy, TemplateRef } from '@angular/core';
ChangeDetectionStrategy,
Component,
forwardRef,
Input,
OnDestroy,
TemplateRef,
} from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
FormBuilder, FormBuilder,
@ -33,7 +26,6 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { import {
ConnectorBaseConfig, ConnectorBaseConfig,
ConnectorType,
MappingType, MappingType,
RequestMappingData, RequestMappingData,
RequestType, RequestType,
@ -44,8 +36,7 @@ import {
BrokerConfigControlComponent, BrokerConfigControlComponent,
MappingTableComponent, MappingTableComponent,
SecurityConfigComponent, SecurityConfigComponent,
WorkersConfigControlComponent, WorkersConfigControlComponent
GeneralConfigComponent
} from '@home/components/widget/lib/gateway/connectors-configuration/public-api'; } from '@home/components/widget/lib/gateway/connectors-configuration/public-api';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@ -75,7 +66,6 @@ import { isObject } from 'lodash';
WorkersConfigControlComponent, WorkersConfigControlComponent,
BrokerConfigControlComponent, BrokerConfigControlComponent,
MappingTableComponent, MappingTableComponent,
GeneralConfigComponent,
], ],
styles: [` styles: [`
:host { :host {
@ -90,15 +80,16 @@ import { isObject } from 'lodash';
}) })
export class MqttBasicConfigComponent implements ControlValueAccessor, Validator, OnDestroy { export class MqttBasicConfigComponent implements ControlValueAccessor, Validator, OnDestroy {
@Input() generalTabContent: TemplateRef<GeneralConfigComponent>;
@Input()
generalTabContent: TemplateRef<any>;
mappingTypes = MappingType; mappingTypes = MappingType;
basicFormGroup: FormGroup; basicFormGroup: FormGroup;
onChange!: (value: string) => void; private onChange: (value: string) => void;
onTouched!: () => void; private onTouched: () => void;
protected readonly connectorType = ConnectorType;
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
constructor(private fb: FormBuilder) { constructor(private fb: FormBuilder) {
@ -157,7 +148,7 @@ export class MqttBasicConfigComponent implements ControlValueAccessor, Validator
if (isObject(value)) { if (isObject(value)) {
Object.keys(value).forEach((configKey: string) => { Object.keys(value).forEach((configKey: string) => {
for (let mapping of value[configKey]) { for (const mapping of value[configKey]) {
mappingConfigs.push({ mappingConfigs.push({
requestType: configKey, requestType: configKey,
requestValue: mapping requestValue: mapping

15
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/opc-ua-basic-config/opc-ua-basic-config.component.ts

@ -14,14 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { import { ChangeDetectionStrategy, Component, forwardRef, Input, OnDestroy, TemplateRef } from '@angular/core';
ChangeDetectionStrategy,
Component,
forwardRef,
Input,
OnDestroy,
TemplateRef,
} from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
FormBuilder, FormBuilder,
@ -43,8 +36,7 @@ import {
MappingTableComponent, MappingTableComponent,
SecurityConfigComponent, SecurityConfigComponent,
ServerConfigComponent, ServerConfigComponent,
WorkersConfigControlComponent, WorkersConfigControlComponent
GeneralConfigComponent
} from '@home/components/widget/lib/gateway/connectors-configuration/public-api'; } from '@home/components/widget/lib/gateway/connectors-configuration/public-api';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@ -73,7 +65,6 @@ import { Subject } from 'rxjs';
WorkersConfigControlComponent, WorkersConfigControlComponent,
BrokerConfigControlComponent, BrokerConfigControlComponent,
MappingTableComponent, MappingTableComponent,
GeneralConfigComponent,
ServerConfigComponent, ServerConfigComponent,
], ],
styles: [` styles: [`
@ -89,7 +80,7 @@ import { Subject } from 'rxjs';
}) })
export class OpcUaBasicConfigComponent implements ControlValueAccessor, Validator, OnDestroy { export class OpcUaBasicConfigComponent implements ControlValueAccessor, Validator, OnDestroy {
@Input() generalTabContent: TemplateRef<GeneralConfigComponent>; @Input() generalTabContent: TemplateRef<any>;
mappingTypes = MappingType; mappingTypes = MappingType;
basicFormGroup: FormGroup; basicFormGroup: FormGroup;

1
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/public-api.ts

@ -24,4 +24,3 @@ export * from './broker-config-control/broker-config-control.component';
export * from './workers-config-control/workers-config-control.component'; export * from './workers-config-control/workers-config-control.component';
export * from './opc-ua-basic-config/opc-ua-basic-config.component'; export * from './opc-ua-basic-config/opc-ua-basic-config.component';
export * from './mqtt-basic-config/mqtt-basic-config.component'; export * from './mqtt-basic-config/mqtt-basic-config.component';
export * from './general-config/general-config.component';

9
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/security-config/security-config.component.ts

@ -68,21 +68,22 @@ import { CommonModule } from '@angular/common';
] ]
}) })
export class SecurityConfigComponent implements ControlValueAccessor, OnInit, OnDestroy { export class SecurityConfigComponent implements ControlValueAccessor, OnInit, OnDestroy {
@Input() @Input()
title: string = 'gateway.security'; title = 'gateway.security';
@Input() @Input()
@coerceBoolean() @coerceBoolean()
extendCertificatesModel = false; extendCertificatesModel = false;
BrokerSecurityType = SecurityType; BrokerSecurityType = SecurityType;
securityTypes = Object.values(SecurityType); securityTypes = Object.values(SecurityType) as SecurityType[];
modeTypes = Object.values(ModeType); modeTypes = Object.values(ModeType);
SecurityTypeTranslationsMap = SecurityTypeTranslationsMap; SecurityTypeTranslationsMap = SecurityTypeTranslationsMap;
securityFormGroup: UntypedFormGroup; securityFormGroup: UntypedFormGroup;
onChange!: (value: string) => void; private onChange: (value: string) => void;
onTouched!: () => void; private onTouched: () => void;
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();

4
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.html

@ -58,7 +58,7 @@
<div class="tb-flex no-gap"> <div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic"> <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="security"> <mat-select formControlName="security">
<mat-option *ngFor="let version of serverSecurityTypes" [value]="version.value">{{ version.name }}</mat-option> <mat-option *ngFor="let version of securityPolicyTypes" [value]="version.value">{{ version.name }}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
@ -119,7 +119,7 @@
</mat-label> </mat-label>
</mat-slide-toggle> </mat-slide-toggle>
</div> </div>
<tb-security-config [formControl]="serverConfigFormGroup.get('identity')" <tb-security-config formControlName="identity"
[extendCertificatesModel]="true"> [extendCertificatesModel]="true">
</tb-security-config> </tb-security-config>
</div> </div>

18
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.ts

@ -14,12 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
ChangeDetectionStrategy,
Component,
forwardRef,
OnDestroy
} from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
FormBuilder, FormBuilder,
@ -32,9 +27,9 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { import {
noLeadTrailSpacesRegex, noLeadTrailSpacesRegex,
SecurityType, SecurityPolicy,
ServerConfig, SecurityPolicyTypes,
ServerSecurityTypes ServerConfig
} from '@home/components/widget/lib/gateway/gateway-widget.models'; } from '@home/components/widget/lib/gateway/gateway-widget.models';
import { SharedModule } from '@shared/shared.module'; import { SharedModule } from '@shared/shared.module';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
@ -67,7 +62,8 @@ import { takeUntil } from 'rxjs/operators';
] ]
}) })
export class ServerConfigComponent implements ControlValueAccessor, Validator, OnDestroy { export class ServerConfigComponent implements ControlValueAccessor, Validator, OnDestroy {
serverSecurityTypes = ServerSecurityTypes;
securityPolicyTypes = SecurityPolicyTypes;
serverConfigFormGroup: UntypedFormGroup; serverConfigFormGroup: UntypedFormGroup;
onChange!: (value: string) => void; onChange!: (value: string) => void;
@ -84,7 +80,7 @@ export class ServerConfigComponent implements ControlValueAccessor, Validator, O
enableSubscriptions: [true, []], enableSubscriptions: [true, []],
subCheckPeriodInMillis: [10, [Validators.required, Validators.min(10)]], subCheckPeriodInMillis: [10, [Validators.required, Validators.min(10)]],
showMap: [false, []], showMap: [false, []],
security: [SecurityType.BASIC128, []], security: [SecurityPolicy.BASIC128, []],
identity: [{}, [Validators.required]] identity: [{}, [Validators.required]]
}); });

5
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/workers-config-control/workers-config-control.component.ts

@ -57,10 +57,11 @@ import { takeUntil } from 'rxjs/operators';
] ]
}) })
export class WorkersConfigControlComponent implements OnDestroy, ControlValueAccessor, Validator { export class WorkersConfigControlComponent implements OnDestroy, ControlValueAccessor, Validator {
workersConfigFormGroup: UntypedFormGroup; workersConfigFormGroup: UntypedFormGroup;
onChange!: (value: string) => void; private onChange: (value: string) => void;
onTouched!: () => void; private onTouched: () => void;
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();

86
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.html

@ -156,9 +156,7 @@
{{ initialConnector?.type ? gatewayConnectorDefaultTypes.get(initialConnector.type) : '' }} {{ initialConnector?.type ? gatewayConnectorDefaultTypes.get(initialConnector.type) : '' }}
{{ 'gateway.configuration' | translate }} {{ 'gateway.configuration' | translate }}
</div> </div>
<tb-toggle-select *ngIf="initialConnector && <tb-toggle-select *ngIf="initialConnector && allowBasicConfig.has(initialConnector.type)"
(initialConnector.type === connectorType.MQTT ||
initialConnector.type === connectorType.OPCUA)"
formControlName="mode" appearance="fill"> formControlName="mode" appearance="fill">
<tb-toggle-option [value]="connectorConfigurationModes.BASIC"> <tb-toggle-option [value]="connectorConfigurationModes.BASIC">
{{ 'gateway.basic' | translate }} {{ 'gateway.basic' | translate }}
@ -173,19 +171,18 @@
class="no-data-found" translate> class="no-data-found" translate>
gateway.select-connector gateway.select-connector
</span> </span>
<ng-template #generalTabContent>
<tb-general-config></tb-general-config>
</ng-template>
<section class="tb-form-panel section-container no-border no-padding tb-flex space-between" *ngIf="initialConnector"> <section class="tb-form-panel section-container no-border no-padding tb-flex space-between" *ngIf="initialConnector">
<ng-container *ngIf="connectorForm.get('mode')?.value === connectorConfigurationModes.BASIC else defaultConfig"> <ng-container *ngIf="connectorForm.get('mode')?.value === connectorConfigurationModes.BASIC else defaultConfig">
<tb-mqtt-basic-config *ngIf="(initialConnector.type === connectorType.MQTT)" <ng-container [ngSwitch]="initialConnector.type">
formControlName="basicConfig" <tb-mqtt-basic-config *ngSwitchCase="connectorType.MQTT"
[generalTabContent]="generalTabContent">
</tb-mqtt-basic-config>
<tb-opc-ua-basic-config *ngIf="(initialConnector.type === connectorType.OPCUA)"
formControlName="basicConfig" formControlName="basicConfig"
[generalTabContent]="generalTabContent"> [generalTabContent]="generalTabContent">
</tb-opc-ua-basic-config> </tb-mqtt-basic-config>
<tb-opc-ua-basic-config *ngSwitchCase="connectorType.OPCUA"
formControlName="basicConfig"
[generalTabContent]="generalTabContent">
</tb-opc-ua-basic-config>
</ng-container>
</ng-container> </ng-container>
<ng-template #defaultConfig> <ng-template #defaultConfig>
<mat-tab-group> <mat-tab-group>
@ -215,3 +212,68 @@
</section> </section>
</section> </section>
</div> </div>
<ng-template #generalTabContent>
<section [formGroup]="connectorForm" class="tb-form-panel no-border no-padding padding-top section-container flex">
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center" >
<div class="fixed-title-width tb-required" translate>gateway.name</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput autocomplete="off" name="value" formControlName="name" placeholder="{{ 'gateway.set' | translate }}"/>
<mat-icon matSuffix
matTooltipPosition="above"
matTooltipClass="tb-error-tooltip"
[matTooltip]="(connectorForm.get('name').hasError('duplicateName') ?
'gateway.connector-duplicate-name' : 'gateway.name-required') | translate"
*ngIf="(connectorForm.get('name').hasError('required') && connectorForm.get('name').touched) ||
connectorForm.get('name').hasError('duplicateName')"
class="tb-error">
warning
</mat-icon>
</mat-form-field>
</div>
</div>
<div *ngIf="connectorForm.get('type').value === connectorType.CUSTOM" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.connectors-table-class</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput name="value" formControlName="class" placeholder="{{ 'gateway.set' | translate }}"/>
</mat-form-field>
</div>
</div>
<div *ngIf="connectorForm.get('type').value === connectorType.GRPC" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.connectors-table-key</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<input matInput name="value" formControlName="key" placeholder="{{ 'gateway.set' | translate }}"/>
</mat-form-field>
</div>
</div>
<div class="tb-form-panel stroked">
<div class="tb-form-panel-title" translate>gateway.logs-configuration</div>
<div class="tb-form-row" fxLayoutAlign="space-between center">
<mat-slide-toggle class="mat-slide" formControlName="enableRemoteLogging">
<mat-label>
{{ 'gateway.enable-remote-logging' | translate }}
</mat-label>
</mat-slide-toggle>
</div>
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<div class="fixed-title-width" translate>gateway.remote-logging-level</div>
<div class="tb-flex no-gap">
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="logLevel">
<mat-option *ngFor="let logLevel of gatewayLogLevel" [value]="logLevel">{{ logLevel }}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div *ngIf="connectorForm.get('type').value === connectorType.MQTT" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
<mat-slide-toggle class="mat-slide" formControlName="sendDataOnlyOnChange">
<mat-label tb-hint-tooltip-icon="{{ 'gateway.send-change-data-hint' | translate }}">
{{ 'gateway.send-change-data' | translate }}
</mat-label>
</mat-slide-toggle>
</div>
</section>
</ng-template>

53
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

@ -21,20 +21,12 @@ import {
ElementRef, ElementRef,
Input, Input,
NgZone, NgZone,
ViewChild, OnDestroy,
ViewChild
} from '@angular/core'; } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { import { FormBuilder, FormControl, FormGroup, UntypedFormControl, ValidatorFn, Validators } from '@angular/forms';
FormBuilder,
FormControl,
FormGroup,
FormGroupDirective,
NgForm,
UntypedFormControl,
ValidatorFn,
Validators
} from '@angular/forms';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';
import { AttributeService } from '@core/http/attribute.service'; import { AttributeService } from '@core/http/attribute.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -72,7 +64,7 @@ import { ErrorStateMatcher } from '@angular/material/core';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
export class ForceErrorStateMatcher implements ErrorStateMatcher { export class ForceErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { isErrorState(control: FormControl | null): boolean {
return (control && control.invalid); return (control && control.invalid);
} }
} }
@ -83,7 +75,7 @@ export class ForceErrorStateMatcher implements ErrorStateMatcher {
providers: [{ provide: ErrorStateMatcher, useClass: ForceErrorStateMatcher }], providers: [{ provide: ErrorStateMatcher, useClass: ForceErrorStateMatcher }],
styleUrls: ['./gateway-connectors.component.scss'] styleUrls: ['./gateway-connectors.component.scss']
}) })
export class GatewayConnectorComponent extends PageComponent implements AfterViewInit { export class GatewayConnectorComponent extends PageComponent implements AfterViewInit, OnDestroy {
@Input() @Input()
ctx: WidgetContext; ctx: WidgetContext;
@ -98,6 +90,13 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
connectorType = ConnectorType; connectorType = ConnectorType;
allowBasicConfig = new Set<ConnectorType>([
ConnectorType.MQTT,
ConnectorType.OPCUA
]);
gatewayLogLevel = Object.values(GatewayLogLevel);
dataSource: MatTableDataSource<AttributeData>; dataSource: MatTableDataSource<AttributeData>;
displayedColumns = ['enabled', 'key', 'type', 'syncStatus', 'errors', 'actions']; displayedColumns = ['enabled', 'key', 'type', 'syncStatus', 'errors', 'actions'];
@ -137,7 +136,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
onDataUpdated: () => this.ctx.ngZone.run(() => { onDataUpdated: () => this.ctx.ngZone.run(() => {
this.onDataUpdated(); this.onDataUpdated();
}), }),
onDataUpdateError: (subscription, e) => this.ctx.ngZone.run(() => { onDataUpdateError: (_, e) => this.ctx.ngZone.run(() => {
this.onDataUpdateError(e); this.onDataUpdateError(e);
}) })
} }
@ -196,7 +195,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
defaultConfig[0].value); defaultConfig[0].value);
this.cd.detectChanges(); this.cd.detectChanges();
} }
}) });
} }
}); });
@ -214,11 +213,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
const basicConfig = this.connectorForm.get('basicConfig'); const basicConfig = this.connectorForm.get('basicConfig');
const type = this.connectorForm.get('type').value; const type = this.connectorForm.get('type').value;
const mode = this.connectorForm.get('mode').value; const mode = this.connectorForm.get('mode').value;
if ( if (!isEqual(config, basicConfig?.value) && this.allowBasicConfig.has(type) && mode === ConnectorConfigurationModes.ADVANCED) {
!isEqual(config, basicConfig?.value) &&
(type === ConnectorType.MQTT || type === ConnectorType.OPCUA) &&
mode === ConnectorConfigurationModes.ADVANCED
) {
this.connectorForm.get('basicConfig').patchValue(config, {emitEvent: false}); this.connectorForm.get('basicConfig').patchValue(config, {emitEvent: false});
} }
}); });
@ -350,7 +345,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
...value.configurationJson.workers, ...value.configurationJson.workers,
} }
} }
} };
} }
private updateData(reload: boolean = false): void { private updateData(reload: boolean = false): void {
@ -607,11 +602,15 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
const wasEnabled = this.activeConnectors.includes(key); const wasEnabled = this.activeConnectors.includes(key);
if (wasEnabled) { if (wasEnabled) {
const index = this.activeConnectors.indexOf(key); const index = this.activeConnectors.indexOf(key);
if (index !== -1) this.activeConnectors.splice(index, 1); if (index !== -1) {
this.activeConnectors.splice(index, 1);
}
this.inactiveConnectors.push(key); this.inactiveConnectors.push(key);
} else { } else {
const index = this.inactiveConnectors.indexOf(key); const index = this.inactiveConnectors.indexOf(key);
if (index !== -1) this.inactiveConnectors.splice(index, 1); if (index !== -1) {
this.inactiveConnectors.splice(index, 1);
}
this.activeConnectors.push(key); this.activeConnectors.push(key);
} }
} }
@ -689,12 +688,8 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
const configJson = this.connectorForm.get('configurationJson'); const configJson = this.connectorForm.get('configurationJson');
const type = this.connectorForm.get('type').value; const type = this.connectorForm.get('type').value;
const mode = this.connectorForm.get('mode').value; const mode = this.connectorForm.get('mode').value;
if ( if (!isEqual(config, configJson?.value) && this.allowBasicConfig.has(type) && mode === ConnectorConfigurationModes.BASIC) {
!isEqual(config, configJson?.value) && const newConfig = {...configJson.value, ...config};
(type === ConnectorType.MQTT || type === ConnectorType.OPCUA) &&
mode === ConnectorConfigurationModes.BASIC
) {
const newConfig = { ...configJson.value, ...config };
this.connectorForm.get('configurationJson').patchValue(newConfig, {emitEvent: false}); this.connectorForm.get('configurationJson').patchValue(newConfig, {emitEvent: false});
} }
}); });

83
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-widget.models.ts

@ -18,7 +18,7 @@ import { ResourcesService } from '@core/services/resources.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ValueTypeData } from '@shared/models/constants'; import { ValueTypeData } from '@shared/models/constants';
export const noLeadTrailSpacesRegex: RegExp = /^(?! )[\S\s]*(?<! )$/; export const noLeadTrailSpacesRegex = /^(?! )[\S\s]*(?<! )$/;
export enum StorageTypes { export enum StorageTypes {
MEMORY = 'memory', MEMORY = 'memory',
@ -288,15 +288,16 @@ export const GatewayConnectorDefaultTypesTranslatesMap = new Map<ConnectorType,
]); ]);
export interface RPCCommand { export interface RPCCommand {
command: string, command: string;
params: any, params: any;
time: number time: number;
} }
export enum ModbusCommandTypes { export enum ModbusCommandTypes {
Bits = 'bits', Bits = 'bits',
Bit = 'bit', Bit = 'bit',
// eslint-disable-next-line id-blacklist
String = 'string', String = 'string',
Bytes = 'bytes', Bytes = 'bytes',
Int8 = '8int', Int8 = '8int',
@ -321,7 +322,7 @@ export const ModbusCodesTranslate = new Map<number, string>([
[6, 'gateway.rpc.write-single-holding-register'], [6, 'gateway.rpc.write-single-holding-register'],
[15, 'gateway.rpc.write-multiple-coils'], [15, 'gateway.rpc.write-multiple-coils'],
[16, 'gateway.rpc.write-multiple-holding-registers'] [16, 'gateway.rpc.write-multiple-holding-registers']
]) ]);
export enum BACnetRequestTypes { export enum BACnetRequestTypes {
WriteProperty = 'writeProperty', WriteProperty = 'writeProperty',
@ -330,8 +331,8 @@ export enum BACnetRequestTypes {
export const BACnetRequestTypesTranslates = new Map<BACnetRequestTypes, string>([ export const BACnetRequestTypesTranslates = new Map<BACnetRequestTypes, string>([
[BACnetRequestTypes.WriteProperty, 'gateway.rpc.write-property'], [BACnetRequestTypes.WriteProperty, 'gateway.rpc.write-property'],
[BACnetRequestTypes.ReadProperty, "gateway.rpc.read-property"] [BACnetRequestTypes.ReadProperty, 'gateway.rpc.read-property']
]) ]);
export enum BACnetObjectTypes { export enum BACnetObjectTypes {
BinaryInput = 'binaryInput', BinaryInput = 'binaryInput',
@ -349,7 +350,7 @@ export const BACnetObjectTypesTranslates = new Map<BACnetObjectTypes, string>([
[BACnetObjectTypes.BinaryInput, 'gateway.rpc.binary-input'], [BACnetObjectTypes.BinaryInput, 'gateway.rpc.binary-input'],
[BACnetObjectTypes.BinaryValue, 'gateway.rpc.binary-value'], [BACnetObjectTypes.BinaryValue, 'gateway.rpc.binary-value'],
[BACnetObjectTypes.AnalogValue, 'gateway.rpc.analog-value'] [BACnetObjectTypes.AnalogValue, 'gateway.rpc.analog-value']
]) ]);
export enum BLEMethods { export enum BLEMethods {
WRITE = 'write', WRITE = 'write',
@ -361,7 +362,7 @@ export const BLEMethodsTranslates = new Map<BLEMethods, string>([
[BLEMethods.WRITE, 'gateway.rpc.write'], [BLEMethods.WRITE, 'gateway.rpc.write'],
[BLEMethods.READ, 'gateway.rpc.read'], [BLEMethods.READ, 'gateway.rpc.read'],
[BLEMethods.SCAN, 'gateway.rpc.scan'], [BLEMethods.SCAN, 'gateway.rpc.scan'],
]) ]);
export enum CANByteOrders { export enum CANByteOrders {
LITTLE = 'LITTLE', LITTLE = 'LITTLE',
@ -374,18 +375,18 @@ export enum SocketMethodProcessings {
export const SocketMethodProcessingsTranslates = new Map<SocketMethodProcessings, string>([ export const SocketMethodProcessingsTranslates = new Map<SocketMethodProcessings, string>([
[SocketMethodProcessings.WRITE, 'gateway.rpc.write'] [SocketMethodProcessings.WRITE, 'gateway.rpc.write']
]) ]);
export enum SNMPMethods { export enum SNMPMethods {
SET = 'set', SET = 'set',
MULTISET = "multiset", MULTISET = 'multiset',
GET = "get", GET = 'get',
BULKWALK = "bulkwalk", BULKWALK = 'bulkwalk',
TABLE = "table", TABLE = 'table',
MULTIGET = "multiget", MULTIGET = 'multiget',
GETNEXT = "getnext", GETNEXT = 'getnext',
BULKGET = "bulkget", BULKGET = 'bulkget',
WALKS = "walk" WALKS = 'walk'
} }
export const SNMPMethodsTranslations = new Map<SNMPMethods, string>([ export const SNMPMethodsTranslations = new Map<SNMPMethods, string>([
@ -398,7 +399,7 @@ export const SNMPMethodsTranslations = new Map<SNMPMethods, string>([
[SNMPMethods.GETNEXT, 'gateway.rpc.get-next'], [SNMPMethods.GETNEXT, 'gateway.rpc.get-next'],
[SNMPMethods.BULKGET, 'gateway.rpc.bulk-get'], [SNMPMethods.BULKGET, 'gateway.rpc.bulk-get'],
[SNMPMethods.WALKS, 'gateway.rpc.walk'] [SNMPMethods.WALKS, 'gateway.rpc.walk']
]) ]);
export enum HTTPMethods { export enum HTTPMethods {
CONNECT = 'CONNECT', CONNECT = 'CONNECT',
@ -427,8 +428,8 @@ export interface RPCTemplateConfig {
} }
export interface SaveRPCTemplateData { export interface SaveRPCTemplateData {
config: RPCTemplateConfig, config: RPCTemplateConfig;
templates: Array<RPCTemplate> templates: Array<RPCTemplate>;
} }
export interface LogLink { export interface LogLink {
@ -445,33 +446,33 @@ export interface GatewayLogData {
} }
export interface AddConnectorConfigData { export interface AddConnectorConfigData {
dataSourceData: Array<any> dataSourceData: Array<any>;
} }
export interface CreatedConnectorConfigData { export interface CreatedConnectorConfigData {
type: ConnectorType, type: ConnectorType;
name: string, name: string;
logLevel: GatewayLogLevel, logLevel: GatewayLogLevel;
useDefaults: boolean, useDefaults: boolean;
sendDataOnlyOnChange: boolean, sendDataOnlyOnChange: boolean;
configurationJson?: {[key: string]: any} configurationJson?: {[key: string]: any};
} }
export interface MappingDataKey { export interface MappingDataKey {
key: string, key: string;
value: any, value: any;
type: MappingValueType type: MappingValueType;
} }
export interface RpcMethodsMapping { export interface RpcMethodsMapping {
method: string, method: string;
arguments: Array<MappingDataKey> arguments: Array<MappingDataKey>;
} }
export interface MappingInfo { export interface MappingInfo {
mappingType: MappingType, mappingType: MappingType;
value: {[key: string]: any}, value: {[key: string]: any};
buttonTitle: string buttonTitle: string;
} }
export enum ConnectorConfigurationModes { export enum ConnectorConfigurationModes {
@ -727,14 +728,14 @@ export const DataConversionTranslationsMap = new Map<ConvertorType, string>(
] ]
); );
export enum SecurityType { export enum SecurityPolicy {
BASIC128 = 'Basic128Rsa15', BASIC128 = 'Basic128Rsa15',
BASIC256 = 'Basic256', BASIC256 = 'Basic256',
BASIC256SHA = 'Basic256Sha256' BASIC256SHA = 'Basic256Sha256'
} }
export const ServerSecurityTypes = [ export const SecurityPolicyTypes = [
{ value: 'Basic128Rsa15', name: 'Basic128RSA15' }, { value: SecurityPolicy.BASIC128, name: 'Basic128RSA15' },
{ value: 'Basic256', name: 'Basic256' }, { value: SecurityPolicy.BASIC256, name: 'Basic256' },
{ value: 'Basic256Sha256', name: 'Basic256SHA256' } { value: SecurityPolicy.BASIC256SHA, name: 'Basic256SHA256' }
]; ];

2
ui-ngx/src/app/modules/home/components/widget/widget-components.module.ts

@ -111,7 +111,6 @@ import {
TypeValuePanelComponent, TypeValuePanelComponent,
BrokerConfigControlComponent, BrokerConfigControlComponent,
WorkersConfigControlComponent, WorkersConfigControlComponent,
GeneralConfigComponent,
MqttBasicConfigComponent, MqttBasicConfigComponent,
OpcUaBasicConfigComponent, OpcUaBasicConfigComponent,
} from '@home/components/widget/lib/gateway/connectors-configuration/public-api'; } from '@home/components/widget/lib/gateway/connectors-configuration/public-api';
@ -194,7 +193,6 @@ import {
BrokerConfigControlComponent, BrokerConfigControlComponent,
WorkersConfigControlComponent, WorkersConfigControlComponent,
ServerConfigComponent, ServerConfigComponent,
GeneralConfigComponent,
MqttBasicConfigComponent, MqttBasicConfigComponent,
MappingTableComponent, MappingTableComponent,
OpcUaBasicConfigComponent, OpcUaBasicConfigComponent,

Loading…
Cancel
Save