Browse Source

Merge pull request #13469 from vvlladd28/fix/unit-convertor/typo

Fixed unit conversion
pull/13556/head
Igor Kulikov 1 year ago
committed by GitHub
parent
commit
2e7b5cda25
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ui-ngx/src/app/modules/home/components/widget/config/basic/chart/time-series-chart-basic-config.component.html
  2. 6
      ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts
  3. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.html
  4. 3
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-threshold-row.component.html
  5. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-threshold-row.component.ts
  6. 1
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-thresholds-panel.component.html
  7. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-thresholds-panel.component.ts
  8. 1
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.html
  9. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.ts
  10. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.html
  11. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts
  12. 2
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts
  13. 8
      ui-ngx/src/app/shared/components/unit-settings-panel.component.ts
  14. 4
      ui-ngx/src/app/shared/models/widget-settings.models.ts
  15. 12
      ui-ngx/src/assets/locale/locale.constant-en_US.json

4
ui-ngx/src/app/modules/home/components/widget/config/basic/chart/time-series-chart-basic-config.component.html

@ -104,6 +104,7 @@
</tb-time-series-chart-states-panel> </tb-time-series-chart-states-panel>
<tb-time-series-chart-y-axes-panel <tb-time-series-chart-y-axes-panel
formControlName="yAxes" formControlName="yAxes"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion"
(axisRemoved)="yAxisRemoved($event)"> (axisRemoved)="yAxisRemoved($event)">
</tb-time-series-chart-y-axes-panel> </tb-time-series-chart-y-axes-panel>
<tb-time-series-chart-thresholds-panel <tb-time-series-chart-thresholds-panel
@ -112,7 +113,8 @@
[dataKeyCallbacks]="callbacks" [dataKeyCallbacks]="callbacks"
[datasource]="datasource" [datasource]="datasource"
[widgetConfig]="widgetConfig?.config" [widgetConfig]="widgetConfig?.config"
[yAxisIds]="yAxisIds"> [yAxisIds]="yAxisIds"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion">
</tb-time-series-chart-thresholds-panel> </tb-time-series-chart-thresholds-panel>
<div class="tb-form-panel"> <div class="tb-form-panel">
<div class="tb-form-panel-title" translate>widget-config.appearance</div> <div class="tb-form-panel-title" translate>widget-config.appearance</div>

6
ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts

@ -167,7 +167,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
private defaultPageSize; private defaultPageSize;
private defaultSortOrder = 'entityName'; private defaultSortOrder = 'entityName';
private contentsInfo: {[key: string]: CellContentInfo} = {}; private contentsInfo: {[key: string]: WithOptional<CellContentInfo, 'valueFormat'>} = {};
private stylesInfo: {[key: string]: Observable<CellStyleInfo>} = {}; private stylesInfo: {[key: string]: Observable<CellStyleInfo>} = {};
private columnWidth: {[key: string]: string} = {}; private columnWidth: {[key: string]: string} = {};
private columnDefaultVisibility: {[key: string]: boolean} = {}; private columnDefaultVisibility: {[key: string]: boolean} = {};
@ -759,7 +759,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
return content$; return content$;
} }
private defaultContent(key: EntityColumn, contentInfo: CellContentInfo, value: any): any { private defaultContent(key: EntityColumn, contentInfo: WithOptional<CellContentInfo, 'valueFormat'>, value: any): any {
if (isDefined(value)) { if (isDefined(value)) {
const entityField = entityFields[key.name]; const entityField = entityFields[key.name];
if (entityField) { if (entityField) {
@ -767,7 +767,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
return this.datePipe.transform(value, 'yyyy-MM-dd HH:mm:ss'); return this.datePipe.transform(value, 'yyyy-MM-dd HH:mm:ss');
} }
} }
return contentInfo.valueFormat.format(value); return contentInfo.valueFormat?.format(value) ?? value;
} else { } else {
return ''; return '';
} }

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.html

@ -63,6 +63,7 @@
<tb-time-series-chart-y-axes-panel <tb-time-series-chart-y-axes-panel
formControlName="yAxes" formControlName="yAxes"
(axisRemoved)="yAxisRemoved($event)" (axisRemoved)="yAxisRemoved($event)"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion"
advanced> advanced>
</tb-time-series-chart-y-axes-panel> </tb-time-series-chart-y-axes-panel>
<tb-time-series-chart-thresholds-panel <tb-time-series-chart-thresholds-panel
@ -71,7 +72,8 @@
[dataKeyCallbacks]="dataKeyCallbacks" [dataKeyCallbacks]="dataKeyCallbacks"
[datasource]="datasource" [datasource]="datasource"
[widgetConfig]="widgetConfig?.config" [widgetConfig]="widgetConfig?.config"
[yAxisIds]="yAxisIds"> [yAxisIds]="yAxisIds"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion">
</tb-time-series-chart-thresholds-panel> </tb-time-series-chart-thresholds-panel>
<div class="tb-form-panel"> <div class="tb-form-panel">
<div class="tb-form-panel-title" translate>widgets.time-series-chart.chart-style</div> <div class="tb-form-panel-title" translate>widgets.time-series-chart.chart-style</div>

