thingsboard/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html

120 lines
5.0 KiB
HTML
Raw Normal View History

<!--
2023-01-31 10:43:56 +02:00
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-dashboard-widget-select">
<ng-container *ngIf="selectWidgetMode === 'bundles'; else allWidgets">
<ng-container *ngIf="widgetsBundle; else bundles">
<ng-container *ngTemplateOutlet="widgets; context:{ fetchFunction: widgetsFetchFunction, filter: widgetsFilter }"></ng-container>
</ng-container>
</ng-container>
<ng-template #allWidgets>
<ng-container *ngTemplateOutlet="widgets; context:{ fetchFunction: allWidgetsFetchFunction, filter: allWidgetsFilter }"></ng-container>
</ng-template>
<ng-template #widgets let-fetchFunction="fetchFunction" let-filter="filter">
<tb-scroll-grid
[columns]="columns"
[fetchFunction]="fetchFunction"
[filter]="filter"
[itemCard]="widgetCard"
[loadingCell]="widgetLoadingCard"
[dataLoading]="loadingWidgets"
[noData]="noWidgets">
</tb-scroll-grid>
<ng-template #widgetCard let-item="item">
<mat-card class="tb-widget-preview-card" appearance="raised" fxFlexFill fxLayout="row" fxLayoutGap="16px" (click)="onWidgetClicked($event, item)">
<div class="preview-container" fxFlex="45">
<img class="preview" [src]="getPreviewImage(item.image)" alt="{{ item.title }}">
</div>
<div fxFlex fxLayout="column">
<mat-card-title>{{item.name}}<div *ngIf="item.deprecated" class="tb-deprecated" translate>widget.deprecated</div></mat-card-title>
<mat-card-subtitle>{{ 'widget.' + item.widgetType | translate }}</mat-card-subtitle>
<mat-card-content *ngIf="item.description">
{{ item.description }}
</mat-card-content>
</div>
</mat-card>
</ng-template>
<ng-template #loadingWidgets>
<div fxLayout="column"
fxLayoutAlign="center center" class="tb-absolute-fill">
2023-02-17 19:24:01 +02:00
<span class="mat-headline-5" style="padding-bottom: 20px;">
{{ 'widget.loading-widgets' | translate }}
</span>
<mat-spinner color="accent" strokeWidth="5"></mat-spinner>
</div>
</ng-template>
<ng-template #noWidgets>
<span style="display: flex;"
fxLayoutAlign="center center"
class="mat-headline-5 tb-absolute-fill">{{(selectWidgetMode === 'bundles' ? 'widgets-bundle.empty' : 'widget.no-widgets-text') | translate}}</span>
</ng-template>
</ng-template>
2021-03-03 18:41:01 +02:00
<ng-template #bundles>
<tb-scroll-grid
[columns]="columns"
[fetchFunction]="widgetBundlesFetchFunction"
[filter]="widgetsBundleFilter"
[itemCard]="widgetsBundleCard"
[loadingCell]="widgetLoadingCard"
[dataLoading]="loadingWidgetBundles"
[noData]="noWidgetBundles">
</tb-scroll-grid>
<ng-template #widgetsBundleCard let-item="item">
<mat-card class="tb-widget-preview-card" appearance="raised" fxFlexFill fxLayout="row" fxLayoutGap="16px" (click)="selectBundle($event, item)">
<div class="preview-container" fxFlex="45">
<img class="preview" [src]=getPreviewImage(item.image) alt="{{ item.title }}">
</div>
<div fxFlex fxLayout="column">
<mat-card-title>{{ item.title }}</mat-card-title>
<mat-card-subtitle *ngIf="isSystem(item)" translate>widgets-bundle.system</mat-card-subtitle>
<mat-card-content *ngIf="item.description">
{{ item.description }}
</mat-card-content>
</div>
</mat-card>
</ng-template>
<ng-template #loadingWidgetBundles>
<div fxLayout="column"
fxLayoutAlign="center center" class="tb-absolute-fill">
2023-02-17 19:24:01 +02:00
<span class="mat-headline-5" style="padding-bottom: 20px;">
{{ 'widgets-bundle.loading-widgets-bundles' | translate }}
</span>
<mat-spinner strokeWidth="5"></mat-spinner>
</div>
</ng-template>
<ng-template #noWidgetBundles>
<span translate
style="display: flex;"
fxLayoutAlign="center center"
2023-02-17 19:24:01 +02:00
class="mat-headline-5 tb-absolute-fill">widgets-bundle.no-widgets-bundles-text</span>
</ng-template>
2021-03-03 18:41:01 +02:00
</ng-template>
<ng-template #widgetLoadingCard>
<mat-card class="tb-widget-preview-card loading-cell" appearance="raised" fxLayout="row" fxLayoutGap="16px">
<div class="preview-container" fxFlex="45">
</div>
<div fxFlex fxLayout="column">
<mat-card-title>
</mat-card-title>
<mat-card-content>
</mat-card-content>
</div>
</mat-card>
</ng-template>
</div>