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/+admin | |
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/+admin')
8 files changed, 393 insertions, 8 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-block-list/video-block-list.component.scss b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.scss index c92d1c39c..0e34150c1 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.scss +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.scss | |||
@@ -1,12 +1,8 @@ | |||
1 | @import 'mixins'; | 1 | @import 'mixins'; |
2 | 2 | ||
3 | my-global-icon { | 3 | my-global-icon { |
4 | @include apply-svg-color(#7d7d7d); | 4 | width: 24px; |
5 | 5 | height: 24px; | |
6 | width: 12px; | ||
7 | height: 12px; | ||
8 | position: relative; | ||
9 | top: -1px; | ||
10 | } | 6 | } |
11 | 7 | ||
12 | .input-group { | 8 | .input-group { |
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..45c5fe28f --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.html | |||
@@ -0,0 +1,118 @@ | |||
1 | <h1> | ||
2 | <my-global-icon iconName="message-circle" aria-hidden="true"></my-global-icon> | ||
3 | <ng-container i18n>Video comments</ng-container> | ||
4 | |||
5 | <my-feed [syndicationItems]="syndicationItems"></my-feed> | ||
6 | </h1> | ||
7 | |||
8 | <em>This view also shows comments from muted accounts.</em> | ||
9 | |||
10 | <p-table | ||
11 | [value]="comments" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" | ||
12 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id" | ||
13 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | ||
14 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} comments" | ||
15 | (onPage)="onPage($event)" [expandedRowKeys]="expandedRows" | ||
16 | > | ||
17 | <ng-template pTemplate="caption"> | ||
18 | <div class="caption"> | ||
19 | <div class="ml-auto"> | ||
20 | <div class="input-group has-feedback has-clear"> | ||
21 | <div class="input-group-prepend c-hand" ngbDropdown placement="bottom-left auto" container="body"> | ||
22 | <div class="input-group-text" ngbDropdownToggle> | ||
23 | <span class="caret" aria-haspopup="menu" role="button"></span> | ||
24 | </div> | ||
25 | |||
26 | <div role="menu" ngbDropdownMenu> | ||
27 | <h6 class="dropdown-header" i18n>Advanced comments filters</h6> | ||
28 | <a [routerLink]="[ '/admin/moderation/video-comments/list' ]" [queryParams]="{ 'search': 'local:true' }" class="dropdown-item" i18n>Local comments</a> | ||
29 | <a [routerLink]="[ '/admin/moderation/video-comments/list' ]" [queryParams]="{ 'search': 'local:false' }" class="dropdown-item" i18n>Remote comments</a> | ||
30 | </div> | ||
31 | </div> | ||
32 | <input | ||
33 | type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..." | ||
34 | (keyup)="onInputSearch($event)" | ||
35 | > | ||
36 | <a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" (click)="resetTableFilter()"></a> | ||
37 | <span class="sr-only" i18n>Clear filters</span> | ||
38 | </div> | ||
39 | </div> | ||
40 | </div> | ||
41 | </ng-template> | ||
42 | |||
43 | <ng-template pTemplate="header"> | ||
44 | <tr> | ||
45 | <th style="width: 40px"></th> | ||
46 | <th style="width: 300px" i18n>Account</th> | ||
47 | <th style="width: 300px" i18n>Video</th> | ||
48 | <th i18n>Comment</th> | ||
49 | <th style="width: 150px;" i18n pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
50 | <th style="width: 150px;"></th> | ||
51 | </tr> | ||
52 | </ng-template> | ||
53 | |||
54 | <ng-template pTemplate="body" let-videoComment let-expanded="expanded"> | ||
55 | <tr> | ||
56 | <td class="expand-cell c-hand" [pRowToggler]="videoComment" i18n-ngbTooltip ngbTooltip="More information" placement="top-left" container="body"> | ||
57 | <span class="expander"> | ||
58 | <i [ngClass]="expanded ? 'glyphicon glyphicon-menu-down' : 'glyphicon glyphicon-menu-right'"></i> | ||
59 | </span> | ||
60 | </td> | ||
61 | |||
62 | <td> | ||
63 | <a [href]="videoComment.account.localUrl" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer"> | ||
64 | <div class="chip two-lines"> | ||
65 | <img | ||
66 | class="avatar" | ||
67 | [src]="videoComment.accountAvatarUrl" | ||
68 | alt="" | ||
69 | > | ||
70 | <div> | ||
71 | {{ videoComment.account.displayName }} | ||
72 | <span>{{ videoComment.by }}</span> | ||
73 | </div> | ||
74 | </div> | ||
75 | </a> | ||
76 | </td> | ||
77 | |||
78 | <td class="video"> | ||
79 | <em i18n>Commented video</em> | ||
80 | |||
81 | <a [href]="videoComment.localUrl" target="_blank" rel="noopener noreferrer">{{ videoComment.video.name }}</a> | ||
82 | </td> | ||
83 | |||
84 | <td class="comment-html"> | ||
85 | <div [innerHTML]="videoComment.textHtml"></div> | ||
86 | </td> | ||
87 | |||
88 | <td>{{ videoComment.createdAt | date: 'short' }}</td> | ||
89 | |||
90 | <td class="action-cell"> | ||
91 | <my-action-dropdown | ||
92 | [ngClass]="{ 'show': expanded }" placement="bottom-right" container="body" | ||
93 | i18n-label label="Actions" [actions]="videoCommentActions" [entry]="videoComment" | ||
94 | ></my-action-dropdown> | ||
95 | </td> | ||
96 | </tr> | ||
97 | </ng-template> | ||
98 | |||
99 | <ng-template pTemplate="rowexpansion" let-videoComment> | ||
100 | <tr> | ||
101 | <td class="expand-cell" colspan="5"> | ||
102 | <div [innerHTML]="videoComment.textHtml"></div> | ||
103 | </td> | ||
104 | </tr> | ||
105 | </ng-template> | ||
106 | |||
107 | <ng-template pTemplate="emptymessage"> | ||
108 | <tr> | ||
109 | <td colspan="5"> | ||
110 | <div class="no-results"> | ||
111 | <ng-container *ngIf="search" i18n>No comments found matching current filters.</ng-container> | ||
112 | <ng-container *ngIf="!search" i18n>No comments found.</ng-container> | ||
113 | </div> | ||
114 | </td> | ||
115 | </tr> | ||
116 | </ng-template> | ||
117 | </p-table> | ||
118 | |||
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..439835899 --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.scss | |||
@@ -0,0 +1,66 @@ | |||
1 | @import 'mixins'; | ||
2 | |||
3 | h1 { | ||
4 | my-feed { | ||
5 | margin-left: 5px; | ||
6 | display: inline-block; | ||
7 | |||
8 | ::ng-deep { | ||
9 | my-global-icon { | ||
10 | width: 15px !important; | ||
11 | top: 0 !important; | ||
12 | } | ||
13 | } | ||
14 | } | ||
15 | } | ||
16 | |||
17 | my-global-icon { | ||
18 | width: 24px; | ||
19 | height: 24px; | ||
20 | } | ||
21 | |||
22 | .input-group { | ||
23 | @include peertube-input-group(300px); | ||
24 | |||
25 | .dropdown-toggle::after { | ||
26 | margin-left: 0; | ||
27 | } | ||
28 | } | ||
29 | |||
30 | .caption { | ||
31 | justify-content: flex-end; | ||
32 | |||
33 | input { | ||
34 | @include peertube-input-text(250px); | ||
35 | flex-grow: 1; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | .video { | ||
40 | display: flex; | ||
41 | flex-direction: column; | ||
42 | |||
43 | em { | ||
44 | font-size: 11px; | ||
45 | } | ||
46 | |||
47 | a { | ||
48 | @include ellipsis | ||
49 | } | ||
50 | } | ||
51 | |||
52 | .comment-html { | ||
53 | ::ng-deep { | ||
54 | > div { | ||
55 | max-height: 22px; | ||
56 | } | ||
57 | |||
58 | div, p { | ||
59 | @include ellipsis; | ||
60 | } | ||
61 | |||
62 | p { | ||
63 | margin: 0; | ||
64 | } | ||
65 | } | ||
66 | } | ||
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..d26047125 --- /dev/null +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts | |||
@@ -0,0 +1,169 @@ | |||
1 | import { SortMeta } from 'primeng/api' | ||
2 | import { filter } from 'rxjs/operators' | ||
3 | import { AfterViewInit, Component, OnInit } from '@angular/core' | ||
4 | import { ActivatedRoute, Params, Router } from '@angular/router' | ||
5 | import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core' | ||
6 | import { DropdownAction } from '@app/shared/shared-main' | ||
7 | import { BulkService } from '@app/shared/shared-moderation' | ||
8 | import { VideoCommentAdmin, VideoCommentService } from '@app/shared/shared-video-comment' | ||
9 | import { FeedFormat, UserRight } from '@shared/models' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-video-comment-list', | ||
13 | templateUrl: './video-comment-list.component.html', | ||
14 | styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './video-comment-list.component.scss' ] | ||
15 | }) | ||
16 | export class VideoCommentListComponent extends RestTable implements OnInit, AfterViewInit { | ||
17 | comments: VideoCommentAdmin[] | ||
18 | totalRecords = 0 | ||
19 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
21 | |||
22 | videoCommentActions: DropdownAction<VideoCommentAdmin>[][] = [] | ||
23 | |||
24 | syndicationItems = [ | ||
25 | { | ||
26 | format: FeedFormat.RSS, | ||
27 | label: 'media rss 2.0', | ||
28 | url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase() | ||
29 | }, | ||
30 | { | ||
31 | format: FeedFormat.ATOM, | ||
32 | label: 'atom 1.0', | ||
33 | url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase() | ||
34 | }, | ||
35 | { | ||
36 | format: FeedFormat.JSON, | ||
37 | label: 'json 1.0', | ||
38 | url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase() | ||
39 | } | ||
40 | ] | ||
41 | |||
42 | get authUser () { | ||
43 | return this.auth.getUser() | ||
44 | } | ||
45 | |||
46 | constructor ( | ||
47 | private auth: AuthService, | ||
48 | private notifier: Notifier, | ||
49 | private confirmService: ConfirmService, | ||
50 | private videoCommentService: VideoCommentService, | ||
51 | private markdownRenderer: MarkdownService, | ||
52 | private route: ActivatedRoute, | ||
53 | private router: Router, | ||
54 | private bulkService: BulkService | ||
55 | ) { | ||
56 | super() | ||
57 | |||
58 | this.videoCommentActions = [ | ||
59 | [ | ||
60 | { | ||
61 | label: $localize`Delete this comment`, | ||
62 | handler: comment => this.deleteComment(comment), | ||
63 | isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) | ||
64 | }, | ||
65 | |||
66 | { | ||
67 | label: $localize`Delete all comments of this account`, | ||
68 | description: $localize`Comments are deleted after a few minutes`, | ||
69 | handler: comment => this.deleteUserComments(comment), | ||
70 | isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) | ||
71 | } | ||
72 | ] | ||
73 | ] | ||
74 | } | ||
75 | |||
76 | ngOnInit () { | ||
77 | this.initialize() | ||
78 | |||
79 | this.route.queryParams | ||
80 | .pipe(filter(params => params.search !== undefined && params.search !== null)) | ||
81 | .subscribe(params => { | ||
82 | this.search = params.search | ||
83 | this.setTableFilter(params.search) | ||
84 | this.loadData() | ||
85 | }) | ||
86 | } | ||
87 | |||
88 | ngAfterViewInit () { | ||
89 | if (this.search) this.setTableFilter(this.search) | ||
90 | } | ||
91 | |||
92 | onInputSearch (event: Event) { | ||
93 | this.onSearch(event) | ||
94 | this.setQueryParams((event.target as HTMLInputElement).value) | ||
95 | } | ||
96 | |||
97 | setQueryParams (search: string) { | ||
98 | const queryParams: Params = {} | ||
99 | |||
100 | if (search) Object.assign(queryParams, { search }) | ||
101 | this.router.navigate([ '/admin/moderation/video-comments/list' ], { queryParams }) | ||
102 | } | ||
103 | |||
104 | resetTableFilter () { | ||
105 | this.setTableFilter('') | ||
106 | this.setQueryParams('') | ||
107 | this.resetSearch() | ||
108 | } | ||
109 | /* END Table filter functions */ | ||
110 | |||
111 | getIdentifier () { | ||
112 | return 'VideoCommentListComponent' | ||
113 | } | ||
114 | |||
115 | toHtml (text: string) { | ||
116 | return this.markdownRenderer.textMarkdownToHTML(text, true, true) | ||
117 | } | ||
118 | |||
119 | protected loadData () { | ||
120 | this.videoCommentService.getAdminVideoComments({ | ||
121 | pagination: this.pagination, | ||
122 | sort: this.sort, | ||
123 | search: this.search | ||
124 | }).subscribe( | ||
125 | async resultList => { | ||
126 | this.totalRecords = resultList.total | ||
127 | |||
128 | this.comments = [] | ||
129 | |||
130 | for (const c of resultList.data) { | ||
131 | this.comments.push( | ||
132 | new VideoCommentAdmin(c, await this.toHtml(c.text)) | ||
133 | ) | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | err => this.notifier.error(err.message) | ||
138 | ) | ||
139 | } | ||
140 | |||
141 | private deleteComment (comment: VideoCommentAdmin) { | ||
142 | this.videoCommentService.deleteVideoComment(comment.video.id, comment.id) | ||
143 | .subscribe( | ||
144 | () => this.loadData(), | ||
145 | |||
146 | err => this.notifier.error(err.message) | ||
147 | ) | ||
148 | } | ||
149 | |||
150 | private async deleteUserComments (comment: VideoCommentAdmin) { | ||
151 | const message = $localize`Do you really want to delete all comments of ${comment.by}?` | ||
152 | const res = await this.confirmService.confirm(message, $localize`Delete`) | ||
153 | if (res === false) return | ||
154 | |||
155 | const options = { | ||
156 | accountName: comment.by, | ||
157 | scope: 'instance' as 'instance' | ||
158 | } | ||
159 | |||
160 | this.bulkService.removeCommentsOf(options) | ||
161 | .subscribe( | ||
162 | () => { | ||
163 | this.notifier.success($localize`Comments of ${options.accountName} will be deleted in a few minutes`) | ||
164 | }, | ||
165 | |||
166 | err => this.notifier.error(err.message) | ||
167 | ) | ||
168 | } | ||
169 | } | ||