3
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-threshold-row.component.html

@ -89,7 +89,8 @@
</tb-color-input> </tb-color-input>
</div> </div>
<div class="tb-units-field"> <div class="tb-units-field">
<tb-unit-input formControlName="units" supportsUnitConversion> <tb-unit-input formControlName="units"
[supportsUnitConversion]="supportsUnitConversion">
</tb-unit-input> </tb-unit-input>
</div> </div>
<div class="tb-decimals-field"> <div class="tb-decimals-field">

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-threshold-row.component.ts

@ -106,6 +106,10 @@ export class TimeSeriesChartThresholdRowComponent implements ControlValueAccesso
@coerceBoolean() @coerceBoolean()
hideYAxis = false; hideYAxis = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output() @Output()
thresholdRemoved = new EventEmitter(); thresholdRemoved = new EventEmitter();

1
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-thresholds-panel.component.html

@ -33,6 +33,7 @@
[formControl]="thresholdControl" [formControl]="thresholdControl"
[hideYAxis]="hideYAxis" [hideYAxis]="hideYAxis"
[yAxisIds]="yAxisIds" [yAxisIds]="yAxisIds"
[supportsUnitConversion]="supportsUnitConversion"
(thresholdRemoved)="removeThreshold($index)"> (thresholdRemoved)="removeThreshold($index)">
</tb-time-series-chart-threshold-row> </tb-time-series-chart-threshold-row>
<mat-divider *ngIf="!$last"></mat-divider> <mat-divider *ngIf="!$last"></mat-divider>

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-thresholds-panel.component.ts

@ -84,6 +84,10 @@ export class TimeSeriesChartThresholdsPanelComponent implements ControlValueAcce
@coerceBoolean() @coerceBoolean()
hideYAxis = false; hideYAxis = false;
@Input()
@coerceBoolean()
supportsUnitConversion = true;
thresholdsFormGroup: UntypedFormGroup; thresholdsFormGroup: UntypedFormGroup;
private propagateChange = (_val: any) => {}; private propagateChange = (_val: any) => {};

1
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.html

@ -39,6 +39,7 @@
<tb-time-series-chart-y-axis-row class="flex-1" <tb-time-series-chart-y-axis-row class="flex-1"
[formControl]="axisControl" [formControl]="axisControl"
[advanced]="advanced" [advanced]="advanced"
[supportsUnitConversion]="supportsUnitConversion"
(axisRemoved)="removeAxis($index)"> (axisRemoved)="removeAxis($index)">
</tb-time-series-chart-y-axis-row> </tb-time-series-chart-y-axis-row>
<div class="tb-form-table-row-cell-buttons"> <div class="tb-form-table-row-cell-buttons">

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.ts

@ -75,6 +75,10 @@ export class TimeSeriesChartYAxesPanelComponent implements ControlValueAccessor,
@coerceBoolean() @coerceBoolean()
advanced = false; advanced = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output() @Output()
axisRemoved = new EventEmitter<TimeSeriesChartYAxisId>(); axisRemoved = new EventEmitter<TimeSeriesChartYAxisId>();

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.html

@ -41,7 +41,7 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div class="tb-units-field"> <div class="tb-units-field">
<tb-unit-input formControlName="units" supportsUnitConversion> <tb-unit-input formControlName="units" [supportsUnitConversion]="supportsUnitConversion">
</tb-unit-input> </tb-unit-input>
</div> </div>
<div class="tb-decimals-field"> <div class="tb-decimals-field">

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts

@ -69,6 +69,10 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
@coerceBoolean() @coerceBoolean()
advanced = false; advanced = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output() @Output()
axisRemoved = new EventEmitter(); axisRemoved = new EventEmitter();

2
ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

