UI: liquid level widget additions and refactoring after review

This commit is contained in:
Dmitriymush 2023-10-25 10:01:14 +03:00
parent 0bab29c8ec
commit 40581d598a
18 changed files with 77 additions and 69 deletions

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -11,7 +11,7 @@
"resources": [], "resources": [],
"templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>", "templateHtml": "<tb-liquid-level-widget \n [ctx]=\"ctx\">\n</tb-liquid-level-widget>",
"templateCss": "", "templateCss": "",
"controllerScript": "self.onInit = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.onInit();\n }\n}\n\nself.onDataUpdated = function() {\n if (self.ctx.$scope.liquidLevelWidget) {\n self.ctx.$scope.liquidLevelWidget.update();\n }\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n", "controllerScript": "self.onInit = function() {\n}\n\nself.onDataUpdated = function() {\n self.ctx.$scope.liquidLevelWidget.update();\n}\n\nself.typeParameters = function() {\n return {\n maxDatasources: 1,\n maxDataKeys: 1,\n singleEntity: true\n };\n};\n\nself.onDestroy = function() {\n}\n\nself.actionSources = function() { \n return { \n 'cardClick': {\n name: 'widget-action.card-click',\n multiple: false \n } \n };\n}\n",
"settingsSchema": "{}", "settingsSchema": "{}",
"dataKeySettingsSchema": "{}\n", "dataKeySettingsSchema": "{}\n",
"settingsDirective": "tb-liquid-level-card-widget-settings", "settingsDirective": "tb-liquid-level-card-widget-settings",

View File

