You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2022/01/25 20:12:56 UTC

[incubator-streampipes] branch dev updated: [STREAMPIPES-507] Widgets are now deleted from database

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/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new e9f4cb3  [STREAMPIPES-507] Widgets are now deleted from database
e9f4cb3 is described below

commit e9f4cb3a100c1db716e153bb1c5f267554980441
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Jan 25 15:38:32 2022 +0100

    [STREAMPIPES-507] Widgets are now deleted from database
---
 .../data-explorer-dashboard-panel.component.ts     | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/ui/src/app/data-explorer/components/panel/data-explorer-dashboard-panel.component.ts b/ui/src/app/data-explorer/components/panel/data-explorer-dashboard-panel.component.ts
index 76586d7..5876071 100644
--- a/ui/src/app/data-explorer/components/panel/data-explorer-dashboard-panel.component.ts
+++ b/ui/src/app/data-explorer/components/panel/data-explorer-dashboard-panel.component.ts
@@ -18,7 +18,7 @@
 
 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
-import { Observable } from 'rxjs';
+import { Observable, zip } from 'rxjs';
 import { RefreshDashboardService } from '../../services/refresh-dashboard.service';
 import { DataExplorerWidgetModel, DataLakeMeasure } from '../../../core-model/gen/streampipes-model';
 import { DataExplorerDashboardGridComponent } from '../grid/data-explorer-dashboard-grid.component';
@@ -101,14 +101,27 @@ export class DataExplorerDashboardPanelComponent implements OnInit {
     this.dataViewDataExplorerService.updateDashboard(this.dashboard).subscribe(result => {
       this.dashboard._rev = result._rev;
       if (this.widgetIdsToRemove.length > 0) {
-        this.deleteWidgets();
+        const observables = this.deleteWidgets();
+        zip(...observables).subscribe(() => {
+          this.widgetIdsToRemove.forEach(id => {
+            this.dashboardGrid.configuredWidgets.delete(id);
+          });
+
+          this.afterDashboardChange();
+        });
+      } else {
+        this.afterDashboardChange();
       }
-      this.dashboardGrid.updateAllWidgets();
-      this.editModeChange.emit(false);
-      this.closeDesignerPanel();
+
     });
   }
 
+  afterDashboardChange() {
+    this.dashboardGrid.updateAllWidgets();
+    this.editModeChange.emit(false);
+    this.closeDesignerPanel();
+  }
+
   startEditMode(widgetModel: DataExplorerWidgetModel) {
     this.editModeChange.emit(true);
     this.updateCurrentlyConfiguredWidget(widgetModel);
@@ -136,9 +149,9 @@ export class DataExplorerDashboardPanelComponent implements OnInit {
     this.widgetsToUpdate.set(widget._id, widget);
   }
 
-  deleteWidgets() {
-    this.widgetIdsToRemove.forEach(widgetId => {
-      this.dataViewDataExplorerService.deleteWidget(widgetId).subscribe();
+  deleteWidgets(): Observable<any>[] {
+    return this.widgetIdsToRemove.map(widgetId => {
+      return this.dataViewDataExplorerService.deleteWidget(widgetId);
     });
   }