From 0d08b0e7a7ec4b3c66c6d308d6d801ac812ebd50 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 16 Jan 2022 17:10:35 +0100 Subject: [PATCH] Fix deleted files not disappearing from client view Signed-off-by: trivernis --- .../src/app/components/core/core.component.html | 14 +++++++------- .../core/files-tab/files-tab.component.html | 15 ++++++++++----- .../file-action-base.component.ts | 5 ++++- .../file-context-menu.component.html | 5 +++-- .../file-context-menu.component.ts | 10 +++++++++- .../file-gallery/file-gallery.component.html | 2 +- .../file-gallery/file-gallery.component.ts | 4 +++- .../file-grid/file-grid.component.html | 2 +- .../file-grid/file-grid.component.ts | 1 + .../file-multiview/file-multiview.component.html | 5 ++++- .../file-multiview/file-multiview.component.ts | 13 ++++++++++++- 11 files changed, 55 insertions(+), 21 deletions(-) diff --git a/mediarepo-ui/src/app/components/core/core.component.html b/mediarepo-ui/src/app/components/core/core.component.html index 0637827..68c2a53 100644 --- a/mediarepo-ui/src/app/components/core/core.component.html +++ b/mediarepo-ui/src/app/components/core/core.component.html @@ -1,14 +1,14 @@
- + -
+
{{tab.category}} -
@@ -21,13 +21,13 @@
Select the tab type - - + +
- diff --git a/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.html b/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.html index be372c1..eb500d9 100644 --- a/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.html +++ b/mediarepo-ui/src/app/components/core/files-tab/files-tab.component.html @@ -1,12 +1,17 @@ - + - + - + diff --git a/mediarepo-ui/src/app/components/shared/app-base/file-action-base/file-action-base.component.ts b/mediarepo-ui/src/app/components/shared/app-base/file-action-base/file-action-base.component.ts index 520b886..1063fc6 100644 --- a/mediarepo-ui/src/app/components/shared/app-base/file-action-base/file-action-base.component.ts +++ b/mediarepo-ui/src/app/components/shared/app-base/file-action-base/file-action-base.component.ts @@ -79,7 +79,7 @@ export class FileActionBaseComponent { } } - public async deletePermanently(files: File[]) { + public async deletePermanently(files: File[]): Promise { if (files.length === 1) { const deletionConfirmed = await this.openConfirmDialog( "Confirm deletion", @@ -90,6 +90,7 @@ export class FileActionBaseComponent { ); if (deletionConfirmed) { await this.errorBroker.try(() => this.fileService.deleteFile(files[0].id)); + return true; } } else { const deletionConfirmed = await this.openConfirmDialog( @@ -104,8 +105,10 @@ export class FileActionBaseComponent { files, (file) => this.errorBroker.try(() => this.fileService.deleteFile(file.id)) ); + return true; } } + return false; } protected getImageThumbnail(file: File): SafeResourceUrl | undefined { diff --git a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.html b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.html index 5917d35..a53cbcd 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.html @@ -10,8 +10,9 @@ *ngIf="actionDelete" mat-menu-item>Delete - diff --git a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts index e385669..d63e924 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-context-menu/file-context-menu.component.ts @@ -30,7 +30,7 @@ export class FileContextMenuComponent extends FileActionBaseComponent implements public actionDeletePermantently = false; @ViewChild("contextMenu") contextMenu!: ContextMenuComponent; - @Output() fileUpdate = new EventEmitter(); + @Output() fileDeleted = new EventEmitter(); constructor(fileService: FileService, errorBroker: ErrorBrokerService, dialog: MatDialog) { super(dialog, errorBroker, fileService); @@ -48,6 +48,14 @@ export class FileContextMenuComponent extends FileActionBaseComponent implements this.contextMenu.onContextMenu(event); } + public async deleteFilesPermanently() { + const deleted = await this.deletePermanently(this.files); + + if (deleted) { + this.fileDeleted.emit(this.files); + } + } + private applyStatus() { this.actionDeletePermantently = true; this.actionDelete = this.actionArchive = this.actionImported = this.actionRestore = false; diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html index c778839..d81a443 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html @@ -20,4 +20,4 @@
- + diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts index 5702e13..b91a293 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts @@ -31,11 +31,13 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { @Output() fileDblClick = new EventEmitter(); @Output() appClose = new EventEmitter(); @Output() fileDelete = new EventEmitter(); - entries: Selectable[] = []; + @Output() fileDeleted = new EventEmitter(); @ViewChild("virtualScroll") virtualScroll!: CdkVirtualScrollViewport; + @ViewChild("inner") inner!: ElementRef; + public entries: Selectable[] = []; public selectedFile: Selectable | undefined; public fileContentUrl: SafeResourceUrl | undefined; diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html index bd38282..7034cbc 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html @@ -18,7 +18,7 @@ - +