This is an automated email from the ASF dual-hosted git repository.

riemer 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 f9e2539573 Add dialog window for deletion of assets (#3236)
f9e2539573 is described below

commit f9e25395735cf4e36c7f44b20f8adf4cea31167f
Author: Marcel Früholz <[email protected]>
AuthorDate: Tue Sep 17 16:20:06 2024 +0200

    Add dialog window for deletion of assets (#3236)
---
 .../asset-overview/asset-overview.component.ts     | 37 ++++++++++++++++------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git 
a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts 
b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
index 386a03157d..0caf6b79c6 100644
--- a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
+++ b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts
@@ -24,6 +24,7 @@ import {
     SpAssetModel,
 } from '@streampipes/platform-services';
 import {
+    ConfirmDialogComponent,
     CurrentUserService,
     DialogService,
     PanelType,
@@ -35,6 +36,7 @@ import { Router } from '@angular/router';
 import { SpCreateAssetDialogComponent } from 
'../../dialog/create-asset/create-asset-dialog.component';
 import { IdGeneratorService } from 
'../../../core-services/id-generator/id-generator.service';
 import { UserPrivilege } from '../../../_enums/user-privilege.enum';
+import { MatDialog } from '@angular/material/dialog';
 
 @Component({
     selector: 'sp-asset-overview',
@@ -59,6 +61,7 @@ export class SpAssetOverviewComponent implements OnInit {
         private idGeneratorService: IdGeneratorService,
         private assetBrowserService: SpAssetBrowserService,
         private currentUserService: CurrentUserService,
+        private dialog: MatDialog,
     ) {}
 
     ngOnInit(): void {
@@ -118,15 +121,29 @@ export class SpAssetOverviewComponent implements OnInit {
     }
 
     deleteAsset(asset: SpAssetModel) {
-        this.genericStorageService
-            .deleteDocument(
-                AssetConstants.ASSET_APP_DOC_NAME,
-                asset._id,
-                asset._rev,
-            )
-            .subscribe(() => {
-                this.loadAssets();
-                this.assetBrowserService.loadAssetData();
-            });
+        const dialogRef = this.dialog.open(ConfirmDialogComponent, {
+            width: '500px',
+            data: {
+                title: 'Are you sure you want to delete this asset?',
+                subtitle: 'This action cannot be reversed!',
+                cancelTitle: 'Cancel',
+                okTitle: 'Delete Asset',
+                confirmAndCancel: true,
+            },
+        });
+        dialogRef.afterClosed().subscribe(result => {
+            if (result) {
+                this.genericStorageService
+                    .deleteDocument(
+                        AssetConstants.ASSET_APP_DOC_NAME,
+                        asset._id,
+                        asset._rev,
+                    )
+                    .subscribe(() => {
+                        this.loadAssets();
+                        this.assetBrowserService.loadAssetData();
+                    });
+            }
+        });
     }
 }

Reply via email to