adjustments
This commit is contained in:
parent
b25e2a556f
commit
022d64f744
@ -132,17 +132,18 @@ export class MqttBasicConfigComponent implements ControlValueAccessor, Validator
|
|||||||
|
|
||||||
writeValue(basicConfig: ConnectorBaseConfig): void {
|
writeValue(basicConfig: ConnectorBaseConfig): void {
|
||||||
const editedBase = {
|
const editedBase = {
|
||||||
...basicConfig,
|
|
||||||
workers: {
|
workers: {
|
||||||
maxNumberOfWorkers: basicConfig.broker?.maxNumberOfWorkers,
|
maxNumberOfWorkers: basicConfig.broker?.maxNumberOfWorkers,
|
||||||
maxMessageNumberPerWorker: basicConfig.broker?.maxMessageNumberPerWorker,
|
maxMessageNumberPerWorker: basicConfig.broker?.maxMessageNumberPerWorker,
|
||||||
},
|
},
|
||||||
|
dataMapping: basicConfig.dataMapping || [],
|
||||||
|
broker: basicConfig.broker || {},
|
||||||
requestsMapping: Array.isArray(basicConfig.requestsMapping)
|
requestsMapping: Array.isArray(basicConfig.requestsMapping)
|
||||||
? basicConfig.requestsMapping
|
? basicConfig.requestsMapping
|
||||||
: this.getRequestDataArray(basicConfig.requestsMapping),
|
: this.getRequestDataArray(basicConfig.requestsMapping),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.basicFormGroup.patchValue(editedBase, {emitEvent: false});
|
this.basicFormGroup.setValue(editedBase, {emitEvent: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(): ValidationErrors | null {
|
validate(): ValidationErrors | null {
|
||||||
|
|||||||
@ -128,7 +128,12 @@ export class OpcUaBasicConfigComponent implements ControlValueAccessor, Validato
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeValue(basicConfig: ConnectorBaseConfig): void {
|
writeValue(basicConfig: ConnectorBaseConfig): void {
|
||||||
this.basicFormGroup.patchValue(basicConfig, {emitEvent: false});
|
const editedBase = {
|
||||||
|
server: basicConfig.server || {},
|
||||||
|
mapping: basicConfig.mapping || [],
|
||||||
|
};
|
||||||
|
|
||||||
|
this.basicFormGroup.setValue(editedBase, {emitEvent: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(): ValidationErrors | null {
|
validate(): ValidationErrors | null {
|
||||||
|
|||||||
@ -21,9 +21,7 @@ import {
|
|||||||
ElementRef,
|
ElementRef,
|
||||||
Input,
|
Input,
|
||||||
NgZone,
|
NgZone,
|
||||||
QueryList,
|
|
||||||
ViewChild,
|
ViewChild,
|
||||||
ViewChildren
|
|
||||||
} 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';
|
||||||
@ -40,7 +38,7 @@ import {
|
|||||||
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';
|
||||||
import { BehaviorSubject, forkJoin, Observable, of, Subject, Subscription } from 'rxjs';
|
import { forkJoin, Observable, of, Subject, Subscription } from 'rxjs';
|
||||||
import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
||||||
import { PageComponent } from '@shared/components/page.component';
|
import { PageComponent } from '@shared/components/page.component';
|
||||||
import { PageLink } from '@shared/models/page/page-link';
|
import { PageLink } from '@shared/models/page/page-link';
|
||||||
@ -69,10 +67,9 @@ import {
|
|||||||
} from './gateway-widget.models';
|
} from './gateway-widget.models';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { AddConnectorDialogComponent } from '@home/components/widget/lib/gateway/dialog/add-connector-dialog.component';
|
import { AddConnectorDialogComponent } from '@home/components/widget/lib/gateway/dialog/add-connector-dialog.component';
|
||||||
import { debounceTime, distinctUntilChanged, filter, take, takeUntil, tap } from 'rxjs/operators';
|
import { debounceTime, take, takeUntil, tap } from 'rxjs/operators';
|
||||||
import { ErrorStateMatcher } from '@angular/material/core';
|
import { ErrorStateMatcher } from '@angular/material/core';
|
||||||
import { PageData } from '@shared/models/page/page-data';
|
import { PageData } from '@shared/models/page/page-data';
|
||||||
import { MatTab } from '@angular/material/tabs';
|
|
||||||
|
|
||||||
export class ForceErrorStateMatcher implements ErrorStateMatcher {
|
export class ForceErrorStateMatcher implements ErrorStateMatcher {
|
||||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||||
@ -270,6 +267,8 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.observeModeChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
@ -590,6 +589,12 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private observeModeChange(): void {
|
||||||
|
this.connectorForm.get('mode').valueChanges
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
.subscribe(() => this.connectorForm.get('mode').markAsPristine());
|
||||||
|
}
|
||||||
|
|
||||||
private observeAttributeChange(): void {
|
private observeAttributeChange(): void {
|
||||||
this.attributeUpdateSubject.pipe(
|
this.attributeUpdateSubject.pipe(
|
||||||
debounceTime(300),
|
debounceTime(300),
|
||||||
@ -732,9 +737,13 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
switch (connector.type) {
|
switch (connector.type) {
|
||||||
case ConnectorType.MQTT:
|
case ConnectorType.MQTT:
|
||||||
case ConnectorType.OPCUA:
|
case ConnectorType.OPCUA:
|
||||||
this.connectorForm.patchValue({...connector, mode: connector.mode || ConnectorConfigurationModes.BASIC});
|
this.connectorForm.get('type').patchValue(connector.type, {emitValue: false, onlySelf: true});
|
||||||
this.createBasicConfigWatcher();
|
|
||||||
this.connectorForm.markAsPristine();
|
setTimeout(() => {
|
||||||
|
this.connectorForm.patchValue({...connector, mode: connector.mode || ConnectorConfigurationModes.BASIC});
|
||||||
|
this.createBasicConfigWatcher();
|
||||||
|
this.connectorForm.markAsPristine();
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.connectorForm.patchValue({...connector, mode: null});
|
this.connectorForm.patchValue({...connector, mode: null});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user