@ -107,7 +107,7 @@ export interface CellContentFunctionInfo {
export interface CellContentInfo { export interface CellContentInfo {
contentFunction: Observable<CellContentFunctionInfo>; contentFunction: Observable<CellContentFunctionInfo>;
valueFormat?: ValueFormatProcessor valueFormat: ValueFormatProcessor
} }
export type CellStyleFunction = (...args: any[]) => any; export type CellStyleFunction = (...args: any[]) => any;

8
ui-ngx/src/app/shared/components/unit-settings-panel.component.ts

@ -139,7 +139,13 @@ export class UnitSettingsPanelComponent implements OnInit {
} }
clearUnit() { clearUnit() {
this.unitSettingsApplied.emit(null); this.unitSettingForm.reset({
convertUnit: false
});
if (this.required) {
this.unitSettingForm.markAllAsTouched();
}
this.unitSettingForm.markAsDirty();
} }
cancel() { cancel() {

4
ui-ngx/src/app/shared/models/widget-settings.models.ts

@ -907,8 +907,6 @@ export abstract class ValueFormatProcessor {
export class SimpleValueFormatProcessor extends ValueFormatProcessor { export class SimpleValueFormatProcessor extends ValueFormatProcessor {
private readonly isDefinedUnit: boolean;
constructor(protected settings: ValueFormatSettings) { constructor(protected settings: ValueFormatSettings) {
super(settings); super(settings);
this.unitSymbol = !settings.ignoreUnitSymbol && isNotEmptyStr(settings.units) ? (settings.units as string) : null; this.unitSymbol = !settings.ignoreUnitSymbol && isNotEmptyStr(settings.units) ? (settings.units as string) : null;
@ -917,7 +915,7 @@ export class SimpleValueFormatProcessor extends ValueFormatProcessor {
} }
format(value: any): string { format(value: any): string {
if (isDefinedAndNotNull(value) && isNumeric(value) && (this.isDefinedDecimals || this.isDefinedUnit || Number(value).toString() === value)) { if (isDefinedAndNotNull(value) && isNumeric(value) && (this.isDefinedDecimals || this.unitSymbol || Number(value).toString() === value)) {
return this.formatValue(Number(value)); return this.formatValue(Number(value));
} }
return value ?? ''; return value ?? '';

12
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -5938,7 +5938,7 @@
"energy-density": "Energy density", "energy-density": "Energy density",
"force": "Force", "force": "Force",
"frequency": "Frequency", "frequency": "Frequency",
"fuel-efficiency": "fuel efficiency", "fuel-efficiency": "Fuel efficiency",
"heat-capacity": "Heat capacity", "heat-capacity": "Heat capacity",
"illuminance": "Illuminance", "illuminance": "Illuminance",
"inductance": "Inductance", "inductance": "Inductance",
@ -6194,8 +6194,8 @@
"volt": "Volt", "volt": "Volt",
"kilovolt": "Kilovolt", "kilovolt": "Kilovolt",
"megavolt": "Megavolt", "megavolt": "Megavolt",
"dbmV": "dBmV", "dbmV": "Decibel volt",
"dbm": "dBm", "dbm": "Decibel-milliwatts",
"volt-meter": "Volt-Meter", "volt-meter": "Volt-Meter",
"kilovolt-meter": "Kilovolt-Meter", "kilovolt-meter": "Kilovolt-Meter",
"megavolt-meter": "Megavolt-Meter", "megavolt-meter": "Megavolt-Meter",
@ -6230,7 +6230,7 @@
"millimole": "Millimole", "millimole": "Millimole",
"kilomole": "Kilomole", "kilomole": "Kilomole",
"mole-per-cubic-meter": "Mole per Cubic Meter", "mole-per-cubic-meter": "Mole per Cubic Meter",
"rssi": "RSSI", "rssi": "Received signal strength indicator",
"ppm": "Parts Per Million", "ppm": "Parts Per Million",
"ppb": "Parts Per Billion", "ppb": "Parts Per Billion",
"micrograms-per-cubic-meter": "Micrograms per Cubic Meter", "micrograms-per-cubic-meter": "Micrograms per Cubic Meter",
@ -6412,9 +6412,9 @@
"radian-per-second": "Radian per second", "radian-per-second": "Radian per second",
"radian-per-second-squared": "Radian per second squared", "radian-per-second-squared": "Radian per second squared",
"revolutions-per-minute-per-second": "Angular acceleration", "revolutions-per-minute-per-second": "Angular acceleration",
"deg-per-second": "deg/s", "deg-per-second": "Degrees per second",
"rotation-per-minute": "Rotation per minute", "rotation-per-minute": "Rotation per minute",
"degrees-brix": "Degrees Brix", "degrees-brix": "Degrees brix",
"katal": "Katal", "katal": "Katal",
"katal-per-cubic-metre": "Katal per Cubic Metre", "katal-per-cubic-metre": "Katal per Cubic Metre",
"paris-inch": "Paris inch" "paris-inch": "Paris inch"

Loading…
Cancel
Save