2021-03-23 18:51:53 +02:00
|
|
|
<!--
|
|
|
|
|
|
2023-01-31 10:43:56 +02:00
|
|
|
Copyright © 2016-2023 The Thingsboard Authors
|
2021-03-23 18:51:53 +02: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.
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
<div class="tb-details-buttons" fxLayout.xs="column">
|
2021-12-28 12:01:26 +02:00
|
|
|
<button mat-raised-button color="primary"
|
|
|
|
|
[disabled]="(isLoading$ | async)"
|
|
|
|
|
(click)="onEntityAction($event, 'open')"
|
|
|
|
|
[fxShow]="!isEdit && !isDetailsPage">
|
|
|
|
|
{{'common.open-details-page' | translate }}
|
|
|
|
|
</button>
|
2021-04-13 10:12:56 +03:00
|
|
|
<button mat-raised-button color="primary" fxFlex.xs
|
|
|
|
|
[disabled]="(isLoading$ | async)"
|
2021-06-16 23:06:52 +03:00
|
|
|
(click)="onEntityAction($event, 'downloadResource')"
|
2021-04-13 10:12:56 +03:00
|
|
|
[fxShow]="!isEdit">
|
2021-06-16 23:06:52 +03:00
|
|
|
{{ 'resource.download' | translate }}
|
2021-04-13 10:12:56 +03:00
|
|
|
</button>
|
2021-03-23 18:51:53 +02:00
|
|
|
<button mat-raised-button color="primary" fxFlex.xs
|
|
|
|
|
[disabled]="(isLoading$ | async)"
|
|
|
|
|
(click)="onEntityAction($event, 'delete')"
|
|
|
|
|
[fxShow]="!hideDelete() && !isEdit">
|
2021-06-16 23:06:52 +03:00
|
|
|
{{ 'resource.delete' | translate }}
|
2021-03-23 18:51:53 +02:00
|
|
|
</button>
|
2021-06-16 23:06:52 +03:00
|
|
|
<div fxLayout="row" fxLayout.xs="column">
|
|
|
|
|
<button mat-raised-button
|
|
|
|
|
ngxClipboard
|
|
|
|
|
(cbOnSuccess)="onResourceIdCopied()"
|
|
|
|
|
[cbContent]="entity?.id?.id"
|
|
|
|
|
[fxShow]="!isEdit">
|
|
|
|
|
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
|
|
|
|
|
<span translate>resource.copyId</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2021-03-23 18:51:53 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="mat-padding" fxLayout="column">
|
|
|
|
|
<form [formGroup]="entityForm">
|
|
|
|
|
<fieldset [disabled]="(isLoading$ | async) || !isEdit">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>resource.resource-type</mat-label>
|
|
|
|
|
<mat-select formControlName="resourceType" required>
|
|
|
|
|
<mat-option *ngFor="let resourceType of resourceTypes" [value]="resourceType">
|
2023-05-19 19:23:21 +03:00
|
|
|
{{ resourceTypesTranslationMap.get(resourceType) | translate }}
|
2021-03-23 18:51:53 +02:00
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field class="mat-block" *ngIf="entityForm.get('resourceType').value !== resourceType.LWM2M_MODEL || !isAdd">
|
|
|
|
|
<mat-label translate>resource.title</mat-label>
|
2021-03-25 13:00:44 +02:00
|
|
|
<input matInput formControlName="title" required>
|
2021-03-23 18:51:53 +02:00
|
|
|
<mat-error *ngIf="entityForm.get('title').hasError('required')">
|
|
|
|
|
{{ 'resource.title-required' | translate }}
|
|
|
|
|
</mat-error>
|
2021-07-01 16:21:44 +03:00
|
|
|
<mat-error *ngIf="entityForm.get('title').hasError('maxlength')">
|
|
|
|
|
{{ 'resource.title-max-length' | translate }}
|
|
|
|
|
</mat-error>
|
2021-03-23 18:51:53 +02:00
|
|
|
</mat-form-field>
|
2023-05-19 19:23:21 +03:00
|
|
|
<tb-file-input *ngIf="isAdd || (isEdit && entityForm.get('resourceType').value === resourceType.JS_MODULE)"
|
2021-03-23 18:51:53 +02:00
|
|
|
formControlName="data"
|
|
|
|
|
required
|
2023-12-22 15:13:18 +02:00
|
|
|
label="{{ (entityForm.get('resourceType').value === resourceType.LWM2M_MODEL ? 'resource.resource-files' : 'resource.resource-file') | translate }}"
|
2021-04-09 11:43:11 +03:00
|
|
|
[readAsBinary]="true"
|
2023-12-22 15:13:18 +02:00
|
|
|
[maxSizeByte]="maxResourceSize"
|
2021-03-23 18:51:53 +02:00
|
|
|
[allowedExtensions]="getAllowedExtensions()"
|
2021-04-09 11:43:11 +03:00
|
|
|
[contentConvertFunction]="convertToBase64File"
|
2021-03-23 18:51:53 +02:00
|
|
|
[accept]="getAcceptType()"
|
2021-04-09 11:43:11 +03:00
|
|
|
[multipleFile]="entityForm.get('resourceType').value === resourceType.LWM2M_MODEL"
|
2022-05-11 15:58:15 +03:00
|
|
|
dropLabel="{{'resource.drop-resource-file-or' | translate}}"
|
2021-03-23 18:51:53 +02:00
|
|
|
[existingFileName]="entityForm.get('fileName')?.value"
|
|
|
|
|
(fileNameChanged)="entityForm?.get('fileName').patchValue($event)">
|
|
|
|
|
</tb-file-input>
|
2023-05-19 19:23:21 +03:00
|
|
|
<div *ngIf="!isAdd && !(isEdit && entityForm.get('resourceType').value === resourceType.JS_MODULE)" fxLayout="row" fxLayoutGap.gt-md="8px" fxLayoutGap.sm="8px" fxLayout.xs="column" fxLayout.md="column">
|
2021-06-16 23:06:52 +03:00
|
|
|
<mat-form-field fxFlex>
|
|
|
|
|
<mat-label translate>resource.file-name</mat-label>
|
|
|
|
|
<input matInput formControlName="fileName" type="text">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
2021-03-23 18:51:53 +02:00
|
|
|
</fieldset>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|