This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new ee4160c20c fix: Ensure that only one get sample request is triggered
(#4132)
ee4160c20c is described below
commit ee4160c20cd235dddc2ebda9e9f64244d67ed132
Author: Philipp Zehnder <[email protected]>
AuthorDate: Wed Jan 28 10:20:04 2026 +0100
fix: Ensure that only one get sample request is triggered (#4132)
---
.../adapter-configuration-state.service.ts | 97 ++++++++++++----------
1 file changed, 52 insertions(+), 45 deletions(-)
diff --git
a/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
b/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
index 0d94319861..ecfad38d74 100644
---
a/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
+++
b/ui/src/app/connect/components/adapter-configuration/adapter-configuration-state-service/adapter-configuration-state.service.ts
@@ -27,7 +27,7 @@ import {
import { AdapterConfigurationState } from './AdapterConfigurationState';
import { HttpErrorResponse } from '@angular/common/http';
import { RestService } from '../../../services/rest.service';
-import { Observable } from 'rxjs';
+import { Observable, Subscription } from 'rxjs';
import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { ConfirmDialogComponent } from '@streampipes/shared-ui';
@@ -77,6 +77,8 @@ export class AdapterConfigurationStateService {
public state = this._state.asReadonly();
+ private sampleRequestSubscription?: Subscription;
+
public updateState(newState: Partial<AdapterConfigurationState>): void {
this._state.update(current => ({ ...current, ...newState }));
}
@@ -221,56 +223,61 @@ export class AdapterConfigurationStateService {
// New action method focusing on state transitions
public getSampleEvent(adapter: AdapterDescription): void {
+ this.sampleRequestSubscription?.unsubscribe();
+ this.sampleRequestSubscription = undefined;
+
this.updateState({
isGettingSample: true,
sampleError: null,
adapterDescription: adapter,
});
- this.restService.getSampleEvents(adapter).subscribe({
- next: sampleData => {
- const updatedAdapter = { ...adapter };
- updatedAdapter.transformationConfig.inputs = [
- sampleData.samples[0],
- ];
-
- const scriptActive =
- updatedAdapter.transformationConfig.scriptActive;
-
- if (!scriptActive) {
- updatedAdapter.transformationConfig.outputs =
- updatedAdapter.transformationConfig.inputs;
- }
-
- const transformationConfigurationChanged =
- this.checkIfTransformationConfigurationChanged(
- updatedAdapter,
- );
-
- this.updateState({
- adapterDescription: updatedAdapter,
- isGettingSample: false,
- adapterSettingsChanged: false, // Reset the warning
- adapterSettingsString: JSON.stringify(
- updatedAdapter.config,
- ),
- transformationConfigurationChanged:
- transformationConfigurationChanged,
- sampleFieldStatusInfos: sampleData.fieldStatusInfos,
- });
-
- if (scriptActive) {
- this.runScript(updatedAdapter);
- }
- },
- error: (error: HttpErrorResponse) => {
- // Update state with error AND metadata (error/idle)
- this.updateState({
- isGettingSample: false,
- sampleError: error.error as SpLogMessage, // Assuming
error.error is the SpLogMessage
- });
- },
- });
+ this.sampleRequestSubscription = this.restService
+ .getSampleEvents(adapter)
+ .subscribe({
+ next: sampleData => {
+ const updatedAdapter = { ...adapter };
+ updatedAdapter.transformationConfig.inputs = [
+ sampleData.samples[0],
+ ];
+
+ const scriptActive =
+ updatedAdapter.transformationConfig.scriptActive;
+
+ if (!scriptActive) {
+ updatedAdapter.transformationConfig.outputs =
+ updatedAdapter.transformationConfig.inputs;
+ }
+
+ const transformationConfigurationChanged =
+ this.checkIfTransformationConfigurationChanged(
+ updatedAdapter,
+ );
+
+ this.updateState({
+ adapterDescription: updatedAdapter,
+ isGettingSample: false,
+ adapterSettingsChanged: false, // Reset the warning
+ adapterSettingsString: JSON.stringify(
+ updatedAdapter.config,
+ ),
+ transformationConfigurationChanged:
+ transformationConfigurationChanged,
+ sampleFieldStatusInfos: sampleData.fieldStatusInfos,
+ });
+
+ if (scriptActive) {
+ this.runScript(updatedAdapter);
+ }
+ },
+ error: (error: HttpErrorResponse) => {
+ // Update state with error AND metadata (error/idle)
+ this.updateState({
+ isGettingSample: false,
+ sampleError: error.error as SpLogMessage, // Assuming
error.error is the SpLogMessage
+ });
+ },
+ });
}
public runScript(adapter: AdapterDescription): void {