thingsboard/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html

342 lines
16 KiB
HTML
Raw Normal View History

<!--
2024-01-09 10:46:16 +02:00
Copyright © 2016-2024 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.
-->
<form [formGroup]="layoutsFormGroup" (ngSubmit)="save()">
<mat-toolbar color="primary">
<h2 translate>layout.manage</h2>
<span fxFlex></span>
2023-02-17 19:24:01 +02:00
<button mat-icon-button
(click)="cancel()"
type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div mat-dialog-content fxLayout="column" fxLayoutGap="20px" style="min-width: 300px; overflow: hidden;">
<div class="tb-form-row space-between">
<div class="fixed-title-width" translate>dashboard.layout</div>
<mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="layoutType">
<mat-option *ngFor="let type of layoutTypes" [value]="type">
{{ layoutTypeTranslations.get(type) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
2022-07-27 13:56:11 +03:00
</div>
<!-- <div fxLayout="row" fxLayoutAlign="start center">-->
<!-- <mat-slide-toggle formControlName="right" color="accent">-->
<!-- {{ 'layout.divider' | translate }}-->
<!-- </mat-slide-toggle>-->
<!-- </div>-->
<div *ngIf="!isDividerLayout; else dividerLayout" class="tb-form-panel no-padding no-border">
<!-- <div class="tb-form-table tb-layout-breakpoints">-->
<!-- <div class="tb-form-table-header">-->
<!-- <div class="tb-form-table-header-cell tb-icon-breakpoint"></div>-->
<!-- <div class="tb-form-table-header-cell tb-devices-header">Devices</div>-->
<!-- <div class="tb-form-table-header-cell tb-size-header">Size</div>-->
<!-- <div class="tb-form-table-header-cell tb-actions-header"></div>-->
<!-- </div>-->
<!-- <div class="tb-form-table-body">-->
<!-- <div class="tb-form-table-row">-->
<!-- <div class="tb-form-table-row-cell tb-icon-breakpoint"></div>-->
<!-- <div class="tb-form-table-row-cell tb-devices-header">Default</div>-->
<!-- <div class="tb-form-table-row-cell tb-size-header"></div>-->
<!-- <div class="tb-form-table-row-cell tb-actions-header">-->
<!-- <button mat-icon-button class="tb-mat-20"-->
<!-- (click)="openLayoutSettings('main')"-->
<!-- type="button" >-->
<!-- <mat-icon>settings</mat-icon>-->
<!-- </button>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="tb-form-table-row">-->
<!-- <div class="tb-form-table-row-cell tb-icon-breakpoint"></div>-->
<!-- <div class="tb-form-table-row-cell tb-devices-header">Md</div>-->
<!-- <div class="tb-form-table-row-cell tb-size-header"></div>-->
<!-- <div class="tb-form-table-row-cell tb-actions-header">-->
<!-- <button mat-icon-button class="tb-mat-20"-->
<!-- (click)="openLayoutSettings('main')"-->
<!-- type="button" >-->
<!-- <mat-icon>settings</mat-icon>-->
<!-- </button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div class="table-container" style="width: 600px">
<table mat-table [dataSource]="dataSource">
<ng-container [matColumnDef]="'icon'">
<mat-header-cell *matHeaderCellDef [style]="{ minWidth: '48px', maxWidth: '48px', width: '48px', textAlign: 'center'}">
</mat-header-cell>
<mat-cell *matCellDef="let breakpoint" [style]="{ minWidth: '48px', maxWidth: '48px', width: '48px', textAlign: 'center'}">
<tb-icon>{{ breakpoint.icon }}</tb-icon>
</mat-cell>
</ng-container>
<ng-container [matColumnDef]="'name'">
<mat-header-cell *matHeaderCellDef style="width: 15%;min-width: 15%;max-width: 15%;padding-left:0">
Breakpoints
</mat-header-cell>
<mat-cell *matCellDef="let breakpoint" style="width: 15%;min-width: 15%;max-width: 15%;">
{{ breakpoint.name }}
</mat-cell>
</ng-container>
<ng-container [matColumnDef]="'descriptionSize'" style="width: 85%;min-width: 85%;max-width: 85%;">
<mat-header-cell *matHeaderCellDef>
Size
</mat-header-cell>
<mat-cell *matCellDef="let breakpoint" style="width: 85%;min-width: 85%;max-width: 85%;">
{{ breakpoint.descriptionSize }}
</mat-cell>
</ng-container>
<ng-container matColumnDef="actions" stickyEnd>
<mat-header-cell *matHeaderCellDef
[ngStyle.gt-md]="{ minWidth: '96px', maxWidth: '96px', width: '96px', textAlign: 'center'}">
</mat-header-cell>
<mat-cell *matCellDef="let breakpoint"
[ngStyle.gt-md]="{ minWidth: '96px', maxWidth: '96px', width: '96px'}">
<div fxHide fxShow.gt-md fxFlex fxLayout="row" fxLayoutAlign="end">
<button mat-icon-button
(click)="openLayoutSettings('main', breakpoint.breakpoint)"
type="button" >
<mat-icon>settings</mat-icon>
</button>
<button mat-icon-button
[disabled]="breakpoint.breakpoint === 'default'"
(click)="deleteBreakpoint(breakpoint.breakpoint)"
type="button" >
<tb-icon>delete</tb-icon>
</button>
</div>
<div fxHide fxShow.lt-lg fxFlex fxLayout="row" fxLayoutAlign="end">
<button mat-icon-button
(click)="$event.stopPropagation()"
[matMenuTriggerFor]="cellActionsMenu">
<mat-icon class="material-icons">more_vert</mat-icon>
</button>
<mat-menu #cellActionsMenu="matMenu" xPosition="before">
<button mat-icon-button
(click)="openLayoutSettings('main', breakpoint.breakpoint)"
type="button" >
<mat-icon>settings</mat-icon>
</button>
<button mat-icon-button
(click)="openLayoutSettings('main')"
type="button" >
<tb-icon>delete</tb-icon>-->
</button>
</mat-menu>
</div>
</mat-cell>
</ng-container>
<mat-header-row class="mat-row-select" *matHeaderRowDef="['icon', 'name', 'descriptionSize', 'actions']; sticky: true"></mat-header-row>
<mat-row *matRowDef="let breakpoint; columns: ['icon', 'name', 'descriptionSize', 'actions']"></mat-row>
</table>
</div>
<button mat-button fxFlex class="tb-add-breakpoint-button"
matTooltip="Add breakpoint"
matTooltipPosition="above"
type="button"
*ngIf="!addBreakpointMode"
(click)="addBreakpoint()">
<mat-icon>add</mat-icon>
</button>
<div *ngIf="addBreakpointMode" class="tb-form-row space-between column-lt-md" [formGroup]="addBreakpointFormGroup">
<div fxLayout="row" fxFlex.lt-md fxLayoutAlign="start center" fxLayoutGap="8px">
<div>Add breakpoint</div>
<mat-form-field fxFlex.lt-md appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="new">
<mat-option *ngFor="let breakpoint of allowBreakpointIds" [value]="breakpoint">
{{ breakpoint }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row" fxFlex.lt-md fxLayoutAlign="start center" fxLayoutGap="8px">
<div>Copy from</div>
<mat-form-field fxFlex.lt-md appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="copyFrom">
<mat-option *ngFor="let breakpoint of selectedBreakpointIds" [value]="breakpoint">
{{ breakpoint }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayoutGap="8px">
<button mat-icon-button class="tb-mat-20"
type="button" (click)="createdBreakPoint()">
<tb-icon>check</tb-icon>
</button>
<button mat-icon-button class="tb-mat-20"
type="button" (click)="addBreakpoint()">
<tb-icon>close</tb-icon>
</button>
</div>
</div>
</div>
<ng-template #dividerLayout>
<div fxLayout="column" fxLayoutAlign="start center" fxLayoutGap="20px">
<mat-button-toggle-group aria-label="Select width value type"
formControlName="type"
[fxShow]="isDividerLayout">
<mat-button-toggle fxFlex value="percentage">
{{ 'layout.percentage-width' | translate }}
</mat-button-toggle>
<mat-button-toggle fxFlex value="fixed">
{{ 'layout.fixed-width' | translate }}
</mat-button-toggle>
</mat-button-toggle-group>
<div fxLayout="row" fxLayoutAlign="center center" class="tb-layout-preview">
<div fxLayout="row"
fxLayoutAlign="start center"
class="tb-layout-preview-container"
#tooltip="matTooltip"
matTooltip=""
matTooltipPosition="below">
2022-09-20 18:09:25 +03:00
<div fxLayout="column" fxLayoutAlign="start center" fxFlex="{{ buttonFlexValue() }}" class="tb-layout-preview-container-main">
<button mat-icon-button
type="button"
matTooltip="{{ 'dashboard.layout-settings' | translate }}"
matTooltipPosition="above"
(click)="openLayoutSettings('main')"
class="tb-layout-preview-element"
2022-08-19 13:57:49 +03:00
aria-label="Layout settings"
2022-09-20 18:09:25 +03:00
[ngClass]="layoutButtonClass('main')">
<mat-icon>settings</mat-icon>
</button>
<button fxFlex
type="button"
mat-raised-button
color="primary"
class="tb-layout-button"
(mouseover)="mainLayoutTooltip.show()"
(mouseleave)="mainLayoutTooltip.hide()"
(click)="setFixedLayout('main')"
2022-09-20 18:09:25 +03:00
[ngClass]="layoutButtonClass('main', true)">
<span [matTooltip]="layoutButtonText('main')"
#mainLayoutTooltip="matTooltip"
matTooltipPosition="above">
{{ (isDividerLayout ? 'layout.left' : 'layout.main') | translate }}
</span>
</button>
2022-09-20 18:09:25 +03:00
<div fxFlex class="tb-layout-preview-element tb-layout-preview-input" *ngIf="showPreviewInputs('main')">
<input *ngIf="layoutsFormGroup.get('type').value !== layoutWidthType.FIXED"
2022-07-27 13:56:11 +03:00
formControlName="leftWidthPercentage"
type="number"
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutPercentageSize.MIN }}"
max="{{ layoutPercentageSize.MAX }}"
required>
2022-09-20 18:09:25 +03:00
<input *ngIf="layoutsFormGroup.get('type').value === layoutWidthType.FIXED &&
layoutsFormGroup.get('fixedLayout').value === 'main'"
formControlName="fixedWidth"
type="number"
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutFixedSize.MIN }}"
max="{{ layoutFixedSize.MAX }}"
required>
</div>
</div>
<div fxLayout="column" fxLayoutAlign="start center" fxFlex *ngIf="isDividerLayout" matTooltip="">
<button mat-icon-button
type="button"
matTooltip="{{ 'dashboard.layout-settings' | translate }}"
matTooltipPosition="above"
(click)="openLayoutSettings('right')"
class="tb-layout-preview-element"
2022-08-19 13:57:49 +03:00
aria-label="Layout settings"
2022-09-20 18:09:25 +03:00
[ngClass]="layoutButtonClass('right')">
<mat-icon>settings</mat-icon>
</button>
<button fxFlex
type="button"
mat-raised-button
color="primary"
2022-09-20 18:09:25 +03:00
class="tb-layout-button tb-layout-button-right"
(mouseover)="rightLayoutTooltip.show()"
(mouseleave)="rightLayoutTooltip.hide()"
(click)="setFixedLayout('right')"
2022-09-20 18:09:25 +03:00
[ngClass]="layoutButtonClass('right')">
<span [matTooltip]="layoutButtonText('right')"
#rightLayoutTooltip="matTooltip"
matTooltipPosition="above">
{{ 'layout.right' | translate }}
</span>
</button>
2022-09-20 18:09:25 +03:00
<div fxFlex class="tb-layout-preview-element tb-layout-preview-input" *ngIf="showPreviewInputs('right')">
<input *ngIf="layoutsFormGroup.get('type').value !== layoutWidthType.FIXED"
2022-07-27 13:56:11 +03:00
formControlName="rightWidthPercentage"
type="number"
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutPercentageSize.MIN }}"
max="{{ layoutPercentageSize.MAX }}"
required>
2022-09-20 18:09:25 +03:00
<input *ngIf="layoutsFormGroup.get('type').value === layoutWidthType.FIXED"
formControlName="fixedWidth"
type="number"
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutFixedSize.MIN }}"
max="{{ layoutFixedSize.MAX }}"
required>
</div>
2022-04-05 13:56:44 +03:00
</div>
2022-07-27 13:56:11 +03:00
</div>
</div>
<div fxLayout="column" fxLayoutAlign="center center" fxLayoutGap="8px" *ngIf="isDividerLayout" style="width: 80%">
2022-09-20 18:09:25 +03:00
<mat-slider *ngIf="layoutsFormGroup.get('type').value === layoutWidthType.PERCENTAGE"
2022-08-19 13:57:49 +03:00
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutPercentageSize.MIN }}"
max="{{ layoutPercentageSize.MAX }}"
2022-08-19 13:57:49 +03:00
style="width: 100%;"
2022-08-22 13:28:38 +03:00
color="accent"
2023-02-23 19:01:53 +02:00
discrete
[displayWith]="formatSliderTooltipLabel.bind(this)"><input matSliderThumb formControlName="sliderPercentage"/>
2022-08-19 13:57:49 +03:00
</mat-slider>
2022-09-20 18:09:25 +03:00
<mat-slider *ngIf="layoutsFormGroup.get('type').value !== layoutWidthType.PERCENTAGE"
2022-08-19 13:57:49 +03:00
step="1"
2022-09-20 18:09:25 +03:00
min="{{ layoutFixedSize.MIN }}"
max="{{ layoutFixedSize.MAX }}"
2022-08-19 13:57:49 +03:00
style="width: 100%;"
2022-08-22 13:28:38 +03:00
color="accent"
2023-02-23 19:01:53 +02:00
discrete
[displayWith]="formatSliderTooltipLabel.bind(this)"><input matSliderThumb formControlName="sliderFixed"/>
2022-08-19 13:57:49 +03:00
</mat-slider>
<div fxLayout="row" fxLayoutAlign="space-between center" class="tb-hint tb-hint-group" style="width: 100%;">
2022-09-20 18:09:25 +03:00
<label>
{{layoutsFormGroup.get('type').value === layoutWidthType.PERCENTAGE ? layoutPercentageSize.MIN + '%' : layoutFixedSize.MIN + 'px'}}
</label>
<label>
{{layoutsFormGroup.get('type').value === layoutWidthType.PERCENTAGE ? layoutPercentageSize.MAX + '%' : layoutFixedSize.MAX + 'px'}}
</label>
2022-04-05 13:56:44 +03:00
</div>
</div>
2022-07-27 13:56:11 +03:00
</div>
</ng-template>
</div>
<div mat-dialog-actions fxLayoutAlign="end center">
<button mat-button
color="primary"
type="button"
(click)="cancel()" cdkFocusInitial>
{{ 'action.cancel' | translate }}
</button>
2020-10-14 12:32:07 +03:00
<button mat-raised-button color="primary"
type="submit"
2022-07-27 13:56:11 +03:00
[disabled]="layoutsFormGroup.invalid || !layoutsFormGroup.dirty">
2020-10-14 12:32:07 +03:00
{{ 'action.save' | translate }}
</button>
</div>
</form>