aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-comment
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-13 16:38:23 +0100
committerChocobozzz <me@florianbigard.com>2020-11-13 16:38:23 +0100
commit0f8d00e3144060270d7fe603865fccaf18649c47 (patch)
tree6ccd0b44735ea4541a53d4fda17459260a69e676 /client/src/app/shared/shared-video-comment
parentdc13623baa244e13c33cc803de808818ef1e95a4 (diff)
downloadPeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.tar.gz
PeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.tar.zst
PeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.zip
Implement video comment list in admin
Diffstat (limited to 'client/src/app/shared/shared-video-comment')
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.model.ts52
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.service.ts45
2 files changed, 95 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts
index e85443196..1589091e5 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.model.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts
@@ -1,6 +1,6 @@
1import { getAbsoluteAPIUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl } from '@app/helpers'
2import { Actor } from '@app/shared/shared-main' 2import { Actor } from '@app/shared/shared-main'
3import { Account as AccountInterface, VideoComment as VideoCommentServerModel } from '@shared/models' 3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models'
4 4
5export class VideoComment implements VideoCommentServerModel { 5export class VideoComment implements VideoCommentServerModel {
6 id: number 6 id: number
@@ -46,3 +46,53 @@ export class VideoComment implements VideoCommentServerModel {
46 } 46 }
47 } 47 }
48} 48}
49
50export class VideoCommentAdmin implements VideoCommentAdminServerModel {
51 id: number
52 url: string
53 text: string
54 textHtml: string
55
56 threadId: number
57 inReplyToCommentId: number
58
59 createdAt: Date | string
60 updatedAt: Date | string
61
62 account: AccountInterface
63
64 video: {
65 id: number
66 uuid: string
67 name: string
68 }
69
70 by: string
71 accountAvatarUrl: string
72
73 constructor (hash: VideoCommentAdminServerModel, textHtml: string) {
74 this.id = hash.id
75 this.url = hash.url
76 this.text = hash.text
77 this.textHtml = textHtml
78
79 this.threadId = hash.threadId
80 this.inReplyToCommentId = hash.inReplyToCommentId
81
82 this.createdAt = new Date(hash.createdAt.toString())
83 this.updatedAt = new Date(hash.updatedAt.toString())
84
85 this.video = {
86 id: hash.video.id,
87 uuid: hash.video.uuid,
88 name: hash.video.name
89 }
90
91 this.account = hash.account
92
93 if (this.account) {
94 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
95 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
96 }
97 }
98}
diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.ts
index 81c65aa38..e318e069d 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.service.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts
@@ -2,18 +2,20 @@ import { Observable } from 'rxjs'
2import { catchError, map } from 'rxjs/operators' 2import { catchError, map } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core' 5import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core'
6import { objectLineFeedToHtml } from '@app/helpers' 6import { objectLineFeedToHtml } from '@app/helpers'
7import { 7import {
8 FeedFormat, 8 FeedFormat,
9 ResultList, 9 ResultList,
10 VideoComment as VideoCommentServerModel, 10 VideoComment as VideoCommentServerModel,
11 VideoCommentAdmin,
11 VideoCommentCreate, 12 VideoCommentCreate,
12 VideoCommentThreadTree as VideoCommentThreadTreeServerModel 13 VideoCommentThreadTree as VideoCommentThreadTreeServerModel
13} from '@shared/models' 14} from '@shared/models'
14import { environment } from '../../../environments/environment' 15import { environment } from '../../../environments/environment'
15import { VideoCommentThreadTree } from './video-comment-thread-tree.model' 16import { VideoCommentThreadTree } from './video-comment-thread-tree.model'
16import { VideoComment } from './video-comment.model' 17import { VideoComment } from './video-comment.model'
18import { SortMeta } from 'primeng/api'
17 19
18@Injectable() 20@Injectable()
19export class VideoCommentService { 21export class VideoCommentService {
@@ -48,6 +50,27 @@ export class VideoCommentService {
48 ) 50 )
49 } 51 }
50 52
53 getAdminVideoComments (options: {
54 pagination: RestPagination,
55 sort: SortMeta,
56 search?: string
57 }): Observable<ResultList<VideoCommentAdmin>> {
58 const { pagination, sort, search } = options
59 const url = VideoCommentService.BASE_VIDEO_URL + '/comments'
60
61 let params = new HttpParams()
62 params = this.restService.addRestGetParams(params, pagination, sort)
63
64 if (search) {
65 params = this.buildParamsFromSearch(search, params)
66 }
67
68 return this.authHttp.get<ResultList<VideoCommentAdmin>>(url, { params })
69 .pipe(
70 catchError(res => this.restExtractor.handleError(res))
71 )
72 }
73
51 getVideoCommentThreads (parameters: { 74 getVideoCommentThreads (parameters: {
52 videoId: number | string, 75 videoId: number | string,
53 componentPagination: ComponentPaginationLight, 76 componentPagination: ComponentPaginationLight,
@@ -146,4 +169,24 @@ export class VideoCommentService {
146 169
147 return tree as VideoCommentThreadTree 170 return tree as VideoCommentThreadTree
148 } 171 }
172
173 private buildParamsFromSearch (search: string, params: HttpParams) {
174 const filters = this.restService.parseQueryStringFilter(search, {
175 state: {
176 prefix: 'local:',
177 isBoolean: true,
178 handler: v => {
179 if (v === 'true') return v
180 if (v === 'false') return v
181
182 return undefined
183 }
184 },
185
186 searchAccount: { prefix: 'account:' },
187 searchVideo: { prefix: 'video:' }
188 })
189
190 return this.restService.addObjectParams(params, filters)
191 }
149} 192}