aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-07 17:22:44 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-07 17:22:44 +0100
commitbaeefe22caf8ae6cb58dc40754e5db14b50168bf (patch)
tree67ccfe9629bd7ea69036017c8a959e36e1eab6fd /client/src/app/videos/+video-edit/video-add.component.ts
parent8e7f08b5a5e65195ad6dd3d7850fda57021421f3 (diff)
downloadPeerTube-baeefe22caf8ae6cb58dc40754e5db14b50168bf.tar.gz
PeerTube-baeefe22caf8ae6cb58dc40754e5db14b50168bf.tar.zst
PeerTube-baeefe22caf8ae6cb58dc40754e5db14b50168bf.zip
First upload step is ok
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts52
1 files changed, 22 insertions, 30 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts
index 071f9a28b..c2ee4ae2e 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -23,12 +23,14 @@ export class VideoAddComponent extends FormReactive implements OnInit {
23 @ViewChild('videofileInput') videofileInput 23 @ViewChild('videofileInput') videofileInput
24 24
25 isUploadingVideo = false 25 isUploadingVideo = false
26 videoUploaded = false
26 progressPercent = 0 27 progressPercent = 0
27 28
28 error: string = null 29 error: string = null
29 form: FormGroup 30 form: FormGroup
30 formErrors: { [ id: string ]: string } = {} 31 formErrors: { [ id: string ]: string } = {}
31 validationMessages: ValidatorMessage = {} 32 validationMessages: ValidatorMessage = {}
33
32 userVideoChannels = [] 34 userVideoChannels = []
33 videoPrivacies = [] 35 videoPrivacies = []
34 firstStepPrivacy = 0 36 firstStepPrivacy = 0
@@ -53,8 +55,12 @@ export class VideoAddComponent extends FormReactive implements OnInit {
53 ngOnInit () { 55 ngOnInit () {
54 this.buildForm() 56 this.buildForm()
55 57
56 this.videoPrivacies = this.serverService.getVideoPrivacies() 58 this.serverService.videoCategoriesLoaded
57 this.firstStepPrivacy = this.videoPrivacies[0].id 59 .subscribe(
60 () => {
61 this.videoPrivacies = this.serverService.getVideoPrivacies()
62 this.firstStepPrivacy = this.videoPrivacies[0].id
63 })
58 64
59 this.authService.userInformationLoaded 65 this.authService.userInformationLoaded
60 .subscribe( 66 .subscribe(
@@ -71,8 +77,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
71 ) 77 )
72 } 78 }
73 79
74 fileChange ($event) { 80 fileChange () {
75 console.log('uploading file ?') 81 this.uploadFirstStep()
76 } 82 }
77 83
78 checkForm () { 84 checkForm () {
@@ -82,38 +88,26 @@ export class VideoAddComponent extends FormReactive implements OnInit {
82 } 88 }
83 89
84 uploadFirstStep () { 90 uploadFirstStep () {
85 const formValue: VideoCreate = this.form.value
86
87 const name = formValue.name
88 const privacy = formValue.privacy
89 const nsfw = formValue.nsfw
90 const category = formValue.category
91 const licence = formValue.licence
92 const language = formValue.language
93 const channelId = formValue.channelId
94 const description = formValue.description
95 const tags = formValue.tags
96 const videofile = this.videofileInput.nativeElement.files[0] 91 const videofile = this.videofileInput.nativeElement.files[0]
92 const name = videofile.name
93 const privacy = this.firstStepPrivacy.toString()
94 const nsfw = false
95 const channelId = this.firstStepChannel.toString()
97 96
98 const formData = new FormData() 97 const formData = new FormData()
99 formData.append('name', name) 98 formData.append('name', name)
100 formData.append('privacy', privacy.toString()) 99 formData.append('privacy', privacy.toString())
101 formData.append('category', '' + category)
102 formData.append('nsfw', '' + nsfw) 100 formData.append('nsfw', '' + nsfw)
103 formData.append('licence', '' + licence)
104 formData.append('channelId', '' + channelId) 101 formData.append('channelId', '' + channelId)
105 formData.append('videofile', videofile) 102 formData.append('videofile', videofile)
106 103
107 // Language is optional 104 this.isUploadingVideo = true
108 if (language) { 105 this.form.patchValue({
109 formData.append('language', '' + language) 106 name,
110 } 107 privacy,
111 108 nsfw,
112 formData.append('description', description) 109 channelId
113 110 })
114 for (let i = 0; i < tags.length; i++) {
115 formData.append(`tags[${i}]`, tags[i])
116 }
117 111
118 this.videoService.uploadVideo(formData).subscribe( 112 this.videoService.uploadVideo(formData).subscribe(
119 event => { 113 event => {
@@ -121,10 +115,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
121 this.progressPercent = Math.round(100 * event.loaded / event.total) 115 this.progressPercent = Math.round(100 * event.loaded / event.total)
122 } else if (event instanceof HttpResponse) { 116 } else if (event instanceof HttpResponse) {
123 console.log('Video uploaded.') 117 console.log('Video uploaded.')
124 this.notificationsService.success('Success', 'Video uploaded.')
125 118
126 // Display all the videos once it's finished 119 this.videoUploaded = true
127 this.router.navigate([ '/videos/trending' ])
128 } 120 }
129 }, 121 },
130 122