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/shared-main/feeds/feed.component.html2
-rw-r--r--client/src/app/shared/shared-main/feeds/feed.component.scss2
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.model.ts59
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.service.ts48
4 files changed, 106 insertions, 5 deletions
diff --git a/client/src/app/shared/shared-main/feeds/feed.component.html b/client/src/app/shared/shared-main/feeds/feed.component.html
index 13883fd9b..a00011785 100644
--- a/client/src/app/shared/shared-main/feeds/feed.component.html
+++ b/client/src/app/shared/shared-main/feeds/feed.component.html
@@ -1,4 +1,4 @@
1<div class="video-feed"> 1<div class="feed">
2 <my-global-icon 2 <my-global-icon
3 *ngIf="syndicationItems.length !== 0" [ngbPopover]="feedsList" [autoClose]="true" placement="bottom left auto" 3 *ngIf="syndicationItems.length !== 0" [ngbPopover]="feedsList" [autoClose]="true" placement="bottom left auto"
4 class="icon-syndication" role="button" iconName="syndication" 4 class="icon-syndication" role="button" iconName="syndication"
diff --git a/client/src/app/shared/shared-main/feeds/feed.component.scss b/client/src/app/shared/shared-main/feeds/feed.component.scss
index 34dd0e937..333d59440 100644
--- a/client/src/app/shared/shared-main/feeds/feed.component.scss
+++ b/client/src/app/shared/shared-main/feeds/feed.component.scss
@@ -1,7 +1,7 @@
1@import '_variables'; 1@import '_variables';
2@import '_mixins'; 2@import '_mixins';
3 3
4.video-feed { 4.feed {
5 width: min-content; 5 width: min-content;
6 6
7 a { 7 a {
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 @@
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,60 @@ 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 & { 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'
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 {
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}