]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-edit/video-add.component.ts
Video support field inherits channel support field
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-add.component.ts
index e81243d3e70556af2fde0ce9ef5e942afe3fdbb7..997f033b75faa3b9a38078008fc8a629f9a746fc 100644 (file)
@@ -7,7 +7,7 @@ import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.
 import { LoadingBarService } from '@ngx-loading-bar/core'
 import { NotificationsService } from 'angular2-notifications'
 import { BytesPipe } from 'ngx-pipes'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
 import { VideoPrivacy } from '../../../../../shared/models/videos'
 import { AuthService, ServerService } from '../../core'
 import { FormReactive } from '../../shared'
@@ -24,7 +24,6 @@ import { VideoService } from '../../shared/video/video.service'
     './video-add.component.scss'
   ]
 })
-
 export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate {
   @ViewChild('videofileInput') videofileInput
 
@@ -43,7 +42,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
   formErrors: { [ id: string ]: string } = {}
   validationMessages: ValidatorMessage = {}
 
-  userVideoChannels = []
+  userVideoChannels: { id: number, label: string, support: string }[] = []
   userVideoQuotaUsed = 0
   videoPrivacies = []
   firstStepPrivacyId = 0
@@ -133,9 +132,15 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
   }
 
   uploadFirstStep () {
-    const videofile = this.videofileInput.nativeElement.files[0]
+    const videofile = this.videofileInput.nativeElement.files[0] as File
     if (!videofile) return
 
+    // Cannot upload videos > 4GB for now
+    if (videofile.size > 4 * 1024 * 1024 * 1024) {
+      this.notificationsService.error('Error', 'We are sorry but PeerTube cannot handle videos > 4GB')
+      return
+    }
+
     const videoQuota = this.authService.getUser().videoQuota
     if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) {
       const bytePipes = new BytesPipe()
@@ -150,7 +155,16 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
 
     this.videoFileName = videofile.name
 
-    const name = videofile.name.replace(/\.[^/.]+$/, '')
+    const nameWithoutExtension = videofile.name.replace(/\.[^/.]+$/, '')
+    let name: string
+
+    // If the name of the file is very small, keep the extension
+    if (nameWithoutExtension.length < 3) {
+      name = videofile.name
+    } else {
+      name = nameWithoutExtension
+    }
+
     const privacy = this.firstStepPrivacyId.toString()
     const nsfw = false
     const commentsEnabled = true
@@ -158,7 +172,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
 
     const formData = new FormData()
     formData.append('name', name)
-    // Put the video "private" -> we wait he validates the second step
+    // Put the video "private" -> we are waiting the user validation of the second step
     formData.append('privacy', VideoPrivacy.PRIVATE.toString())
     formData.append('nsfw', '' + nsfw)
     formData.append('commentsEnabled', '' + commentsEnabled)
@@ -205,7 +219,6 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
 
     const video = new VideoEdit()
     video.patch(this.form.value)
-    video.channel = this.firstStepChannelId
     video.id = this.videoUploadedIds.id
     video.uuid = this.videoUploadedIds.uuid