From f9e25395735cf4e36c7f44b20f8adf4cea31167f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fr=C3=BCholz?= <78954450+Marcelfrueh@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:20:06 +0200 Subject: [PATCH] Add dialog window for deletion of assets (#3236) --- .../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(); + }); + } + }); } }