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.ts12
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.html10
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.scss1
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.ts37
-rw-r--r--client/src/app/shared/video/video-details.model.ts1
-rw-r--r--client/src/app/shared/video/video-edit.model.ts3
-rw-r--r--client/src/app/shared/video/video.service.ts1
7 files changed, 43 insertions, 22 deletions
diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts
index 34a237a12..9ecbbbd60 100644
--- a/client/src/app/shared/forms/form-validators/video.ts
+++ b/client/src/app/shared/forms/form-validators/video.ts
@@ -44,10 +44,10 @@ export const VIDEO_CHANNEL = {
44} 44}
45 45
46export const VIDEO_DESCRIPTION = { 46export const VIDEO_DESCRIPTION = {
47 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(3000) ], 47 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
48 MESSAGES: { 48 MESSAGES: {
49 'minlength': 'Video description must be at least 3 characters long.', 49 'minlength': 'Video description must be at least 3 characters long.',
50 'maxlength': 'Video description cannot be more than 3000 characters long.' 50 'maxlength': 'Video description cannot be more than 10000 characters long.'
51 } 51 }
52} 52}
53 53
@@ -58,3 +58,11 @@ export const VIDEO_TAGS = {
58 'maxlength': 'A tag should be less than 30 characters long.' 58 'maxlength': 'A tag should be less than 30 characters long.'
59 } 59 }
60} 60}
61
62export const VIDEO_SUPPORT = {
63 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(300) ],
64 MESSAGES: {
65 'minlength': 'Video support must be at least 3 characters long.',
66 'maxlength': 'Video support cannot be more than 300 characters long.'
67 }
68}
diff --git a/client/src/app/shared/forms/markdown-textarea.component.html b/client/src/app/shared/forms/markdown-textarea.component.html
index e8c5ded5b..46a97b163 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.html
+++ b/client/src/app/shared/forms/markdown-textarea.component.html
@@ -1,12 +1,12 @@
1<div class="root" [ngStyle]="{ 'flex-direction': flexDirection }"> 1<div class="root" [ngStyle]="{ 'flex-direction': flexDirection }">
2 <textarea 2 <textarea
3 [(ngModel)]="description" (ngModelChange)="onModelChange()" 3 [(ngModel)]="content" (ngModelChange)="onModelChange()"
4 [ngClass]="classes" [ngStyle]="{ width: textareaWidth, height: textareaHeight, 'margin-right': textareaMarginRight }" 4 [ngClass]="classes" [ngStyle]="{ width: textareaWidth, height: textareaHeight, 'margin-right': textareaMarginRight }"
5 id="description" name="description"> 5 id="description" name="description">
6 </textarea> 6 </textarea>
7 7
8 <tabset *ngIf="arePreviewsDisplayed()" 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 preview" [innerHTML]="truncatedPreviewHTML"></tab>
10 <tab heading="Complete description preview" [innerHTML]="descriptionHTML"></tab> 10 <tab heading="Complete preview" [innerHTML]="previewHTML"></tab>
11 </tabset> 11 </tabset>
12</div> 12</div>
diff --git a/client/src/app/shared/forms/markdown-textarea.component.scss b/client/src/app/shared/forms/markdown-textarea.component.scss
index 82aff541d..6f7494621 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.scss
+++ b/client/src/app/shared/forms/markdown-textarea.component.scss
@@ -22,6 +22,7 @@
22 min-height: 75px; 22 min-height: 75px;
23 padding: 15px; 23 padding: 15px;
24 font-size: 15px; 24 font-size: 15px;
25 word-wrap: break-word;
25 } 26 }
26 } 27 }
27} 28}
diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts
index 2eae1b27e..928a63b28 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/forms/markdown-textarea.component.ts
@@ -21,29 +21,30 @@ import truncate from 'lodash-es/truncate'
21}) 21})
22 22
23export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { 23export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
24 @Input() description = '' 24 @Input() content = ''
25 @Input() classes: string[] = [] 25 @Input() classes: string[] = []
26 @Input() textareaWidth = '100%' 26 @Input() textareaWidth = '100%'
27 @Input() textareaHeight = '150px' 27 @Input() textareaHeight = '150px'
28 @Input() previewColumn = false 28 @Input() previewColumn = false
29 @Input() truncate: number 29 @Input() truncate: number
30 @Input() markdownType: 'text' | 'enhanced' = 'text'
30 31
31 textareaMarginRight = '0' 32 textareaMarginRight = '0'
32 flexDirection = 'column' 33 flexDirection = 'column'
33 truncatedDescriptionHTML = '' 34 truncatedPreviewHTML = ''
34 descriptionHTML = '' 35 previewHTML = ''
35 36
36 private descriptionChanged = new Subject<string>() 37 private contentChanged = new Subject<string>()
37 38
38 constructor (private markdownService: MarkdownService) {} 39 constructor (private markdownService: MarkdownService) {}
39 40
40 ngOnInit () { 41 ngOnInit () {
41 this.descriptionChanged 42 this.contentChanged
42 .debounceTime(150) 43 .debounceTime(150)
43 .distinctUntilChanged() 44 .distinctUntilChanged()
44 .subscribe(() => this.updateDescriptionPreviews()) 45 .subscribe(() => this.updatePreviews())
45 46
46 this.descriptionChanged.next(this.description) 47 this.contentChanged.next(this.content)
47 48
48 if (this.previewColumn) { 49 if (this.previewColumn) {
49 this.flexDirection = 'row' 50 this.flexDirection = 'row'
@@ -54,9 +55,9 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
54 propagateChange = (_: any) => { /* empty */ } 55 propagateChange = (_: any) => { /* empty */ }
55 56
56 writeValue (description: string) { 57 writeValue (description: string) {
57 this.description = description 58 this.content = description
58 59
59 this.descriptionChanged.next(this.description) 60 this.contentChanged.next(this.content)
60 } 61 }
61 62
62 registerOnChange (fn: (_: any) => void) { 63 registerOnChange (fn: (_: any) => void) {
@@ -68,19 +69,25 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
68 } 69 }
69 70
70 onModelChange () { 71 onModelChange () {
71 this.propagateChange(this.description) 72 this.propagateChange(this.content)
72 73
73 this.descriptionChanged.next(this.description) 74 this.contentChanged.next(this.content)
74 } 75 }
75 76
76 arePreviewsDisplayed () { 77 arePreviewsDisplayed () {
77 return isInSmallView() === false 78 return isInSmallView() === false
78 } 79 }
79 80
80 private updateDescriptionPreviews () { 81 private updatePreviews () {
81 if (this.description === null || this.description === undefined) return 82 if (this.content === null || this.content === undefined) return
82 83
83 this.truncatedDescriptionHTML = this.markdownService.markdownToHTML(truncate(this.description, { length: this.truncate })) 84 this.truncatedPreviewHTML = this.markdownRender(truncate(this.content, { length: this.truncate }))
84 this.descriptionHTML = this.markdownService.markdownToHTML(this.description) 85 this.previewHTML = this.markdownRender(this.content)
86 }
87
88 private markdownRender (text: string) {
89 if (this.markdownType === 'text') return this.markdownService.textMarkdownToHTML(text)
90
91 return this.markdownService.enhancedMarkdownToHTML(text)
85 } 92 }
86} 93}
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index c746bfd66..4e4f64c7b 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -57,6 +57,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
57 this.channel = hash.channel 57 this.channel = hash.channel
58 this.account = hash.account 58 this.account = hash.account
59 this.tags = hash.tags 59 this.tags = hash.tags
60 this.support = hash.support
60 this.commentsEnabled = hash.commentsEnabled 61 this.commentsEnabled = hash.commentsEnabled
61 62
62 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100 63 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index c39252f46..a8bbb63eb 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -12,6 +12,7 @@ export class VideoEdit {
12 commentsEnabled: boolean 12 commentsEnabled: boolean
13 channel: number 13 channel: number
14 privacy: VideoPrivacy 14 privacy: VideoPrivacy
15 support: string
15 thumbnailfile?: any 16 thumbnailfile?: any
16 previewfile?: any 17 previewfile?: any
17 thumbnailUrl: string 18 thumbnailUrl: string
@@ -33,6 +34,7 @@ export class VideoEdit {
33 this.commentsEnabled = videoDetails.commentsEnabled 34 this.commentsEnabled = videoDetails.commentsEnabled
34 this.channel = videoDetails.channel.id 35 this.channel = videoDetails.channel.id
35 this.privacy = videoDetails.privacy 36 this.privacy = videoDetails.privacy
37 this.support = videoDetails.support
36 this.thumbnailUrl = videoDetails.thumbnailUrl 38 this.thumbnailUrl = videoDetails.thumbnailUrl
37 this.previewUrl = videoDetails.previewUrl 39 this.previewUrl = videoDetails.previewUrl
38 } 40 }
@@ -50,6 +52,7 @@ export class VideoEdit {
50 licence: this.licence, 52 licence: this.licence,
51 language: this.language, 53 language: this.language,
52 description: this.description, 54 description: this.description,
55 support: this.support,
53 name: this.name, 56 name: this.name,
54 tags: this.tags, 57 tags: this.tags,
55 nsfw: this.nsfw, 58 nsfw: this.nsfw,
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 2e7138cd1..99da14779 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -62,6 +62,7 @@ export class VideoService {
62 tags: video.tags, 62 tags: video.tags,
63 nsfw: video.nsfw, 63 nsfw: video.nsfw,
64 commentsEnabled: video.commentsEnabled, 64 commentsEnabled: video.commentsEnabled,
65 support: video.support,
65 thumbnailfile: video.thumbnailfile, 66 thumbnailfile: video.thumbnailfile,
66 previewfile: video.previewfile 67 previewfile: video.previewfile
67 } 68 }