diff options
-rw-r--r-- | client/src/app/+admin/overview/videos/video-list.component.html | 2 | ||||
-rw-r--r-- | client/src/app/+admin/overview/videos/video-list.component.ts | 4 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/video/video.model.ts | 11 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 4 | ||||
-rw-r--r-- | server/tests/api/transcoding/transcoder.ts | 4 | ||||
-rw-r--r-- | server/tests/api/transcoding/video-studio.ts | 4 | ||||
-rw-r--r-- | server/tests/cli/update-host.ts | 2 | ||||
-rw-r--r-- | server/tests/shared/videos.ts | 13 | ||||
-rw-r--r-- | shared/core-utils/videos/privacy.ts | 14 |
9 files changed, 36 insertions, 22 deletions
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 06b9ab347..14bbb55e9 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html | |||
@@ -109,6 +109,7 @@ | |||
109 | {{ file.resolution.label }}: {{ file.size | bytes: 1 }} | 109 | {{ file.resolution.label }}: {{ file.size | bytes: 1 }} |
110 | 110 | ||
111 | <my-global-icon | 111 | <my-global-icon |
112 | *ngIf="canRemoveOneFile(video)" | ||
112 | i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" | 113 | i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" |
113 | (click)="removeVideoFile(video, file, 'webtorrent')" | 114 | (click)="removeVideoFile(video, file, 'webtorrent')" |
114 | ></my-global-icon> | 115 | ></my-global-icon> |
@@ -124,6 +125,7 @@ | |||
124 | {{ file.resolution.label }}: {{ file.size | bytes: 1 }} | 125 | {{ file.resolution.label }}: {{ file.size | bytes: 1 }} |
125 | 126 | ||
126 | <my-global-icon | 127 | <my-global-icon |
128 | *ngIf="canRemoveOneFile(video)" | ||
127 | i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" | 129 | i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" |
128 | (click)="removeVideoFile(video, file, 'hls')" | 130 | (click)="removeVideoFile(video, file, 'hls')" |
129 | ></my-global-icon> | 131 | ></my-global-icon> |
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 ed7ec54a1..cb693ce12 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts | |||
@@ -166,6 +166,10 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
166 | return video.files.length !== 0 | 166 | return video.files.length !== 0 |
167 | } | 167 | } |
168 | 168 | ||
169 | canRemoveOneFile (video: Video) { | ||
170 | return video.canRemoveOneFile(this.authUser) | ||
171 | } | ||
172 | |||
169 | getFilesSize (video: Video) { | 173 | getFilesSize (video: Video) { |
170 | let files = video.files | 174 | let files = video.files |
171 | 175 | ||
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 2e4ab87d7..c9c6b979c 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { AuthUser } from '@app/core' | 1 | import { AuthUser } from '@app/core' |
2 | import { User } from '@app/core/users/user.model' | 2 | import { User } from '@app/core/users/user.model' |
3 | import { durationToString, prepareIcu, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' | 3 | import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl, prepareIcu } from '@app/helpers' |
4 | import { Actor } from '@app/shared/shared-main/account/actor.model' | 4 | import { Actor } from '@app/shared/shared-main/account/actor.model' |
5 | import { buildVideoWatchPath } from '@shared/core-utils' | 5 | import { buildVideoWatchPath, getAllFiles } from '@shared/core-utils' |
6 | import { peertubeTranslate } from '@shared/core-utils/i18n' | 6 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
7 | import { | 7 | import { |
8 | ActorImage, | 8 | ActorImage, |
@@ -240,6 +240,13 @@ export class Video implements VideoServerModel { | |||
240 | return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS)) | 240 | return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS)) |
241 | } | 241 | } |
242 | 242 | ||
243 | canRemoveOneFile (user: AuthUser) { | ||
244 | return this.isLocal && | ||
245 | user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) && | ||
246 | this.state.id !== VideoState.TO_TRANSCODE && | ||
247 | getAllFiles(this).length > 1 | ||
248 | } | ||
249 | |||
243 | canRemoveFiles (user: AuthUser) { | 250 | canRemoveFiles (user: AuthUser) { |
244 | return this.isLocal && | 251 | return this.isLocal && |
245 | user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) && | 252 | user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) && |
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 48982f4de..885751285 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { basename, join } from 'path' | 4 | import { basename, join } from 'path' |
5 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' | 5 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' |
6 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, getAllFiles, testImage } from '@server/tests/shared' | 6 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' |
7 | import { wait } from '@shared/core-utils' | 7 | import { getAllFiles, wait } from '@shared/core-utils' |
8 | import { | 8 | import { |
9 | HttpStatusCode, | 9 | HttpStatusCode, |
10 | LiveVideo, | 10 | LiveVideo, |
diff --git a/server/tests/api/transcoding/transcoder.ts b/server/tests/api/transcoding/transcoder.ts index db0127805..c591f5f6f 100644 --- a/server/tests/api/transcoding/transcoder.ts +++ b/server/tests/api/transcoding/transcoder.ts | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { canDoQuickTranscode } from '@server/helpers/ffmpeg' | 4 | import { canDoQuickTranscode } from '@server/helpers/ffmpeg' |
5 | import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared' | 5 | import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared' |
6 | import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils' | 6 | import { buildAbsoluteFixturePath, getAllFiles, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils' |
7 | import { | 7 | import { |
8 | buildFileMetadata, | 8 | buildFileMetadata, |
9 | getAudioStream, | 9 | getAudioStream, |
diff --git a/server/tests/api/transcoding/video-studio.ts b/server/tests/api/transcoding/video-studio.ts index ac1c0fc7e..9613111b5 100644 --- a/server/tests/api/transcoding/video-studio.ts +++ b/server/tests/api/transcoding/video-studio.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { expectStartWith, getAllFiles } from '@server/tests/shared' | 2 | import { expectStartWith } from '@server/tests/shared' |
3 | import { areObjectStorageTestsDisabled } from '@shared/core-utils' | 3 | import { areObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils' |
4 | import { VideoStudioTask } from '@shared/models' | 4 | import { VideoStudioTask } from '@shared/models' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 53c4e7824..97632450a 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { getAllFiles } from '@shared/core-utils' | ||
4 | import { | 5 | import { |
5 | cleanupTests, | 6 | cleanupTests, |
6 | createSingleServer, | 7 | createSingleServer, |
@@ -11,7 +12,6 @@ import { | |||
11 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/server-commands' | 14 | } from '@shared/server-commands' |
14 | import { getAllFiles } from '../shared' | ||
15 | 15 | ||
16 | describe('Test update host scripts', function () { | 16 | describe('Test update host scripts', function () { |
17 | let server: PeerTubeServer | 17 | let server: PeerTubeServer |
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts index 3ab245392..e18329e07 100644 --- a/server/tests/shared/videos.ts +++ b/server/tests/shared/videos.ts | |||
@@ -241,16 +241,6 @@ async function uploadRandomVideoOnServers ( | |||
241 | return res | 241 | return res |
242 | } | 242 | } |
243 | 243 | ||
244 | function getAllFiles (video: VideoDetails) { | ||
245 | const files = video.files | ||
246 | |||
247 | if (video.streamingPlaylists[0]) { | ||
248 | return files.concat(video.streamingPlaylists[0].files) | ||
249 | } | ||
250 | |||
251 | return files | ||
252 | } | ||
253 | |||
254 | // --------------------------------------------------------------------------- | 244 | // --------------------------------------------------------------------------- |
255 | 245 | ||
256 | export { | 246 | export { |
@@ -258,6 +248,5 @@ export { | |||
258 | checkUploadVideoParam, | 248 | checkUploadVideoParam, |
259 | uploadRandomVideoOnServers, | 249 | uploadRandomVideoOnServers, |
260 | checkVideoFilesWereRemoved, | 250 | checkVideoFilesWereRemoved, |
261 | saveVideoInServers, | 251 | saveVideoInServers |
262 | getAllFiles | ||
263 | } | 252 | } |
diff --git a/shared/core-utils/videos/privacy.ts b/shared/core-utils/videos/privacy.ts index 7d3b67d50..f33487b49 100644 --- a/shared/core-utils/videos/privacy.ts +++ b/shared/core-utils/videos/privacy.ts | |||
@@ -1,9 +1,21 @@ | |||
1 | import { VideoDetails } from '../../models/videos/video.model' | ||
1 | import { VideoPrivacy } from '../../models/videos/video-privacy.enum' | 2 | import { VideoPrivacy } from '../../models/videos/video-privacy.enum' |
2 | 3 | ||
3 | function getAllPrivacies () { | 4 | function getAllPrivacies () { |
4 | return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] | 5 | return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] |
5 | } | 6 | } |
6 | 7 | ||
8 | function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) { | ||
9 | const files = video.files | ||
10 | |||
11 | if (video.streamingPlaylists[0]) { | ||
12 | return files.concat(video.streamingPlaylists[0].files) | ||
13 | } | ||
14 | |||
15 | return files | ||
16 | } | ||
17 | |||
7 | export { | 18 | export { |
8 | getAllPrivacies | 19 | getAllPrivacies, |
20 | getAllFiles | ||
9 | } | 21 | } |