thingsboard/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html

132 lines
7.7 KiB
HTML
Raw Normal View History

2020-01-30 13:03:53 +02:00
<!--
2025-02-25 09:39:16 +02:00
Copyright © 2016-2025 The Thingsboard Authors
2020-01-30 13:03: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.
-->
2021-12-14 12:40:18 +02:00
<div class="tb-table-widget tb-absolute-fill">
<div class="tb-absolute-fill flex flex-1 flex-col">
<mat-toolbar class="mat-mdc-table-toolbar" [class.!hidden]="!textSearchMode">
2020-01-30 13:03:53 +02:00
<div class="mat-toolbar-tools">
2023-02-17 19:24:01 +02:00
<button mat-icon-button
2020-01-30 13:03:53 +02:00
matTooltip="{{ 'action.search' | translate }}"
matTooltipPosition="above">
<mat-icon>search</mat-icon>
</button>
<mat-form-field class="flex-1">
2020-01-30 13:03:53 +02:00
<mat-label>&nbsp;</mat-label>
<input #searchInput matInput
[formControl]="textSearch"
2020-01-30 13:03:53 +02:00
placeholder="{{ 'widget.search-data' | translate }}"/>
</mat-form-field>
2023-02-17 19:24:01 +02:00
<button mat-icon-button (click)="exitFilterMode()"
2020-01-30 13:03:53 +02:00
matTooltip="{{ 'action.close' | translate }}"
matTooltipPosition="above">
<mat-icon>close</mat-icon>
</button>
</div>
</mat-toolbar>
<mat-tab-group [class.tb-headless]="sources.length === 1"
class="flex-1"
2023-02-21 19:18:04 +02:00
mat-stretch-tabs="false"
2020-01-30 13:03:53 +02:00
[(selectedIndex)]="sourceIndex" (selectedIndexChange)="onSourceIndexChanged()">
<mat-tab *ngFor="let source of sources; trackBy: trackBySourcesIndex; let index = index;" [label]="getTabLabel(source)">
<ng-template [ngIf]="isActiveTab(index)">
<div class="table-container flex-1">
<table mat-table [dataSource]="source.timeseriesDatasource" [trackBy]="trackByRowTimestamp"
matSort [matSortActive]="source.pageLink.sortOrder.property" [matSortDirection]="source.pageLink.sortDirection()" matSortDisableClear>
<ng-container *ngIf="showTimestamp" [matColumnDef]="'0'">
<mat-header-cell *matHeaderCellDef mat-sort-header>Timestamp</mat-header-cell>
<mat-cell *matCellDef="let row; let rowIndex = index"
[innerHTML]="cellContent(source, null, 0, row, row[0], rowIndex) | async"
[style]="cellStyle(source, null, 0, row, row[0], rowIndex) | async">
</mat-cell>
</ng-container>
<ng-container [matColumnDef]="h.index + ''" *ngFor="let h of source.header; trackBy: trackByColumnIndex;">
<mat-header-cell *matHeaderCellDef mat-sort-header [disabled]="!h.sortable"> {{ h.dataKey.label }} </mat-header-cell>
<mat-cell *matCellDef="let row; let rowIndex = index"
[innerHTML]="cellContent(source, h, h.index, row, row[h.index], rowIndex) | async"
[style]="cellStyle(source, h, h.index, row, row[h.index], rowIndex) | async">
</mat-cell>
</ng-container>
2021-03-12 12:15:35 +02:00
<ng-container matColumnDef="actions" [stickyEnd]="enableStickyAction">
<mat-header-cell *matHeaderCellDef>
<ng-container *ngIf="source.timeseriesDatasource.countCellButtonAction">
<div class="gt-md:!hidden" style="min-width: 40px;">
</div>
<div class="lt-lg:!hidden"
[style.min-width]="(source.timeseriesDatasource.countCellButtonAction * 40) + 'px'">
</div>
</ng-container>
</mat-header-cell>
<mat-cell *matCellDef="let row; let rowIndex = index" [style]="rowStyle(source, row, rowIndex) | async">
<ng-container *ngIf="source.timeseriesDatasource.countCellButtonAction">
<div [class.lt-lg:!hidden]="showCellActionsMenu && source.timeseriesDatasource.countCellButtonAction !== 1" class="flex flex-row items-stretch justify-end"
[style.min-width]="(source.timeseriesDatasource.countCellButtonAction * 40) + 'px'">
<ng-container *ngFor="let actionDescriptor of row.actionCellButtons; trackBy: trackByActionCellDescriptionId">
<span *ngIf="!actionDescriptor.icon" style="width: 40px;"></span>
<button *ngIf="actionDescriptor.icon"
class="tb-mat-40"
mat-icon-button [disabled]="isLoading$ | async"
matTooltip="{{ actionDescriptor.displayName }}"
matTooltipPosition="above"
(click)="onActionButtonClick($event, row, actionDescriptor)">
<tb-icon>{{actionDescriptor.icon}}</tb-icon>
</button>
</ng-container>
</div>
<div [class.!hidden]="!showCellActionsMenu || source.timeseriesDatasource.countCellButtonAction === 1" class="gt-md:!hidden" *ngIf="row.hasActions">
<button mat-icon-button
class="tb-mat-40"
(click)="$event.stopPropagation(); ctx.detectChanges();"
[matMenuTriggerFor]="cellActionsMenu">
<mat-icon class="material-icons">more_vert</mat-icon>
</button>
<mat-menu #cellActionsMenu="matMenu" xPosition="before">
<ng-container *ngFor="let actionDescriptor of row.actionCellButtons; trackBy: trackByActionCellDescriptionId">
<button mat-menu-item *ngIf="actionDescriptor.icon"
[disabled]="isLoading$ | async"
(click)="onActionButtonClick($event, row, actionDescriptor)">
<tb-icon matMenuItemIcon>{{actionDescriptor.icon}}</tb-icon>
<span>{{ actionDescriptor.displayName }}</span>
</button>
</ng-container>
</mat-menu>
</div>
</ng-container>
</mat-cell>
</ng-container>
2021-03-12 12:15:35 +02:00
<mat-header-row *matHeaderRowDef="source.displayedColumns; sticky: enableStickyHeader"></mat-header-row>
<mat-row [class.tb-pointer]="hasRowAction"
*matRowDef="let row; columns: source.displayedColumns; let rowIndex = index"
[style]="rowStyle(source, row, rowIndex) | async"
(click)="onRowClick($event, row)"></mat-row>
</table>
<span [class.!hidden]="(source.timeseriesDatasource.isEmpty() | async) === false"
class="no-data-found flex items-center justify-center">{{ noDataDisplayMessageText }}</span>
</div>
<mat-divider *ngIf="displayPagination"></mat-divider>
<mat-paginator *ngIf="displayPagination"
[length]="source.timeseriesDatasource.total() | async"
[pageIndex]="source.pageLink.page"
[pageSize]="source.pageLink.pageSize"
[pageSizeOptions]="pageSizeOptions"
[hidePageSize]="hidePageSize"
showFirstLastButtons></mat-paginator>
</ng-template>
2020-01-30 13:03:53 +02:00
</mat-tab>
</mat-tab-group>
</div>
</div>