From 1bb4c9ab2e8b3b3022351b33a82a5e527fa5d4d7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jul 2022 14:50:41 +0200 Subject: Add ability to delete a specific video file --- .../+admin/overview/videos/video-list.component.html | 10 ++++++++++ .../+admin/overview/videos/video-list.component.scss | 7 +++++++ .../app/+admin/overview/videos/video-list.component.ts | 18 +++++++++++++++++- .../src/app/shared/shared-main/video/video.service.ts | 5 +++++ 4 files changed, 39 insertions(+), 1 deletion(-) (limited to 'client') 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 fdd682ee2..06b9ab347 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -107,6 +107,11 @@ @@ -117,6 +122,11 @@ diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scss index dcd41a1b4..d538ca30a 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.scss +++ b/client/src/app/+admin/overview/videos/video-list.component.scss @@ -13,6 +13,13 @@ my-embed { .video-info > div { display: flex; + + my-global-icon { + width: 16px; + margin-left: 3px; + position: relative; + top: -2px; + } } .loading { 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 67e52d100..ed7ec54a1 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -8,7 +8,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { VideoBlockComponent, VideoBlockService } from '@app/shared/shared-moderation' import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' -import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' +import { UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' import { VideoAdminService } from './video-admin.service' @Component({ @@ -196,6 +196,22 @@ export class VideoListComponent extends RestTable implements OnInit { }) } + async removeVideoFile (video: Video, file: VideoFile, type: 'hls' | 'webtorrent') { + const message = $localize`Are you sure you want to delete this ${file.resolution.label} file?` + const res = await this.confirmService.confirm(message, $localize`Delete file`) + if (res === false) return + + this.videoService.removeFile(video.uuid, file.id, type) + .subscribe({ + next: () => { + this.notifier.success($localize`File removed.`) + this.reloadData() + }, + + error: err => this.notifier.error(err.message) + }) + } + private async removeVideos (videos: Video[]) { const message = prepareIcu($localize`Are you sure you want to delete {count, plural, =1 {this video} other {these {count} videos}}?`)( { count: videos.length }, diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index f2bf02695..8c8b1e08f 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -305,6 +305,11 @@ export class VideoService { ) } + removeFile (videoId: number | string, fileId: number, type: 'hls' | 'webtorrent') { + return this.authHttp.delete(VideoService.BASE_VIDEO_URL + '/' + videoId + '/' + type + '/' + fileId) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + runTranscoding (videoIds: (number | string)[], type: 'hls' | 'webtorrent') { const body: VideoTranscodingCreate = { transcodingType: type } -- cgit v1.2.3