]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-edit/video-add.component.ts
Add other video description tests
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-add.component.ts
index 21311b184067add1af455b3bc7228b5f346e240d..92b03e8c96cae9c6898aa871929a3e139ef38f0d 100644 (file)
@@ -11,12 +11,14 @@ import {
   VIDEO_LICENCE,
   VIDEO_LANGUAGE,
   VIDEO_DESCRIPTION,
-  VIDEO_TAGS
+  VIDEO_TAGS,
+  VIDEO_CHANNEL,
+  VIDEO_FILE
 } from '../../shared'
+import { AuthService, ServerService } from '../../core'
 import { VideoService } from '../shared'
 import { VideoCreate } from '../../../../../shared'
 import { HttpEventType, HttpResponse } from '@angular/common/http'
-import { VIDEO_FILE } from '../../shared/forms/form-validators/video'
 
 @Component({
   selector: 'my-videos-add',
@@ -32,6 +34,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
   videoCategories = []
   videoLicences = []
   videoLanguages = []
+  userVideoChannels = []
 
   tagValidators = VIDEO_TAGS.VALIDATORS
   tagValidatorsMessages = VIDEO_TAGS.MESSAGES
@@ -43,6 +46,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     category: '',
     licence: '',
     language: '',
+    channelId: '',
     description: '',
     videofile: ''
   }
@@ -51,6 +55,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     category: VIDEO_CATEGORY.MESSAGES,
     licence: VIDEO_LICENCE.MESSAGES,
     language: VIDEO_LANGUAGE.MESSAGES,
+    channelId: VIDEO_CHANNEL.MESSAGES,
     description: VIDEO_DESCRIPTION.MESSAGES,
     videofile: VIDEO_FILE.MESSAGES
   }
@@ -59,6 +64,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     private formBuilder: FormBuilder,
     private router: Router,
     private notificationsService: NotificationsService,
+    private authService: AuthService,
+    private serverService: ServerService,
     private videoService: VideoService
   ) {
     super()
@@ -75,6 +82,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
       category: [ '', VIDEO_CATEGORY.VALIDATORS ],
       licence: [ '', VIDEO_LICENCE.VALIDATORS ],
       language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
+      channelId: [ this.userVideoChannels[0].id, VIDEO_CHANNEL.VALIDATORS ],
       description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
       videofile: [ '', VIDEO_FILE.VALIDATORS ],
       tags: [ '' ]
@@ -84,9 +92,12 @@ export class VideoAddComponent extends FormReactive implements OnInit {
   }
 
   ngOnInit () {
-    this.videoCategories = this.videoService.videoCategories
-    this.videoLicences = this.videoService.videoLicences
-    this.videoLanguages = this.videoService.videoLanguages
+    this.videoCategories = this.serverService.getVideoCategories()
+    this.videoLicences = this.serverService.getVideoLicences()
+    this.videoLanguages = this.serverService.getVideoLanguages()
+
+    const user = this.authService.getUser()
+    this.userVideoChannels = user.videoChannels.map(v => ({ id: v.id, label: v.name }))
 
     this.buildForm()
   }
@@ -120,6 +131,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     const category = formValue.category
     const licence = formValue.licence
     const language = formValue.language
+    const channelId = formValue.channelId
     const description = formValue.description
     const tags = formValue.tags
     const videofile = this.videofileInput.nativeElement.files[0]
@@ -129,6 +141,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     formData.append('category', '' + category)
     formData.append('nsfw', '' + nsfw)
     formData.append('licence', '' + licence)
+    formData.append('channelId', '' + channelId)
     formData.append('videofile', videofile)
 
     // Language is optional