diff --git a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html index 4899cd46..96c0a5b2 100644 --- a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html +++ b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html @@ -58,7 +58,7 @@

Edit Chart Export

diff --git a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.ts b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.ts index f7ca133f..98304e1e 100644 --- a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.ts +++ b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.ts @@ -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 { diff --git a/src/app/widgets/charts/shared/chart-types/timeline/timeline.component.ts b/src/app/widgets/charts/shared/chart-types/timeline/timeline.component.ts index dd55a335..6b0c0def 100644 --- a/src/app/widgets/charts/shared/chart-types/timeline/timeline.component.ts +++ b/src/app/widgets/charts/shared/chart-types/timeline/timeline.component.ts @@ -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; }