diff options
Diffstat (limited to 'client')
9 files changed, 373 insertions, 4 deletions
diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index b661a5517..dd92ed2ca 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts | |||
@@ -62,6 +62,13 @@ export class AdminComponent implements OnInit { | |||
62 | iconName: 'cross' | 62 | iconName: 'cross' |
63 | }) | 63 | }) |
64 | } | 64 | } |
65 | if (this.hasVideoCommentsRight()) { | ||
66 | moderationItems.children.push({ | ||
67 | label: $localize`Video comments`, | ||
68 | routerLink: '/admin/moderation/video-comments/list', | ||
69 | iconName: 'message-circle' | ||
70 | }) | ||
71 | } | ||
65 | if (this.hasAccountsBlocklistRight()) { | 72 | if (this.hasAccountsBlocklistRight()) { |
66 | moderationItems.children.push({ | 73 | moderationItems.children.push({ |
67 | label: $localize`Muted accounts`, | 74 | label: $localize`Muted accounts`, |
@@ -140,4 +147,8 @@ export class AdminComponent implements OnInit { | |||
140 | hasDebugRight () { | 147 | hasDebugRight () { |
141 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) | 148 | return this.auth.getUser().hasRight(UserRight.MANAGE_DEBUG) |
142 | } | 149 | } |
150 | |||
151 | hasVideoCommentsRight () { | ||
152 | return this.auth.getUser().hasRight(UserRight.SEE_ALL_COMMENTS) | ||
153 | } | ||
143 | } | 154 | } |
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index da517a55b..5c0864f48 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts | |||
@@ -7,6 +7,7 @@ import { SharedFormModule } from '@app/shared/shared-forms' | |||
7 | import { SharedGlobalIconModule } from '@app/shared/shared-icons' | 7 | import { SharedGlobalIconModule } from '@app/shared/shared-icons' |
8 | import { SharedMainModule } from '@app/shared/shared-main' | 8 | import { SharedMainModule } from '@app/shared/shared-main' |
9 | import { SharedModerationModule } from '@app/shared/shared-moderation' | 9 | import { SharedModerationModule } from '@app/shared/shared-moderation' |
10 | import { SharedVideoCommentModule } from '@app/shared/shared-video-comment' | ||
10 | import { AdminRoutingModule } from './admin-routing.module' | 11 | import { AdminRoutingModule } from './admin-routing.module' |
11 | import { AdminComponent } from './admin.component' | 12 | import { AdminComponent } from './admin.component' |
12 | import { ConfigComponent, EditCustomConfigComponent } from './config' | 13 | import { ConfigComponent, EditCustomConfigComponent } from './config' |
@@ -18,6 +19,7 @@ import { VideoRedundancyInformationComponent } from './follows/video-redundancie | |||
18 | import { AbuseListComponent, VideoBlockListComponent } from './moderation' | 19 | import { AbuseListComponent, VideoBlockListComponent } from './moderation' |
19 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist' | 20 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist' |
20 | import { ModerationComponent } from './moderation/moderation.component' | 21 | import { ModerationComponent } from './moderation/moderation.component' |
22 | import { VideoCommentListComponent } from './moderation/video-comment-list' | ||
21 | import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component' | 23 | import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component' |
22 | import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component' | 24 | import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component' |
23 | import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component' | 25 | import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component' |
@@ -37,6 +39,7 @@ import { UserCreateComponent, UserListComponent, UserPasswordComponent, UsersCom | |||
37 | SharedModerationModule, | 39 | SharedModerationModule, |
38 | SharedGlobalIconModule, | 40 | SharedGlobalIconModule, |
39 | SharedAbuseListModule, | 41 | SharedAbuseListModule, |
42 | SharedVideoCommentModule, | ||
40 | 43 | ||
41 | TableModule, | 44 | TableModule, |
42 | SelectButtonModule, | 45 | SelectButtonModule, |
@@ -62,6 +65,7 @@ import { UserCreateComponent, UserListComponent, UserPasswordComponent, UsersCom | |||
62 | ModerationComponent, | 65 | ModerationComponent, |
63 | VideoBlockListComponent, | 66 | VideoBlockListComponent, |
64 | AbuseListComponent, | 67 | AbuseListComponent, |
68 | VideoCommentListComponent, | ||
65 | 69 | ||
66 | InstanceServerBlocklistComponent, | 70 | InstanceServerBlocklistComponent, |
67 | InstanceAccountBlocklistComponent, | 71 | InstanceAccountBlocklistComponent, |
diff --git a/client/src/app/+admin/moderation/moderation.routes.ts b/client/src/app/+admin/moderation/moderation.routes.ts index b60dd5334..2e28f0911 100644 --- a/client/src/app/+admin/moderation/moderation.routes.ts +++ b/client/src/app/+admin/moderation/moderation.routes.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import { Routes } from '@angular/router' | 1 | import { Routes } from '@angular/router' |
2 | import { AbuseListComponent } from '@app/+admin/moderation/abuse-list' | ||
2 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from '@app/+admin/moderation/instance-blocklist' | 3 | import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from '@app/+admin/moderation/instance-blocklist' |
3 | import { ModerationComponent } from '@app/+admin/moderation/moderation.component' | 4 | import { ModerationComponent } from '@app/+admin/moderation/moderation.component' |
4 | import { AbuseListComponent } from '@app/+admin/moderation/abuse-list' | ||
5 | import { VideoBlockListComponent } from '@app/+admin/moderation/video-block-list' | 5 | import { VideoBlockListComponent } from '@app/+admin/moderation/video-block-list' |
6 | import { VideoCommentListComponent } from './video-comment-list' | ||
6 | import { UserRightGuard } from '@app/core' | 7 | import { UserRightGuard } from '@app/core' |
7 | import { UserRight } from '@shared/models' | 8 | import { UserRight } from '@shared/models' |
8 | 9 | ||
@@ -37,6 +38,7 @@ export const ModerationRoutes: Routes = [ | |||
37 | } | 38 | } |
38 | } | 39 | } |
39 | }, | 40 | }, |
41 | |||
40 | { | 42 | { |
41 | path: 'video-blacklist', | 43 | path: 'video-blacklist', |
42 | redirectTo: 'video-blocks/list', | 44 | redirectTo: 'video-blocks/list', |
@@ -64,10 +66,28 @@ export const ModerationRoutes: Routes = [ | |||
64 | data: { | 66 | data: { |
65 | userRight: UserRight.MANAGE_VIDEO_BLACKLIST, | 67 | userRight: UserRight.MANAGE_VIDEO_BLACKLIST, |
66 | meta: { | 68 | meta: { |
67 | title: $localize`Videos blocked` | 69 | title: $localize`Blocked videos` |
68 | } | 70 | } |
69 | } | 71 | } |
70 | }, | 72 | }, |
73 | |||
74 | { | ||
75 | path: 'video-comments', | ||
76 | redirectTo: 'video-comments/list', | ||
77 | pathMatch: 'full' | ||
78 | }, | ||
79 | { | ||
80 | path: 'video-comments/list', | ||
81 | component: VideoCommentListComponent, | ||
82 | canActivate: [ UserRightGuard ], | ||
83 | data: { | ||
84 | userRight: UserRight.SEE_ALL_COMMENTS, | ||
85 | meta: { | ||
86 | title: $localize`Video comments` | ||
87 | } | ||
88 | } | ||
89 | }, | ||
90 | |||
71 | { | 91 | { |
72 | path: 'blocklist/accounts', | 92 | path: 'blocklist/accounts', |
73 | component: InstanceAccountBlocklistComponent, | 93 | component: InstanceAccountBlocklistComponent, |
diff --git a/client/src/app/+admin/moderation/video-comment-list/index.ts b/client/src/app/+admin/moderation/video-comment-list/index.ts new file mode 100644 index 000000000..eb08b4177 --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './video-comment-list.component' | |||
diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.html b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.html new file mode 100644 index 000000000..b4f66a75f --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.html | |||
@@ -0,0 +1,102 @@ | |||
1 | <h1> | ||
2 | <my-global-icon iconName="cross" aria-hidden="true"></my-global-icon> | ||
3 | <ng-container i18n>Video comments</ng-container> | ||
4 | </h1> | ||
5 | |||
6 | this view does show comments from muted accounts so you can delete them | ||
7 | |||
8 | <p-table | ||
9 | [value]="comments" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" | ||
10 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id" | ||
11 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | ||
12 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} comments" | ||
13 | (onPage)="onPage($event)" [expandedRowKeys]="expandedRows" | ||
14 | > | ||
15 | <ng-template pTemplate="caption"> | ||
16 | <div class="caption"> | ||
17 | <div class="ml-auto"> | ||
18 | <div class="input-group has-feedback has-clear"> | ||
19 | <div class="input-group-prepend c-hand" ngbDropdown placement="bottom-left auto" container="body"> | ||
20 | <div class="input-group-text" ngbDropdownToggle> | ||
21 | <span class="caret" aria-haspopup="menu" role="button"></span> | ||
22 | </div> | ||
23 | |||
24 | <div role="menu" ngbDropdownMenu> | ||
25 | <h6 class="dropdown-header" i18n>Advanced comments filters</h6> | ||
26 | <a [routerLink]="[ '/admin/moderation/video-comments/list' ]" [queryParams]="{ 'search': 'local:true' }" class="dropdown-item" i18n>Local comments</a> | ||
27 | <a [routerLink]="[ '/admin/moderation/video-comments/list' ]" [queryParams]="{ 'search': 'local:false' }" class="dropdown-item" i18n>Remote comments</a> | ||
28 | </div> | ||
29 | </div> | ||
30 | <input | ||
31 | type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..." | ||
32 | (keyup)="onSearch($event)" | ||
33 | > | ||
34 | <a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" (click)="resetTableFilter()"></a> | ||
35 | <span class="sr-only" i18n>Clear filters</span> | ||
36 | </div> | ||
37 | </div> | ||
38 | </div> | ||
39 | </ng-template> | ||
40 | |||
41 | <ng-template pTemplate="header"> | ||
42 | <tr> | ||
43 | <th style="width: 40px"></th> | ||
44 | <th style="width: 100px;" i18n>Account</th> | ||
45 | <th style="width: 100px;" i18n>Video</th> | ||
46 | <th style="width: 100px;" i18n>Comment</th> | ||
47 | <th style="width: 150px;" i18n pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
48 | <th style="width: 150px;"></th> | ||
49 | </tr> | ||
50 | </ng-template> | ||
51 | |||
52 | <ng-template pTemplate="body" let-videoComment let-expanded="expanded"> | ||
53 | <tr> | ||
54 | <td class="expand-cell c-hand" [pRowToggler]="videoComment" i18n-ngbTooltip ngbTooltip="More information" placement="top-left" container="body"> | ||
55 | <span class="expander"> | ||
56 | <i [ngClass]="expanded ? 'glyphicon glyphicon-menu-down' : 'glyphicon glyphicon-menu-right'"></i> | ||
57 | </span> | ||
58 | </td> | ||
59 | |||
60 | <td> | ||
61 | {{ videoComment.by }} | ||
62 | </td> | ||
63 | |||
64 | <td> | ||
65 | {{ videoComment.video.name }} | ||
66 | </td> | ||
67 | |||
68 | <td> | ||
69 | <div [innerHTML]="videoComment.textHtml"></div> | ||
70 | </td> | ||
71 | |||
72 | <td>{{ videoComment.createdAt | date: 'short' }}</td> | ||
73 | |||
74 | <td class="action-cell"> | ||
75 | <my-action-dropdown | ||
76 | [ngClass]="{ 'show': expanded }" placement="bottom-right" container="body" | ||
77 | i18n-label label="Actions" [actions]="videoCommentActions" [entry]="videoComment" | ||
78 | ></my-action-dropdown> | ||
79 | </td> | ||
80 | </tr> | ||
81 | </ng-template> | ||
82 | |||
83 | <ng-template pTemplate="rowexpansion" let-videoComment> | ||
84 | <tr> | ||
85 | <td class="expand-cell" colspan="5"> | ||
86 | <div [innerHTML]="videoComment.textHtml"></div> | ||
87 | </td> | ||
88 | </tr> | ||
89 | </ng-template> | ||
90 | |||
91 | <ng-template pTemplate="emptymessage"> | ||
92 | <tr> | ||
93 | <td colspan="5"> | ||
94 | <div class="no-results"> | ||
95 | <ng-container *ngIf="search" i18n>No comments found matching current filters.</ng-container> | ||
96 | <ng-container *ngIf="!search" i18n>No comments found.</ng-container> | ||
97 | </div> | ||
98 | </td> | ||
99 | </tr> | ||
100 | </ng-template> | ||
101 | </p-table> | ||
102 | |||
diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.scss b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.scss new file mode 100644 index 000000000..c92d1c39c --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.scss | |||
@@ -0,0 +1,27 @@ | |||
1 | @import 'mixins'; | ||
2 | |||
3 | my-global-icon { | ||
4 | @include apply-svg-color(#7d7d7d); | ||
5 | |||
6 | width: 12px; | ||
7 | height: 12px; | ||
8 | position: relative; | ||
9 | top: -1px; | ||
10 | } | ||
11 | |||
12 | .input-group { | ||
13 | @include peertube-input-group(300px); | ||
14 | |||
15 | .dropdown-toggle::after { | ||
16 | margin-left: 0; | ||
17 | } | ||
18 | } | ||
19 | |||
20 | .caption { | ||
21 | justify-content: flex-end; | ||
22 | |||
23 | input { | ||
24 | @include peertube-input-text(250px); | ||
25 | flex-grow: 1; | ||
26 | } | ||
27 | } | ||
diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts new file mode 100644 index 000000000..fdd5ec76e --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts | |||
@@ -0,0 +1,111 @@ | |||
1 | import { SortMeta } from 'primeng/api' | ||
2 | import { filter } from 'rxjs/operators' | ||
3 | import { AfterViewInit, Component, OnInit } from '@angular/core' | ||
4 | import { DomSanitizer } from '@angular/platform-browser' | ||
5 | import { ActivatedRoute, Params, Router } from '@angular/router' | ||
6 | import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' | ||
7 | import { DropdownAction, VideoService } from '@app/shared/shared-main' | ||
8 | import { VideoCommentAdmin, VideoCommentService } from '@app/shared/shared-video-comment' | ||
9 | |||
10 | @Component({ | ||
11 | selector: 'my-video-comment-list', | ||
12 | templateUrl: './video-comment-list.component.html', | ||
13 | styleUrls: [ './video-comment-list.component.scss' ] | ||
14 | }) | ||
15 | export class VideoCommentListComponent extends RestTable implements OnInit, AfterViewInit { | ||
16 | comments: VideoCommentAdmin[] | ||
17 | totalRecords = 0 | ||
18 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
19 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
20 | |||
21 | videoCommentActions: DropdownAction<VideoCommentAdmin>[][] = [] | ||
22 | |||
23 | constructor ( | ||
24 | private notifier: Notifier, | ||
25 | private serverService: ServerService, | ||
26 | private confirmService: ConfirmService, | ||
27 | private videoCommentService: VideoCommentService, | ||
28 | private markdownRenderer: MarkdownService, | ||
29 | private sanitizer: DomSanitizer, | ||
30 | private videoService: VideoService, | ||
31 | private route: ActivatedRoute, | ||
32 | private router: Router | ||
33 | ) { | ||
34 | super() | ||
35 | |||
36 | this.videoCommentActions = [ | ||
37 | [ | ||
38 | |||
39 | // remove this comment, | ||
40 | |||
41 | // remove all comments of this account | ||
42 | |||
43 | ] | ||
44 | ] | ||
45 | } | ||
46 | |||
47 | ngOnInit () { | ||
48 | this.initialize() | ||
49 | |||
50 | this.route.queryParams | ||
51 | .pipe(filter(params => params.search !== undefined && params.search !== null)) | ||
52 | .subscribe(params => { | ||
53 | this.search = params.search | ||
54 | this.setTableFilter(params.search) | ||
55 | this.loadData() | ||
56 | }) | ||
57 | } | ||
58 | |||
59 | ngAfterViewInit () { | ||
60 | if (this.search) this.setTableFilter(this.search) | ||
61 | } | ||
62 | |||
63 | onSearch (event: Event) { | ||
64 | this.onSearch(event) | ||
65 | this.setQueryParams((event.target as HTMLInputElement).value) | ||
66 | } | ||
67 | |||
68 | setQueryParams (search: string) { | ||
69 | const queryParams: Params = {} | ||
70 | |||
71 | if (search) Object.assign(queryParams, { search }) | ||
72 | this.router.navigate([ '/admin/moderation/video-comments/list' ], { queryParams }) | ||
73 | } | ||
74 | |||
75 | resetTableFilter () { | ||
76 | this.setTableFilter('') | ||
77 | this.setQueryParams('') | ||
78 | this.resetSearch() | ||
79 | } | ||
80 | /* END Table filter functions */ | ||
81 | |||
82 | getIdentifier () { | ||
83 | return 'VideoCommentListComponent' | ||
84 | } | ||
85 | |||
86 | toHtml (text: string) { | ||
87 | return this.markdownRenderer.textMarkdownToHTML(text) | ||
88 | } | ||
89 | |||
90 | protected loadData () { | ||
91 | this.videoCommentService.getAdminVideoComments({ | ||
92 | pagination: this.pagination, | ||
93 | sort: this.sort, | ||
94 | search: this.search | ||
95 | }).subscribe( | ||
96 | async resultList => { | ||
97 | this.totalRecords = resultList.total | ||
98 | |||
99 | this.comments = [] | ||
100 | |||
101 | for (const c of resultList.data) { | ||
102 | this.comments.push( | ||
103 | new VideoCommentAdmin(c, await this.toHtml(c.text)) | ||
104 | ) | ||
105 | } | ||
106 | }, | ||
107 | |||
108 | err => this.notifier.error(err.message) | ||
109 | ) | ||
110 | } | ||
111 | } | ||
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 @@ | |||
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,53 @@ 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 | ||
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' | |||
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 { |
@@ -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 | } |