Revert "Added emmition of default values on Connector with basic config creation"
This reverts commit e9967306b67a31778312059354457bb6adf92021.
This commit is contained in:
parent
e9967306b6
commit
01fb50d73a
@ -74,7 +74,7 @@
|
|||||||
aria-label="Generate"
|
aria-label="Generate"
|
||||||
matTooltip="{{ 'gateway.generate-client-id' | translate }}"
|
matTooltip="{{ 'gateway.generate-client-id' | translate }}"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
(click)="generate()"
|
(click)="generate('clientId')"
|
||||||
*ngIf="!brokerConfigFormGroup.get('clientId').value">
|
*ngIf="!brokerConfigFormGroup.get('clientId').value">
|
||||||
<mat-icon>autorenew</mat-icon>
|
<mat-icon>autorenew</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { AfterViewInit, ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ControlValueAccessor,
|
ControlValueAccessor,
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
@ -61,7 +61,7 @@ import { Subject } from 'rxjs';
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class BrokerConfigControlComponent implements ControlValueAccessor, Validator, AfterViewInit, OnDestroy {
|
export class BrokerConfigControlComponent implements ControlValueAccessor, Validator, OnDestroy {
|
||||||
brokerConfigFormGroup: UntypedFormGroup;
|
brokerConfigFormGroup: UntypedFormGroup;
|
||||||
mqttVersions = MqttVersions;
|
mqttVersions = MqttVersions;
|
||||||
portLimits = PortLimits;
|
portLimits = PortLimits;
|
||||||
@ -78,7 +78,7 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
|
|||||||
host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]],
|
host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]],
|
||||||
port: [null, [Validators.required, Validators.min(PortLimits.MIN), Validators.max(PortLimits.MAX)]],
|
port: [null, [Validators.required, Validators.min(PortLimits.MIN), Validators.max(PortLimits.MAX)]],
|
||||||
version: [5, []],
|
version: [5, []],
|
||||||
clientId: ['tb_gw_' + generateSecret(5), [Validators.pattern(noLeadTrailSpacesRegex)]],
|
clientId: ['', [Validators.pattern(noLeadTrailSpacesRegex)]],
|
||||||
security: []
|
security: []
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -101,17 +101,13 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
this.emitDefaultValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
generate(): void {
|
generate(formControlName: string): void {
|
||||||
this.brokerConfigFormGroup.get('clientId').patchValue('tb_gw_' + generateSecret(5));
|
this.brokerConfigFormGroup.get(formControlName)?.patchValue('tb_gw_' + generateSecret(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOnChange(fn: (value: string) => void): void {
|
registerOnChange(fn: (value: string) => void): void {
|
||||||
@ -131,8 +127,4 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
|
|||||||
brokerConfigFormGroup: {valid: false}
|
brokerConfigFormGroup: {valid: false}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitDefaultValue(): void {
|
|
||||||
this.onChange(this.brokerConfigFormGroup.value);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,12 +114,10 @@ export class MqttBasicConfigComponent implements ControlValueAccessor, Validator
|
|||||||
|
|
||||||
writeValue(basicConfig: ConnectorBaseConfig): void {
|
writeValue(basicConfig: ConnectorBaseConfig): void {
|
||||||
const editedBase = {
|
const editedBase = {
|
||||||
workers: basicConfig.broker
|
workers: {
|
||||||
? {
|
maxNumberOfWorkers: basicConfig.broker?.maxNumberOfWorkers,
|
||||||
maxNumberOfWorkers: basicConfig.broker.maxNumberOfWorkers,
|
maxMessageNumberPerWorker: basicConfig.broker?.maxMessageNumberPerWorker,
|
||||||
maxMessageNumberPerWorker: basicConfig.broker.maxMessageNumberPerWorker,
|
},
|
||||||
}
|
|
||||||
: {},
|
|
||||||
dataMapping: basicConfig.dataMapping || [],
|
dataMapping: basicConfig.dataMapping || [],
|
||||||
broker: basicConfig.broker || {},
|
broker: basicConfig.broker || {},
|
||||||
requestsMapping: Array.isArray(basicConfig.requestsMapping)
|
requestsMapping: Array.isArray(basicConfig.requestsMapping)
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
@ -68,7 +67,7 @@ import { CommonModule } from '@angular/common';
|
|||||||
SharedModule,
|
SharedModule,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SecurityConfigComponent implements ControlValueAccessor, OnInit, AfterViewInit, OnDestroy {
|
export class SecurityConfigComponent implements ControlValueAccessor, OnInit, OnDestroy {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
title = 'gateway.security';
|
title = 'gateway.security';
|
||||||
@ -113,10 +112,6 @@ export class SecurityConfigComponent implements ControlValueAccessor, OnInit, Af
|
|||||||
).subscribe((type) => this.updateValidators(type));
|
).subscribe((type) => this.updateValidators(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
this.emitDefaultValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
@ -148,10 +143,6 @@ export class SecurityConfigComponent implements ControlValueAccessor, OnInit, Af
|
|||||||
this.onTouched = fn;
|
this.onTouched = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitDefaultValue(): void {
|
|
||||||
this.onChange(this.securityFormGroup.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
private updateValidators(type: SecurityType): void {
|
private updateValidators(type: SecurityType): void {
|
||||||
if (type) {
|
if (type) {
|
||||||
this.securityFormGroup.get('username').disable({emitEvent: false});
|
this.securityFormGroup.get('username').disable({emitEvent: false});
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { AfterViewInit, ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ControlValueAccessor,
|
ControlValueAccessor,
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
@ -61,7 +61,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
SecurityConfigComponent,
|
SecurityConfigComponent,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class ServerConfigComponent implements ControlValueAccessor, Validator, AfterViewInit, OnDestroy {
|
export class ServerConfigComponent implements ControlValueAccessor, Validator, OnDestroy {
|
||||||
|
|
||||||
securityPolicyTypes = SecurityPolicyTypes;
|
securityPolicyTypes = SecurityPolicyTypes;
|
||||||
serverConfigFormGroup: UntypedFormGroup;
|
serverConfigFormGroup: UntypedFormGroup;
|
||||||
@ -92,10 +92,6 @@ export class ServerConfigComponent implements ControlValueAccessor, Validator, A
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
this.emitDefaultValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
@ -118,8 +114,4 @@ export class ServerConfigComponent implements ControlValueAccessor, Validator, A
|
|||||||
writeValue(serverConfig: ServerConfig): void {
|
writeValue(serverConfig: ServerConfig): void {
|
||||||
this.serverConfigFormGroup.patchValue(serverConfig, {emitEvent: false});
|
this.serverConfigFormGroup.patchValue(serverConfig, {emitEvent: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitDefaultValue(): void {
|
|
||||||
this.onChange(this.serverConfigFormGroup.value);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
@ -26,9 +25,7 @@ import {
|
|||||||
FormBuilder,
|
FormBuilder,
|
||||||
NG_VALIDATORS,
|
NG_VALIDATORS,
|
||||||
NG_VALUE_ACCESSOR,
|
NG_VALUE_ACCESSOR,
|
||||||
UntypedFormGroup,
|
UntypedFormGroup, ValidationErrors, Validator,
|
||||||
ValidationErrors,
|
|
||||||
Validator,
|
|
||||||
Validators
|
Validators
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import { SharedModule } from '@shared/shared.module';
|
import { SharedModule } from '@shared/shared.module';
|
||||||
@ -59,7 +56,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class WorkersConfigControlComponent implements AfterViewInit, OnDestroy, ControlValueAccessor, Validator {
|
export class WorkersConfigControlComponent implements OnDestroy, ControlValueAccessor, Validator {
|
||||||
|
|
||||||
workersConfigFormGroup: UntypedFormGroup;
|
workersConfigFormGroup: UntypedFormGroup;
|
||||||
|
|
||||||
@ -80,10 +77,6 @@ export class WorkersConfigControlComponent implements AfterViewInit, OnDestroy,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
this.emitDefaultValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
@ -106,8 +99,4 @@ export class WorkersConfigControlComponent implements AfterViewInit, OnDestroy,
|
|||||||
workersConfigFormGroup: {valid: false}
|
workersConfigFormGroup: {valid: false}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitDefaultValue(): void {
|
|
||||||
this.onChange(this.workersConfigFormGroup.value);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -551,6 +551,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
}
|
}
|
||||||
value.basicConfig = value.configurationJson;
|
value.basicConfig = value.configurationJson;
|
||||||
this.updateConnector(value);
|
this.updateConnector(value);
|
||||||
|
this.generate('basicConfig.broker.clientId');
|
||||||
setTimeout(() => this.saveConnector());
|
setTimeout(() => this.saveConnector());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -558,6 +559,10 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generate(formControlName: string): void {
|
||||||
|
this.connectorForm.get(formControlName)?.patchValue('tb_gw_' + generateSecret(5));
|
||||||
|
}
|
||||||
|
|
||||||
uniqNameRequired(): ValidatorFn {
|
uniqNameRequired(): ValidatorFn {
|
||||||
return (c: UntypedFormControl) => {
|
return (c: UntypedFormControl) => {
|
||||||
const newName = c.value.trim().toLowerCase();
|
const newName = c.value.trim().toLowerCase();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user