thingsboard/ui-ngx/src/app/modules/home/components/relation/relation-table.component.html

175 lines
8.8 KiB
HTML
Raw Normal View History

2019-08-23 15:06:42 +03:00
<!--
2024-01-09 10:46:16 +02:00
Copyright © 2016-2024 The Thingsboard Authors
2019-08-23 15:06:42 +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.
-->
2021-12-14 12:40:18 +02:00
<div class="mat-padding tb-entity-table tb-absolute-fill">
<div class="tb-entity-table-content tb-outlined-border flex-1 flex flex-col">
<mat-toolbar class="mat-mdc-table-toolbar" [class.!hidden]="textSearchMode || !dataSource.selection.isEmpty()">
2019-08-23 15:06:42 +03:00
<div class="mat-toolbar-tools">
<div class="title-container flex flex-row justify-start items-center xs:flex-col xs:justify-center xs:items-start">
<span class="tb-entity-table-title">
{{(direction == directions.FROM ? 'relation.from-relations' : 'relation.to-relations') | translate}}
</span>
<mat-form-field class="mat-block tb-relation-direction">
<mat-label translate>relation.direction</mat-label>
<mat-select [ngModel]="direction"
(ngModelChange)="directionChanged($event)">
<mat-option *ngFor="let type of directionTypes" [value]="type">
{{ directionTypeTranslations.get(directions[type]) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<span class="flex-1"></span>
<button mat-icon-button [disabled]="isLoading$ | async"
2019-08-23 15:06:42 +03:00
(click)="addRelation($event)"
matTooltip="{{ 'action.add' | translate }}"
matTooltipPosition="above">
<mat-icon>add</mat-icon>
</button>
<button mat-icon-button [disabled]="isLoading$ | async" (click)="reloadRelations()"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'action.refresh' | translate }}"
matTooltipPosition="above">
<mat-icon>refresh</mat-icon>
</button>
<button mat-icon-button [disabled]="isLoading$ | async" (click)="enterFilterMode()"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'action.search' | translate }}"
matTooltipPosition="above">
<mat-icon>search</mat-icon>
</button>
</div>
</mat-toolbar>
<mat-toolbar class="mat-mdc-table-toolbar" [class.!hidden]="!textSearchMode || !dataSource.selection.isEmpty()">
2019-08-23 15:06:42 +03:00
<div class="mat-toolbar-tools">
<button mat-icon-button
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'action.search' | translate }}"
matTooltipPosition="above">
<mat-icon>search</mat-icon>
</button>
<mat-form-field class="flex-1">
2019-08-23 15:06:42 +03:00
<mat-label>&nbsp;</mat-label>
<input #searchInput matInput
[formControl]="textSearch"
2019-08-23 15:06:42 +03:00
placeholder="{{ 'common.enter-search' | translate }}"/>
</mat-form-field>
<button mat-icon-button (click)="exitFilterMode()"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'action.close' | translate }}"
matTooltipPosition="above">
<mat-icon>close</mat-icon>
</button>
</div>
</mat-toolbar>
<mat-toolbar class="mat-mdc-table-toolbar" color="primary" [class.!hidden]="dataSource.selection.isEmpty()">
<div class="mat-toolbar-tools flex justify-between items-center">
<span class="tb-entity-table-info">
{{ 'relation.selected-relations' | translate:{count: dataSource.selection.selected.length} }}
</span>
<button mat-icon-button [disabled]="isLoading$ | async"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'action.delete' | translate }}"
matTooltipPosition="above"
(click)="deleteRelations($event)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-toolbar>
<div class="table-container flex-1">
<table mat-table [dataSource]="dataSource"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
2019-08-23 15:06:42 +03:00
<ng-container matColumnDef="select" sticky>
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef style="width: 30px;">
2019-08-23 15:06:42 +03:00
<mat-checkbox (change)="$event ? dataSource.masterToggle() : null"
[checked]="dataSource.selection.hasValue() && (dataSource.isAllSelected() | async)"
[indeterminate]="dataSource.selection.hasValue() && !(dataSource.isAllSelected() | async)">
</mat-checkbox>
</mat-header-cell>
<mat-cell *matCellDef="let relation">
<mat-checkbox (click)="$event.stopPropagation()"
(change)="$event ? dataSource.selection.toggle(relation) : null"
[checked]="dataSource.selection.isSelected(relation)">
</mat-checkbox>
</mat-cell>
</ng-container>
<ng-container matColumnDef="type">
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef mat-sort-header style="width: 33%"> {{ 'relation.type' | translate }} </mat-header-cell>
2019-08-23 15:06:42 +03:00
<mat-cell *matCellDef="let relation">
{{ relation.type }}
</mat-cell>
</ng-container>
<ng-container *ngIf="direction === directions.FROM" matColumnDef="toEntityTypeName">
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef mat-sort-header style="width: 33%"> {{ 'relation.to-entity-type' | translate }} </mat-header-cell>
2019-08-23 15:06:42 +03:00
<mat-cell *matCellDef="let relation">
{{ relation.toEntityTypeName }}
</mat-cell>
</ng-container>
<ng-container *ngIf="direction === directions.FROM" matColumnDef="toName">
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef mat-sort-header style="width: 33%"> {{ 'relation.to-entity-name' | translate }} </mat-header-cell>
2019-08-23 15:06:42 +03:00
<mat-cell *matCellDef="let relation">
2021-12-28 12:01:26 +02:00
<a class="link" [routerLink]="relation.entityURL">
{{ relation.toName }}
</a>
2019-08-23 15:06:42 +03:00
</mat-cell>
</ng-container>
<ng-container *ngIf="direction === directions.TO" matColumnDef="fromEntityTypeName">
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef mat-sort-header style="width: 33%"> {{ 'relation.from-entity-type' | translate }} </mat-header-cell>
2019-08-23 15:06:42 +03:00
<mat-cell *matCellDef="let relation">
{{ relation.fromEntityTypeName }}
</mat-cell>
</ng-container>
<ng-container *ngIf="direction === directions.TO" matColumnDef="fromName">
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef mat-sort-header style="width: 33%"> {{ 'relation.from-entity-name' | translate }} </mat-header-cell>
2019-08-23 15:06:42 +03:00
<mat-cell *matCellDef="let relation">
2021-12-28 12:01:26 +02:00
<a class="link" [routerLink]="relation.entityURL">
{{ relation.fromName }}
</a>
2019-08-23 15:06:42 +03:00
</mat-cell>
</ng-container>
<ng-container matColumnDef="actions" stickyEnd>
2020-02-04 19:50:18 +02:00
<mat-header-cell *matHeaderCellDef style="min-width: 80px; max-width: 80px; width: 80px">
2019-08-23 15:06:42 +03:00
</mat-header-cell>
2020-02-04 19:50:18 +02:00
<mat-cell *matCellDef="let relation">
<div class="flex-1 flex flex-row justify-end items-stretch">
<button mat-icon-button [disabled]="isLoading$ | async"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'relation.edit' | translate }}"
matTooltipPosition="above"
(click)="editRelation($event, relation)">
<mat-icon>edit</mat-icon>
</button>
<button mat-icon-button [disabled]="isLoading$ | async"
2019-08-23 15:06:42 +03:00
matTooltip="{{ 'relation.delete' | translate }}"
matTooltipPosition="above"
(click)="deleteRelation($event, relation)">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-cell>
</ng-container>
<mat-header-row class="mat-row-select" *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
<mat-row class="mat-row-select"
[class.mat-selected]="dataSource.selection.isSelected(relation)"
2019-08-23 15:06:42 +03:00
*matRowDef="let relation; columns: displayedColumns;" (click)="dataSource.selection.toggle(relation)"></mat-row>
</table>
<span [class.!hidden]="(dataSource.isEmpty() | async) === false"
class="no-data-found flex justify-center items-center" translate>{{ 'relation.no-relations-text' }}</span>
2019-08-23 15:06:42 +03:00
</div>
<mat-divider></mat-divider>
<mat-paginator [length]="dataSource.total() | async"
[pageIndex]="pageLink.page"
[pageSize]="pageLink.pageSize"
[pageSizeOptions]="[10, 20, 30]"
[hidePageSize]="hidePageSize"></mat-paginator>
2019-08-23 15:06:42 +03:00
</div>
</div>