68 lines
3.1 KiB
HTML
68 lines
3.1 KiB
HTML
<!--
|
|
|
|
Copyright © 2016-2023 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.
|
|
|
|
-->
|
|
<div class="tb-container">
|
|
<label class="tb-title" *ngIf="label" [ngClass]="{'tb-error': !disabled && (required && !safeImageUrl), 'tb-required': !disabled && required}">{{label}}</label>
|
|
<ng-container #flow="flow"
|
|
[flowConfig]="{singleFile: true, allowDuplicateUploads: true}">
|
|
<div class="tb-image-select-container">
|
|
<div class="image-container" *ngIf="showPreview && (safeImageUrl || disabled)" [class]="{'disabled': disabled}">
|
|
<div class="tb-image-preview-container">
|
|
<div class="tb-image-preview-text" *ngIf="!safeImageUrl && disabled; else elseBlock">{{ 'dashboard.empty-image' | translate }}</div>
|
|
<ng-template #elseBlock><img class="tb-image-preview" [src]="safeImageUrl" /></ng-template>
|
|
</div>
|
|
<button *ngIf="safeImageUrl && !disabled"
|
|
mat-icon-button color="primary"
|
|
class="tb-mat-24"
|
|
type="button"
|
|
(click)="clearImage()"
|
|
matTooltip="{{ 'action.remove' | translate }}"
|
|
matTooltipPosition="above">
|
|
<mat-icon>close</mat-icon>
|
|
</button>
|
|
</div>
|
|
<div *ngIf="!disabled" class="drop-area tb-flow-drop"
|
|
flowDrop
|
|
[flow]="flow.flowJs">
|
|
<div class="upload-label">
|
|
<mat-icon class="tb-mat-32">cloud_upload</mat-icon>
|
|
<div class="upload-text-area">
|
|
<span class="hide-xs" translate>image-input.drag-and-drop</span>
|
|
<div class="upload-button-area">
|
|
<span class="hide-xs" translate>image-input.or</span>
|
|
<button type="button" mat-button color="primary" class="browse-file">
|
|
<label for="{{inputId}}">{{'image-input.browse' | translate}}</label>
|
|
</button>
|
|
<input class="file-input" flowButton type="file" [flow]="flow.flowJs" [flowAttributes]="{accept: 'image/*'}" id="{{inputId}}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<button *ngIf="!showPreview && safeImageUrl && !disabled"
|
|
mat-icon-button color="primary"
|
|
class="tb-mat-24"
|
|
type="button"
|
|
(click)="clearImage()"
|
|
matTooltip="{{ 'action.remove' | translate }}"
|
|
matTooltipPosition="above">
|
|
<mat-icon>close</mat-icon>
|
|
</button>
|
|
</div>
|
|
</ng-container>
|
|
<div class="tb-hint" *ngIf="maxSizeByte && !disabled" translate [translateParams]="{ size: maxSizeByte | fileSize}">dashboard.maximum-upload-file-size</div>
|
|
</div>
|