;
step = 0;
@@ -173,17 +163,24 @@ export class ChartDataSettingsComponent implements OnInit {
this.loadPipelinesAndMeasurements();
}
+ ngOnDestroy(): void {
+ clearTimeout(this.dataRefreshTimeout);
+ }
+
loadPipelinesAndMeasurements() {
this.datalakeRestService.getMeasurementSummary().subscribe(response => {
this.availableMeasurements = response.resources.sort((a, b) =>
a.measureName.localeCompare(b.measureName),
);
- this.applyMeasurementSearch();
+ this.syncSelectedMeasurementSummary();
if (!this.sourceConfig) {
const defaultConfigs = this.findDefaultConfig();
this.initializeSourceConfig(defaultConfigs.measureName);
if (defaultConfigs.measureName !== undefined) {
+ this.selectedMeasurement = this.findMeasurementSummary(
+ defaultConfigs.measureName,
+ );
this.loadMeasurement(
defaultConfigs.measureName,
true,
@@ -229,45 +226,35 @@ export class ChartDataSettingsComponent implements OnInit {
updateMeasure(sourceConfig: SourceConfig, measureName: string) {
sourceConfig.measureName = measureName;
- this.measurementInputValue = measureName;
+ this.selectedMeasurement = this.findMeasurementSummary(measureName);
this.loadMeasurement(measureName, true, true);
}
- onMeasurementSearchChange(value: string): void {
- this.measurementInputValue = value;
- this.applyMeasurementSearch();
- }
-
- clearMeasurementSearch(): void {
- this.measurementInputValue = '';
- this.applyMeasurementSearch();
- }
-
- hasActiveMeasurementSearch(): boolean {
- return this.measurementInputValue.trim().length > 0;
- }
-
- onMeasurementSelected(
+ onMeasurementSelectionChange(
sourceConfig: SourceConfig,
- event: MatAutocompleteSelectedEvent,
+ selectedMeasurement:
+ | DatasetSummaryDto
+ | DatasetSummaryDto[]
+ | undefined,
): void {
- this.updateMeasure(sourceConfig, event.option.value);
- }
+ if (Array.isArray(selectedMeasurement)) {
+ return;
+ }
- private applyMeasurementSearch(): void {
- const query = this.measurementInputValue.trim().toLowerCase();
- if (!query) {
- this.filteredMeasurements = this.availableMeasurements;
+ if (!selectedMeasurement) {
+ this.clearMeasure(sourceConfig);
return;
}
- this.filteredMeasurements = this.availableMeasurements.filter(
- measurement =>
- measurement.measureName.toLowerCase().includes(query) ||
- measurement.pipelines.some(pipeline =>
- pipeline.toLowerCase().includes(query),
- ),
- );
+ this.updateMeasure(sourceConfig, selectedMeasurement.measureName);
+ }
+
+ private clearMeasure(sourceConfig: SourceConfig): void {
+ sourceConfig.measureName = '';
+ sourceConfig.measure = undefined;
+ sourceConfig.queryConfig.fields = [];
+ sourceConfig.queryConfig.groupBy = [];
+ this.selectedMeasurement = undefined;
}
private loadMeasurement(
@@ -300,12 +287,15 @@ export class ChartDataSettingsComponent implements OnInit {
this.dataLakeMeasureChange.emit(measure);
sourceConfig.measureName = measure.measureName;
sourceConfig.measure = measure;
- this.measurementInputValue = measure.measureName;
+ this.selectedMeasurement = this.findMeasurementSummary(
+ measure.measureName,
+ );
if (!resetQueryConfig) {
return;
}
+ this.pendingMeasurementRefresh = refreshData;
sourceConfig.queryConfig.fields = [];
if (this.fieldSelectionPanel) {
this.fieldSelectionPanel.applyDefaultFields();
@@ -316,8 +306,8 @@ export class ChartDataSettingsComponent implements OnInit {
this.groupSelectionPanel.applyDefaultFields();
}
- if (refreshData) {
- this.triggerDataRefresh();
+ if (refreshData && this.fieldSelectionPanel) {
+ this.scheduleDataRefresh();
}
}
@@ -325,12 +315,32 @@ export class ChartDataSettingsComponent implements OnInit {
if (this.sourceConfig?.measure) {
this.dataLakeMeasure = this.sourceConfig.measure;
this.dataLakeMeasureChange.emit(this.sourceConfig.measure);
- this.measurementInputValue = this.sourceConfig.measure.measureName;
+ this.selectedMeasurement = this.findMeasurementSummary(
+ this.sourceConfig.measure.measureName,
+ );
} else if (this.sourceConfig?.measureName) {
- this.measurementInputValue = this.sourceConfig.measureName;
+ this.selectedMeasurement = this.findMeasurementSummary(
+ this.sourceConfig.measureName,
+ );
+ }
+ }
+
+ private syncSelectedMeasurementSummary(): void {
+ if (this.sourceConfig?.measureName) {
+ this.selectedMeasurement = this.findMeasurementSummary(
+ this.sourceConfig.measureName,
+ );
}
}
+ private findMeasurementSummary(
+ measureName: string,
+ ): DatasetSummaryDto | undefined {
+ return this.availableMeasurements.find(
+ measurement => measurement.measureName === measureName,
+ );
+ }
+
changeDataAggregation() {
this.fieldSelectionPanel.applyDefaultFields();
this.triggerDataRefresh();
@@ -368,7 +378,14 @@ export class ChartDataSettingsComponent implements OnInit {
};
}
- createDefaultWidget(): void {
+ onInitialFieldSelection(): void {
+ const defaultWidgetCreated = this.createDefaultWidget();
+ if (defaultWidgetCreated || this.pendingMeasurementRefresh) {
+ this.scheduleDataRefresh();
+ }
+ }
+
+ createDefaultWidget(): boolean {
if (this.checkIfDefaultTableShouldBeShown()) {
const fields = this.fieldProviderService.generateFieldLists(
this.dataConfig.sourceConfigs,
@@ -379,13 +396,18 @@ export class ChartDataSettingsComponent implements OnInit {
this.widgetTypeService.notify({
widgetId: this.currentlyConfiguredWidget.elementId,
newWidgetTypeId: this.currentlyConfiguredWidget.widgetType,
+ deferInitialDataLoad: true,
});
this.createWidgetEmitter.emit({
a: this.dataLakeMeasure,
b: this.currentlyConfiguredWidget,
});
+
+ return true;
}
+
+ return false;
}
/**
@@ -404,6 +426,12 @@ export class ChartDataSettingsComponent implements OnInit {
});
}
+ private scheduleDataRefresh(): void {
+ this.pendingMeasurementRefresh = false;
+ clearTimeout(this.dataRefreshTimeout);
+ this.dataRefreshTimeout = setTimeout(() => this.triggerDataRefresh());
+ }
+
toggleExpandFieldsDataSource() {
this.expandFieldsDataSource = !this.expandFieldsDataSource;
}
diff --git a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.html b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.html
index 85b7c1b9fe..b25614c70a 100644
--- a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.html
+++ b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.html
@@ -37,43 +37,14 @@
@if (deploymentMode === 'filter') {
-
-
- @for (
- serviceTag of deploymentConfiguration.desiredServiceTags;
- track serviceTag
- ) {
-
- {{ serviceTag.value }}
-
-
- }
-
-
-
- @for (
- serviceTag of filteredServiceTags | async;
- track serviceTag
- ) {
-
- {{ serviceTag }}
-
- }
-
-
+
+
}
diff --git a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.ts b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.ts
index 852e20378c..147fe632bd 100644
--- a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.ts
+++ b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-deployment-settings/adapter-deployment-settings.component.ts
@@ -16,41 +16,24 @@
*
*/
-import {
- Component,
- ElementRef,
- inject,
- Input,
- OnInit,
- ViewChild,
-} from '@angular/core';
+import { Component, inject, Input, OnInit } from '@angular/core';
import {
ExtensionDeploymentConfiguration,
ServiceTagService,
SpServiceTag,
} from '@streampipes/platform-services';
-import { Observable } from 'rxjs';
-import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { COMMA, ENTER } from '@angular/cdk/keycodes';
-import { MatChipInputEvent, MatChipsModule } from '@angular/material/chips';
-import { map, startWith } from 'rxjs/operators';
-import {
- MatAutocomplete,
- MatAutocompleteSelectedEvent,
- MatAutocompleteTrigger,
-} from '@angular/material/autocomplete';
+import { FormsModule } from '@angular/forms';
import {
MatRadioButton,
MatRadioChange,
MatRadioGroup,
} from '@angular/material/radio';
import { FlexDirective, LayoutDirective } from '@ngbracket/ngx-layout/flex';
-import { MatFormField } from '@angular/material/form-field';
-import { MatIcon } from '@angular/material/icon';
-import { MatOption } from '@angular/material/select';
-import { AsyncPipe } from '@angular/common';
import { TranslatePipe } from '@ngx-translate/core';
-import { FormFieldComponent } from '@streampipes/shared-ui';
+import {
+ FormFieldComponent,
+ SearchSelectComponent,
+} from '@streampipes/shared-ui';
@Component({
selector: 'sp-adapter-deployment-settings',
@@ -61,16 +44,9 @@ import { FormFieldComponent } from '@streampipes/shared-ui';
MatRadioGroup,
FormsModule,
MatRadioButton,
- MatFormField,
- MatChipsModule,
- MatIcon,
- MatAutocompleteTrigger,
- ReactiveFormsModule,
- MatAutocomplete,
- MatOption,
- AsyncPipe,
TranslatePipe,
FormFieldComponent,
+ SearchSelectComponent,
],
})
export class SpAdapterDeploymentSettingsComponent implements OnInit {
@@ -80,81 +56,26 @@ export class SpAdapterDeploymentSettingsComponent implements OnInit {
deploymentConfiguration: ExtensionDeploymentConfiguration;
availableServiceTags: SpServiceTag[] = [];
- availableServiceTagValues: string[] = [];
deploymentMode = 'all';
- separatorKeysCodes: number[] = [ENTER, COMMA];
- serviceTagCtrl = new FormControl('');
- filteredServiceTags: Observable;
-
- @ViewChild('serviceTagInput') serviceTagInput: ElementRef;
-
- constructor() {
- this.filteredServiceTags = this.serviceTagCtrl.valueChanges.pipe(
- startWith(null),
- map((serviceTagValue: string | null) => {
- return serviceTagValue
- ? this._filter(serviceTagValue)
- : this.availableServiceTagValues.slice();
- }),
- );
- }
-
ngOnInit(): void {
if (this.deploymentConfiguration.desiredServiceTags.length > 0) {
this.deploymentMode = 'filter';
}
this.serviceTagService.getCustomServiceTags().subscribe(res => {
this.availableServiceTags = res;
- this.availableServiceTagValues = res.map(st => st.value);
});
}
- add(event: MatChipInputEvent): void {
- const value = (event.value || '').trim();
-
- if (value) {
- this.deploymentConfiguration.desiredServiceTags.push(
- this.findTag(value),
- );
- }
-
- if (event.chipInput) {
- event.chipInput.clear();
- }
-
- this.serviceTagCtrl.setValue(null);
- }
-
- findTag(value: string): SpServiceTag {
- return this.availableServiceTags.find(st => st.value === value);
- }
-
- remove(serviceTag: string): void {
- const index = this.deploymentConfiguration.desiredServiceTags.findIndex(
- st => st.value === serviceTag,
- );
-
- if (index >= 0) {
- this.deploymentConfiguration.desiredServiceTags.splice(index, 1);
- }
- }
-
- selected(event: MatAutocompleteSelectedEvent): void {
- this.deploymentConfiguration.desiredServiceTags.push(
- this.findTag(event.option.viewValue),
- );
- this.serviceTagInput.nativeElement.value = '';
- this.serviceTagCtrl.setValue(null);
- }
-
- private _filter(value: string): string[] {
- const filterValue = value.toLowerCase();
-
- return this.availableServiceTagValues.filter(st =>
- st.toLowerCase().includes(filterValue),
- );
+ onServiceTagsChange(
+ serviceTags: SpServiceTag | SpServiceTag[] | undefined,
+ ): void {
+ this.deploymentConfiguration.desiredServiceTags = Array.isArray(
+ serviceTags,
+ )
+ ? serviceTags
+ : [];
}
handleSelectionChange(event: MatRadioChange): void {