@ -72,7 +72,7 @@ import {
} from '@home/components/widget/config/basic/cards/progress-bar-basic-config.component'; } from '@home/components/widget/config/basic/cards/progress-bar-basic-config.component';
import { import {
LiquidLevelCardBasicConfigComponent LiquidLevelCardBasicConfigComponent
} from '@home/components/widget/config/basic/cards/liquid-level-card-basic-config.component'; } from '@home/components/widget/config/basic/indicator/liquid-level-card-basic-config.component';
@NgModule({ @NgModule({
declarations: [ declarations: [

View File

@ -199,12 +199,12 @@
<div class="tb-form-panel-title" translate>widgets.liquid-level-card.color-and-font</div> <div class="tb-form-panel-title" translate>widgets.liquid-level-card.color-and-font</div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.tank-color</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.tank-color</div>
<tb-color-settings formControlName="tankColor"> <tb-color-settings formControlName="tankColor" settingsKey="{{'widgets.liquid-level-card.tank-color' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.liquid-color</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.liquid-color</div>
<tb-color-settings formControlName="liquidColor"> <tb-color-settings formControlName="liquidColor" settingsKey="{{'widgets.liquid-level-card.liquid-color' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between" <div class="tb-form-row space-between"
@ -218,7 +218,7 @@
<tb-font-settings formControlName="valueFont" <tb-font-settings formControlName="valueFont"
[previewText]="valuePreviewFn"> [previewText]="valuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="valueColor"> <tb-color-settings formControlName="valueColor" settingsKey="{{'widgets.liquid-level-card.value' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -228,7 +228,7 @@
<tb-font-settings formControlName="volumeFont" <tb-font-settings formControlName="volumeFont"
[previewText]="totalVolumeValuePreviewFn"> [previewText]="totalVolumeValuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="volumeColor"> <tb-color-settings formControlName="volumeColor" settingsKey="{{'widgets.liquid-level-card.total-volume' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -236,7 +236,7 @@
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showBackgroundOverlay"> <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showBackgroundOverlay">
{{ 'widgets.liquid-level-card.background-overlay' | translate }} {{ 'widgets.liquid-level-card.background-overlay' | translate }}
</mat-slide-toggle> </mat-slide-toggle>
<tb-color-settings formControlName="backgroundOverlayColor"> <tb-color-settings formControlName="backgroundOverlayColor" settingsKey="{{'widgets.liquid-level-card.background-overlay' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -270,7 +270,7 @@
<tb-font-settings formControlName="tooltipLevelFont" <tb-font-settings formControlName="tooltipLevelFont"
[previewText]="tooltipValuePreviewFn"> [previewText]="tooltipValuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="tooltipLevelColor"> <tb-color-settings formControlName="tooltipLevelColor" settingsKey="{{'widgets.liquid-level-card.background-overlay' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -283,13 +283,13 @@
<tb-font-settings formControlName="tooltipDateFont" <tb-font-settings formControlName="tooltipDateFont"
[previewText]="datePreviewFn"> [previewText]="datePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="tooltipDateColor"> <tb-color-settings formControlName="tooltipDateColor" settingsKey="{{'widgets.value-card.date' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.tooltip-background</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.tooltip-background</div>
<tb-color-settings formControlName="tooltipBackgroundColor"> <tb-color-settings formControlName="tooltipBackgroundColor" settingsKey="{{'widgets.liquid-level-card.tooltip-background' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">

View File

@ -60,7 +60,6 @@ import { ImageCardsSelectComponent } from '@home/components/widget/lib/settings/
import { map, share, tap } from 'rxjs/operators'; import { map, share, tap } from 'rxjs/operators';
import { Observable, of, ReplaySubject } from 'rxjs'; import { Observable, of, ReplaySubject } from 'rxjs';
import { ResourcesService } from '@core/services/resources.service'; import { ResourcesService } from '@core/services/resources.service';
import { UnitInputComponent } from '@shared/components/unit-input.component';
import { UtilsService } from '@core/services/utils.service'; import { UtilsService } from '@core/services/utils.service';
@Component({ @Component({
@ -74,8 +73,6 @@ export class LiquidLevelCardBasicConfigComponent extends BasicWidgetConfigCompon
@ViewChild('shapesImageCardsSelect', { static: false }) shapesImageCardsSelect: ImageCardsSelectComponent; @ViewChild('shapesImageCardsSelect', { static: false }) shapesImageCardsSelect: ImageCardsSelectComponent;
@ViewChild('widgetUnits', { static: false }) widgetUnits: UnitInputComponent;
public get datasource(): Datasource { public get datasource(): Datasource {
if (this.widgetConfig.config.datasources && this.widgetConfig.config.datasources) { if (this.widgetConfig.config.datasources && this.widgetConfig.config.datasources) {
return this.widgetConfig.config.datasources[0]; return this.widgetConfig.config.datasources[0];
@ -88,18 +85,18 @@ export class LiquidLevelCardBasicConfigComponent extends BasicWidgetConfigCompon
const datasourceUnits = this.levelCardWidgetConfigForm.get('datasourceUnits').value; const datasourceUnits = this.levelCardWidgetConfigForm.get('datasourceUnits').value;
const layout: LevelCardLayout = this.levelCardWidgetConfigForm.get('layout').value; const layout: LevelCardLayout = this.levelCardWidgetConfigForm.get('layout').value;
const units = this.levelCardWidgetConfigForm.get('units').value; const units = this.levelCardWidgetConfigForm.get('units').value;
return !(datasourceUnits === CapacityUnits.percent && layout !== LevelCardLayout.absolute
|| (datasourceUnits === CapacityUnits.percent && units === CapacityUnits.percent)); if (layout === LevelCardLayout.absolute) {
return true;
}
return !(datasourceUnits === CapacityUnits.percent && units === CapacityUnits.percent);
} }
public get widgetUnitsInput(): boolean { public get widgetUnitsInput(): boolean {
const layout: LevelCardLayout = this.levelCardWidgetConfigForm.get('layout').value; const layout: LevelCardLayout = this.levelCardWidgetConfigForm.get('layout').value;
if (layout === LevelCardLayout.absolute) { return layout === LevelCardLayout.absolute;
const datasourceUnits = this.levelCardWidgetConfigForm.get('datasourceUnits').value;
return !(datasourceUnits === CapacityUnits.percent);
}
return false;
} }
public get displayTimewindowConfig(): boolean { public get displayTimewindowConfig(): boolean {
@ -343,8 +340,10 @@ export class LiquidLevelCardBasicConfigComponent extends BasicWidgetConfigCompon
} }
if (trigger === 'datasourceUnits' || trigger === 'layout' || trigger === 'units') { if (trigger === 'datasourceUnits' || trigger === 'layout' || trigger === 'units') {
if (datasourceUnits === CapacityUnits.percent && (layout !== LevelCardLayout.absolute) if (
|| (datasourceUnits === CapacityUnits.percent && units?.value === CapacityUnits.percent) datasourceUnits === CapacityUnits.percent &&
layout !== LevelCardLayout.absolute &&
(!units?.value || units?.value === CapacityUnits.percent)
) { ) {
volumeSource.disable({emitEvent: false}); volumeSource.disable({emitEvent: false});
this.levelCardWidgetConfigForm.get('volumeConstant').disable({emitEvent: false}); this.levelCardWidgetConfigForm.get('volumeConstant').disable({emitEvent: false});

View File

@ -44,7 +44,7 @@ import {
} from '@shared/models/widget-settings.models'; } from '@shared/models/widget-settings.models';
import { ResourcesService } from '@core/services/resources.service'; import { ResourcesService } from '@core/services/resources.service';
import { NULL_UUID } from '@shared/models/id/has-uuid'; import { NULL_UUID } from '@shared/models/id/has-uuid';
import { Component, Input, OnInit } from '@angular/core'; import { Component, ElementRef, Host, HostBinding, Input, OnInit } from '@angular/core';
import ITooltipsterInstance = JQueryTooltipster.ITooltipsterInstance; import ITooltipsterInstance = JQueryTooltipster.ITooltipsterInstance;
@ -54,6 +54,9 @@ import ITooltipsterInstance = JQueryTooltipster.ITooltipsterInstance;
}) })
export class LiquidLevelWidgetComponent implements OnInit { export class LiquidLevelWidgetComponent implements OnInit {
@HostBinding('style.width') width = '100%';
@HostBinding('style.height') height = '100%';
@Input() @Input()
ctx: WidgetContext; ctx: WidgetContext;
@ -93,22 +96,21 @@ export class LiquidLevelWidgetComponent implements OnInit {
widgetUnits: string; widgetUnits: string;
constructor() { constructor(@Host() private elementRef: ElementRef) {
} }
ngOnInit(): void { ngOnInit(): void {
this.ctx.$scope.liquidLevelWidget = this; this.ctx.$scope.liquidLevelWidget = this;
this.settings = {...levelCardDefaultSettings(), ...this.ctx.widgetConfig, ...this.ctx.settings}; this.settings = {...levelCardDefaultSettings(), ...this.ctx.widgetConfig, ...this.ctx.settings};
this.declareStyles(); this.declareStyles();
}
public onInit() {
this.getData().subscribe(data => { this.getData().subscribe(data => {
if (data) { if (data) {
const { svg, volume, units } = data; const { svg, volume, units } = data;
if (svg && isString(svg) && this.ctx.$container) { if (svg && isString(svg) && this.elementRef.nativeElement) {
this.ctx.$container.html(svg); const jQueryContainerElement = $(this.elementRef.nativeElement);
this.svg = this.ctx.$container.find('svg'); jQueryContainerElement.html(svg);
this.svg = jQueryContainerElement.find('svg');
this.svg.on('click', this.cardClick.bind(this)); this.svg.on('click', this.cardClick.bind(this));
this.createSVG(); this.createSVG();
this.createValueElement(); this.createValueElement();
@ -247,9 +249,10 @@ export class LiquidLevelWidgetComponent implements OnInit {
} }
private createValueElement(): void { private createValueElement(): void {
const containerOverlay = this.ctx.$container.find('.container-overlay'); const jQueryContainerElement = $(this.elementRef.nativeElement);
const percentageOverlay = this.ctx.$container.find('.percentage-overlay'); const containerOverlay = jQueryContainerElement.find('.container-overlay');
const absoluteOverlay = this.ctx.$container.find('.absolute-overlay'); const percentageOverlay = jQueryContainerElement.find('.percentage-overlay');
const absoluteOverlay = jQueryContainerElement.find('.absolute-overlay');
if (this.settings.layout === LevelCardLayout.absolute) { if (this.settings.layout === LevelCardLayout.absolute) {
this.overlayContainer = absoluteOverlay; this.overlayContainer = absoluteOverlay;
@ -350,8 +353,9 @@ export class LiquidLevelWidgetComponent implements OnInit {
private updateLevel(newY: number, percentage: number): void { private updateLevel(newY: number, percentage: number): void {
this.liquidColor.update(percentage); this.liquidColor.update(percentage);
const fill = this.ctx.$container.find('.tb-liquid-fill'); const jQueryContainerElement = $(this.elementRef.nativeElement);
const surfaces = this.ctx.$container.find('.tb-liquid-surface'); const fill = jQueryContainerElement.find('.tb-liquid-fill');
const surfaces = jQueryContainerElement.find('.tb-liquid-surface');
const surfacePositionAttr = this.shape !== Shapes.vCylinder ? 'y' : 'cy'; const surfacePositionAttr = this.shape !== Shapes.vCylinder ? 'y' : 'cy';
const animationSpeed = 500; const animationSpeed = 500;
@ -377,8 +381,9 @@ export class LiquidLevelWidgetComponent implements OnInit {
} }
private updateShapeColor(value: number): void { private updateShapeColor(value: number): void {
const shapeStrokes = this.ctx.$container.find('.tb-shape-stroke'); const jQueryContainerElement = $(this.elementRef.nativeElement);
const shapeFill = this.ctx.$container.find('.tb-shape-fill'); const shapeStrokes = jQueryContainerElement.find('.tb-shape-stroke');
const shapeFill = jQueryContainerElement.find('.tb-shape-fill');
this.tankColor.update(value); this.tankColor.update(value);
shapeStrokes.each((index, element) => { shapeStrokes.each((index, element) => {
@ -393,6 +398,7 @@ export class LiquidLevelWidgetComponent implements OnInit {
private updateValueElement(data: number, percentage: number): void { private updateValueElement(data: number, percentage: number): void {
let content: string; let content: string;
let container: JQuery<HTMLElement>; let container: JQuery<HTMLElement>;
const jQueryContainerElement = $(this.elementRef.nativeElement);
const value = convertLiters(data, this.widgetUnits as CapacityUnits, ConversionType.from) const value = convertLiters(data, this.widgetUnits as CapacityUnits, ConversionType.from)
.toFixed(this.settings.decimals || 0); .toFixed(this.settings.decimals || 0);
@ -412,12 +418,12 @@ export class LiquidLevelWidgetComponent implements OnInit {
const volumeTextStyle = cssTextFromInlineStyle({...inlineTextStyle(this.settings.volumeFont), const volumeTextStyle = cssTextFromInlineStyle({...inlineTextStyle(this.settings.volumeFont),
color: this.volumeColor.color}); color: this.volumeColor.color});
container = this.ctx.$container.find('.absolute-value-container'); container = jQueryContainerElement.find('.absolute-value-container');
content = createAbsoluteLayout({inputValue: value, volume}, content = createAbsoluteLayout({inputValue: value, volume},
{valueStyle: valueTextStyle, volumeStyle: volumeTextStyle}, this.widgetUnits); {valueStyle: valueTextStyle, volumeStyle: volumeTextStyle}, this.widgetUnits);
} else if (this.settings.layout === LevelCardLayout.percentage) { } else if (this.settings.layout === LevelCardLayout.percentage) {
container = this.ctx.$container.find('.percentage-value-container'); container = jQueryContainerElement.find('.percentage-value-container');
content = createPercentLayout(value, valueTextStyle); content = createPercentLayout(value, valueTextStyle);
} }

View File

@ -369,13 +369,14 @@ export const valueContainerStyleDefaults = cssTextFromInlineStyle({
'align-items': 'center', 'align-items': 'center',
'align-content': 'center', 'align-content': 'center',
'justify-content': 'center', 'justify-content': 'center',
'font-family': 'Roboto, Helvetica Neue, sans-serif'
}); });
export const valueTextStyleDefaults = 'letterSpacing: normal; font-style: normal; font-weight: 500; line-height: 100%;' + export const valueTextStyleDefaults = 'letter-spacing: normal; font-style: normal; font-weight: 500; line-height: 100%;' +
' font-size: 24px; font-family: Roboto; color: #000000DE'; ' font-size: 24px; font-family: Roboto, Helvetica Neue, sans-serif; color: #000000DE';
export const volumeTextStyleDefaults = 'letterSpacing: normal; font-style: normal; font-weight: 500;' + export const volumeTextStyleDefaults = 'letter-spacing: normal; font-style: normal; font-weight: 500;' +
' line-height: 100%; font-size: 14px; font-family: Roboto; color: rgba(0, 0, 0, 0.18)'; ' line-height: 100%; font-size: 14px; font-family: Roboto, Helvetica Neue, sans-serif; color: rgba(0, 0, 0, 0.18)';
export const createAbsoluteLayout = (values?: {inputValue: number | string; volume: number | string}, export const createAbsoluteLayout = (values?: {inputValue: number | string; volume: number | string},
styles?: {valueStyle: string; volumeStyle: string}, styles?: {valueStyle: string; volumeStyle: string},

View File

@ -158,12 +158,12 @@
<div class="tb-form-panel-title" translate>widgets.liquid-level-card.color-and-font</div> <div class="tb-form-panel-title" translate>widgets.liquid-level-card.color-and-font</div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.tank-color</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.tank-color</div>
<tb-color-settings formControlName="tankColor"> <tb-color-settings formControlName="tankColor" settingsKey="{{'widgets.liquid-level-card.tank-color' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.liquid-color</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.liquid-color</div>
<tb-color-settings formControlName="liquidColor"> <tb-color-settings formControlName="liquidColor" settingsKey="{{'widgets.liquid-level-card.liquid-color' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between" <div class="tb-form-row space-between"
@ -173,7 +173,7 @@
<tb-font-settings formControlName="valueFont" <tb-font-settings formControlName="valueFont"
[previewText]="valuePreviewFn"> [previewText]="valuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="valueColor"> <tb-color-settings formControlName="valueColor" settingsKey="{{'widgets.liquid-level-card.value' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -183,7 +183,7 @@
<tb-font-settings formControlName="volumeFont" <tb-font-settings formControlName="volumeFont"
[previewText]="totalVolumeValuePreviewFn"> [previewText]="totalVolumeValuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="volumeColor"> <tb-color-settings formControlName="volumeColor" settingsKey="{{'widgets.liquid-level-card.total-volume' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -191,7 +191,7 @@
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showBackgroundOverlay"> <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showBackgroundOverlay">
{{ 'widgets.liquid-level-card.background-overlay' | translate }} {{ 'widgets.liquid-level-card.background-overlay' | translate }}
</mat-slide-toggle> </mat-slide-toggle>
<tb-color-settings formControlName="backgroundOverlayColor"> <tb-color-settings formControlName="backgroundOverlayColor" settingsKey="{{'widgets.liquid-level-card.background-overlay' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -225,7 +225,7 @@
<tb-font-settings formControlName="tooltipLevelFont" <tb-font-settings formControlName="tooltipLevelFont"
[previewText]="tooltipValuePreviewFn"> [previewText]="tooltipValuePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="tooltipLevelColor"> <tb-color-settings formControlName="tooltipLevelColor" settingsKey="{{'widgets.liquid-level-card.level' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
@ -238,13 +238,13 @@
<tb-font-settings formControlName="tooltipDateFont" <tb-font-settings formControlName="tooltipDateFont"
[previewText]="datePreviewFn"> [previewText]="datePreviewFn">
</tb-font-settings> </tb-font-settings>
<tb-color-settings formControlName="tooltipDateColor"> <tb-color-settings formControlName="tooltipDateColor" settingsKey="{{'widgets.value-card.date' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">
<div class="fixed-title-width" translate>widgets.liquid-level-card.tooltip-background</div> <div class="fixed-title-width" translate>widgets.liquid-level-card.tooltip-background</div>
<tb-color-settings formControlName="tooltipBackgroundColor"> <tb-color-settings formControlName="tooltipBackgroundColor" settingsKey="{{'widgets.liquid-level-card.tooltip-background' | translate }}">
</tb-color-settings> </tb-color-settings>
</div> </div>
<div class="tb-form-row space-between"> <div class="tb-form-row space-between">

View File

@ -67,18 +67,18 @@ export class LiquidLevelCardWidgetSettingsComponent extends WidgetSettingsCompon
const datasourceUnits = this.levelCardWidgetSettingsForm.get('datasourceUnits').value; const datasourceUnits = this.levelCardWidgetSettingsForm.get('datasourceUnits').value;
const layout: LevelCardLayout = this.levelCardWidgetSettingsForm.get('layout').value; const layout: LevelCardLayout = this.levelCardWidgetSettingsForm.get('layout').value;
const widgetUnits = this.levelCardWidgetSettingsForm.get('units').value; const widgetUnits = this.levelCardWidgetSettingsForm.get('units').value;
return !(datasourceUnits === CapacityUnits.percent && layout !== LevelCardLayout.absolute
|| (datasourceUnits === CapacityUnits.percent && widgetUnits === CapacityUnits.percent)); if (layout === LevelCardLayout.absolute) {
return true;
}
return !(datasourceUnits === CapacityUnits.percent && widgetUnits === CapacityUnits.percent);
} }
public get widgetUnitsInput(): boolean { public get widgetUnitsInput(): boolean {
const layout: LevelCardLayout = this.levelCardWidgetSettingsForm.get('layout').value; const layout: LevelCardLayout = this.levelCardWidgetSettingsForm.get('layout').value;
if (layout === LevelCardLayout.absolute) { return layout === LevelCardLayout.absolute;
const datasourceUnits = this.levelCardWidgetSettingsForm.get('datasourceUnits').value;
return !(datasourceUnits === CapacityUnits.percent);
}
return false;
} }
public get datasource(): Datasource { public get datasource(): Datasource {
@ -239,8 +239,10 @@ export class LiquidLevelCardWidgetSettingsComponent extends WidgetSettingsCompon
} }
if (trigger === 'datasourceUnits' || trigger === 'layout' || trigger === 'units') { if (trigger === 'datasourceUnits' || trigger === 'layout' || trigger === 'units') {
if (datasourceUnits === CapacityUnits.percent && (layout !== LevelCardLayout.absolute) if (
|| (datasourceUnits === CapacityUnits.percent && widgetUnits?.value === CapacityUnits.percent) datasourceUnits === CapacityUnits.percent &&
layout !== LevelCardLayout.absolute &&
(!widgetUnits?.value || widgetUnits?.value === CapacityUnits.percent)
) { ) {
volumeSource.disable({emitEvent: false}); volumeSource.disable({emitEvent: false});
this.levelCardWidgetSettingsForm.get('volumeConstant').disable({emitEvent: false}); this.levelCardWidgetSettingsForm.get('volumeConstant').disable({emitEvent: false});

View File

@ -302,7 +302,7 @@ import {
} from '@home/components/widget/lib/settings/cards/progress-bar-widget-settings.component'; } from '@home/components/widget/lib/settings/cards/progress-bar-widget-settings.component';
import { import {
LiquidLevelCardWidgetSettingsComponent LiquidLevelCardWidgetSettingsComponent
} from '@home/components/widget/lib/settings/cards/liquid-level-card-widget-settings.component'; } from '@home/components/widget/lib/settings/indicator/liquid-level-card-widget-settings.component';
@NgModule({ @NgModule({
declarations: [ declarations: [