Skip to content

Commit

Permalink
fixed missing save of time and group changes in widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahannes committed Mar 8, 2024
1 parent d63f8b5 commit 04617df
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2 mat-dialog-title>Edit Chart Export</h2>
<data-source-selector
[dataSourceConfig]="dataSourceConfig"
[enableAggretationConfig]="true"
(updatedDataSourceConfig)="dataSourceUpdated($event)"
(updatedDataSourceConfig)="dataSourceConfigChanged($event)"
[enableFieldSelection]="true"
></data-source-selector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,42 @@ export class ChartsExportEditDialogComponent implements OnInit {

}

dataSourceUpdated(updatedDataSourceConfig: DataSourceConfig) {
dataSourceConfigChanged(updatedDataSourceConfig: DataSourceConfig) {
console.log(updatedDataSourceConfig)
this.formGroupController.get('properties.vAxes')?.patchValue(updatedDataSourceConfig.fields);
this.formGroupController.get('properties.exports')?.patchValue(updatedDataSourceConfig.exports);
this.formGroupController.get('properties.timeRangeType')?.patchValue(updatedDataSourceConfig.timeRange?.type);
this.formGroupController.get('properties.ahead')?.patchValue(updatedDataSourceConfig.timeRange?.time);
this.formGroupController.get('properties.end')?.patchValue(updatedDataSourceConfig.timeRange?.end);
this.formGroupController.get('properties.start')?.patchValue(updatedDataSourceConfig.timeRange?.start);
const timeRangeType = updatedDataSourceConfig.timeRange?.type;
const timeRangeLevel = updatedDataSourceConfig.timeRange?.level || "";

if(timeRangeType === ChartsExportRangeTimeTypeEnum.Absolute) {
const start = updatedDataSourceConfig.timeRange?.start;
if(start != null && start !== '') {
this.formGroupController.get('properties.time.start')?.patchValue(start + timeRangeLevel);
}
const end = updatedDataSourceConfig.timeRange?.end;
if(end != null && end !== '') {
this.formGroupController.get('properties.time.end')?.patchValue(end + timeRangeLevel);
}
} else if(timeRangeType === ChartsExportRangeTimeTypeEnum.Relative) {
const last = updatedDataSourceConfig.timeRange?.time;
if(last != null) {
this.formGroupController.get('properties.time.last')?.patchValue(last + timeRangeLevel);
}
} else if(timeRangeType === ChartsExportRangeTimeTypeEnum.RelativeAhead) {
const ahead = updatedDataSourceConfig.timeRange?.time;;
if(ahead != null) {
this.formGroupController.get('properties.time.ahead')?.patchValue(ahead + timeRangeLevel);
}
}

const groupTimeType = updatedDataSourceConfig.group?.type;
const groupTimeLevel = updatedDataSourceConfig.group?.level || '';
const groupTimeValue = updatedDataSourceConfig.group?.time;
this.formGroupController.get('properties.group.time')?.patchValue(groupTimeValue + groupTimeLevel);
this.formGroupController.get('properties.group.type')?.patchValue(groupTimeType);

console.log(this.formGroupController.value)
}

initFormGroup(widget: WidgetModel): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,15 @@ export class TimelineComponent implements OnInit, OnChanges {

getAliasOfMatchingRule(vAxis: ChartsExportVAxesModel, firstValue: any, lastValue: any) {
let alias;
console.log(vAxis);

(vAxis?.conversions || []).forEach(conversion => {
console.log(conversion.to + "-" + lastValue + "-" + conversion.from + "-" + firstValue)
//console.log(conversion.to + "-" + lastValue + "-" + conversion.from + "-" + firstValue)
// convert everything to string, as there are problems with booleans in the conversion that are sometimes strings or bool
if(String(conversion.to) === String(lastValue) && String(conversion.from) === String(firstValue)) {
alias = conversion.alias || String(conversion.to);
return;
}
});
console.log(alias)
return alias;
}

Expand Down

0 comments on commit 04617df

Please sign in to comment.