UI: New widget settings layout
This commit is contained in:
parent
cb75f8a430
commit
c6a5043382
@ -15,9 +15,43 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<button cdkOverlayOrigin #legendConfigPanelOrigin="cdkOverlayOrigin" [disabled]="disabled"
|
<form [formGroup]="legendConfigForm">
|
||||||
type="button"
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
||||||
mat-button mat-raised-button color="primary" (click)="openEditMode()">
|
fxLayoutGap="8px">
|
||||||
<mat-icon class="material-icons">toc</mat-icon>
|
<mat-form-field fxFlex>
|
||||||
<span translate>legend.settings</span>
|
<mat-label translate>legend.direction</mat-label>
|
||||||
</button>
|
<mat-select matInput formControlName="direction">
|
||||||
|
<mat-option *ngFor="let direction of legendDirections" [value]="direction">
|
||||||
|
{{ legendDirectionTranslations.get(legendDirection[direction]) | translate }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label translate>legend.position</mat-label>
|
||||||
|
<mat-select matInput formControlName="position">
|
||||||
|
<mat-option *ngFor="let pos of legendPositions" [value]="pos"
|
||||||
|
[disabled]="legendConfigForm.get('direction').value === legendDirection.row &&
|
||||||
|
(pos === legendPosition.left || pos === legendPosition.right)">
|
||||||
|
{{ legendPositionTranslations.get(legendPosition[pos]) | translate }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row wrap" fxLayoutAlign="space-between center" fxLayoutGap="8px">
|
||||||
|
<mat-checkbox formControlName="sortDataKeys" fxFlex="48">
|
||||||
|
{{ 'legend.sort-legend' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
<mat-checkbox formControlName="showMin" fxFlex="48">
|
||||||
|
{{ 'legend.show-min' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
<mat-checkbox formControlName="showMax" fxFlex="48">
|
||||||
|
{{ 'legend.show-max' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
<mat-checkbox formControlName="showAvg" fxFlex="48">
|
||||||
|
{{ 'legend.show-avg' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
<mat-checkbox formControlName="showTotal" fxFlex="48">
|
||||||
|
{{ 'legend.show-total' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|||||||
@ -17,30 +17,21 @@
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
Inject,
|
|
||||||
Injector,
|
|
||||||
Input,
|
Input,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
StaticProvider,
|
|
||||||
ViewChild,
|
|
||||||
ViewContainerRef
|
ViewContainerRef
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { isDefined } from '@core/utils';
|
||||||
import { CdkOverlayOrigin, ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
|
||||||
import { ComponentPortal } from '@angular/cdk/portal';
|
|
||||||
import { MediaBreakpoints } from '@shared/models/constants';
|
|
||||||
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
||||||
import { WINDOW } from '@core/services/window.service';
|
|
||||||
import { deepClone } from '@core/utils';
|
|
||||||
import { LegendConfig } from '@shared/models/widget.models';
|
|
||||||
import {
|
import {
|
||||||
LEGEND_CONFIG_PANEL_DATA,
|
LegendConfig,
|
||||||
LegendConfigPanelComponent,
|
LegendDirection,
|
||||||
LegendConfigPanelData
|
legendDirectionTranslationMap,
|
||||||
} from '@home/components/widget/legend-config-panel.component';
|
LegendPosition,
|
||||||
|
legendPositionTranslationMap
|
||||||
|
} from '@shared/models/widget.models';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
// @dynamic
|
// @dynamic
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-legend-config',
|
selector: 'tb-legend-config',
|
||||||
@ -58,105 +49,37 @@ export class LegendConfigComponent implements OnInit, OnDestroy, ControlValueAcc
|
|||||||
|
|
||||||
@Input() disabled: boolean;
|
@Input() disabled: boolean;
|
||||||
|
|
||||||
@ViewChild('legendConfigPanelOrigin') legendConfigPanelOrigin: CdkOverlayOrigin;
|
legendSettings: LegendConfig;
|
||||||
|
legendConfigForm: FormGroup;
|
||||||
|
legendDirection = LegendDirection;
|
||||||
|
legendDirections = Object.keys(LegendDirection);
|
||||||
|
legendDirectionTranslations = legendDirectionTranslationMap;
|
||||||
|
legendPosition = LegendPosition;
|
||||||
|
legendPositions = Object.keys(LegendPosition);
|
||||||
|
legendPositionTranslations = legendPositionTranslationMap;
|
||||||
|
|
||||||
innerValue: LegendConfig;
|
legendSettingsChangesSubscription: Subscription;
|
||||||
|
|
||||||
private propagateChange = (_: any) => {};
|
private propagateChange = (_: any) => {};
|
||||||
|
|
||||||
constructor(private overlay: Overlay,
|
constructor(public fb: FormBuilder,
|
||||||
public viewContainerRef: ViewContainerRef,
|
public viewContainerRef: ViewContainerRef) {
|
||||||
public breakpointObserver: BreakpointObserver,
|
|
||||||
@Inject(DOCUMENT) private document: Document,
|
|
||||||
@Inject(WINDOW) private window: Window) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.legendConfigForm = this.fb.group({
|
||||||
|
direction: [null, []],
|
||||||
|
position: [null, []],
|
||||||
|
sortDataKeys: [null, []],
|
||||||
|
showMin: [null, []],
|
||||||
|
showMax: [null, []],
|
||||||
|
showAvg: [null, []],
|
||||||
|
showTotal: [null, []]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
}
|
this.removeChangeSubscriptions();
|
||||||
|
|
||||||
openEditMode() {
|
|
||||||
if (this.disabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isGtSm = this.breakpointObserver.isMatched(MediaBreakpoints['gt-sm']);
|
|
||||||
const position = this.overlay.position();
|
|
||||||
const config = new OverlayConfig({
|
|
||||||
panelClass: 'tb-legend-config-panel',
|
|
||||||
backdropClass: 'cdk-overlay-transparent-backdrop',
|
|
||||||
hasBackdrop: isGtSm,
|
|
||||||
});
|
|
||||||
if (isGtSm) {
|
|
||||||
config.minWidth = '220px';
|
|
||||||
config.maxHeight = '300px';
|
|
||||||
const panelHeight = 220;
|
|
||||||
const panelWidth = 220;
|
|
||||||
const el = this.legendConfigPanelOrigin.elementRef.nativeElement;
|
|
||||||
const offset = el.getBoundingClientRect();
|
|
||||||
const scrollTop = this.window.pageYOffset || this.document.documentElement.scrollTop || this.document.body.scrollTop || 0;
|
|
||||||
const scrollLeft = this.window.pageXOffset || this.document.documentElement.scrollLeft || this.document.body.scrollLeft || 0;
|
|
||||||
const bottomY = offset.bottom - scrollTop;
|
|
||||||
const leftX = offset.left - scrollLeft;
|
|
||||||
let originX;
|
|
||||||
let originY;
|
|
||||||
let overlayX;
|
|
||||||
let overlayY;
|
|
||||||
const wHeight = this.document.documentElement.clientHeight;
|
|
||||||
const wWidth = this.document.documentElement.clientWidth;
|
|
||||||
if (bottomY + panelHeight > wHeight) {
|
|
||||||
originY = 'top';
|
|
||||||
overlayY = 'bottom';
|
|
||||||
} else {
|
|
||||||
originY = 'bottom';
|
|
||||||
overlayY = 'top';
|
|
||||||
}
|
|
||||||
if (leftX + panelWidth > wWidth) {
|
|
||||||
originX = 'end';
|
|
||||||
overlayX = 'end';
|
|
||||||
} else {
|
|
||||||
originX = 'start';
|
|
||||||
overlayX = 'start';
|
|
||||||
}
|
|
||||||
const connectedPosition: ConnectedPosition = {
|
|
||||||
originX,
|
|
||||||
originY,
|
|
||||||
overlayX,
|
|
||||||
overlayY
|
|
||||||
};
|
|
||||||
config.positionStrategy = position.flexibleConnectedTo(this.legendConfigPanelOrigin.elementRef)
|
|
||||||
.withPositions([connectedPosition]);
|
|
||||||
} else {
|
|
||||||
config.minWidth = '100%';
|
|
||||||
config.minHeight = '100%';
|
|
||||||
config.positionStrategy = position.global().top('0%').left('0%')
|
|
||||||
.right('0%').bottom('0%');
|
|
||||||
}
|
|
||||||
|
|
||||||
const overlayRef = this.overlay.create(config);
|
|
||||||
|
|
||||||
overlayRef.backdropClick().subscribe(() => {
|
|
||||||
overlayRef.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
const injector = this._createLegendConfigPanelInjector(
|
|
||||||
overlayRef,
|
|
||||||
{
|
|
||||||
legendConfig: deepClone(this.innerValue),
|
|
||||||
legendConfigUpdated: this.legendConfigUpdated.bind(this)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
overlayRef.attach(new ComponentPortal(LegendConfigPanelComponent, this.viewContainerRef, injector));
|
|
||||||
}
|
|
||||||
|
|
||||||
private _createLegendConfigPanelInjector(overlayRef: OverlayRef, data: LegendConfigPanelData): Injector {
|
|
||||||
const providers: StaticProvider[] = [
|
|
||||||
{provide: LEGEND_CONFIG_PANEL_DATA, useValue: data},
|
|
||||||
{provide: OverlayRef, useValue: overlayRef}
|
|
||||||
];
|
|
||||||
return Injector.create({parent: this.viewContainerRef.injector, providers});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
registerOnChange(fn: any): void {
|
||||||
@ -168,14 +91,45 @@ export class LegendConfigComponent implements OnInit, OnDestroy, ControlValueAcc
|
|||||||
|
|
||||||
setDisabledState(isDisabled: boolean): void {
|
setDisabledState(isDisabled: boolean): void {
|
||||||
this.disabled = isDisabled;
|
this.disabled = isDisabled;
|
||||||
|
if (this.disabled) {
|
||||||
|
this.legendConfigForm.disable({emitEvent: false});
|
||||||
|
} else {
|
||||||
|
this.legendConfigForm.enable({emitEvent: false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeChangeSubscriptions() {
|
||||||
|
if (this.legendSettingsChangesSubscription) {
|
||||||
|
this.legendSettingsChangesSubscription.unsubscribe();
|
||||||
|
this.legendSettingsChangesSubscription = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private createChangeSubscriptions() {
|
||||||
|
this.legendSettingsChangesSubscription = this.legendConfigForm.valueChanges.subscribe(
|
||||||
|
() => this.legendConfigUpdated()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeValue(obj: LegendConfig): void {
|
writeValue(obj: LegendConfig): void {
|
||||||
this.innerValue = obj;
|
this.legendSettings = obj;
|
||||||
|
this.removeChangeSubscriptions();
|
||||||
|
if (this.legendSettings) {
|
||||||
|
this.legendConfigForm.patchValue({
|
||||||
|
direction: this.legendSettings.direction,
|
||||||
|
position: this.legendSettings.position,
|
||||||
|
sortDataKeys: isDefined(this.legendSettings.sortDataKeys) ? this.legendSettings.sortDataKeys : false,
|
||||||
|
showMin: isDefined(this.legendSettings.showMin) ? this.legendSettings.showMin : false,
|
||||||
|
showMax: isDefined(this.legendSettings.showMax) ? this.legendSettings.showMax : false,
|
||||||
|
showAvg: isDefined(this.legendSettings.showAvg) ? this.legendSettings.showAvg : false,
|
||||||
|
showTotal: isDefined(this.legendSettings.showTotal) ? this.legendSettings.showTotal : false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.createChangeSubscriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private legendConfigUpdated(legendConfig: LegendConfig) {
|
private legendConfigUpdated() {
|
||||||
this.innerValue = legendConfig;
|
this.legendSettings = this.legendConfigForm.value;
|
||||||
this.propagateChange(this.innerValue);
|
this.propagateChange(this.legendSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,12 +292,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="{{ 'widget-config.settings' | translate }}">
|
<mat-tab label="{{ 'widget-config.settings' | translate }}">
|
||||||
<div class="mat-content mat-padding" fxLayout="column" fxLayoutGap="8px">
|
<div class="mat-content mat-padding" fxLayout="column">
|
||||||
<div [formGroup]="widgetSettings" fxLayout="column" fxLayoutGap="8px">
|
<div [formGroup]="widgetSettings" fxLayout="column">
|
||||||
<span translate>widget-config.general-settings</span>
|
<fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center">
|
<legend class="group-title" translate>widget-config.title</legend>
|
||||||
<div fxLayout="column" fxLayoutAlign="center" fxFlex.sm="40%" fxFlex.gt-sm="30%">
|
<mat-slide-toggle formControlName="showTitle">
|
||||||
<mat-form-field fxFlex class="mat-block">
|
{{ 'widget-config.display-title' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
||||||
|
fxLayoutGap="8px">
|
||||||
|
<mat-form-field fxFlex>
|
||||||
<mat-label translate>widget-config.title</mat-label>
|
<mat-label translate>widget-config.title</mat-label>
|
||||||
<input matInput formControlName="title">
|
<input matInput formControlName="title">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@ -306,7 +310,13 @@
|
|||||||
<input matInput formControlName="titleTooltip">
|
<input matInput formControlName="titleTooltip">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div fxFlex [fxShow]="widgetSettings.get('showTitle').value">
|
<mat-expansion-panel class="tb-settings">
|
||||||
|
<mat-expansion-panel-header>
|
||||||
|
<mat-panel-description fxLayoutAlign="end" translate>
|
||||||
|
widget-config.advanced-settings
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
<div fxFlex>
|
||||||
<tb-json-object-edit
|
<tb-json-object-edit
|
||||||
[editorStyle]="{minHeight: '100px'}"
|
[editorStyle]="{minHeight: '100px'}"
|
||||||
required
|
required
|
||||||
@ -314,20 +324,17 @@
|
|||||||
formControlName="titleStyle"
|
formControlName="titleStyle"
|
||||||
></tb-json-object-edit>
|
></tb-json-object-edit>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</mat-expansion-panel>
|
||||||
<div fxLayout="column" fxLayoutAlign="center" fxLayout.gt-md="row" fxLayoutAlign.gt-md="start center" fxFlex="100%"
|
<fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
|
||||||
fxLayoutGap="8px">
|
<legend class="group-title" translate>widget-config.title-icon</legend>
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
<mat-slide-toggle formControlName="showTitleIcon">
|
||||||
fxLayoutGap="8px" fxFlex.gt-md>
|
|
||||||
<mat-checkbox fxFlex formControlName="showTitleIcon">
|
|
||||||
{{ 'widget-config.display-icon' | translate }}
|
{{ 'widget-config.display-icon' | translate }}
|
||||||
</mat-checkbox>
|
</mat-slide-toggle>
|
||||||
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row wrap" fxLayoutAlign="start center"
|
||||||
|
fxLayoutGap="8px">
|
||||||
<tb-material-icon-select fxFlex
|
<tb-material-icon-select fxFlex
|
||||||
formControlName="titleIcon">
|
formControlName="titleIcon">
|
||||||
</tb-material-icon-select>
|
</tb-material-icon-select>
|
||||||
</div>
|
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
|
||||||
fxLayoutGap="8px" fxFlex.gt-md>
|
|
||||||
<tb-color-input fxFlex
|
<tb-color-input fxFlex
|
||||||
label="{{'widget-config.icon-color' | translate}}"
|
label="{{'widget-config.icon-color' | translate}}"
|
||||||
icon="format_color_fill"
|
icon="format_color_fill"
|
||||||
@ -339,29 +346,10 @@
|
|||||||
<input matInput formControlName="iconSize">
|
<input matInput formControlName="iconSize">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</fieldset>
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
</fieldset>
|
||||||
fxLayoutGap="8px">
|
<fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
|
||||||
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="8px" fxFlex.sm="40%" fxFlex.gt-sm="30%">
|
<legend class="group-title" translate>widget-config.widget-style</legend>
|
||||||
<mat-checkbox formControlName="showTitle">
|
|
||||||
{{ 'widget-config.display-title' | translate }}
|
|
||||||
</mat-checkbox>
|
|
||||||
<mat-checkbox formControlName="dropShadow">
|
|
||||||
{{ 'widget-config.drop-shadow' | translate }}
|
|
||||||
</mat-checkbox>
|
|
||||||
<mat-checkbox formControlName="enableFullscreen">
|
|
||||||
{{ 'widget-config.enable-fullscreen' | translate }}
|
|
||||||
</mat-checkbox>
|
|
||||||
</div>
|
|
||||||
<div fxFlex>
|
|
||||||
<tb-json-object-edit
|
|
||||||
[editorStyle]="{minHeight: '100px'}"
|
|
||||||
required
|
|
||||||
label="{{ 'widget-config.widget-style' | translate }}"
|
|
||||||
formControlName="widgetStyle"
|
|
||||||
></tb-json-object-edit>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div fxLayout="column" fxLayoutAlign="center" fxLayout.gt-md="row" fxLayoutAlign.gt-md="start center"
|
<div fxLayout="column" fxLayoutAlign="center" fxLayout.gt-md="row" fxLayoutAlign.gt-md="start center"
|
||||||
fxFlex="100%" fxLayoutGap="8px">
|
fxFlex="100%" fxLayoutGap="8px">
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
||||||
@ -391,6 +379,70 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<mat-slide-toggle formControlName="dropShadow">
|
||||||
|
{{ 'widget-config.drop-shadow' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
<mat-slide-toggle formControlName="enableFullscreen">
|
||||||
|
{{ 'widget-config.enable-fullscreen' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
<mat-expansion-panel class="tb-settings">
|
||||||
|
<mat-expansion-panel-header>
|
||||||
|
<mat-panel-description fxLayoutAlign="end" translate>
|
||||||
|
widget-config.advanced-settings
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
<div fxFlex>
|
||||||
|
<tb-json-object-edit
|
||||||
|
[editorStyle]="{minHeight: '100px'}"
|
||||||
|
required
|
||||||
|
label="{{ 'widget-config.widget-style' | translate }}"
|
||||||
|
formControlName="widgetStyle"
|
||||||
|
></tb-json-object-edit>
|
||||||
|
</div>
|
||||||
|
</mat-expansion-panel>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="fields-group fields-group-slider" fxLayout="column" fxLayoutGap="8px">
|
||||||
|
<legend class="group-title" translate>widget-config.legend</legend>
|
||||||
|
<mat-expansion-panel class="tb-settings">
|
||||||
|
<mat-expansion-panel-header fxLayout="row wrap">
|
||||||
|
<mat-panel-title>
|
||||||
|
<mat-slide-toggle formControlName="showLegend" (click)="$event.stopPropagation()" fxLayoutAlign="center">
|
||||||
|
{{ 'widget-config.display-legend' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
</mat-panel-title>
|
||||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate>
|
||||||
|
widget-config.advanced-settings
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
<tb-legend-config formControlName="legendConfig"></tb-legend-config>
|
||||||
|
</mat-expansion-panel>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset [formGroup]="layoutSettings" class="fields-group fields-group-slider" fxLayout="column" fxLayoutGap="8px">
|
||||||
|
<legend class="group-title" translate>widget-config.mobile-mode-settings</legend>
|
||||||
|
<mat-expansion-panel class="tb-settings">
|
||||||
|
<mat-expansion-panel-header>
|
||||||
|
<mat-panel-title>
|
||||||
|
<mat-slide-toggle formControlName="mobileHide" (click)="$event.stopPropagation()" fxLayoutAlign="center">
|
||||||
|
{{ 'widget-config.mobile-hide' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
</mat-panel-title>
|
||||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate>
|
||||||
|
widget-config.advanced-settings
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
||||||
|
fxLayoutGap="8px">
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label translate>widget-config.order</mat-label>
|
||||||
|
<input matInput formControlName="mobileOrder" type="number" step="1">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label translate>widget-config.height</mat-label>
|
||||||
|
<input matInput formControlName="mobileHeight" type="number" min="1" max="10" step="1">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</mat-expansion-panel>
|
||||||
|
</fieldset>
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
||||||
fxLayoutGap="8px">
|
fxLayoutGap="8px">
|
||||||
<mat-form-field fxFlex>
|
<mat-form-field fxFlex>
|
||||||
@ -402,34 +454,6 @@
|
|||||||
<input matInput formControlName="decimals" type="number" min="0" max="15" step="1">
|
<input matInput formControlName="decimals" type="number" min="0" max="15" step="1">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div [fxShow]="widgetType === widgetTypes.timeseries || widgetType === widgetTypes.latest"
|
|
||||||
fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
|
||||||
fxLayoutGap="8px" fxFlex="100%">
|
|
||||||
<mat-checkbox fxFlex.gt-xs formControlName="showLegend">
|
|
||||||
{{ 'widget-config.display-legend' | translate }}
|
|
||||||
</mat-checkbox>
|
|
||||||
<section fxFlex.gt-xs fxLayout="row" fxLayoutAlign="start center" style="margin-bottom: 16px;">
|
|
||||||
<tb-legend-config formControlName="legendConfig">
|
|
||||||
</tb-legend-config>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div [formGroup]="layoutSettings" fxLayout="column" fxLayoutGap="8px">
|
|
||||||
<span translate>widget-config.mobile-mode-settings</span>
|
|
||||||
<div fxLayout.xs="column" fxLayoutAlign.xs="center" fxLayout="row" fxLayoutAlign="start center"
|
|
||||||
fxLayoutGap="8px">
|
|
||||||
<mat-checkbox formControlName="mobileHide">
|
|
||||||
{{ 'widget-config.mobile-hide' | translate }}
|
|
||||||
</mat-checkbox>
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<mat-label translate>widget-config.order</mat-label>
|
|
||||||
<input matInput formControlName="mobileOrder" type="number" step="1">
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<mat-label translate>widget-config.height</mat-label>
|
|
||||||
<input matInput formControlName="mobileHeight" type="number" min="1" max="10" step="1">
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|||||||
@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
:host {
|
:host {
|
||||||
.tb-widget-config {
|
.tb-widget-config {
|
||||||
.tb-advanced-widget-config {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
.tb-advanced-widget-config {
|
.tb-advanced-widget-config {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@ -69,6 +66,25 @@
|
|||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.fields-group {
|
||||||
|
padding: 0 16px 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border: 1px groove rgba(0, 0, 0, .25);
|
||||||
|
border-radius: 4px;
|
||||||
|
legend {
|
||||||
|
color: rgba(0, 0, 0, .7);
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.fields-group-slider {
|
||||||
|
padding: 0;
|
||||||
|
legend {
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
.tb-settings {
|
||||||
|
padding: 0 16px 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +110,36 @@
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
.mat-expansion-panel {
|
.mat-expansion-panel {
|
||||||
|
&.tb-settings {
|
||||||
|
box-shadow: none;
|
||||||
|
.mat-content {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
.mat-expansion-panel-header {
|
||||||
|
padding: 0;
|
||||||
|
&:hover {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
.mat-expansion-indicator {
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.mat-expansion-panel-header-description {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.mat-expansion-panel-body{
|
||||||
|
padding: 0 0 16px;
|
||||||
|
}
|
||||||
|
.tb-json-object-panel {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.mat-checkbox-layout {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
.mat-checkbox-inner-container {
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
&.tb-datasources {
|
&.tb-datasources {
|
||||||
&.mat-expanded {
|
&.mat-expanded {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
@ -152,5 +198,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.mat-slide-toggle-content {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,11 +212,28 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
|
|||||||
showLegend: [null, []],
|
showLegend: [null, []],
|
||||||
legendConfig: [null, []]
|
legendConfig: [null, []]
|
||||||
});
|
});
|
||||||
|
this.widgetSettings.get('showTitle').valueChanges.subscribe((value: boolean) => {
|
||||||
|
if (value) {
|
||||||
|
this.widgetSettings.get('titleStyle').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('titleTooltip').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('showTitleIcon').enable({emitEvent: false});
|
||||||
|
} else {
|
||||||
|
this.widgetSettings.get('titleStyle').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('titleTooltip').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('showTitleIcon').patchValue(false);
|
||||||
|
this.widgetSettings.get('showTitleIcon').disable({emitEvent: false});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.widgetSettings.get('showTitleIcon').valueChanges.subscribe((value: boolean) => {
|
this.widgetSettings.get('showTitleIcon').valueChanges.subscribe((value: boolean) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.widgetSettings.get('titleIcon').enable({emitEvent: false});
|
this.widgetSettings.get('titleIcon').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconColor').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconSize').enable({emitEvent: false});
|
||||||
} else {
|
} else {
|
||||||
this.widgetSettings.get('titleIcon').disable({emitEvent: false});
|
this.widgetSettings.get('titleIcon').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconColor').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconSize').disable({emitEvent: false});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.widgetSettings.get('showLegend').valueChanges.subscribe((value: boolean) => {
|
this.widgetSettings.get('showLegend').valueChanges.subscribe((value: boolean) => {
|
||||||
@ -236,6 +253,10 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.removeChangeSubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
private removeChangeSubscriptions() {
|
private removeChangeSubscriptions() {
|
||||||
if (this.dataSettingsChangesSubscription) {
|
if (this.dataSettingsChangesSubscription) {
|
||||||
this.dataSettingsChangesSubscription.unsubscribe();
|
this.dataSettingsChangesSubscription.unsubscribe();
|
||||||
@ -376,7 +397,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
|
|||||||
iconColor: isDefined(config.iconColor) ? config.iconColor : 'rgba(0, 0, 0, 0.87)',
|
iconColor: isDefined(config.iconColor) ? config.iconColor : 'rgba(0, 0, 0, 0.87)',
|
||||||
iconSize: isDefined(config.iconSize) ? config.iconSize : '24px',
|
iconSize: isDefined(config.iconSize) ? config.iconSize : '24px',
|
||||||
titleTooltip: isDefined(config.titleTooltip) ? config.titleTooltip : '',
|
titleTooltip: isDefined(config.titleTooltip) ? config.titleTooltip : '',
|
||||||
showTitle: config.showTitle,
|
showTitle: isDefined(config.showTitle) ? config.showTitle : false,
|
||||||
dropShadow: isDefined(config.dropShadow) ? config.dropShadow : true,
|
dropShadow: isDefined(config.dropShadow) ? config.dropShadow : true,
|
||||||
enableFullscreen: isDefined(config.enableFullscreen) ? config.enableFullscreen : true,
|
enableFullscreen: isDefined(config.enableFullscreen) ? config.enableFullscreen : true,
|
||||||
backgroundColor: config.backgroundColor,
|
backgroundColor: config.backgroundColor,
|
||||||
@ -396,11 +417,25 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
|
|||||||
},
|
},
|
||||||
{emitEvent: false}
|
{emitEvent: false}
|
||||||
);
|
);
|
||||||
|
const showTitle: boolean = this.widgetSettings.get('showTitle').value;
|
||||||
|
if (showTitle) {
|
||||||
|
this.widgetSettings.get('titleTooltip').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('titleStyle').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('showTitleIcon').enable({emitEvent: false});
|
||||||
|
} else {
|
||||||
|
this.widgetSettings.get('titleTooltip').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('titleStyle').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('showTitleIcon').disable({emitEvent: false});
|
||||||
|
}
|
||||||
const showTitleIcon: boolean = this.widgetSettings.get('showTitleIcon').value;
|
const showTitleIcon: boolean = this.widgetSettings.get('showTitleIcon').value;
|
||||||
if (showTitleIcon) {
|
if (showTitleIcon) {
|
||||||
this.widgetSettings.get('titleIcon').enable({emitEvent: false});
|
this.widgetSettings.get('titleIcon').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconColor').enable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconSize').enable({emitEvent: false});
|
||||||
} else {
|
} else {
|
||||||
this.widgetSettings.get('titleIcon').disable({emitEvent: false});
|
this.widgetSettings.get('titleIcon').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconColor').disable({emitEvent: false});
|
||||||
|
this.widgetSettings.get('iconSize').disable({emitEvent: false});
|
||||||
}
|
}
|
||||||
const showLegend: boolean = this.widgetSettings.get('showLegend').value;
|
const showLegend: boolean = this.widgetSettings.get('showLegend').value;
|
||||||
if (showLegend) {
|
if (showLegend) {
|
||||||
|
|||||||
@ -3026,16 +3026,16 @@
|
|||||||
"title": "Title",
|
"title": "Title",
|
||||||
"title-tooltip": "Title Tooltip",
|
"title-tooltip": "Title Tooltip",
|
||||||
"general-settings": "General settings",
|
"general-settings": "General settings",
|
||||||
"display-title": "Display title",
|
"display-title": "Display widget title",
|
||||||
"drop-shadow": "Drop shadow",
|
"drop-shadow": "Drop shadow",
|
||||||
"enable-fullscreen": "Enable fullscreen",
|
"enable-fullscreen": "Allow fullscreen",
|
||||||
"background-color": "Background color",
|
"background-color": "Background color",
|
||||||
"text-color": "Text color",
|
"text-color": "Text color",
|
||||||
"padding": "Padding",
|
"padding": "Padding",
|
||||||
"margin": "Margin",
|
"margin": "Margin",
|
||||||
"widget-style": "Widget style",
|
"widget-style": "Widget style",
|
||||||
"title-style": "Title style",
|
"title-style": "Title style",
|
||||||
"mobile-mode-settings": "Mobile mode settings",
|
"mobile-mode-settings": "Mobile mode",
|
||||||
"order": "Order",
|
"order": "Order",
|
||||||
"height": "Height",
|
"height": "Height",
|
||||||
"mobile-hide": "Hide widget in mobile mode",
|
"mobile-hide": "Hide widget in mobile mode",
|
||||||
@ -3044,6 +3044,7 @@
|
|||||||
"timewindow": "Timewindow",
|
"timewindow": "Timewindow",
|
||||||
"use-dashboard-timewindow": "Use dashboard timewindow",
|
"use-dashboard-timewindow": "Use dashboard timewindow",
|
||||||
"display-timewindow": "Display timewindow",
|
"display-timewindow": "Display timewindow",
|
||||||
|
"legend": "Legend",
|
||||||
"display-legend": "Display legend",
|
"display-legend": "Display legend",
|
||||||
"datasources": "Datasources",
|
"datasources": "Datasources",
|
||||||
"maximum-datasources": "Maximum { count, plural, 1 {1 datasource is allowed.} other {# datasources are allowed} }",
|
"maximum-datasources": "Maximum { count, plural, 1 {1 datasource is allowed.} other {# datasources are allowed} }",
|
||||||
@ -3071,9 +3072,11 @@
|
|||||||
"delete-action": "Delete action",
|
"delete-action": "Delete action",
|
||||||
"delete-action-title": "Delete widget action",
|
"delete-action-title": "Delete widget action",
|
||||||
"delete-action-text": "Are you sure you want delete widget action with name '{{actionName}}'?",
|
"delete-action-text": "Are you sure you want delete widget action with name '{{actionName}}'?",
|
||||||
|
"title-icon": "Title icon",
|
||||||
"display-icon": "Display title icon",
|
"display-icon": "Display title icon",
|
||||||
"icon-color": "Icon color",
|
"icon-color": "Icon color",
|
||||||
"icon-size": "Icon size"
|
"icon-size": "Icon size",
|
||||||
|
"advanced-settings": "Advanced settings"
|
||||||
},
|
},
|
||||||
"widget-type": {
|
"widget-type": {
|
||||||
"import": "Import widget type",
|
"import": "Import widget type",
|
||||||
|
|||||||
@ -1631,7 +1631,7 @@
|
|||||||
"advanced": "Дополнительно",
|
"advanced": "Дополнительно",
|
||||||
"title": "Название",
|
"title": "Название",
|
||||||
"general-settings": "Общие настройки",
|
"general-settings": "Общие настройки",
|
||||||
"display-title": "Показать название",
|
"display-title": "Показать название на виджете",
|
||||||
"drop-shadow": "Тень",
|
"drop-shadow": "Тень",
|
||||||
"enable-fullscreen": "Во весь экран",
|
"enable-fullscreen": "Во весь экран",
|
||||||
"background-color": "Цвет фона",
|
"background-color": "Цвет фона",
|
||||||
@ -1640,7 +1640,7 @@
|
|||||||
"margin": "Margin",
|
"margin": "Margin",
|
||||||
"widget-style": "Стиль виджета",
|
"widget-style": "Стиль виджета",
|
||||||
"title-style": "Стиль названия",
|
"title-style": "Стиль названия",
|
||||||
"mobile-mode-settings": "Настройки мобильного режима",
|
"mobile-mode-settings": "Мобильный режим",
|
||||||
"order": "Порядок",
|
"order": "Порядок",
|
||||||
"height": "Высота",
|
"height": "Высота",
|
||||||
"units": "Специальный символ после значения",
|
"units": "Специальный символ после значения",
|
||||||
@ -1648,6 +1648,7 @@
|
|||||||
"timewindow": "Временное окно",
|
"timewindow": "Временное окно",
|
||||||
"use-dashboard-timewindow": "Использовать временное окно дашборда",
|
"use-dashboard-timewindow": "Использовать временное окно дашборда",
|
||||||
"display-timewindow": "Показывать временное окно",
|
"display-timewindow": "Показывать временное окно",
|
||||||
|
"legend": "Легенда",
|
||||||
"display-legend": "Показать легенду",
|
"display-legend": "Показать легенду",
|
||||||
"datasources": "Источники данных",
|
"datasources": "Источники данных",
|
||||||
"maximum-datasources": "Максимальной количество источников данных равно {{count}}",
|
"maximum-datasources": "Максимальной количество источников данных равно {{count}}",
|
||||||
@ -1673,9 +1674,11 @@
|
|||||||
"delete-action": "Удалить действие",
|
"delete-action": "Удалить действие",
|
||||||
"delete-action-title": "Удалить действие виджета",
|
"delete-action-title": "Удалить действие виджета",
|
||||||
"delete-action-text": "Вы точно хотите удалить действие виджета '{{actionName}}'?",
|
"delete-action-text": "Вы точно хотите удалить действие виджета '{{actionName}}'?",
|
||||||
"display-icon": "Показывать иконку в названии",
|
"title-icon": "Иконка в названии виджета",
|
||||||
|
"display-icon": "Показывать иконку в названии виджета",
|
||||||
"icon-color": "Цвет иконки",
|
"icon-color": "Цвет иконки",
|
||||||
"icon-size": "Размер иконки"
|
"icon-size": "Размер иконки",
|
||||||
|
"advanced-settings": "Расширенные настройки"
|
||||||
},
|
},
|
||||||
"widget-type": {
|
"widget-type": {
|
||||||
"import": "Импортировать тип виджета",
|
"import": "Импортировать тип виджета",
|
||||||
|
|||||||
@ -2202,7 +2202,7 @@
|
|||||||
"advanced": "Додатково",
|
"advanced": "Додатково",
|
||||||
"title": "Назва",
|
"title": "Назва",
|
||||||
"general-settings": "Загальні налаштування",
|
"general-settings": "Загальні налаштування",
|
||||||
"display-title": "Відобразити назву",
|
"display-title": "Відобразити назву у віджеті",
|
||||||
"drop-shadow": "Тінь",
|
"drop-shadow": "Тінь",
|
||||||
"enable-fullscreen": "Увімкнути повноекранний режим",
|
"enable-fullscreen": "Увімкнути повноекранний режим",
|
||||||
"enable-data-export": "Увімкнути експорт даних",
|
"enable-data-export": "Увімкнути експорт даних",
|
||||||
@ -2212,7 +2212,7 @@
|
|||||||
"margin": "Границі",
|
"margin": "Границі",
|
||||||
"widget-style": "Стиль віджетів",
|
"widget-style": "Стиль віджетів",
|
||||||
"title-style": "Стиль заголовка",
|
"title-style": "Стиль заголовка",
|
||||||
"mobile-mode-settings": "Налаштування мобільного режиму",
|
"mobile-mode-settings": "мобільний режим",
|
||||||
"order": "Порядок",
|
"order": "Порядок",
|
||||||
"height": "Висота",
|
"height": "Висота",
|
||||||
"units": "Спеціальний символ після значення",
|
"units": "Спеціальний символ після значення",
|
||||||
@ -2220,6 +2220,7 @@
|
|||||||
"timewindow": "Вікно часу",
|
"timewindow": "Вікно часу",
|
||||||
"use-dashboard-timewindow": "Використати вікно часу на панелі візуалізації",
|
"use-dashboard-timewindow": "Використати вікно часу на панелі візуалізації",
|
||||||
"display-timewindow": "Показувати вікно часу",
|
"display-timewindow": "Показувати вікно часу",
|
||||||
|
"legend": "Легенда",
|
||||||
"display-legend": "Показати легенду",
|
"display-legend": "Показати легенду",
|
||||||
"datasources": "Джерела даних",
|
"datasources": "Джерела даних",
|
||||||
"maximum-datasources": "Максимально { count, plural, 1 {1 дозволене джерело даних.} other {# дозволені джерела даних } }",
|
"maximum-datasources": "Максимально { count, plural, 1 {1 дозволене джерело даних.} other {# дозволені джерела даних } }",
|
||||||
@ -2245,9 +2246,11 @@
|
|||||||
"delete-action": "Видалити дію",
|
"delete-action": "Видалити дію",
|
||||||
"delete-action-title": "Видалити дію віджета",
|
"delete-action-title": "Видалити дію віджета",
|
||||||
"delete-action-text": "Ви впевнені, що хочете видалити дію віджета '{{actionName}}'?",
|
"delete-action-text": "Ви впевнені, що хочете видалити дію віджета '{{actionName}}'?",
|
||||||
"display-icon": "Показувати іконку у назві",
|
"title-icon": "Іконка у назві віджету",
|
||||||
|
"display-icon": "Показувати іконку у назві віджету",
|
||||||
"icon-color": "Колір іконки",
|
"icon-color": "Колір іконки",
|
||||||
"icon-size": "Розмір іконки"
|
"icon-size": "Розмір іконки",
|
||||||
|
"advanced-settings": "Розширені налаштування"
|
||||||
},
|
},
|
||||||
"widget-type": {
|
"widget-type": {
|
||||||
"import": "Імпортувати тип віджета",
|
"import": "Імпортувати тип віджета",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user