thingsboard/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html
2022-09-12 15:52:27 +03:00

181 lines
8.2 KiB
HTML

<!--
Copyright © 2016-2022 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>
<button mat-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 fxLayout="row" fxLayoutAlign="start center">
<mat-slide-toggle formControlName="right" color="accent">
{{ 'layout.divider' | translate }}
</mat-slide-toggle>
</div>
<div fxLayout="column" fxLayoutAlign="start center" fxLayoutGap="20px">
<mat-button-toggle-group aria-label="Select width value type"
formControlName="type"
[fxShow]="layoutsFormGroup.get('right').value">
<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">
<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"
aria-label="Layout settings"
[ngClass]="layoutButtonTextAndClass('main', false)">
<mat-icon>settings</mat-icon>
</button>
<button fxFlex
type="button"
mat-raised-button
color="primary"
class="tb-layout-button"
[matTooltip]="layoutButtonTextAndClass('main', true)"
matTooltipPosition="above"
matTooltipClass="tb-layout-button-tooltip"
(click)="setFixedLayout('main')"
[ngClass]="layoutButtonTextAndClass('main', false)"
[ngStyle]="layoutsFormGroup.get('right').value ?
{'border-radius': '5px 0 0 5px;'} :
{'border-radius': '5px 5px 5px 5px;'}">
<span>{{ (layoutsFormGroup.value.right ? 'layout.left' : 'layout.main') | translate }}</span>
</button>
<div fxFlex class="tb-layout-preview-element tb-layout-preview-input" [fxShow]="showPreviewInputs('main')">
<input [fxShow]="layoutsFormGroup.get('type').value !== LayoutWidthType.FIXED"
formControlName="leftWidthPercentage"
type="number"
step="1"
min="10"
max="90"
required>
<input [fxShow]="layoutsFormGroup.get('type').value === LayoutWidthType.FIXED"
*ngIf="layoutsFormGroup.get('fixedLayout').value === 'main'"
formControlName="fixedWidth"
type="number"
step="1"
min="150"
max="1700"
required>
</div>
</div>
<div fxLayout="column" fxLayoutAlign="start center" fxFlex [fxShow]="layoutsFormGroup.get('right').value" matTooltip="">
<button mat-icon-button
type="button"
matTooltip="{{ 'dashboard.layout-settings' | translate }}"
matTooltipPosition="above"
(click)="openLayoutSettings('right')"
class="tb-layout-preview-element"
aria-label="Layout settings"
[ngClass]="layoutButtonTextAndClass('right', false)">
<mat-icon>settings</mat-icon>
</button>
<button fxFlex
type="button"
mat-raised-button
color="primary"
class="tb-layout-button"
[matTooltip]="layoutButtonTextAndClass('right', true)"
matTooltipPosition="above"
matTooltipClass="tb-layout-button-tooltip"
(click)="setFixedLayout('right')"
[ngClass]="layoutButtonTextAndClass('right', false)"
style="border-radius: 0 5px 5px 0;">
<span>{{ 'layout.right' | translate }}</span>
</button>
<div fxFlex class="tb-layout-preview-element tb-layout-preview-input" [fxShow]="showPreviewInputs('right')">
<input [fxShow]="layoutsFormGroup.get('type').value !== LayoutWidthType.FIXED"
formControlName="rightWidthPercentage"
type="number"
step="1"
min="10"
max="90"
required>
<input [fxShow]="layoutsFormGroup.get('type').value === LayoutWidthType.FIXED"
formControlName="fixedWidth"
type="number"
step="1"
min="150"
max="1700"
required>
</div>
</div>
</div>
</div>
<div fxLayout="column" fxLayoutAlign="center center" fxLayoutGap="8px" [fxShow]="layoutsFormGroup.get('right').value" style="width: 80%">
<mat-slider [fxShow]="layoutsFormGroup.get('type').value === LayoutWidthType.PERCENTAGE"
min="10"
step="1"
max="90"
style="width: 100%;"
color="accent"
formControlName="sliderPercentage"
thumbLabel
[displayWith]="formatSliderTooltipLabel.bind(this)">
</mat-slider>
<mat-slider [fxShow]="layoutsFormGroup.get('type').value !== LayoutWidthType.PERCENTAGE"
min="150"
step="1"
max="1700"
style="width: 100%;"
color="accent"
formControlName="sliderFixed"
thumbLabel
[displayWith]="formatSliderTooltipLabel.bind(this)">
</mat-slider>
<div fxLayout="row" fxLayoutAlign="space-between center" class="tb-hint tb-hint-group" style="width: 100%;">
<label>{{layoutsFormGroup.get('type').value === LayoutWidthType.PERCENTAGE ? '10 %' : '150px'}}</label>
<label>{{layoutsFormGroup.get('type').value === LayoutWidthType.PERCENTAGE ? '90 %' : '1700px'}}</label>
</div>
</div>
</div>
</div>
<div mat-dialog-actions fxLayoutAlign="end center">
<button mat-button
color="primary"
type="button"
(click)="cancel()" cdkFocusInitial>
{{ 'action.cancel' | translate }}
</button>
<button mat-raised-button color="primary"
type="submit"
[disabled]="layoutsFormGroup.invalid || !layoutsFormGroup.dirty">
{{ 'action.save' | translate }}
</button>
</div>
</form>