From b46cf4b920984492df598c1b61179acfc7f6f22e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Nov 2021 16:04:53 +0100 Subject: Add ability to remove hls/webtorrent files --- .../overview/videos/video-list.component.html | 4 +- .../+admin/overview/videos/video-list.component.ts | 55 +++++++++++++++++----- 2 files changed, 44 insertions(+), 15 deletions(-) (limited to 'client/src/app/+admin/overview') diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index 9b536ec11..6e4fb4c6f 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -57,7 +57,7 @@ @@ -127,4 +127,4 @@ - + diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 7f268bb23..3c21adb44 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -39,7 +39,8 @@ export class VideoListComponent extends RestTable implements OnInit { report: false, duplicate: true, mute: true, - liveInfo: false + liveInfo: false, + removeFiles: true } loading = true @@ -71,17 +72,34 @@ export class VideoListComponent extends RestTable implements OnInit { { label: $localize`Delete`, handler: videos => this.removeVideos(videos), - isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO) + isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO), + iconName: 'delete' }, { label: $localize`Block`, handler: videos => this.videoBlockModal.show(videos), - isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => !v.blacklisted) + isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => !v.blacklisted), + iconName: 'no' }, { label: $localize`Unblock`, handler: videos => this.unblockVideos(videos), - isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => v.blacklisted) + isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => v.blacklisted), + iconName: 'undo' + } + ], + [ + { + label: $localize`Delete HLS files`, + handler: videos => this.removeVideoFiles(videos, 'hls'), + isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()), + iconName: 'delete' + }, + { + label: $localize`Delete WebTorrent files`, + handler: videos => this.removeVideoFiles(videos, 'webtorrent'), + isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()), + iconName: 'delete' } ] ] @@ -95,10 +113,6 @@ export class VideoListComponent extends RestTable implements OnInit { return this.selectedVideos.length !== 0 } - onVideoRemoved () { - this.reloadData() - } - getPrivacyBadgeClass (video: Video) { if (video.privacy.id === VideoPrivacy.PUBLIC) return 'badge-green' @@ -146,11 +160,7 @@ export class VideoListComponent extends RestTable implements OnInit { return files.reduce((p, f) => p += f.size, 0) } - onVideoBlocked () { - this.reloadData() - } - - protected reloadData () { + reloadData () { this.selectedVideos = [] this.loading = true @@ -197,4 +207,23 @@ export class VideoListComponent extends RestTable implements OnInit { error: err => this.notifier.error(err.message) }) } + + private async removeVideoFiles (videos: Video[], type: 'hls' | 'webtorrent') { + const message = type === 'hls' + ? $localize`Are you sure you want to delete ${videos.length} HLS streaming playlists?` + : $localize`Are you sure you want to delete WebTorrent files of ${videos.length} videos?` + + const res = await this.confirmService.confirm(message, $localize`Delete`) + if (res === false) return + + this.videoService.removeVideoFiles(videos.map(v => v.id), type) + .subscribe({ + next: () => { + this.notifier.success($localize`Files were removed.`) + this.reloadData() + }, + + error: err => this.notifier.error(err.message) + }) + } } -- cgit v1.2.3