109 lines
5.2 KiB
HTML
109 lines
5.2 KiB
HTML
<!--
|
|
|
|
Copyright © 2016-2020 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.
|
|
|
|
-->
|
|
<form [formGroup]="deviceCredentialsFormGroup" (ngSubmit)="save()" style="min-width: 350px;">
|
|
<mat-toolbar color="primary">
|
|
<h2 translate>device.device-credentials</h2>
|
|
<span fxFlex></span>
|
|
<button mat-icon-button
|
|
(click)="cancel()"
|
|
type="button">
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
</button>
|
|
</mat-toolbar>
|
|
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
|
|
</mat-progress-bar>
|
|
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
|
|
<div mat-dialog-content>
|
|
<fieldset [disabled]="(isLoading$ | async) || isReadOnly">
|
|
<mat-form-field class="mat-block">
|
|
<mat-label translate>device.credentials-type</mat-label>
|
|
<mat-select formControlName="credentialsType"
|
|
(ngModelChange)="credentialsTypeChanged()">
|
|
<mat-option *ngFor="let credentialsType of credentialsTypes" [value]="credentialsType">
|
|
{{ credentialTypeNamesMap.get(deviceCredentialsType[credentialsType]) }}
|
|
</mat-option>
|
|
</mat-select>
|
|
</mat-form-field>
|
|
<mat-form-field *ngIf="deviceCredentialsFormGroup.get('credentialsType').value === deviceCredentialsType.ACCESS_TOKEN"
|
|
class="mat-block">
|
|
<mat-label translate>device.access-token</mat-label>
|
|
<input matInput formControlName="credentialsId" required>
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsId').hasError('required')">
|
|
{{ 'device.access-token-required' | translate }}
|
|
</mat-error>
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsId').hasError('pattern')">
|
|
{{ 'device.access-token-invalid' | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|
|
<mat-form-field *ngIf="deviceCredentialsFormGroup.get('credentialsType').value === deviceCredentialsType.X509_CERTIFICATE"
|
|
class="mat-block">
|
|
<mat-label translate>device.rsa-key</mat-label>
|
|
<textarea matInput formControlName="credentialsValue" cols="15" rows="5" required></textarea>
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsValue').hasError('required')">
|
|
{{ 'device.rsa-key-required' | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|
|
<section *ngIf="deviceCredentialsFormGroup.get('credentialsType').value === deviceCredentialsType.MQTT_BASIC" formGroupName="credentialsBasic">
|
|
<mat-form-field class="mat-block">
|
|
<mat-label translate>device.client-id</mat-label>
|
|
<input matInput formControlName="clientId">
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsBasic.clientId').hasError('pattern')">
|
|
{{ 'device.client-id-pattern' | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|
|
<mat-form-field class="mat-block">
|
|
<mat-label translate>device.user-name</mat-label>
|
|
<input matInput formControlName="userName" [required]="!!deviceCredentialsFormGroup.get('credentialsBasic.password').value">
|
|
<mat-error *ngIf="deviceCredentialsFormGroup.get('credentialsBasic.userName').hasError('required')">
|
|
{{ 'device.user-name-required' | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|
|
<mat-form-field class="mat-block">
|
|
<mat-label translate>device.password</mat-label>
|
|
<input matInput formControlName="password"
|
|
autocomplete="new-password"
|
|
(ngModelChange)="passwordChanged()"
|
|
[type]="hidePassword ? 'password' : 'text'">
|
|
<button mat-icon-button matSuffix type="button"
|
|
(click)="hidePassword = !hidePassword"
|
|
[attr.aria-pressed]="hidePassword">
|
|
<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>
|
|
</section>
|
|
</fieldset>
|
|
</div>
|
|
<div mat-dialog-actions fxLayoutAlign="end center">
|
|
<button *ngIf="!isReadOnly" mat-raised-button color="primary"
|
|
type="submit"
|
|
[disabled]="(isLoading$ | async) || deviceCredentialsFormGroup.invalid
|
|
|| !deviceCredentialsFormGroup.dirty">
|
|
{{ 'action.save' | translate }}
|
|
</button>
|
|
<button mat-button color="primary"
|
|
type="button"
|
|
[disabled]="(isLoading$ | async)"
|
|
(click)="cancel()" cdkFocusInitial>
|
|
{{ (isReadOnly ? 'action.close' : 'action.cancel') | translate }}
|
|
</button>
|
|
</div>
|
|
</form>
|