aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-comment/video-comment.service.ts
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/video-comment.service.ts
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/video-comment.service.ts')
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.service.ts45
1 files changed, 44 insertions, 1 deletions
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}