2019-08-14 19:55:24 +03:00
|
|
|
<!--
|
|
|
|
|
|
2020-02-20 10:26:43 +02:00
|
|
|
Copyright © 2016-2020 The Thingsboard Authors
|
2019-08-14 19:55:24 +03:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
-->
|
2020-04-03 21:14:39 +03:00
|
|
|
<form #deviceCredentialsForm="ngForm" [formGroup]="deviceCredentialsFormGroup" (ngSubmit)="save()" style="min-width: 350px;">
|
|
|
|
|
<mat-toolbar color="primary">
|
2019-08-14 19:55:24 +03:00
|
|
|
<h2 translate>device.device-credentials</h2>
|
|
|
|
|
<span fxFlex></span>
|
2020-04-03 21:14:39 +03:00
|
|
|
<button mat-icon-button
|
2019-08-14 19:55:24 +03:00
|
|
|
(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>
|
2020-04-03 21:14:39 +03:00
|
|
|
<mat-select formControlName="credentialsType"
|
2019-08-14 19:55:24 +03:00
|
|
|
(ngModelChange)="credentialsTypeChanged()">
|
|
|
|
|
<mat-option *ngFor="let credentialsType of credentialsTypes" [value]="credentialsType">
|
2020-02-04 15:14:17 +02:00
|
|
|
{{ credentialTypeNamesMap.get(deviceCredentialsType[credentialsType]) }}
|
2019-08-14 19:55:24 +03:00
|
|
|
</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>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</div>
|
2020-04-03 21:14:39 +03:00
|
|
|
<div mat-dialog-actions fxLayoutAlign="end center">
|
|
|
|
|
<button *ngIf="!isReadOnly" mat-raised-button color="primary"
|
2019-08-14 19:55:24 +03:00
|
|
|
type="submit"
|
|
|
|
|
[disabled]="(isLoading$ | async) || deviceCredentialsForm.invalid
|
|
|
|
|
|| !deviceCredentialsForm.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>
|