aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/forms/form-validators/video.ts5
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.html2
-rw-r--r--client/src/app/shared/misc/utils.ts24
-rw-r--r--client/src/app/shared/shared.module.ts5
-rw-r--r--client/src/app/shared/video/video-edit.model.ts6
-rw-r--r--client/src/app/shared/video/video-thumbnail.component.html2
-rw-r--r--client/src/app/shared/video/video.service.ts17
7 files changed, 50 insertions, 11 deletions
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts
index 500b5bc5f..34a237a12 100644
--- a/client/src/app/shared/forms/form-validators/video.ts
+++ b/client/src/app/shared/forms/form-validators/video.ts
@@ -31,6 +31,11 @@ export const VIDEO_LANGUAGE = {
31 MESSAGES: {} 31 MESSAGES: {}
32} 32}
33 33
34export const VIDEO_IMAGE = {
35 VALIDATORS: [ ],
36 MESSAGES: {}
37}
38
34export const VIDEO_CHANNEL = { 39export const VIDEO_CHANNEL = {
35 VALIDATORS: [ Validators.required ], 40 VALIDATORS: [ Validators.required ],
36 MESSAGES: { 41 MESSAGES: {
diff --git a/client/src/app/shared/forms/markdown-textarea.component.html b/client/src/app/shared/forms/markdown-textarea.component.html
index d2d4cf95c..e8c5ded5b 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.html
+++ b/client/src/app/shared/forms/markdown-textarea.component.html
@@ -5,7 +5,7 @@
5 id="description" name="description"> 5 id="description" name="description">
6 </textarea> 6 </textarea>
7 7
8 <tabset *ngIf="arePreviewsDisplayed()" #staticTabs class="previews"> 8 <tabset *ngIf="arePreviewsDisplayed()" class="previews">
9 <tab *ngIf="truncate !== undefined" heading="Truncated description preview" [innerHTML]="truncatedDescriptionHTML"></tab> 9 <tab *ngIf="truncate !== undefined" heading="Truncated description preview" [innerHTML]="truncatedDescriptionHTML"></tab>
10 <tab heading="Complete description preview" [innerHTML]="descriptionHTML"></tab> 10 <tab heading="Complete description preview" [innerHTML]="descriptionHTML"></tab>
11 </tabset> 11 </tabset>
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index e6a697098..e2e4c5b36 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -67,6 +67,27 @@ function isInMobileView () {
67 return window.innerWidth < 500 67 return window.innerWidth < 500
68} 68}
69 69
70// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
71function objectToFormData (obj: any, form?: FormData, namespace?: string) {
72 let fd = form || new FormData()
73 let formKey
74
75 for (let key of Object.keys(obj)) {
76 if (namespace) formKey = `${namespace}[${key}]`
77 else formKey = key
78
79 if (obj[key] === undefined) continue
80
81 if (typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) {
82 objectToFormData(obj[ key ], fd, key)
83 } else {
84 fd.append(formKey, obj[ key ])
85 }
86 }
87
88 return fd
89}
90
70export { 91export {
71 viewportHeight, 92 viewportHeight,
72 getParameterByName, 93 getParameterByName,
@@ -75,5 +96,6 @@ export {
75 dateToHuman, 96 dateToHuman,
76 isInSmallView, 97 isInSmallView,
77 isInMobileView, 98 isInMobileView,
78 immutableAssign 99 immutableAssign,
100 objectToFormData
79} 101}
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 330a0ba84..2a9426479 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -40,10 +40,10 @@ import { VideoService } from './video/video.service'
40 40
41 BsDropdownModule.forRoot(), 41 BsDropdownModule.forRoot(),
42 ModalModule.forRoot(), 42 ModalModule.forRoot(),
43 TabsModule.forRoot(),
43 44
44 PrimeSharedModule, 45 PrimeSharedModule,
45 NgPipesModule, 46 NgPipesModule
46 TabsModule.forRoot()
47 ], 47 ],
48 48
49 declarations: [ 49 declarations: [
@@ -69,6 +69,7 @@ import { VideoService } from './video/video.service'
69 69
70 BsDropdownModule, 70 BsDropdownModule,
71 ModalModule, 71 ModalModule,
72 TabsModule,
72 PrimeSharedModule, 73 PrimeSharedModule,
73 BytesPipe, 74 BytesPipe,
74 KeysPipe, 75 KeysPipe,
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index b1c772217..c39252f46 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -12,6 +12,10 @@ export class VideoEdit {
12 commentsEnabled: boolean 12 commentsEnabled: boolean
13 channel: number 13 channel: number
14 privacy: VideoPrivacy 14 privacy: VideoPrivacy
15 thumbnailfile?: any
16 previewfile?: any
17 thumbnailUrl: string
18 previewUrl: string
15 uuid?: string 19 uuid?: string
16 id?: number 20 id?: number
17 21
@@ -29,6 +33,8 @@ export class VideoEdit {
29 this.commentsEnabled = videoDetails.commentsEnabled 33 this.commentsEnabled = videoDetails.commentsEnabled
30 this.channel = videoDetails.channel.id 34 this.channel = videoDetails.channel.id
31 this.privacy = videoDetails.privacy 35 this.privacy = videoDetails.privacy
36 this.thumbnailUrl = videoDetails.thumbnailUrl
37 this.previewUrl = videoDetails.previewUrl
32 } 38 }
33 } 39 }
34 40
diff --git a/client/src/app/shared/video/video-thumbnail.component.html b/client/src/app/shared/video/video-thumbnail.component.html
index 8acfb3c41..4604d10e2 100644
--- a/client/src/app/shared/video/video-thumbnail.component.html
+++ b/client/src/app/shared/video/video-thumbnail.component.html
@@ -2,7 +2,7 @@
2 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" 2 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name"
3class="video-thumbnail" 3class="video-thumbnail"
4> 4>
5<img [attr.src]="getImageUrl()" alt="video thumbnail" [ngClass]="{ 'blur-filter': nsfw }" /> 5<img [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" />
6 6
7<div class="video-thumbnail-overlay"> 7<div class="video-thumbnail-overlay">
8 {{ video.durationLabel }} 8 {{ video.durationLabel }}
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 01d32176b..2e7138cd1 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -18,6 +18,7 @@ import { SortField } from './sort-field.type'
18import { VideoDetails } from './video-details.model' 18import { VideoDetails } from './video-details.model'
19import { VideoEdit } from './video-edit.model' 19import { VideoEdit } from './video-edit.model'
20import { Video } from './video.model' 20import { Video } from './video.model'
21import { objectToFormData } from '@app/shared/misc/utils'
21 22
22@Injectable() 23@Injectable()
23export class VideoService { 24export class VideoService {
@@ -46,10 +47,10 @@ export class VideoService {
46 } 47 }
47 48
48 updateVideo (video: VideoEdit) { 49 updateVideo (video: VideoEdit) {
49 const language = video.language || null 50 const language = video.language || undefined
50 const licence = video.licence || null 51 const licence = video.licence || undefined
51 const category = video.category || null 52 const category = video.category || undefined
52 const description = video.description || null 53 const description = video.description || undefined
53 54
54 const body: VideoUpdate = { 55 const body: VideoUpdate = {
55 name: video.name, 56 name: video.name,
@@ -60,10 +61,14 @@ export class VideoService {
60 privacy: video.privacy, 61 privacy: video.privacy,
61 tags: video.tags, 62 tags: video.tags,
62 nsfw: video.nsfw, 63 nsfw: video.nsfw,
63 commentsEnabled: video.commentsEnabled 64 commentsEnabled: video.commentsEnabled,
65 thumbnailfile: video.thumbnailfile,
66 previewfile: video.previewfile
64 } 67 }
65 68
66 return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, body) 69 const data = objectToFormData(body)
70
71 return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
67 .map(this.restExtractor.extractDataBool) 72 .map(this.restExtractor.extractDataBool)
68 .catch(this.restExtractor.handleError) 73 .catch(this.restExtractor.handleError)
69 } 74 }