Skip to content

Commit

Permalink
Set table as default widget type
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelfrueh committed Dec 13, 2024
1 parent 25ab4b6 commit 74d9f0f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#dataSettingsPanel
[(dataLakeMeasure)]="dataLakeMeasure"
[dataConfig]="currentlyConfiguredWidget.dataConfig"
[currentlyConfiguredWidget]="
currentlyConfiguredWidget
"
[newWidgetMode]="newWidgetMode"
[widgetId]="currentlyConfiguredWidget.elementId"
(createWidgetEmitter)="createNewWidget()"
Expand All @@ -55,6 +58,7 @@
>
<div class="scroll-tab-content">
<sp-explorer-visualisation-settings
*ngIf="currentlyConfiguredWidget.widgetType"
fxFlex="100"
fxLayout="column"
[currentlyConfiguredWidget]="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
<sp-field-selection-panel
#fieldSelectionPanel
[sourceConfig]="sourceConfig"
(initialFieldSelectionEvent)="createDefaultWidget()"
></sp-field-selection-panel>

<sp-filter-selection-panel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import { zip } from 'rxjs';
import { WidgetConfigurationService } from '../../../../services/widget-configuration.service';
import { FieldSelectionPanelComponent } from './field-selection-panel/field-selection-panel.component';
import { GroupSelectionPanelComponent } from './group-selection-panel/group-selection-panel.component';
import { TableVisConfig } from '../../../widgets/table/model/table-widget.model';
import { DataExplorerFieldProviderService } from 'src/app/data-explorer/services/data-explorer-field-provider-service';
import { FieldProvider } from 'src/app/data-explorer/models/dataview-dashboard.model';
import { WidgetTypeService } from 'src/app/data-explorer/services/widget-type.service';

@Component({
selector: 'sp-data-explorer-widget-data-settings',
Expand All @@ -48,6 +52,7 @@ export class DataExplorerWidgetDataSettingsComponent implements OnInit {
@Input() dataLakeMeasure: DataLakeMeasure;
@Input() newWidgetMode: boolean;
@Input() widgetId: string;
@Input() currentlyConfiguredWidget: DataExplorerWidgetModel;

@Output() createWidgetEmitter: EventEmitter<
Tuple2<DataLakeMeasure, DataExplorerWidgetModel>
Expand All @@ -72,6 +77,8 @@ export class DataExplorerWidgetDataSettingsComponent implements OnInit {
private dataExplorerService: DataViewDataExplorerService,
private datalakeRestService: DatalakeRestService,
private widgetConfigService: WidgetConfigurationService,
private fieldProviderService: DataExplorerFieldProviderService,
private widgetTypeService: WidgetTypeService,
) {}

ngOnInit(): void {
Expand All @@ -86,6 +93,13 @@ export class DataExplorerWidgetDataSettingsComponent implements OnInit {
this.availablePipelines = response[0];
this.availableMeasurements = response[1];

this.availablePipelines.sort((a, b) =>
a.pipelineName.localeCompare(b.pipelineName),
);
this.availableMeasurements.sort((a, b) =>
a.measureName.localeCompare(b.measureName),
);

// replace pipeline event schemas. Reason: Available measures do not contain field for timestamp
this.availablePipelines.forEach(p => {
const measurement = this.availableMeasurements.find(m => {
Expand Down Expand Up @@ -212,6 +226,29 @@ export class DataExplorerWidgetDataSettingsComponent implements OnInit {
};
}

makeVisualizationConfig(fields: FieldProvider): TableVisConfig {
return {
configurationValid: true,
searchValue: '',
selectedColumns: fields.allFields,
};
}

createDefaultWidget(): void {
if (this.dataConfig.sourceConfigs.length === 1) {
const fields = this.fieldProviderService.generateFieldLists(
this.dataConfig.sourceConfigs,
);
this.currentlyConfiguredWidget.visualizationConfig =
this.makeVisualizationConfig(fields);
this.currentlyConfiguredWidget.widgetType = 'table';
this.widgetTypeService.notify({
widgetId: this.currentlyConfiguredWidget.elementId,
newWidgetTypeId: this.currentlyConfiguredWidget.widgetType,
});
}
}

removeSourceConfig(index: number) {
this.dataConfig.sourceConfigs.splice(index, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import {
EventPropertyUnion,
FieldConfig,
Expand All @@ -35,6 +35,9 @@ export class FieldSelectionPanelComponent implements OnInit {

@Input() sourceConfig: SourceConfig;

@Output()
initialFieldSelectionEvent: EventEmitter<void> = new EventEmitter();

expandFields = false;

constructor(
Expand All @@ -44,6 +47,7 @@ export class FieldSelectionPanelComponent implements OnInit {

ngOnInit() {
this.applyDefaultFields();
this.initialFieldSelectionEvent.emit();
}

applyDefaultFields() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class OrderSelectionPanelComponent implements OnInit {
constructor(private widgetConfigService: WidgetConfigurationService) {}

ngOnInit(): void {
this.sourceConfig.queryConfig.order ??= 'ASC';
this.sourceConfig.queryConfig.order ??= 'DESC';
}

triggerConfigurationUpdate() {
Expand Down

0 comments on commit 74d9f0f

Please sign in to comment.