Browse Source
Merge pull request #3579 from vvlladd28/improvement/device-credential
UI: Refactoring show error in device-credentials
pull/3580/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
8 deletions
-
ui-ngx/src/app/modules/home/components/device/device-credentials.component.html
-
ui-ngx/src/app/modules/home/components/device/device-credentials.component.ts
|
|
|
@ -70,8 +70,8 @@ |
|
|
|
<mat-icon>{{hidePassword ? 'visibility_off' : 'visibility'}}</mat-icon> |
|
|
|
</button> |
|
|
|
</mat-form-field> |
|
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsBasic').hasError('atLeastOne')"> |
|
|
|
{{ 'device.client-id-or-user-name-necessary' | translate }} |
|
|
|
</mat-error> |
|
|
|
<tb-error style="margin-top: -12px; display: block;" |
|
|
|
[error]="deviceCredentialsFormGroup.get('credentialsBasic').hasError('atLeastOne') ? |
|
|
|
('device.client-id-or-user-name-necessary' | translate) : ''"></tb-error> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
@ -174,8 +174,8 @@ export class DeviceCredentialsComponent implements ControlValueAccessor, OnInit, |
|
|
|
|
|
|
|
updateValidators(): void { |
|
|
|
this.hidePassword = true; |
|
|
|
const crendetialsType = this.deviceCredentialsFormGroup.get('credentialsType').value as DeviceCredentialsType; |
|
|
|
switch (crendetialsType) { |
|
|
|
const credentialsType = this.deviceCredentialsFormGroup.get('credentialsType').value as DeviceCredentialsType; |
|
|
|
switch (credentialsType) { |
|
|
|
case DeviceCredentialsType.ACCESS_TOKEN: |
|
|
|
this.deviceCredentialsFormGroup.get('credentialsId').setValidators([Validators.required, Validators.pattern(/^.{1,20}$/)]); |
|
|
|
this.deviceCredentialsFormGroup.get('credentialsId').updateValueAndValidity({emitEvent: false}); |
|
|
|
@ -215,9 +215,6 @@ export class DeviceCredentialsComponent implements ControlValueAccessor, OnInit, |
|
|
|
const value = this.deviceCredentialsFormGroup.get('credentialsBasic.password').value; |
|
|
|
if (value !== '') { |
|
|
|
this.deviceCredentialsFormGroup.get('credentialsBasic.userName').setValidators([Validators.required]); |
|
|
|
if (this.deviceCredentialsFormGroup.get('credentialsBasic.userName').untouched) { |
|
|
|
this.deviceCredentialsFormGroup.get('credentialsBasic.userName').markAsTouched({onlySelf: true}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.deviceCredentialsFormGroup.get('credentialsBasic.userName').setValidators([]); |
|
|
|
} |
|
|
|
|