diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-16 13:49:09 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-16 13:57:14 +0100 |
commit | 19149d45b8f68569535f7188ef25e09e3d62c8b4 (patch) | |
tree | 92da0e0db2b0e277b2110a630f502433c86c9119 /client/src/app/shared/shared-video-comment | |
parent | 8872828d59a5152e27734711ae30ebe86e84f570 (diff) | |
parent | f1273314593a4a7dc7ec9594ce0c6c3ae8f62b34 (diff) | |
download | PeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.tar.gz PeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.tar.zst PeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.zip |
Merge branch 'feature/admin-comments' into develop
Diffstat (limited to 'client/src/app/shared/shared-video-comment')
-rw-r--r-- | client/src/app/shared/shared-video-comment/video-comment.model.ts | 59 | ||||
-rw-r--r-- | client/src/app/shared/shared-video-comment/video-comment.service.ts | 48 |
2 files changed, 104 insertions, 3 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..eeee397af 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 @@ | |||
1 | import { getAbsoluteAPIUrl } from '@app/helpers' | 1 | import { getAbsoluteAPIUrl } from '@app/helpers' |
2 | import { Actor } from '@app/shared/shared-main' | 2 | import { Actor } from '@app/shared/shared-main' |
3 | import { Account as AccountInterface, VideoComment as VideoCommentServerModel } from '@shared/models' | 3 | import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models' |
4 | 4 | ||
5 | export class VideoComment implements VideoCommentServerModel { | 5 | export class VideoComment implements VideoCommentServerModel { |
6 | id: number | 6 | id: number |
@@ -46,3 +46,60 @@ export class VideoComment implements VideoCommentServerModel { | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | } | 48 | } |
49 | |||
50 | export 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 & { localUrl?: string } | ||
63 | localUrl: string | ||
64 | |||
65 | video: { | ||
66 | id: number | ||
67 | uuid: string | ||
68 | name: string | ||
69 | localUrl: string | ||
70 | } | ||
71 | |||
72 | by: string | ||
73 | accountAvatarUrl: string | ||
74 | |||
75 | constructor (hash: VideoCommentAdminServerModel, textHtml: string) { | ||
76 | this.id = hash.id | ||
77 | this.url = hash.url | ||
78 | this.text = hash.text | ||
79 | this.textHtml = textHtml | ||
80 | |||
81 | this.threadId = hash.threadId | ||
82 | this.inReplyToCommentId = hash.inReplyToCommentId | ||
83 | |||
84 | this.createdAt = new Date(hash.createdAt.toString()) | ||
85 | this.updatedAt = new Date(hash.updatedAt.toString()) | ||
86 | |||
87 | this.video = { | ||
88 | id: hash.video.id, | ||
89 | uuid: hash.video.uuid, | ||
90 | name: hash.video.name, | ||
91 | localUrl: '/videos/watch/' + hash.video.uuid | ||
92 | } | ||
93 | |||
94 | this.localUrl = this.video.localUrl + ';threadId=' + this.threadId | ||
95 | |||
96 | this.account = hash.account | ||
97 | |||
98 | if (this.account) { | ||
99 | this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host) | ||
100 | this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) | ||
101 | |||
102 | this.account.localUrl = '/accounts/' + this.by | ||
103 | } | ||
104 | } | ||
105 | } | ||
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..1ab996a76 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,23 +2,26 @@ import { Observable } from 'rxjs' | |||
2 | import { catchError, map } from 'rxjs/operators' | 2 | import { catchError, map } from 'rxjs/operators' |
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core' | 5 | import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core' |
6 | import { objectLineFeedToHtml } from '@app/helpers' | 6 | import { objectLineFeedToHtml } from '@app/helpers' |
7 | import { | 7 | import { |
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' |
14 | import { environment } from '../../../environments/environment' | 15 | import { environment } from '../../../environments/environment' |
15 | import { VideoCommentThreadTree } from './video-comment-thread-tree.model' | 16 | import { VideoCommentThreadTree } from './video-comment-thread-tree.model' |
16 | import { VideoComment } from './video-comment.model' | 17 | import { VideoComment } from './video-comment.model' |
18 | import { SortMeta } from 'primeng/api' | ||
17 | 19 | ||
18 | @Injectable() | 20 | @Injectable() |
19 | export class VideoCommentService { | 21 | export class VideoCommentService { |
22 | static BASE_FEEDS_URL = environment.apiUrl + '/feeds/video-comments.' | ||
23 | |||
20 | private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' | 24 | private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' |
21 | private static BASE_FEEDS_URL = environment.apiUrl + '/feeds/video-comments.' | ||
22 | 25 | ||
23 | constructor ( | 26 | constructor ( |
24 | private authHttp: HttpClient, | 27 | private authHttp: HttpClient, |
@@ -48,6 +51,27 @@ export class VideoCommentService { | |||
48 | ) | 51 | ) |
49 | } | 52 | } |
50 | 53 | ||
54 | getAdminVideoComments (options: { | ||
55 | pagination: RestPagination, | ||
56 | sort: SortMeta, | ||
57 | search?: string | ||
58 | }): Observable<ResultList<VideoCommentAdmin>> { | ||
59 | const { pagination, sort, search } = options | ||
60 | const url = VideoCommentService.BASE_VIDEO_URL + 'comments' | ||
61 | |||
62 | let params = new HttpParams() | ||
63 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
64 | |||
65 | if (search) { | ||
66 | params = this.buildParamsFromSearch(search, params) | ||
67 | } | ||
68 | |||
69 | return this.authHttp.get<ResultList<VideoCommentAdmin>>(url, { params }) | ||
70 | .pipe( | ||
71 | catchError(res => this.restExtractor.handleError(res)) | ||
72 | ) | ||
73 | } | ||
74 | |||
51 | getVideoCommentThreads (parameters: { | 75 | getVideoCommentThreads (parameters: { |
52 | videoId: number | string, | 76 | videoId: number | string, |
53 | componentPagination: ComponentPaginationLight, | 77 | componentPagination: ComponentPaginationLight, |
@@ -146,4 +170,24 @@ export class VideoCommentService { | |||
146 | 170 | ||
147 | return tree as VideoCommentThreadTree | 171 | return tree as VideoCommentThreadTree |
148 | } | 172 | } |
173 | |||
174 | private buildParamsFromSearch (search: string, params: HttpParams) { | ||
175 | const filters = this.restService.parseQueryStringFilter(search, { | ||
176 | isLocal: { | ||
177 | prefix: 'local:', | ||
178 | isBoolean: true, | ||
179 | handler: v => { | ||
180 | if (v === 'true') return v | ||
181 | if (v === 'false') return v | ||
182 | |||
183 | return undefined | ||
184 | } | ||
185 | }, | ||
186 | |||
187 | searchAccount: { prefix: 'account:' }, | ||
188 | searchVideo: { prefix: 'video:' } | ||
189 | }) | ||
190 | |||
191 | return this.restService.addObjectParams(params, filters) | ||
192 | } | ||
149 | } | 193 | } |