From ffd9bf1c8b6f55e2333ae8c1aa072ea859fb0cb8 Mon Sep 17 00:00:00 2001 From: Wicklow <123956049+wickloww@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:29:07 +0000 Subject: [PATCH] Add ability to download videos from my videos page (#6008) * Fix object storage download * Add ability to download videos from my videos page * Updated code based on review comments * Styling --------- Co-authored-by: Chocobozzz --- .../my-videos/my-videos.component.ts | 2 +- .../app/shared/shared-main/video/video.model.ts | 2 +- .../video-actions-dropdown.component.ts | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index 4a7604878..caa3bcb44 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts @@ -48,7 +48,7 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { } videoDropdownDisplayOptions: VideoActionsDisplayType = { playlist: false, - download: false, + download: true, update: false, blacklist: false, delete: true, diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index ed28fb3f8..81a7cd3ee 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -232,7 +232,7 @@ export class Video implements VideoServerModel { this.isUpdatableBy(user) } - canSeeStats (user: AuthUser) { + isOwnerOrHasSeeAllVideosRight (user: AuthUser) { return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS)) } diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 4b3ed6e99..806629601 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts @@ -16,6 +16,7 @@ import { import { LiveStreamInformationComponent } from '../shared-video-live' import { VideoAddToPlaylistComponent } from '../shared-video-playlist' import { VideoDownloadComponent } from './video-download.component' +import { of } from 'rxjs' export type VideoActionsDisplayType = { playlist?: boolean @@ -128,7 +129,13 @@ export class VideoActionsDropdownComponent implements OnChanges { showDownloadModal () { this.modalOpened.emit() - this.videoDownloadModal.show(this.video as VideoDetails, this.videoCaptions) + const obs = this.video instanceof VideoDetails + ? of(this.video) + : this.videoService.getVideo({ videoId: this.video.uuid }) + + obs.subscribe((videoDetails: VideoDetails) => { + this.videoDownloadModal.show(videoDetails, this.videoCaptions) + }) } showReportModal () { @@ -160,7 +167,7 @@ export class VideoActionsDropdownComponent implements OnChanges { } isVideoStatsAvailable () { - return this.video.canSeeStats(this.user) + return this.video.isOwnerOrHasSeeAllVideosRight(this.user) } isVideoRemovable () { @@ -180,10 +187,14 @@ export class VideoActionsDropdownComponent implements OnChanges { } isVideoDownloadable () { - return this.video && + if (this.video.isOwnerOrHasSeeAllVideosRight(this.user)) return true + + return ( + this.video && this.video.isLive !== true && this.video instanceof VideoDetails && this.video.downloadEnabled + ) } canVideoBeDuplicated () {