diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2022-06-21 15:31:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 15:31:25 +0200 |
commit | 2e401e8575decb1d491d0db48ca1ab1eba5b2a66 (patch) | |
tree | eee1e6213ca4d635837ca01c2bdc5c876b8d8b7d /client/src | |
parent | dec49521556fc228c6e05b6199e9b07f619b38fb (diff) | |
download | PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.gz PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.zst PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.zip |
store uploaded video filename (#4885)
* store uploaded video filename
closes #4731
* dont crash if videos channel exist
* migration: use raw query
* video source: fixes after code review
* cleanup
* bump migration
* updates after code review
* refactor: use checkUserCanManageVideo
* videoSource: add openapi doc
* test(check-params/video-source): fix timeout
* Styling
* Correctly set original filename as source
Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'client/src')
6 files changed, 42 insertions, 3 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html index 595200c3b..650448a74 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html | |||
@@ -340,6 +340,21 @@ | |||
340 | </div> | 340 | </div> |
341 | 341 | ||
342 | <div class="col-md-12 col-xl-4"> | 342 | <div class="col-md-12 col-xl-4"> |
343 | |||
344 | <div *ngIf="videoSource" class="form-group"> | ||
345 | <label i18n for="filename">Filename</label> | ||
346 | |||
347 | <my-help> | ||
348 | <ng-template ptTemplate="preHtml"> | ||
349 | <ng-container i18n> | ||
350 | Name of the uploaded file | ||
351 | </ng-container> | ||
352 | </ng-template> | ||
353 | </my-help> | ||
354 | |||
355 | <input type="text" [disabled]="true" id="filename" class="form-control" [value]="videoSource.filename" /> | ||
356 | </div> | ||
357 | |||
343 | <div class="form-group originally-published-at"> | 358 | <div class="form-group originally-published-at"> |
344 | <label i18n for="originallyPublishedAt">Original publication date</label> | 359 | <label i18n for="originallyPublishedAt">Original publication date</label> |
345 | <my-help> | 360 | <my-help> |
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 16b964482..c74ef5731 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts | |||
@@ -37,6 +37,7 @@ import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' | |||
37 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' | 37 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' |
38 | import { VideoCaptionEditModalComponent } from './video-caption-edit-modal/video-caption-edit-modal.component' | 38 | import { VideoCaptionEditModalComponent } from './video-caption-edit-modal/video-caption-edit-modal.component' |
39 | import { VideoEditType } from './video-edit.type' | 39 | import { VideoEditType } from './video-edit.type' |
40 | import { VideoSource } from '@shared/models/videos/video-source' | ||
40 | 41 | ||
41 | type VideoLanguages = VideoConstant<string> & { group?: string } | 42 | type VideoLanguages = VideoConstant<string> & { group?: string } |
42 | type PluginField = { | 43 | type PluginField = { |
@@ -61,6 +62,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
61 | @Input() forbidScheduledPublication = true | 62 | @Input() forbidScheduledPublication = true |
62 | 63 | ||
63 | @Input() videoCaptions: VideoCaptionWithPathEdit[] = [] | 64 | @Input() videoCaptions: VideoCaptionWithPathEdit[] = [] |
65 | @Input() videoSource: VideoSource | ||
64 | 66 | ||
65 | @Input() waitTranscodingEnabled = true | 67 | @Input() waitTranscodingEnabled = true |
66 | @Input() type: VideoEditType | 68 | @Input() type: VideoEditType |
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html index 6a32f1477..ffd125695 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.html +++ b/client/src/app/+videos/+video-edit/video-update.component.html | |||
@@ -12,6 +12,7 @@ | |||
12 | [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()" | 12 | [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()" |
13 | type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()" | 13 | type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()" |
14 | [liveVideo]="liveVideo" [videoToUpdate]="videoDetails" | 14 | [liveVideo]="liveVideo" [videoToUpdate]="videoDetails" |
15 | [videoSource]="videoSource" | ||
15 | 16 | ||
16 | (formBuilt)="onFormBuilt()" | 17 | (formBuilt)="onFormBuilt()" |
17 | ></my-video-edit> | 18 | ></my-video-edit> |
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index 9c4998f2e..43e8ba3e5 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts | |||
@@ -10,6 +10,7 @@ import { LiveVideoService } from '@app/shared/shared-video-live' | |||
10 | import { LoadingBarService } from '@ngx-loading-bar/core' | 10 | import { LoadingBarService } from '@ngx-loading-bar/core' |
11 | import { LiveVideo, LiveVideoUpdate, VideoPrivacy } from '@shared/models' | 11 | import { LiveVideo, LiveVideoUpdate, VideoPrivacy } from '@shared/models' |
12 | import { hydrateFormFromVideo } from './shared/video-edit-utils' | 12 | import { hydrateFormFromVideo } from './shared/video-edit-utils' |
13 | import { VideoSource } from '@shared/models/videos/video-source' | ||
13 | 14 | ||
14 | @Component({ | 15 | @Component({ |
15 | selector: 'my-videos-update', | 16 | selector: 'my-videos-update', |
@@ -19,6 +20,7 @@ import { hydrateFormFromVideo } from './shared/video-edit-utils' | |||
19 | export class VideoUpdateComponent extends FormReactive implements OnInit { | 20 | export class VideoUpdateComponent extends FormReactive implements OnInit { |
20 | video: VideoEdit | 21 | video: VideoEdit |
21 | videoDetails: VideoDetails | 22 | videoDetails: VideoDetails |
23 | videoSource: VideoSource | ||
22 | userVideoChannels: SelectChannelItem[] = [] | 24 | userVideoChannels: SelectChannelItem[] = [] |
23 | videoCaptions: VideoCaptionEdit[] = [] | 25 | videoCaptions: VideoCaptionEdit[] = [] |
24 | liveVideo: LiveVideo | 26 | liveVideo: LiveVideo |
@@ -46,13 +48,14 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
46 | this.buildForm({}) | 48 | this.buildForm({}) |
47 | 49 | ||
48 | const { videoData } = this.route.snapshot.data | 50 | const { videoData } = this.route.snapshot.data |
49 | const { video, videoChannels, videoCaptions, liveVideo } = videoData | 51 | const { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData |
50 | 52 | ||
51 | this.video = new VideoEdit(video) | 53 | this.video = new VideoEdit(video) |
52 | this.videoDetails = video | 54 | this.videoDetails = video |
53 | 55 | ||
54 | this.userVideoChannels = videoChannels | 56 | this.userVideoChannels = videoChannels |
55 | this.videoCaptions = videoCaptions | 57 | this.videoCaptions = videoCaptions |
58 | this.videoSource = videoSource | ||
56 | this.liveVideo = liveVideo | 59 | this.liveVideo = liveVideo |
57 | 60 | ||
58 | this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE | 61 | this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE |
diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 82dae5c1c..db5017340 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts | |||
@@ -23,7 +23,8 @@ export class VideoUpdateResolver implements Resolve<any> { | |||
23 | return this.videoService.getVideo({ videoId: uuid }) | 23 | return this.videoService.getVideo({ videoId: uuid }) |
24 | .pipe( | 24 | .pipe( |
25 | switchMap(video => forkJoin(this.buildVideoObservables(video))), | 25 | switchMap(video => forkJoin(this.buildVideoObservables(video))), |
26 | map(([ video, videoChannels, videoCaptions, liveVideo ]) => ({ video, videoChannels, videoCaptions, liveVideo })) | 26 | map(([ video, videoSource, videoChannels, videoCaptions, liveVideo ]) => |
27 | ({ video, videoChannels, videoCaptions, videoSource, liveVideo })) | ||
27 | ) | 28 | ) |
28 | } | 29 | } |
29 | 30 | ||
@@ -33,6 +34,8 @@ export class VideoUpdateResolver implements Resolve<any> { | |||
33 | .loadCompleteDescription(video.descriptionPath) | 34 | .loadCompleteDescription(video.descriptionPath) |
34 | .pipe(map(description => Object.assign(video, { description }))), | 35 | .pipe(map(description => Object.assign(video, { description }))), |
35 | 36 | ||
37 | this.videoService.getSource(video.id), | ||
38 | |||
36 | listUserChannelsForSelect(this.authService), | 39 | listUserChannelsForSelect(this.authService), |
37 | 40 | ||
38 | this.videoCaptionService | 41 | this.videoCaptionService |
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 142367506..83bc4eeb6 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { from, Observable } from 'rxjs' | 2 | import { from, Observable, of } from 'rxjs' |
3 | import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' | 3 | import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' |
4 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' | 4 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
@@ -24,6 +24,7 @@ import { | |||
24 | VideoTranscodingCreate, | 24 | VideoTranscodingCreate, |
25 | VideoUpdate | 25 | VideoUpdate |
26 | } from '@shared/models' | 26 | } from '@shared/models' |
27 | import { VideoSource } from '@shared/models/videos/video-source' | ||
27 | import { environment } from '../../../../environments/environment' | 28 | import { environment } from '../../../../environments/environment' |
28 | import { Account } from '../account/account.model' | 29 | import { Account } from '../account/account.model' |
29 | import { AccountService } from '../account/account.service' | 30 | import { AccountService } from '../account/account.service' |
@@ -323,6 +324,20 @@ export class VideoService { | |||
323 | ) | 324 | ) |
324 | } | 325 | } |
325 | 326 | ||
327 | getSource (videoId: number) { | ||
328 | return this.authHttp | ||
329 | .get<{ source: VideoSource }>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/source') | ||
330 | .pipe( | ||
331 | catchError(err => { | ||
332 | if (err.status === 404) { | ||
333 | return of(undefined) | ||
334 | } | ||
335 | |||
336 | this.restExtractor.handleError(err) | ||
337 | }) | ||
338 | ) | ||
339 | } | ||
340 | |||
326 | setVideoLike (id: number) { | 341 | setVideoLike (id: number) { |
327 | return this.setVideoRate(id, 'like') | 342 | return this.setVideoRate(id, 'like') |
328 | } | 343 | } |