import { VideoPlaylistValidatorsService } from '@app/shared'
import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
-import { VideoConstant } from '@shared/models'
import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
})
export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylistEdit implements OnInit {
error: string
- videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = []
constructor (
protected formValidatorService: FormValidatorService,
})
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
+ .catch(err => console.error('Cannot populate user video channels.', err))
this.serverService.videoPlaylistPrivaciesLoaded.subscribe(
() => {
import { FormReactive } from '@app/shared'
import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model'
+import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models'
export abstract class MyAccountVideoPlaylistEdit extends FormReactive {
// Declare it here to avoid errors in create template
videoPlaylistToUpdate: VideoPlaylist
userVideoChannels: { id: number, label: string }[] = []
+ videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = []
abstract isCreation (): boolean
abstract getFormButtonTitle (): string
import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
import { VideoPlaylistValidatorsService } from '@app/shared'
import { VideoPlaylistUpdate } from '@shared/models/videos/playlist/video-playlist-update.model'
-import { VideoConstant } from '@shared/models'
-import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
+import { delayWhen, map, switchMap } from 'rxjs/operators'
@Component({
selector: 'my-account-video-playlist-update',
export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylistEdit implements OnInit, OnDestroy {
error: string
videoPlaylistToUpdate: VideoPlaylist
- videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = []
private paramsSub: Subscription
})
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
-
- this.paramsSub = this.route.params.subscribe(routeParams => {
- const videoPlaylistId = routeParams['videoPlaylistId']
-
- this.videoPlaylistService.getVideoPlaylist(videoPlaylistId).subscribe(
- videoPlaylistToUpdate => {
- this.videoPlaylistToUpdate = videoPlaylistToUpdate
-
- this.hydrateFormFromPlaylist()
-
- this.serverService.videoPlaylistPrivaciesLoaded.subscribe(
- () => {
- this.videoPlaylistPrivacies = this.serverService.getVideoPlaylistPrivacies()
- .filter(p => {
- // If the playlist is not private, we cannot put it in private anymore
- return this.videoPlaylistToUpdate.privacy.id === VideoPlaylistPrivacy.PRIVATE ||
- p.id !== VideoPlaylistPrivacy.PRIVATE
- })
- }
- )
- },
-
- err => this.error = err.message
- )
- })
+ .catch(err => console.error('Cannot populate user video channels.', err))
+
+ this.paramsSub = this.route.params
+ .pipe(
+ map(routeParams => routeParams['videoPlaylistId']),
+ switchMap(videoPlaylistId => this.videoPlaylistService.getVideoPlaylist(videoPlaylistId)),
+ delayWhen(() => this.serverService.videoPlaylistPrivaciesLoaded)
+ )
+ .subscribe(
+ videoPlaylistToUpdate => {
+ this.videoPlaylistPrivacies = this.serverService.getVideoPlaylistPrivacies()
+ this.videoPlaylistToUpdate = videoPlaylistToUpdate
+
+ this.hydrateFormFromPlaylist()
+ },
+
+ err => this.error = err.message
+ )
}
ngOnDestroy () {
import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model'
import { removeElementFromArray } from '@app/shared/misc/utils'
import { VideoConstant, VideoPrivacy } from '../../../../../../shared'
+import { VideoService } from '@app/shared/video/video.service'
@Component({
selector: 'my-video-edit',
@Input() form: FormGroup
@Input() formErrors: { [ id: string ]: string } = {}
@Input() validationMessages: FormReactiveValidationMessages = {}
- @Input() videoPrivacies: VideoConstant<VideoPrivacy>[] = []
@Input() userVideoChannels: { id: number, label: string, support: string }[] = []
@Input() schedulePublicationPossible = true
@Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = []
// So that it can be accessed in the template
readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY
+ videoPrivacies: VideoConstant<VideoPrivacy>[] = []
videoCategories: VideoConstant<number>[] = []
videoLicences: VideoConstant<number>[] = []
videoLanguages: VideoConstant<string>[] = []
private formValidatorService: FormValidatorService,
private videoValidatorsService: VideoValidatorsService,
private videoCaptionService: VideoCaptionService,
+ private videoService: VideoService,
private route: ActivatedRoute,
private router: Router,
private notifier: Notifier,
this.videoLicences = this.serverService.getVideoLicences()
this.videoLanguages = this.serverService.getVideoLanguages()
+ const privacies = this.serverService.getVideoPrivacies()
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies)
+
this.initialVideoCaptions = this.videoCaptions.map(c => c.language.id)
this.ngZone.runOutsideAngular(() => {
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [schedulePublicationPossible]="false"
- [validationMessages]="validationMessages" [videoPrivacies]="explainedVideoPrivacies" [userVideoChannels]="userVideoChannels"
+ [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
></my-video-edit>
<div class="submit-container">
previewUrl: null
}))
- this.explainedVideoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
this.hydrateFormFromVideo()
},
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [schedulePublicationPossible]="false"
- [validationMessages]="validationMessages" [videoPrivacies]="explainedVideoPrivacies" [userVideoChannels]="userVideoChannels"
+ [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
></my-video-edit>
<div class="submit-container">
export abstract class VideoSend extends FormReactive implements OnInit {
userVideoChannels: { id: number, label: string, support: string }[] = []
videoPrivacies: VideoConstant<VideoPrivacy>[] = []
- explainedVideoPrivacies: VideoConstant<VideoPrivacy>[] = []
videoCaptions: VideoCaptionEdit[] = []
firstStepPrivacyId = 0
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
- [validationMessages]="validationMessages" [videoPrivacies]="explainedVideoPrivacies" [userVideoChannels]="userVideoChannels"
+ [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
[waitTranscodingEnabled]="waitTranscodingEnabled"
></my-video-edit>
previewfile: this.previewfileUpload
})
- this.explainedVideoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
-
this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
event => {
if (event.type === HttpEventType.UploadProgress) {
<my-video-edit
[form]="form" [formErrors]="formErrors" [schedulePublicationPossible]="schedulePublicationPossible"
- [validationMessages]="validationMessages" [videoPrivacies]="explainedVideoPrivacies" [userVideoChannels]="userVideoChannels"
+ [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
[videoCaptions]="videoCaptions" [waitTranscodingEnabled]="waitTranscodingEnabled"
></my-video-edit>
import { ActivatedRoute, Router } from '@angular/router'
import { LoadingBarService } from '@ngx-loading-bar/core'
import { Notifier } from '@app/core'
-import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
import { ServerService } from '../../core'
import { FormReactive } from '../../shared'
import { VideoEdit } from '../../shared/video/video-edit.model'
video: VideoEdit
isUpdatingVideo = false
- videoPrivacies: VideoConstant<VideoPrivacy>[] = []
- explainedVideoPrivacies: VideoConstant<VideoPrivacy>[] = []
userVideoChannels: { id: number, label: string, support: string }[] = []
schedulePublicationPossible = false
videoCaptions: VideoCaptionEdit[] = []
ngOnInit () {
this.buildForm({})
- this.serverService.videoPrivaciesLoaded
- .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
-
this.route.data
.pipe(map(data => data.videoData))
.subscribe(({ video, videoChannels, videoCaptions }) => {
this.userVideoChannels = videoChannels
this.videoCaptions = videoCaptions
- // We cannot set private a video that was not private
- if (this.video.privacy !== VideoPrivacy.PRIVATE) {
- this.videoPrivacies = this.videoPrivacies.filter(p => p.id !== VideoPrivacy.PRIVATE)
- } else { // We can schedule video publication only if it it is private
- this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
- }
-
- this.explainedVideoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
-
const videoFiles = (video as VideoDetails).files
if (videoFiles.length > 1) { // Already transcoded
this.waitTranscodingEnabled = false