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-y-axes-panel
formControlName="yAxes"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion"
(axisRemoved)="yAxisRemoved($event)">
</tb-time-series-chart-y-axes-panel>
<tb-time-series-chart-thresholds-panel
@ -112,7 +113,8 @@
[dataKeyCallbacks]="callbacks"
[datasource]="datasource"
[widgetConfig]="widgetConfig?.config"
[yAxisIds]="yAxisIds">
[yAxisIds]="yAxisIds"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion">
</tb-time-series-chart-thresholds-panel>
<div class="tb-form-panel">
<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 defaultSortOrder = 'entityName';
private contentsInfo: {[key: string]: CellContentInfo} = {};
private contentsInfo: {[key: string]: WithOptional<CellContentInfo, 'valueFormat'>} = {};
private stylesInfo: {[key: string]: Observable<CellStyleInfo>} = {};
private columnWidth: {[key: string]: string} = {};
private columnDefaultVisibility: {[key: string]: boolean} = {};
@ -759,7 +759,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
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)) {
const entityField = entityFields[key.name];
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 contentInfo.valueFormat.format(value);
return contentInfo.valueFormat?.format(value) ?? value;
} else {
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
formControlName="yAxes"
(axisRemoved)="yAxisRemoved($event)"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion"
advanced>
</tb-time-series-chart-y-axes-panel>
<tb-time-series-chart-thresholds-panel
@ -71,7 +72,8 @@
[dataKeyCallbacks]="dataKeyCallbacks"
[datasource]="datasource"
[widgetConfig]="widgetConfig?.config"
[yAxisIds]="yAxisIds">
[yAxisIds]="yAxisIds"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion">
</tb-time-series-chart-thresholds-panel>
<div class="tb-form-panel">
<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>
</div>
<div class="tb-units-field">
<tb-unit-input formControlName="units" supportsUnitConversion>
<tb-unit-input formControlName="units"
[supportsUnitConversion]="supportsUnitConversion">
</tb-unit-input>
</div>
<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()
hideYAxis = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output()
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"
[hideYAxis]="hideYAxis"
[yAxisIds]="yAxisIds"
[supportsUnitConversion]="supportsUnitConversion"
(thresholdRemoved)="removeThreshold($index)">
</tb-time-series-chart-threshold-row>
<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()
hideYAxis = false;
@Input()
@coerceBoolean()
supportsUnitConversion = true;
thresholdsFormGroup: UntypedFormGroup;
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"
[formControl]="axisControl"
[advanced]="advanced"
[supportsUnitConversion]="supportsUnitConversion"
(axisRemoved)="removeAxis($index)">
</tb-time-series-chart-y-axis-row>
<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()
advanced = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output()
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>
</div>
<div class="tb-units-field">
<tb-unit-input formControlName="units" supportsUnitConversion>
<tb-unit-input formControlName="units" [supportsUnitConversion]="supportsUnitConversion">
</tb-unit-input>
</div>
<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()
advanced = false;
@Input()
@coerceBoolean()
supportsUnitConversion = false;
@Output()
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 {
contentFunction: Observable<CellContentFunctionInfo>;
valueFormat?: ValueFormatProcessor
valueFormat: ValueFormatProcessor
}
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() {
this.unitSettingsApplied.emit(null);
this.unitSettingForm.reset({
convertUnit: false
});
if (this.required) {
this.unitSettingForm.markAllAsTouched();
}
this.unitSettingForm.markAsDirty();
}
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 {
private readonly isDefinedUnit: boolean;
constructor(protected settings: ValueFormatSettings) {
super(settings);
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 {
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 value ?? '';

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

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

Loading…
Cancel
Save