mirror of https://github.com/Chocobozzz/PeerTube
Add ability to set a public to private in client
parent
1b319b7aa6
commit
851f5daa1e
|
@ -7,7 +7,6 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
|
|||
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'
|
||||
|
||||
|
@ -18,7 +17,6 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
|
|||
})
|
||||
export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylistEdit implements OnInit {
|
||||
error: string
|
||||
videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = []
|
||||
|
||||
constructor (
|
||||
protected formValidatorService: FormValidatorService,
|
||||
|
@ -47,6 +45,7 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
|
|||
})
|
||||
|
||||
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
|
||||
.catch(err => console.error('Cannot populate user video channels.', err))
|
||||
|
||||
this.serverService.videoPlaylistPrivaciesLoaded.subscribe(
|
||||
() => {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
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
|
||||
|
|
|
@ -9,9 +9,8 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
|
|||
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',
|
||||
|
@ -21,7 +20,6 @@ import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
|
|||
export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylistEdit implements OnInit, OnDestroy {
|
||||
error: string
|
||||
videoPlaylistToUpdate: VideoPlaylist
|
||||
videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = []
|
||||
|
||||
private paramsSub: Subscription
|
||||
|
||||
|
@ -53,31 +51,24 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
|
|||
})
|
||||
|
||||
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
|
||||
.catch(err => console.error('Cannot populate user video channels.', err))
|
||||
|
||||
this.paramsSub = this.route.params.subscribe(routeParams => {
|
||||
const videoPlaylistId = routeParams['videoPlaylistId']
|
||||
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.videoPlaylistService.getVideoPlaylist(videoPlaylistId).subscribe(
|
||||
videoPlaylistToUpdate => {
|
||||
this.videoPlaylistToUpdate = videoPlaylistToUpdate
|
||||
this.hydrateFormFromPlaylist()
|
||||
},
|
||||
|
||||
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
|
||||
)
|
||||
})
|
||||
err => this.error = err.message
|
||||
)
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
|
|
|
@ -13,6 +13,7 @@ import { VideoCaptionAddModalComponent } from '@app/videos/+video-edit/shared/vi
|
|||
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',
|
||||
|
@ -23,7 +24,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
@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 })[] = []
|
||||
|
@ -34,6 +34,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
// 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>[] = []
|
||||
|
@ -58,6 +59,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
private formValidatorService: FormValidatorService,
|
||||
private videoValidatorsService: VideoValidatorsService,
|
||||
private videoCaptionService: VideoCaptionService,
|
||||
private videoService: VideoService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private notifier: Notifier,
|
||||
|
@ -132,6 +134,9 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
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(() => {
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<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">
|
||||
|
|
|
@ -100,7 +100,6 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
|
|||
previewUrl: null
|
||||
}))
|
||||
|
||||
this.explainedVideoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
|
||||
|
||||
this.hydrateFormFromVideo()
|
||||
},
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<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">
|
||||
|
|
|
@ -14,7 +14,6 @@ import { CanComponentDeactivateResult } from '@app/shared/guards/can-deactivate-
|
|||
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
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<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>
|
||||
|
||||
|
|
|
@ -188,8 +188,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
|||
previewfile: this.previewfileUpload
|
||||
})
|
||||
|
||||
this.explainedVideoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
|
||||
|
||||
this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
|
||||
event => {
|
||||
if (event.type === HttpEventType.UploadProgress) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<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>
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { Component, HostListener, OnInit } from '@angular/core'
|
|||
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'
|
||||
|
@ -23,8 +22,6 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
|||
video: VideoEdit
|
||||
|
||||
isUpdatingVideo = false
|
||||
videoPrivacies: VideoConstant<VideoPrivacy>[] = []
|
||||
explainedVideoPrivacies: VideoConstant<VideoPrivacy>[] = []
|
||||
userVideoChannels: { id: number, label: string, support: string }[] = []
|
||||
schedulePublicationPossible = false
|
||||
videoCaptions: VideoCaptionEdit[] = []
|
||||
|
@ -49,9 +46,6 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
|||
ngOnInit () {
|
||||
this.buildForm({})
|
||||
|
||||
this.serverService.videoPrivaciesLoaded
|
||||
.subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
|
||||
|
||||
this.route.data
|
||||
.pipe(map(data => data.videoData))
|
||||
.subscribe(({ video, videoChannels, videoCaptions }) => {
|
||||
|
@ -59,15 +53,6 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue