aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-03 10:12:36 +0100
committerChocobozzz <me@florianbigard.com>2018-01-03 10:38:19 +0100
commit47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04 (patch)
tree25e2836baf3dfce6f422192d98332db1bfe65890 /client/src/app
parentc5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (diff)
downloadPeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.gz
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.zst
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.zip
Add ability to disable video comments
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/video/video-details.model.ts16
-rw-r--r--client/src/app/shared/video/video-edit.model.ts3
-rw-r--r--client/src/app/shared/video/video.service.ts3
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.html6
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts1
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.html58
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts7
8 files changed, 59 insertions, 37 deletions
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index 8243b9f1c..cf6b71b60 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -1,14 +1,10 @@
1import { Account } from '../../../../../shared/models/actors'
2import { Video } from '../../shared/video/video.model'
3import { AuthUser } from '../../core'
4import { 1import {
5 VideoDetails as VideoDetailsServerModel, 2 UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile, VideoPrivacy,
6 VideoFile, 3 VideoResolution
7 VideoChannel,
8 VideoResolution,
9 UserRight,
10 VideoPrivacy
11} from '../../../../../shared' 4} from '../../../../../shared'
5import { Account } from '../../../../../shared/models/actors'
6import { AuthUser } from '../../core'
7import { Video } from '../../shared/video/video.model'
12 8
13export class VideoDetails extends Video implements VideoDetailsServerModel { 9export class VideoDetails extends Video implements VideoDetailsServerModel {
14 accountName: string 10 accountName: string
@@ -48,6 +44,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
48 account: Account 44 account: Account
49 likesPercent: number 45 likesPercent: number
50 dislikesPercent: number 46 dislikesPercent: number
47 commentsEnabled: boolean
51 48
52 constructor (hash: VideoDetailsServerModel) { 49 constructor (hash: VideoDetailsServerModel) {
53 super(hash) 50 super(hash)
@@ -59,6 +56,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
59 this.channel = hash.channel 56 this.channel = hash.channel
60 this.account = hash.account 57 this.account = hash.account
61 this.tags = hash.tags 58 this.tags = hash.tags
59 this.commentsEnabled = hash.commentsEnabled
62 60
63 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100 61 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
64 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100 62 this.dislikesPercent = (this.dislikes / (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 47c63d976..b1c772217 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -9,6 +9,7 @@ export class VideoEdit {
9 name: string 9 name: string
10 tags: string[] 10 tags: string[]
11 nsfw: boolean 11 nsfw: boolean
12 commentsEnabled: boolean
12 channel: number 13 channel: number
13 privacy: VideoPrivacy 14 privacy: VideoPrivacy
14 uuid?: string 15 uuid?: string
@@ -25,6 +26,7 @@ export class VideoEdit {
25 this.name = videoDetails.name 26 this.name = videoDetails.name
26 this.tags = videoDetails.tags 27 this.tags = videoDetails.tags
27 this.nsfw = videoDetails.nsfw 28 this.nsfw = videoDetails.nsfw
29 this.commentsEnabled = videoDetails.commentsEnabled
28 this.channel = videoDetails.channel.id 30 this.channel = videoDetails.channel.id
29 this.privacy = videoDetails.privacy 31 this.privacy = videoDetails.privacy
30 } 32 }
@@ -45,6 +47,7 @@ export class VideoEdit {
45 name: this.name, 47 name: this.name,
46 tags: this.tags, 48 tags: this.tags,
47 nsfw: this.nsfw, 49 nsfw: this.nsfw,
50 commentsEnabled: this.commentsEnabled,
48 channelId: this.channel, 51 channelId: this.channel,
49 privacy: this.privacy 52 privacy: this.privacy
50 } 53 }
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index fc7505a51..073acb2b6 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -55,7 +55,8 @@ export class VideoService {
55 description, 55 description,
56 privacy: video.privacy, 56 privacy: video.privacy,
57 tags: video.tags, 57 tags: video.tags,
58 nsfw: video.nsfw 58 nsfw: video.nsfw,
59 commentsEnabled: video.commentsEnabled
59 } 60 }
60 61
61 return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, body) 62 return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, body)
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.html b/client/src/app/videos/+video-edit/shared/video-edit.component.html
index 9acbafcb6..80377933e 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.component.html
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.html
@@ -99,5 +99,11 @@
99 <label for="nsfw">This video contains mature or explicit content</label> 99 <label for="nsfw">This video contains mature or explicit content</label>
100 </div> 100 </div>
101 101
102 <div class="form-group form-group-checkbox">
103 <input type="checkbox" id="commentsEnabled" formControlName="commentsEnabled" />
104 <label for="commentsEnabled"></label>
105 <label for="commentsEnabled">Enable video comments</label>
106 </div>
107
102 </div> 108 </div>
103</div> 109</div>
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
index 7fe265284..2b307d5fa 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
@@ -70,6 +70,7 @@ export class VideoEditComponent implements OnInit {
70 this.form.addControl('privacy', new FormControl('', VIDEO_PRIVACY.VALIDATORS)) 70 this.form.addControl('privacy', new FormControl('', VIDEO_PRIVACY.VALIDATORS))
71 this.form.addControl('channelId', new FormControl({ value: '', disabled: true })) 71 this.form.addControl('channelId', new FormControl({ value: '', disabled: true }))
72 this.form.addControl('nsfw', new FormControl(false)) 72 this.form.addControl('nsfw', new FormControl(false))
73 this.form.addControl('commentsEnabled', new FormControl(true))
73 this.form.addControl('category', new FormControl('', VIDEO_CATEGORY.VALIDATORS)) 74 this.form.addControl('category', new FormControl('', VIDEO_CATEGORY.VALIDATORS))
74 this.form.addControl('licence', new FormControl('', VIDEO_LICENCE.VALIDATORS)) 75 this.form.addControl('licence', new FormControl('', VIDEO_LICENCE.VALIDATORS))
75 this.form.addControl('language', new FormControl('', VIDEO_LANGUAGE.VALIDATORS)) 76 this.form.addControl('language', new FormControl('', VIDEO_LANGUAGE.VALIDATORS))
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 9bbee58d8..843475647 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -88,6 +88,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
88 const name = videofile.name.replace(/\.[^/.]+$/, '') 88 const name = videofile.name.replace(/\.[^/.]+$/, '')
89 const privacy = this.firstStepPrivacyId.toString() 89 const privacy = this.firstStepPrivacyId.toString()
90 const nsfw = false 90 const nsfw = false
91 const commentsEnabled = true
91 const channelId = this.firstStepChannelId.toString() 92 const channelId = this.firstStepChannelId.toString()
92 93
93 const formData = new FormData() 94 const formData = new FormData()
@@ -95,6 +96,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
95 // Put the video "private" -> we wait he validates the second step 96 // Put the video "private" -> we wait he validates the second step
96 formData.append('privacy', VideoPrivacy.PRIVATE.toString()) 97 formData.append('privacy', VideoPrivacy.PRIVATE.toString())
97 formData.append('nsfw', '' + nsfw) 98 formData.append('nsfw', '' + nsfw)
99 formData.append('commentsEnabled', '' + commentsEnabled)
98 formData.append('channelId', '' + channelId) 100 formData.append('channelId', '' + channelId)
99 formData.append('videofile', videofile) 101 formData.append('videofile', videofile)
100 102
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html
index 5c6908150..078900e06 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html
@@ -3,35 +3,43 @@
3 Comments 3 Comments
4 </div> 4 </div>
5 5
6 <my-video-comment-add 6 <ng-template [ngIf]="video.commentsEnabled === true">
7 *ngIf="isUserLoggedIn()" 7 <my-video-comment-add
8 [video]="video" 8 *ngIf="isUserLoggedIn()"
9 (commentCreated)="onCommentThreadCreated($event)" 9 [video]="video"
10 ></my-video-comment-add> 10 (commentCreated)="onCommentThreadCreated($event)"
11 ></my-video-comment-add>
11 12
12 <div 13 <div *ngIf="componentPagination.totalItems === 0 && comments.length === 0">No comments.</div>
13 class="comment-threads"
14 infiniteScroll
15 [infiniteScrollUpDistance]="1.5"
16 [infiniteScrollDistance]="0.5"
17 (scrolled)="onNearOfBottom()"
18 >
19 <div *ngFor="let comment of comments">
20 <my-video-comment
21 [comment]="comment"
22 [video]="video"
23 [inReplyToCommentId]="inReplyToCommentId"
24 [commentTree]="threadComments[comment.id]"
25 (wantedToReply)="onWantedToReply($event)"
26 (resetReply)="onResetReply()"
27 ></my-video-comment>
28 14
29 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment)" class="view-replies"> 15 <div
30 View all {{ comment.totalReplies }} replies 16 class="comment-threads"
17 infiniteScroll
18 [infiniteScrollUpDistance]="1.5"
19 [infiniteScrollDistance]="0.5"
20 (scrolled)="onNearOfBottom()"
21 >
22 <div *ngFor="let comment of comments">
23 <my-video-comment
24 [comment]="comment"
25 [video]="video"
26 [inReplyToCommentId]="inReplyToCommentId"
27 [commentTree]="threadComments[comment.id]"
28 (wantedToReply)="onWantedToReply($event)"
29 (resetReply)="onResetReply()"
30 ></my-video-comment>
31 31
32 <span *ngIf="!threadLoading[comment.id]" class="glyphicon glyphicon-menu-down"></span> 32 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment)" class="view-replies">
33 <my-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-loader> 33 View all {{ comment.totalReplies }} replies
34
35 <span *ngIf="!threadLoading[comment.id]" class="glyphicon glyphicon-menu-down"></span>
36 <my-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-loader>
37 </div>
34 </div> 38 </div>
35 </div> 39 </div>
40 </ng-template>
41
42 <div *ngIf="video.commentsEnabled === false">
43 Comments are disabled.
36 </div> 44 </div>
37</div> 45</div>
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index f4dda9089..4d801c970 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -5,6 +5,7 @@ import { AuthService } from '../../../core/auth'
5import { ComponentPagination } from '../../../shared/rest/component-pagination.model' 5import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
6import { User } from '../../../shared/users' 6import { User } from '../../../shared/users'
7import { SortField } from '../../../shared/video/sort-field.type' 7import { SortField } from '../../../shared/video/sort-field.type'
8import { VideoDetails } from '../../../shared/video/video-details.model'
8import { Video } from '../../../shared/video/video.model' 9import { Video } from '../../../shared/video/video.model'
9import { VideoComment } from './video-comment.model' 10import { VideoComment } from './video-comment.model'
10import { VideoCommentService } from './video-comment.service' 11import { VideoCommentService } from './video-comment.service'
@@ -15,7 +16,7 @@ import { VideoCommentService } from './video-comment.service'
15 styleUrls: ['./video-comments.component.scss'] 16 styleUrls: ['./video-comments.component.scss']
16}) 17})
17export class VideoCommentsComponent implements OnInit { 18export class VideoCommentsComponent implements OnInit {
18 @Input() video: Video 19 @Input() video: VideoDetails
19 @Input() user: User 20 @Input() user: User
20 21
21 comments: VideoComment[] = [] 22 comments: VideoComment[] = []
@@ -36,7 +37,9 @@ export class VideoCommentsComponent implements OnInit {
36 ) {} 37 ) {}
37 38
38 ngOnInit () { 39 ngOnInit () {
39 this.loadMoreComments() 40 if (this.video.commentsEnabled === true) {
41 this.loadMoreComments()
42 }
40 } 43 }
41 44
42 viewReplies (comment: VideoComment) { 45 viewReplies (comment: VideoComment) {