|
|
|
@ -14,7 +14,7 @@ |
|
|
|
/// limitations under the License.
|
|
|
|
///
|
|
|
|
|
|
|
|
import { AfterViewInit, ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core'; |
|
|
|
import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core'; |
|
|
|
import { |
|
|
|
ControlValueAccessor, |
|
|
|
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; |
|
|
|
mqttVersions = MqttVersions; |
|
|
|
portLimits = PortLimits; |
|
|
|
@ -78,7 +78,7 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid |
|
|
|
host: ['', [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
port: [null, [Validators.required, Validators.min(PortLimits.MIN), Validators.max(PortLimits.MAX)]], |
|
|
|
version: [5, []], |
|
|
|
clientId: ['tb_gw_' + generateSecret(5), [Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
clientId: ['', [Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
security: [] |
|
|
|
}); |
|
|
|
|
|
|
|
@ -101,17 +101,13 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid |
|
|
|
return ''; |
|
|
|
} |
|
|
|
|
|
|
|
ngAfterViewInit(): void { |
|
|
|
this.emitDefaultValue(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy(): void { |
|
|
|
this.destroy$.next(); |
|
|
|
this.destroy$.complete(); |
|
|
|
} |
|
|
|
|
|
|
|
generate(): void { |
|
|
|
this.brokerConfigFormGroup.get('clientId').patchValue('tb_gw_' + generateSecret(5)); |
|
|
|
generate(formControlName: string): void { |
|
|
|
this.brokerConfigFormGroup.get(formControlName)?.patchValue('tb_gw_' + generateSecret(5)); |
|
|
|
} |
|
|
|
|
|
|
|
registerOnChange(fn: (value: string) => void): void { |
|
|
|
@ -131,8 +127,4 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid |
|
|
|
brokerConfigFormGroup: {valid: false} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
private emitDefaultValue(): void { |
|
|
|
this.onChange(this.brokerConfigFormGroup.value); |
|
|
|
}; |
|
|
|
} |
|
|
|
|