UI: Fixed knob and digital gauge decimals setting
This commit is contained in:
parent
dfc0183c41
commit
a51600f30e
@ -30,7 +30,7 @@ import {
|
|||||||
getTimewindowConfig,
|
getTimewindowConfig,
|
||||||
setTimewindowConfig
|
setTimewindowConfig
|
||||||
} from '@home/components/widget/config/timewindow-config-panel.component';
|
} from '@home/components/widget/config/timewindow-config-panel.component';
|
||||||
import { formatValue, isUndefined } from '@core/utils';
|
import { formatValue, isDefinedAndNotNull, isUndefined } from '@core/utils';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
convertLevelColorsSettingsToColorProcessor,
|
convertLevelColorsSettingsToColorProcessor,
|
||||||
@ -115,7 +115,7 @@ export class DigitalSimpleGaugeBasicConfigComponent extends BasicWidgetConfigCom
|
|||||||
minMaxColor: [settings.minMaxFont?.color, []],
|
minMaxColor: [settings.minMaxFont?.color, []],
|
||||||
|
|
||||||
showValue: [settings.showValue, []],
|
showValue: [settings.showValue, []],
|
||||||
decimals: [configData.config.decimals, []],
|
decimals: [configData.config.decimals || settings.decimals, []],
|
||||||
units: [configData.config.units, []],
|
units: [configData.config.units, []],
|
||||||
valueFont: [settings.valueFont, []],
|
valueFont: [settings.valueFont, []],
|
||||||
valueColor: [settings.valueFont?.color, []],
|
valueColor: [settings.valueFont?.color, []],
|
||||||
@ -157,6 +157,9 @@ export class DigitalSimpleGaugeBasicConfigComponent extends BasicWidgetConfigCom
|
|||||||
this.widgetConfig.config.settings.showValue = config.showValue;
|
this.widgetConfig.config.settings.showValue = config.showValue;
|
||||||
this.widgetConfig.config.units = config.units;
|
this.widgetConfig.config.units = config.units;
|
||||||
this.widgetConfig.config.decimals = config.decimals;
|
this.widgetConfig.config.decimals = config.decimals;
|
||||||
|
if (isDefinedAndNotNull(this.widgetConfig.config.settings.decimals)) {
|
||||||
|
this.widgetConfig.config.settings.decimals = null;
|
||||||
|
}
|
||||||
this.widgetConfig.config.settings.valueFont = config.valueFont;
|
this.widgetConfig.config.settings.valueFont = config.valueFont;
|
||||||
this.widgetConfig.config.settings.valueFont.color = config.valueColor;
|
this.widgetConfig.config.settings.valueFont.color = config.valueColor;
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ export class KnobComponent extends BasicActionWidgetComponent implements OnInit,
|
|||||||
|
|
||||||
this.valueFormat = ValueFormatProcessor.fromSettings(this.ctx.$injector, {
|
this.valueFormat = ValueFormatProcessor.fromSettings(this.ctx.$injector, {
|
||||||
units: this.ctx.units,
|
units: this.ctx.units,
|
||||||
decimals: this.ctx.decimals,
|
decimals: this.ctx.decimals || 0,
|
||||||
showZeroDecimals: true
|
showZeroDecimals: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ export class KnobComponent extends BasicActionWidgetComponent implements OnInit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private turn(ratio: number) {
|
private turn(ratio: number) {
|
||||||
this.newValue = Number((this.minValue + (this.maxValue - this.minValue) * ratio).toFixed(this.ctx.decimals));
|
this.newValue = Number((this.minValue + (this.maxValue - this.minValue) * ratio).toFixed(this.ctx.decimals || 0));
|
||||||
if (this.canvasBar.value !== this.newValue) {
|
if (this.canvasBar.value !== this.newValue) {
|
||||||
this.canvasBar.value = this.newValue;
|
this.canvasBar.value = this.newValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ export class KnobControlWidgetSettingsComponent extends WidgetSettingsComponent
|
|||||||
|
|
||||||
protected prepareInputSettings(settings: WidgetSettings): WidgetSettings {
|
protected prepareInputSettings(settings: WidgetSettings): WidgetSettings {
|
||||||
const knobSettings = prepareKnobSettings(deepClone(settings) as any) as WidgetSettings;
|
const knobSettings = prepareKnobSettings(deepClone(settings) as any) as WidgetSettings;
|
||||||
knobSettings.valueDecimals = this.widgetConfig?.config?.decimals ?? 2;
|
knobSettings.valueDecimals = this.widgetConfig?.config?.decimals;
|
||||||
knobSettings.valueUnits = deepClone(this.widgetConfig?.config?.units);
|
knobSettings.valueUnits = deepClone(this.widgetConfig?.config?.units);
|
||||||
return super.prepareInputSettings(knobSettings);
|
return super.prepareInputSettings(knobSettings);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import {
|
|||||||
digitalGaugeLayoutTranslations,
|
digitalGaugeLayoutTranslations,
|
||||||
DigitalGaugeType
|
DigitalGaugeType
|
||||||
} from '@home/components/widget/lib/digital-gauge.models';
|
} from '@home/components/widget/lib/digital-gauge.models';
|
||||||
import { formatValue } from '@core/utils';
|
import { formatValue, isDefinedAndNotNull } from '@core/utils';
|
||||||
import {
|
import {
|
||||||
ColorSettings,
|
ColorSettings,
|
||||||
ColorType,
|
ColorType,
|
||||||
@ -247,6 +247,10 @@ export class DigitalGaugeWidgetSettingsComponent extends WidgetSettingsComponent
|
|||||||
settings.titleFont.color = this.digitalGaugeWidgetSettingsForm.get('titleColor').value;
|
settings.titleFont.color = this.digitalGaugeWidgetSettingsForm.get('titleColor').value;
|
||||||
settings.labelFont.color = this.digitalGaugeWidgetSettingsForm.get('labelColor').value;
|
settings.labelFont.color = this.digitalGaugeWidgetSettingsForm.get('labelColor').value;
|
||||||
|
|
||||||
|
if (isDefinedAndNotNull(settings.decimals)) {
|
||||||
|
settings.decimals = null;
|
||||||
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export const knobWidgetDefaultSettings: KnobSettings = {
|
|||||||
defaultValue: 50,
|
defaultValue: 50,
|
||||||
executeRpc: {
|
executeRpc: {
|
||||||
method: 'getValue',
|
method: 'getValue',
|
||||||
requestTimeout: 500,
|
requestTimeout: 5000,
|
||||||
requestPersistent: false,
|
requestPersistent: false,
|
||||||
persistentPollingInterval: 5000
|
persistentPollingInterval: 5000
|
||||||
},
|
},
|
||||||
@ -70,7 +70,7 @@ export const knobWidgetDefaultSettings: KnobSettings = {
|
|||||||
action: SetValueAction.EXECUTE_RPC,
|
action: SetValueAction.EXECUTE_RPC,
|
||||||
executeRpc: {
|
executeRpc: {
|
||||||
method: 'setValue',
|
method: 'setValue',
|
||||||
requestTimeout: 500,
|
requestTimeout: 5000,
|
||||||
requestPersistent: false,
|
requestPersistent: false,
|
||||||
persistentPollingInterval: 5000
|
persistentPollingInterval: 5000
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user