Merge pull request #11320 from d2eight/card-padding
[Widgets] - Adding card-padding setting
This commit is contained in:
commit
bbc3e904c8
@ -126,6 +126,12 @@
|
|||||||
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<tb-widget-actions-panel
|
<tb-widget-actions-panel
|
||||||
formControlName="actions">
|
formControlName="actions">
|
||||||
|
|||||||
@ -144,6 +144,7 @@ export class ValueCardBasicConfigComponent extends BasicWidgetConfigComponent {
|
|||||||
|
|
||||||
cardButtons: [this.getCardButtons(configData.config), []],
|
cardButtons: [this.getCardButtons(configData.config), []],
|
||||||
borderRadius: [configData.config.borderRadius, []],
|
borderRadius: [configData.config.borderRadius, []],
|
||||||
|
padding: [settings.padding, []],
|
||||||
|
|
||||||
actions: [configData.config.actions || {}, []]
|
actions: [configData.config.actions || {}, []]
|
||||||
});
|
});
|
||||||
@ -183,6 +184,7 @@ export class ValueCardBasicConfigComponent extends BasicWidgetConfigComponent {
|
|||||||
|
|
||||||
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
||||||
this.widgetConfig.config.borderRadius = config.borderRadius;
|
this.widgetConfig.config.borderRadius = config.borderRadius;
|
||||||
|
this.widgetConfig.config.settings.padding = config.padding;
|
||||||
|
|
||||||
this.widgetConfig.config.actions = config.actions;
|
this.widgetConfig.config.actions = config.actions;
|
||||||
return this.widgetConfig;
|
return this.widgetConfig;
|
||||||
|
|||||||
@ -94,6 +94,12 @@
|
|||||||
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<tb-widget-actions-panel
|
<tb-widget-actions-panel
|
||||||
formControlName="actions">
|
formControlName="actions">
|
||||||
|
|||||||
@ -79,6 +79,7 @@ export class StatusWidgetBasicConfigComponent extends BasicWidgetConfigComponent
|
|||||||
|
|
||||||
cardButtons: [this.getCardButtons(configData.config), []],
|
cardButtons: [this.getCardButtons(configData.config), []],
|
||||||
borderRadius: [configData.config.borderRadius, []],
|
borderRadius: [configData.config.borderRadius, []],
|
||||||
|
padding: [settings.padding, []],
|
||||||
|
|
||||||
actions: [configData.config.actions || {}, []]
|
actions: [configData.config.actions || {}, []]
|
||||||
});
|
});
|
||||||
@ -99,6 +100,7 @@ export class StatusWidgetBasicConfigComponent extends BasicWidgetConfigComponent
|
|||||||
|
|
||||||
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
||||||
this.widgetConfig.config.borderRadius = config.borderRadius;
|
this.widgetConfig.config.borderRadius = config.borderRadius;
|
||||||
|
this.widgetConfig.config.settings.padding = config.padding;
|
||||||
|
|
||||||
this.widgetConfig.config.actions = config.actions;
|
this.widgetConfig.config.actions = config.actions;
|
||||||
return this.widgetConfig;
|
return this.widgetConfig;
|
||||||
|
|||||||
@ -211,6 +211,12 @@
|
|||||||
<tb-background-settings formControlName="background">
|
<tb-background-settings formControlName="background">
|
||||||
</tb-background-settings>
|
</tb-background-settings>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
<div class="tb-form-row space-between column-lt-md">
|
<div class="tb-form-row space-between column-lt-md">
|
||||||
<div translate>widget-config.show-card-buttons</div>
|
<div translate>widget-config.show-card-buttons</div>
|
||||||
<mat-chip-listbox multiple formControlName="cardButtons">
|
<mat-chip-listbox multiple formControlName="cardButtons">
|
||||||
|
|||||||
@ -108,6 +108,7 @@ export class SingleSwitchBasicConfigComponent extends BasicWidgetConfigComponent
|
|||||||
|
|
||||||
cardButtons: [this.getCardButtons(configData.config), []],
|
cardButtons: [this.getCardButtons(configData.config), []],
|
||||||
borderRadius: [configData.config.borderRadius, []],
|
borderRadius: [configData.config.borderRadius, []],
|
||||||
|
padding: [settings.padding, []],
|
||||||
|
|
||||||
actions: [configData.config.actions || {}, []]
|
actions: [configData.config.actions || {}, []]
|
||||||
});
|
});
|
||||||
@ -159,6 +160,7 @@ export class SingleSwitchBasicConfigComponent extends BasicWidgetConfigComponent
|
|||||||
|
|
||||||
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
||||||
this.widgetConfig.config.borderRadius = config.borderRadius;
|
this.widgetConfig.config.borderRadius = config.borderRadius;
|
||||||
|
this.widgetConfig.config.settings.padding = config.padding;
|
||||||
|
|
||||||
this.widgetConfig.config.actions = config.actions;
|
this.widgetConfig.config.actions = config.actions;
|
||||||
return this.widgetConfig;
|
return this.widgetConfig;
|
||||||
|
|||||||
@ -208,6 +208,12 @@
|
|||||||
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
<input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<tb-widget-actions-panel
|
<tb-widget-actions-panel
|
||||||
formControlName="actions">
|
formControlName="actions">
|
||||||
|
|||||||
@ -147,6 +147,7 @@ export class WindSpeedDirectionBasicConfigComponent extends BasicWidgetConfigCom
|
|||||||
|
|
||||||
cardButtons: [this.getCardButtons(configData.config), []],
|
cardButtons: [this.getCardButtons(configData.config), []],
|
||||||
borderRadius: [configData.config.borderRadius, []],
|
borderRadius: [configData.config.borderRadius, []],
|
||||||
|
padding: [settings.padding, []],
|
||||||
|
|
||||||
actions: [configData.config.actions || {}, []]
|
actions: [configData.config.actions || {}, []]
|
||||||
});
|
});
|
||||||
@ -198,6 +199,7 @@ export class WindSpeedDirectionBasicConfigComponent extends BasicWidgetConfigCom
|
|||||||
|
|
||||||
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
this.setCardButtons(config.cardButtons, this.widgetConfig.config);
|
||||||
this.widgetConfig.config.borderRadius = config.borderRadius;
|
this.widgetConfig.config.borderRadius = config.borderRadius;
|
||||||
|
this.widgetConfig.config.settings.padding = config.padding;
|
||||||
|
|
||||||
this.widgetConfig.config.actions = config.actions;
|
this.widgetConfig.config.actions = config.actions;
|
||||||
return this.widgetConfig;
|
return this.widgetConfig;
|
||||||
|
|||||||
@ -15,41 +15,41 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<div #valueCardPanel class="tb-value-card-panel" [class]="this.layout" [style]="backgroundStyle$ | async">
|
<div #valueCardPanel class="tb-value-card-panel" [class]="this.layout" [style.padding]="padding" [style]="backgroundStyle$ | async">
|
||||||
<div class="tb-value-card-overlay" [style]="overlayStyle"></div>
|
<div class="tb-value-card-overlay" [style]="overlayStyle"></div>
|
||||||
<div class="tb-value-card-title-panel">
|
<div class="tb-value-card-title-panel">
|
||||||
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div #valueCardContent class="tb-value-card-content" [class]="this.layout">
|
<div #valueCardContent class="tb-value-card-content" [class]="this.layout">
|
||||||
<ng-container [ngSwitch]="layout">
|
<ng-container [ngSwitch]="layout">
|
||||||
<ng-template [ngSwitchCase]="valueCardLayout.square">
|
<ng-template [ngSwitchCase]="valueCardLayout.square">
|
||||||
<ng-container *ngTemplateOutlet="iconWithLabelTpl"></ng-container>
|
<ng-container *ngTemplateOutlet="iconWithLabelTpl"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template [ngSwitchCase]="valueCardLayout.vertical">
|
|
||||||
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
|
||||||
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
|
||||||
<ng-container *ngTemplateOutlet="iconTpl"></ng-container>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template [ngSwitchCase]="valueCardLayout.centered">
|
|
||||||
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
|
||||||
<div class="tb-value-card-icon-row">
|
|
||||||
<ng-container *ngTemplateOutlet="iconTpl"></ng-container>
|
|
||||||
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
||||||
</div>
|
</ng-template>
|
||||||
<ng-container *ngTemplateOutlet="dateTpl"></ng-container>
|
<ng-template [ngSwitchCase]="valueCardLayout.vertical">
|
||||||
</ng-template>
|
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
||||||
<ng-template [ngSwitchCase]="valueCardLayout.simplified">
|
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
<ng-container *ngTemplateOutlet="iconTpl"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
</ng-template>
|
||||||
</ng-template>
|
<ng-template [ngSwitchCase]="valueCardLayout.centered">
|
||||||
<ng-template [ngSwitchCase]="layout === valueCardLayout.horizontal ||
|
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
||||||
layout === valueCardLayout.horizontal_reversed ? layout : ''">
|
<div class="tb-value-card-icon-row">
|
||||||
<ng-container *ngTemplateOutlet="iconWithLabelTpl"></ng-container>
|
<ng-container *ngTemplateOutlet="iconTpl"></ng-container>
|
||||||
<div fxFlex></div>
|
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
</div>
|
||||||
</ng-template>
|
<ng-container *ngTemplateOutlet="dateTpl"></ng-container>
|
||||||
</ng-container>
|
</ng-template>
|
||||||
|
<ng-template [ngSwitchCase]="valueCardLayout.simplified">
|
||||||
|
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
||||||
|
<ng-container *ngTemplateOutlet="labelTpl"></ng-container>
|
||||||
|
</ng-template>
|
||||||
|
<ng-template [ngSwitchCase]="layout === valueCardLayout.horizontal ||
|
||||||
|
layout === valueCardLayout.horizontal_reversed ? layout : ''">
|
||||||
|
<ng-container *ngTemplateOutlet="iconWithLabelTpl"></ng-container>
|
||||||
|
<div fxFlex></div>
|
||||||
|
<ng-container *ngTemplateOutlet="valueTpl"></ng-container>
|
||||||
|
</ng-template>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #iconWithLabelTpl>
|
<ng-template #iconWithLabelTpl>
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import {
|
|||||||
getSingleTsValue,
|
getSingleTsValue,
|
||||||
iconStyle,
|
iconStyle,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
|
resolveCssSize,
|
||||||
textStyle
|
textStyle
|
||||||
} from '@shared/models/widget-settings.models';
|
} from '@shared/models/widget-settings.models';
|
||||||
import { valueCardDefaultSettings, ValueCardLayout, ValueCardWidgetSettings } from './value-card-widget.models';
|
import { valueCardDefaultSettings, ValueCardLayout, ValueCardWidgetSettings } from './value-card-widget.models';
|
||||||
@ -48,7 +49,6 @@ import { ImagePipe } from '@shared/pipe/image.pipe';
|
|||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
|
||||||
const squareLayoutSize = 160;
|
const squareLayoutSize = 160;
|
||||||
const squareLayoutPadding = 48;
|
|
||||||
const horizontalLayoutHeight = 80;
|
const horizontalLayoutHeight = 80;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -96,6 +96,7 @@ export class ValueCardWidgetComponent implements OnInit, AfterViewInit, OnDestro
|
|||||||
|
|
||||||
backgroundStyle$: Observable<ComponentStyle>;
|
backgroundStyle$: Observable<ComponentStyle>;
|
||||||
overlayStyle: ComponentStyle = {};
|
overlayStyle: ComponentStyle = {};
|
||||||
|
padding: string;
|
||||||
|
|
||||||
private panelResize$: ResizeObserver;
|
private panelResize$: ResizeObserver;
|
||||||
|
|
||||||
@ -148,6 +149,7 @@ export class ValueCardWidgetComponent implements OnInit, AfterViewInit, OnDestro
|
|||||||
|
|
||||||
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
||||||
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
||||||
|
this.padding = this.settings.background.overlay.enabled ? undefined : this.settings.padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngAfterViewInit() {
|
public ngAfterViewInit() {
|
||||||
@ -199,8 +201,13 @@ export class ValueCardWidgetComponent implements OnInit, AfterViewInit, OnDestro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onResize() {
|
private onResize() {
|
||||||
const panelWidth = this.valueCardPanel.nativeElement.getBoundingClientRect().width - squareLayoutPadding;
|
const computedStyle = getComputedStyle(this.valueCardPanel.nativeElement);
|
||||||
const panelHeight = this.valueCardPanel.nativeElement.getBoundingClientRect().height - (this.horizontal ? 0 : squareLayoutPadding);
|
const [pLeft, pRight, pTop, pBottom] = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']
|
||||||
|
.map(side => resolveCssSize(computedStyle[side])[0]);
|
||||||
|
|
||||||
|
const widgetBoundingClientRect = this.valueCardPanel.nativeElement.getBoundingClientRect();
|
||||||
|
const panelWidth = widgetBoundingClientRect.width - (pLeft + pRight);
|
||||||
|
const panelHeight = widgetBoundingClientRect.height - (pTop + pBottom);
|
||||||
let scale: number;
|
let scale: number;
|
||||||
if (!this.horizontal) {
|
if (!this.horizontal) {
|
||||||
const size = Math.min(panelWidth, panelHeight);
|
const size = Math.min(panelWidth, panelHeight);
|
||||||
|
|||||||
@ -19,8 +19,10 @@ import {
|
|||||||
BackgroundType,
|
BackgroundType,
|
||||||
ColorSettings,
|
ColorSettings,
|
||||||
constantColor,
|
constantColor,
|
||||||
cssUnit, DateFormatSettings,
|
cssUnit,
|
||||||
Font, lastUpdateAgoDateFormat
|
DateFormatSettings,
|
||||||
|
Font,
|
||||||
|
lastUpdateAgoDateFormat
|
||||||
} from '@shared/models/widget-settings.models';
|
} from '@shared/models/widget-settings.models';
|
||||||
|
|
||||||
export enum ValueCardLayout {
|
export enum ValueCardLayout {
|
||||||
@ -80,6 +82,7 @@ export interface ValueCardWidgetSettings {
|
|||||||
dateFont: Font;
|
dateFont: Font;
|
||||||
dateColor: ColorSettings;
|
dateColor: ColorSettings;
|
||||||
background: BackgroundSettings;
|
background: BackgroundSettings;
|
||||||
|
padding: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const valueCardDefaultSettings = (horizontal: boolean): ValueCardWidgetSettings => ({
|
export const valueCardDefaultSettings = (horizontal: boolean): ValueCardWidgetSettings => ({
|
||||||
@ -128,5 +131,6 @@ export const valueCardDefaultSettings = (horizontal: boolean): ValueCardWidgetSe
|
|||||||
color: 'rgba(255,255,255,0.72)',
|
color: 'rgba(255,255,255,0.72)',
|
||||||
blur: 3
|
blur: 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
padding: ''
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
<div class="tb-status-widget-title-panel">
|
<div class="tb-status-widget-title-panel">
|
||||||
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div #statusWidgetContent class="tb-status-widget-content" [class]="this.layout">
|
<div #statusWidgetContent class="tb-status-widget-content" [class]="this.layout" [style.padding]="padding">
|
||||||
<div class="tb-status-widget-icon-container">
|
<div class="tb-status-widget-icon-container">
|
||||||
<tb-icon [style]="iconStyle">{{ icon }}</tb-icon>
|
<tb-icon [style]="iconStyle">{{ icon }}</tb-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -21,14 +21,16 @@ import {
|
|||||||
ElementRef,
|
ElementRef,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
Renderer2, ViewChild,
|
Renderer2,
|
||||||
|
ViewChild,
|
||||||
ViewEncapsulation
|
ViewEncapsulation
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { BasicActionWidgetComponent } from '@home/components/widget/lib/action/action-widget.models';
|
import { BasicActionWidgetComponent } from '@home/components/widget/lib/action/action-widget.models';
|
||||||
import {
|
import {
|
||||||
statusWidgetDefaultSettings,
|
statusWidgetDefaultSettings,
|
||||||
StatusWidgetLayout,
|
StatusWidgetLayout,
|
||||||
StatusWidgetSettings, StatusWidgetStateSettings
|
StatusWidgetSettings,
|
||||||
|
StatusWidgetStateSettings
|
||||||
} from '@home/components/widget/lib/indicator/status-widget.models';
|
} from '@home/components/widget/lib/indicator/status-widget.models';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
@ -36,12 +38,12 @@ import {
|
|||||||
ComponentStyle,
|
ComponentStyle,
|
||||||
iconStyle,
|
iconStyle,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
|
resolveCssSize,
|
||||||
textStyle
|
textStyle
|
||||||
} from '@shared/models/widget-settings.models';
|
} from '@shared/models/widget-settings.models';
|
||||||
import { ResizeObserver } from '@juggle/resize-observer';
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
import { ImagePipe } from '@shared/pipe/image.pipe';
|
import { ImagePipe } from '@shared/pipe/image.pipe';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { UtilsService } from '@core/services/utils.service';
|
|
||||||
import { ValueType } from '@shared/models/constants';
|
import { ValueType } from '@shared/models/constants';
|
||||||
|
|
||||||
const initialStatusWidgetSize = 147;
|
const initialStatusWidgetSize = 147;
|
||||||
@ -65,6 +67,7 @@ export class StatusWidgetComponent extends
|
|||||||
|
|
||||||
backgroundStyle$: Observable<ComponentStyle>;
|
backgroundStyle$: Observable<ComponentStyle>;
|
||||||
overlayStyle: ComponentStyle = {};
|
overlayStyle: ComponentStyle = {};
|
||||||
|
padding: string;
|
||||||
|
|
||||||
overlayInset = '12px';
|
overlayInset = '12px';
|
||||||
borderRadius = '';
|
borderRadius = '';
|
||||||
@ -101,9 +104,7 @@ export class StatusWidgetComponent extends
|
|||||||
constructor(protected imagePipe: ImagePipe,
|
constructor(protected imagePipe: ImagePipe,
|
||||||
protected sanitizer: DomSanitizer,
|
protected sanitizer: DomSanitizer,
|
||||||
private renderer: Renderer2,
|
private renderer: Renderer2,
|
||||||
private utils: UtilsService,
|
protected cd: ChangeDetectorRef) {
|
||||||
protected cd: ChangeDetectorRef,
|
|
||||||
private elementRef: ElementRef) {
|
|
||||||
super(cd);
|
super(cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +192,13 @@ export class StatusWidgetComponent extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onResize() {
|
private onResize() {
|
||||||
const panelWidth = this.statusWidgetPanel.nativeElement.getBoundingClientRect().width;
|
const computedStyle = getComputedStyle(this.statusWidgetPanel.nativeElement);
|
||||||
const panelHeight = this.statusWidgetPanel.nativeElement.getBoundingClientRect().height;
|
const [pLeft, pRight, pTop, pBottom] = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']
|
||||||
|
.map(side => resolveCssSize(computedStyle[side])[0]);
|
||||||
|
|
||||||
|
const widgetBoundingClientRect = this.statusWidgetPanel.nativeElement.getBoundingClientRect();
|
||||||
|
const panelWidth = widgetBoundingClientRect.width - (pLeft + pRight);
|
||||||
|
const panelHeight = widgetBoundingClientRect.height - (pTop + pBottom);
|
||||||
const targetSize = Math.min(panelWidth, panelHeight);
|
const targetSize = Math.min(panelWidth, panelHeight);
|
||||||
const scale = targetSize / initialStatusWidgetSize;
|
const scale = targetSize / initialStatusWidgetSize;
|
||||||
const width = initialStatusWidgetSize;
|
const width = initialStatusWidgetSize;
|
||||||
@ -220,6 +226,9 @@ export class StatusWidgetComponent extends
|
|||||||
this.showLabel = stateSettings.showLabel && this.layout !== StatusWidgetLayout.icon;
|
this.showLabel = stateSettings.showLabel && this.layout !== StatusWidgetLayout.icon;
|
||||||
this.showStatus = stateSettings.showStatus && this.layout !== StatusWidgetLayout.icon;
|
this.showStatus = stateSettings.showStatus && this.layout !== StatusWidgetLayout.icon;
|
||||||
this.icon = stateSettings.icon;
|
this.icon = stateSettings.icon;
|
||||||
|
this.padding = stateSettings.backgroundDisabled.overlay.enabled || stateSettings.background.overlay.enabled
|
||||||
|
? undefined
|
||||||
|
: this.settings.padding;
|
||||||
|
|
||||||
const primaryColor = disabled ? stateSettings.primaryColorDisabled : stateSettings.primaryColor;
|
const primaryColor = disabled ? stateSettings.primaryColorDisabled : stateSettings.primaryColor;
|
||||||
const secondaryColor = disabled ? stateSettings.secondaryColorDisabled : stateSettings.secondaryColor;
|
const secondaryColor = disabled ? stateSettings.secondaryColorDisabled : stateSettings.secondaryColor;
|
||||||
|
|||||||
@ -65,6 +65,7 @@ export interface StatusWidgetSettings {
|
|||||||
layout: StatusWidgetLayout;
|
layout: StatusWidgetLayout;
|
||||||
onState: StatusWidgetStateSettings;
|
onState: StatusWidgetStateSettings;
|
||||||
offState: StatusWidgetStateSettings;
|
offState: StatusWidgetStateSettings;
|
||||||
|
padding: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const statusWidgetDefaultSettings: StatusWidgetSettings = {
|
export const statusWidgetDefaultSettings: StatusWidgetSettings = {
|
||||||
@ -200,5 +201,6 @@ export const statusWidgetDefaultSettings: StatusWidgetSettings = {
|
|||||||
blur: 3
|
blur: 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
padding: ''
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<div #singleSwitchPanel class="tb-single-switch-panel" [class.auto-scale]="autoScale" [style.pointer-events]="ctx.isEdit ? 'none' : 'all'" [style]="backgroundStyle$ | async">
|
<div #singleSwitchPanel class="tb-single-switch-panel" [class.auto-scale]="autoScale" [style.pointer-events]="ctx.isEdit ? 'none' : 'all'" [style.padding]="padding" [style]="backgroundStyle$ | async">
|
||||||
<div class="tb-single-switch-overlay" [style]="overlayStyle" [style.inset]="overlayInset"></div>
|
<div class="tb-single-switch-overlay" [style]="overlayStyle" [style.inset]="overlayInset"></div>
|
||||||
<div class="tb-single-switch-title-panel">
|
<div class="tb-single-switch-title-panel">
|
||||||
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import {
|
|||||||
ComponentStyle,
|
ComponentStyle,
|
||||||
iconStyle,
|
iconStyle,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
|
resolveCssSize,
|
||||||
textStyle
|
textStyle
|
||||||
} from '@shared/models/widget-settings.models';
|
} from '@shared/models/widget-settings.models';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
@ -74,6 +75,7 @@ export class SingleSwitchWidgetComponent extends
|
|||||||
|
|
||||||
backgroundStyle$: Observable<ComponentStyle>;
|
backgroundStyle$: Observable<ComponentStyle>;
|
||||||
overlayStyle: ComponentStyle = {};
|
overlayStyle: ComponentStyle = {};
|
||||||
|
padding: string;
|
||||||
overlayInset = '12px';
|
overlayInset = '12px';
|
||||||
|
|
||||||
value = false;
|
value = false;
|
||||||
@ -123,6 +125,7 @@ export class SingleSwitchWidgetComponent extends
|
|||||||
|
|
||||||
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
||||||
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
||||||
|
this.padding = this.settings.background.overlay.enabled ? undefined : this.settings.padding;
|
||||||
|
|
||||||
this.layout = this.settings.layout;
|
this.layout = this.settings.layout;
|
||||||
|
|
||||||
@ -231,11 +234,15 @@ export class SingleSwitchWidgetComponent extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onResize() {
|
private onResize() {
|
||||||
const height = this.singleSwitchPanel.nativeElement.getBoundingClientRect().height;
|
const widgetBoundingClientRect = this.singleSwitchPanel.nativeElement.getBoundingClientRect();
|
||||||
|
const height = widgetBoundingClientRect.height;
|
||||||
const switchScale = height / initialSwitchHeight;
|
const switchScale = height / initialSwitchHeight;
|
||||||
const paddingScale = Math.min(switchScale, 1);
|
const paddingScale = Math.min(switchScale, 1);
|
||||||
const panelWidth = this.singleSwitchPanel.nativeElement.getBoundingClientRect().width - (horizontalLayoutPadding * paddingScale);
|
const computedStyle = getComputedStyle(this.singleSwitchPanel.nativeElement);
|
||||||
const panelHeight = this.singleSwitchPanel.nativeElement.getBoundingClientRect().height - (verticalLayoutPadding * paddingScale);
|
const [pLeft, pRight, pTop, pBottom] = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']
|
||||||
|
.map(side => resolveCssSize(computedStyle[side])[0]);
|
||||||
|
const panelWidth = widgetBoundingClientRect.width - ((pLeft + pRight) || horizontalLayoutPadding * paddingScale);
|
||||||
|
const panelHeight = widgetBoundingClientRect.height - ((pTop + pBottom) || verticalLayoutPadding * paddingScale);
|
||||||
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'transform', `scale(1)`);
|
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'transform', `scale(1)`);
|
||||||
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'width', 'auto');
|
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'width', 'auto');
|
||||||
let contentWidth = this.singleSwitchToggleRow.nativeElement.getBoundingClientRect().width;
|
let contentWidth = this.singleSwitchToggleRow.nativeElement.getBoundingClientRect().width;
|
||||||
|
|||||||
@ -80,6 +80,7 @@ export interface SingleSwitchWidgetSettings {
|
|||||||
offLabelFont: Font;
|
offLabelFont: Font;
|
||||||
offLabelColor: string;
|
offLabelColor: string;
|
||||||
background: BackgroundSettings;
|
background: BackgroundSettings;
|
||||||
|
padding: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const singleSwitchDefaultSettings: SingleSwitchWidgetSettings = {
|
export const singleSwitchDefaultSettings: SingleSwitchWidgetSettings = {
|
||||||
@ -217,5 +218,6 @@ export const singleSwitchDefaultSettings: SingleSwitchWidgetSettings = {
|
|||||||
color: 'rgba(255,255,255,0.72)',
|
color: 'rgba(255,255,255,0.72)',
|
||||||
blur: 3
|
blur: 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
padding: ''
|
||||||
};
|
};
|
||||||
|
|||||||
@ -93,5 +93,11 @@
|
|||||||
<tb-background-settings formControlName="background">
|
<tb-background-settings formControlName="background">
|
||||||
</tb-background-settings>
|
</tb-background-settings>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@ -110,7 +110,8 @@ export class ValueCardWidgetSettingsComponent extends WidgetSettingsComponent {
|
|||||||
dateFont: [settings.dateFont, []],
|
dateFont: [settings.dateFont, []],
|
||||||
dateColor: [settings.dateColor, []],
|
dateColor: [settings.dateColor, []],
|
||||||
|
|
||||||
background: [settings.background, []]
|
background: [settings.background, []],
|
||||||
|
padding: [settings.padding, []]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -123,6 +123,12 @@
|
|||||||
<tb-background-settings formControlName="background">
|
<tb-background-settings formControlName="background">
|
||||||
</tb-background-settings>
|
</tb-background-settings>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tb-form-panel">
|
<div class="tb-form-panel">
|
||||||
<div class="tb-form-panel-title" translate>widgets.single-switch.switch</div>
|
<div class="tb-form-panel-title" translate>widgets.single-switch.switch</div>
|
||||||
|
|||||||
@ -102,7 +102,8 @@ export class SingleSwitchWidgetSettingsComponent extends WidgetSettingsComponent
|
|||||||
offLabelFont: [settings.offLabelFont, []],
|
offLabelFont: [settings.offLabelFont, []],
|
||||||
offLabelColor: [settings.offLabelColor, []],
|
offLabelColor: [settings.offLabelColor, []],
|
||||||
|
|
||||||
background: [settings.background, []]
|
background: [settings.background, []],
|
||||||
|
padding: [settings.padding, []]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,5 +78,11 @@
|
|||||||
[layout]="statusWidgetSettingsForm.get('layout').value"
|
[layout]="statusWidgetSettingsForm.get('layout').value"
|
||||||
formControlName="offState">
|
formControlName="offState">
|
||||||
</tb-status-widget-state-settings>
|
</tb-status-widget-state-settings>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@ -73,7 +73,8 @@ export class StatusWidgetSettingsComponent extends WidgetSettingsComponent {
|
|||||||
disabledState: [settings.disabledState, []],
|
disabledState: [settings.disabledState, []],
|
||||||
layout: [settings.layout, []],
|
layout: [settings.layout, []],
|
||||||
onState: [settings.onState, []],
|
onState: [settings.onState, []],
|
||||||
offState: [settings.offState, []]
|
offState: [settings.offState, []],
|
||||||
|
padding: [settings.padding, []]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,5 +100,11 @@
|
|||||||
<tb-background-settings formControlName="background">
|
<tb-background-settings formControlName="background">
|
||||||
</tb-background-settings>
|
</tb-background-settings>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tb-form-row space-between">
|
||||||
|
<div>{{ 'widget-config.card-padding' | translate }}</div>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
|
<input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@ -91,7 +91,8 @@ export class WindSpeedDirectionWidgetSettingsComponent extends WidgetSettingsCom
|
|||||||
|
|
||||||
arrowColor: [settings.arrowColor, []],
|
arrowColor: [settings.arrowColor, []],
|
||||||
|
|
||||||
background: [settings.background, []]
|
background: [settings.background, []],
|
||||||
|
padding: [settings.padding, []]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<div class="tb-wind-speed-direction-panel" [style]="backgroundStyle$ | async" [class.tb-wind-speed-direction-pointer]="hasCardClickAction" (click)="cardClick($event)">
|
<div class="tb-wind-speed-direction-panel" [style.padding]="padding" [style]="backgroundStyle$ | async" [class.tb-wind-speed-direction-pointer]="hasCardClickAction" (click)="cardClick($event)">
|
||||||
<div class="tb-wind-speed-direction-overlay" [style]="overlayStyle"></div>
|
<div class="tb-wind-speed-direction-overlay" [style]="overlayStyle"></div>
|
||||||
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
|
||||||
<div class="tb-wind-speed-direction-content">
|
<div class="tb-wind-speed-direction-content">
|
||||||
|
|||||||
@ -42,7 +42,6 @@ import {
|
|||||||
getSingleTsValueByDataKey,
|
getSingleTsValueByDataKey,
|
||||||
overlayStyle
|
overlayStyle
|
||||||
} from '@shared/models/widget-settings.models';
|
} from '@shared/models/widget-settings.models';
|
||||||
import { WidgetComponent } from '@home/components/widget/widget.component';
|
|
||||||
import { formatValue, isDefinedAndNotNull, isNumeric } from '@core/utils';
|
import { formatValue, isDefinedAndNotNull, isNumeric } from '@core/utils';
|
||||||
import { ResizeObserver } from '@juggle/resize-observer';
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
import { Path, Svg, SVG, Text } from '@svgdotjs/svg.js';
|
import { Path, Svg, SVG, Text } from '@svgdotjs/svg.js';
|
||||||
@ -92,6 +91,7 @@ export class WindSpeedDirectionWidgetComponent implements OnInit, OnDestroy, Aft
|
|||||||
|
|
||||||
backgroundStyle$: Observable<ComponentStyle>;
|
backgroundStyle$: Observable<ComponentStyle>;
|
||||||
overlayStyle: ComponentStyle = {};
|
overlayStyle: ComponentStyle = {};
|
||||||
|
padding: string;
|
||||||
|
|
||||||
shapeResize$: ResizeObserver;
|
shapeResize$: ResizeObserver;
|
||||||
|
|
||||||
@ -111,8 +111,7 @@ export class WindSpeedDirectionWidgetComponent implements OnInit, OnDestroy, Aft
|
|||||||
private windDirection = 0;
|
private windDirection = 0;
|
||||||
private centerValueText = 'N/A';
|
private centerValueText = 'N/A';
|
||||||
|
|
||||||
constructor(private widgetComponent: WidgetComponent,
|
constructor(private imagePipe: ImagePipe,
|
||||||
private imagePipe: ImagePipe,
|
|
||||||
private sanitizer: DomSanitizer,
|
private sanitizer: DomSanitizer,
|
||||||
private renderer: Renderer2,
|
private renderer: Renderer2,
|
||||||
private cd: ChangeDetectorRef) {
|
private cd: ChangeDetectorRef) {
|
||||||
@ -142,6 +141,7 @@ export class WindSpeedDirectionWidgetComponent implements OnInit, OnDestroy, Aft
|
|||||||
|
|
||||||
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
|
||||||
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
this.overlayStyle = overlayStyle(this.settings.background.overlay);
|
||||||
|
this.padding = this.settings.background.overlay.enabled ? undefined : this.settings.padding;
|
||||||
|
|
||||||
this.hasCardClickAction = this.ctx.actionsApi.getActionDescriptors('cardClick').length > 0;
|
this.hasCardClickAction = this.ctx.actionsApi.getActionDescriptors('cardClick').length > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { BatteryLevelLayout } from '@home/components/widget/lib/indicator/battery-level-widget.models';
|
|
||||||
import {
|
import {
|
||||||
BackgroundSettings,
|
BackgroundSettings,
|
||||||
BackgroundType,
|
BackgroundType,
|
||||||
@ -59,6 +58,7 @@ export interface WindSpeedDirectionWidgetSettings {
|
|||||||
minorTicksColor: string;
|
minorTicksColor: string;
|
||||||
minorTicksFont: Font;
|
minorTicksFont: Font;
|
||||||
background: BackgroundSettings;
|
background: BackgroundSettings;
|
||||||
|
padding: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const windSpeedDirectionDefaultSettings: WindSpeedDirectionWidgetSettings = {
|
export const windSpeedDirectionDefaultSettings: WindSpeedDirectionWidgetSettings = {
|
||||||
@ -101,5 +101,6 @@ export const windSpeedDirectionDefaultSettings: WindSpeedDirectionWidgetSettings
|
|||||||
color: 'rgba(255,255,255,0.72)',
|
color: 'rgba(255,255,255,0.72)',
|
||||||
blur: 3
|
blur: 3
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
padding: ''
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user