diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-04-14 10:55:34 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-04-14 15:53:37 +0200 |
commit | bb152476c819e4c7487d080433c616f0d523e049 (patch) | |
tree | 955b6afa140b6e83eced3cb21c8ec1d62fa6a15e /client/src/app/+admin/moderation | |
parent | 1055eb3a7b89bc50dc611ab933f9dbd603488747 (diff) | |
download | PeerTube-bb152476c819e4c7487d080433c616f0d523e049.tar.gz PeerTube-bb152476c819e4c7487d080433c616f0d523e049.tar.zst PeerTube-bb152476c819e4c7487d080433c616f0d523e049.zip |
Refactor follow/mute as modals in admin, add actions in abuse list
Diffstat (limited to 'client/src/app/+admin/moderation')
6 files changed, 106 insertions, 32 deletions
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.html b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.html index 44c5c2fb8..0e072d84b 100644 --- a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.html +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.html | |||
@@ -4,6 +4,14 @@ | |||
4 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | 4 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate |
5 | currentPageReportTemplate="Showing {first} to {last} of {totalRecords} muted instances" | 5 | currentPageReportTemplate="Showing {first} to {last} of {totalRecords} muted instances" |
6 | > | 6 | > |
7 | <ng-template pTemplate="caption"> | ||
8 | <div class="caption"> | ||
9 | <a class="ml-auto block-button" (click)="addServersToBlock()" (key.enter)="addServersToBlock()"> | ||
10 | <my-global-icon iconName="add"></my-global-icon> | ||
11 | <ng-container i18n>Mute domain</ng-container> | ||
12 | </a> | ||
13 | </div> | ||
14 | </ng-template> | ||
7 | 15 | ||
8 | <ng-template pTemplate="header"> | 16 | <ng-template pTemplate="header"> |
9 | <tr> | 17 | <tr> |
@@ -23,3 +31,11 @@ | |||
23 | </tr> | 31 | </tr> |
24 | </ng-template> | 32 | </ng-template> |
25 | </p-table> | 33 | </p-table> |
34 | |||
35 | <my-batch-domains-modal #batchDomainsModal i18n-action action="Mute domains" (domains)="onDomainsToBlock($event)"> | ||
36 | <ng-container ngProjectAs="warning"> | ||
37 | <div i18n *ngIf="httpEnabled() === false" class="alert alert-warning"> | ||
38 | It seems that you are not on a HTTPS server. Your webserver needs to have TLS activated in order to follow servers. | ||
39 | </div> | ||
40 | </ng-container> | ||
41 | </my-batch-domains-modal> | ||
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.scss b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.scss index 6028b75ea..9d3bedd80 100644 --- a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.scss +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.scss | |||
@@ -4,4 +4,8 @@ | |||
4 | .unblock-button { | 4 | .unblock-button { |
5 | @include peertube-button; | 5 | @include peertube-button; |
6 | @include grey-button; | 6 | @include grey-button; |
7 | } \ No newline at end of file | 7 | } |
8 | |||
9 | .block-button { | ||
10 | @include create-button; | ||
11 | } | ||
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts index 5af6d8f76..431729ef2 100644 --- a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier } from '@app/core' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | 3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
4 | import { RestPagination, RestTable } from '@app/shared' | 4 | import { RestPagination, RestTable } from '@app/shared' |
5 | import { SortMeta } from 'primeng/api' | 5 | import { SortMeta } from 'primeng/api' |
6 | import { BlocklistService } from '@app/shared/blocklist' | 6 | import { BlocklistService } from '@app/shared/blocklist' |
7 | import { ServerBlock } from '../../../../../../shared' | 7 | import { ServerBlock } from '../../../../../../shared' |
8 | import { BatchDomainsModalComponent } from '@app/+admin/config/shared/batch-domains-modal.component' | ||
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
10 | selector: 'my-instance-server-blocklist', | 11 | selector: 'my-instance-server-blocklist', |
@@ -12,6 +13,8 @@ import { ServerBlock } from '../../../../../../shared' | |||
12 | templateUrl: './instance-server-blocklist.component.html' | 13 | templateUrl: './instance-server-blocklist.component.html' |
13 | }) | 14 | }) |
14 | export class InstanceServerBlocklistComponent extends RestTable implements OnInit { | 15 | export class InstanceServerBlocklistComponent extends RestTable implements OnInit { |
16 | @ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent | ||
17 | |||
15 | blockedServers: ServerBlock[] = [] | 18 | blockedServers: ServerBlock[] = [] |
16 | totalRecords = 0 | 19 | totalRecords = 0 |
17 | rowsPerPage = 10 | 20 | rowsPerPage = 10 |
@@ -47,6 +50,27 @@ export class InstanceServerBlocklistComponent extends RestTable implements OnIni | |||
47 | ) | 50 | ) |
48 | } | 51 | } |
49 | 52 | ||
53 | httpEnabled () { | ||
54 | return window.location.protocol === 'https:' | ||
55 | } | ||
56 | |||
57 | addServersToBlock () { | ||
58 | this.batchDomainsModal.openModal() | ||
59 | } | ||
60 | |||
61 | onDomainsToBlock (domains: string[]) { | ||
62 | domains.forEach(domain => { | ||
63 | this.blocklistService.blockServerByInstance(domain) | ||
64 | .subscribe( | ||
65 | () => { | ||
66 | this.notifier.success(this.i18n('Instance {{domain}} muted by your instance.', { domain })) | ||
67 | |||
68 | this.loadData() | ||
69 | } | ||
70 | ) | ||
71 | }) | ||
72 | } | ||
73 | |||
50 | protected loadData () { | 74 | protected loadData () { |
51 | return this.blocklistService.getInstanceServerBlocklist(this.pagination, this.sort) | 75 | return this.blocklistService.getInstanceServerBlocklist(this.pagination, this.sort) |
52 | .subscribe( | 76 | .subscribe( |
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html index 155d10dda..3899ee07f 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html | |||
@@ -48,13 +48,13 @@ | |||
48 | </a> | 48 | </a> |
49 | </td> | 49 | </td> |
50 | 50 | ||
51 | <td> | 51 | <td class="c-hand" [pRowToggler]="videoAbuse"> |
52 | <span *ngIf="isVideoAbuseAccepted(videoAbuse)" [title]="videoAbuse.state.label" class="glyphicon glyphicon-ok"></span> | 52 | <span *ngIf="isVideoAbuseAccepted(videoAbuse)" [title]="videoAbuse.state.label" class="glyphicon glyphicon-ok"></span> |
53 | <span *ngIf="isVideoAbuseRejected(videoAbuse)" [title]="videoAbuse.state.label" class="glyphicon glyphicon-remove"></span> | 53 | <span *ngIf="isVideoAbuseRejected(videoAbuse)" [title]="videoAbuse.state.label" class="glyphicon glyphicon-remove"></span> |
54 | </td> | 54 | </td> |
55 | 55 | ||
56 | <td class="action-cell"> | 56 | <td class="action-cell"> |
57 | <my-action-dropdown placement="bottom-right" i18n-label label="Actions" [actions]="videoAbuseActions" [entry]="videoAbuse"></my-action-dropdown> | 57 | <my-action-dropdown placement="bottom-right auto" i18n-label label="Actions" [actions]="videoAbuseActions" [entry]="videoAbuse"></my-action-dropdown> |
58 | </td> | 58 | </td> |
59 | </tr> | 59 | </tr> |
60 | </ng-template> | 60 | </ng-template> |
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts index b135792a7..5e48cf24f 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Component, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
2 | import { Account } from '../../../shared/account/account.model' | 2 | import { Account } from '@app/shared/account/account.model' |
3 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
4 | import { SortMeta } from 'primeng/api' | 4 | import { SortMeta } from 'primeng/api' |
5 | import { VideoAbuse, VideoAbuseState } from '../../../../../../shared' | 5 | import { VideoAbuse, VideoAbuseState } from '../../../../../../shared' |
6 | import { RestPagination, RestTable, VideoAbuseService } from '../../../shared' | 6 | import { RestPagination, RestTable, VideoAbuseService, VideoBlacklistService } from '../../../shared' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 7 | import { I18n } from '@ngx-translate/i18n-polyfill' |
8 | import { DropdownAction } from '../../../shared/buttons/action-dropdown.component' | 8 | import { DropdownAction } from '../../../shared/buttons/action-dropdown.component' |
9 | import { ConfirmService } from '../../../core/index' | 9 | import { ConfirmService } from '../../../core/index' |
@@ -14,6 +14,7 @@ import { Actor } from '@app/shared/actor/actor.model' | |||
14 | import { buildVideoLink, buildVideoEmbed } from 'src/assets/player/utils' | 14 | import { buildVideoLink, buildVideoEmbed } from 'src/assets/player/utils' |
15 | import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' | 15 | import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' |
16 | import { DomSanitizer } from '@angular/platform-browser' | 16 | import { DomSanitizer } from '@angular/platform-browser' |
17 | import { BlocklistService } from '@app/shared/blocklist' | ||
17 | 18 | ||
18 | @Component({ | 19 | @Component({ |
19 | selector: 'my-video-abuse-list', | 20 | selector: 'my-video-abuse-list', |
@@ -29,11 +30,13 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
29 | sort: SortMeta = { field: 'createdAt', order: 1 } | 30 | sort: SortMeta = { field: 'createdAt', order: 1 } |
30 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 31 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
31 | 32 | ||
32 | videoAbuseActions: DropdownAction<VideoAbuse>[] = [] | 33 | videoAbuseActions: DropdownAction<VideoAbuse>[][] = [] |
33 | 34 | ||
34 | constructor ( | 35 | constructor ( |
35 | private notifier: Notifier, | 36 | private notifier: Notifier, |
36 | private videoAbuseService: VideoAbuseService, | 37 | private videoAbuseService: VideoAbuseService, |
38 | private blocklistService: BlocklistService, | ||
39 | private videoBlacklistService: VideoBlacklistService, | ||
37 | private confirmService: ConfirmService, | 40 | private confirmService: ConfirmService, |
38 | private i18n: I18n, | 41 | private i18n: I18n, |
39 | private markdownRenderer: MarkdownService, | 42 | private markdownRenderer: MarkdownService, |
@@ -42,30 +45,57 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
42 | super() | 45 | super() |
43 | 46 | ||
44 | this.videoAbuseActions = [ | 47 | this.videoAbuseActions = [ |
45 | { | 48 | [ |
46 | label: this.i18n('Delete this report'), | 49 | { |
47 | handler: videoAbuse => this.removeVideoAbuse(videoAbuse) | 50 | label: this.i18n('Internal actions'), |
48 | }, | 51 | isHeader: true |
49 | { | 52 | }, |
50 | label: this.i18n('Add note'), | 53 | { |
51 | handler: videoAbuse => this.openModerationCommentModal(videoAbuse), | 54 | label: this.i18n('Delete report'), |
52 | isDisplayed: videoAbuse => !videoAbuse.moderationComment | 55 | handler: videoAbuse => this.removeVideoAbuse(videoAbuse) |
53 | }, | 56 | }, |
54 | { | 57 | { |
55 | label: this.i18n('Update note'), | 58 | label: this.i18n('Add note'), |
56 | handler: videoAbuse => this.openModerationCommentModal(videoAbuse), | 59 | handler: videoAbuse => this.openModerationCommentModal(videoAbuse), |
57 | isDisplayed: videoAbuse => !!videoAbuse.moderationComment | 60 | isDisplayed: videoAbuse => !videoAbuse.moderationComment |
58 | }, | 61 | }, |
59 | { | 62 | { |
60 | label: this.i18n('Mark as accepted'), | 63 | label: this.i18n('Update note'), |
61 | handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED), | 64 | handler: videoAbuse => this.openModerationCommentModal(videoAbuse), |
62 | isDisplayed: videoAbuse => !this.isVideoAbuseAccepted(videoAbuse) | 65 | isDisplayed: videoAbuse => !!videoAbuse.moderationComment |
63 | }, | 66 | }, |
64 | { | 67 | { |
65 | label: this.i18n('Mark as rejected'), | 68 | label: this.i18n('Mark as accepted'), |
66 | handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.REJECTED), | 69 | handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED), |
67 | isDisplayed: videoAbuse => !this.isVideoAbuseRejected(videoAbuse) | 70 | isDisplayed: videoAbuse => !this.isVideoAbuseAccepted(videoAbuse) |
68 | } | 71 | }, |
72 | { | ||
73 | label: this.i18n('Mark as rejected'), | ||
74 | handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.REJECTED), | ||
75 | isDisplayed: videoAbuse => !this.isVideoAbuseRejected(videoAbuse) | ||
76 | } | ||
77 | ], | ||
78 | [ | ||
79 | { | ||
80 | label: this.i18n('Actions for the video'), | ||
81 | isHeader: true | ||
82 | }, | ||
83 | { | ||
84 | label: this.i18n('Blacklist video'), | ||
85 | handler: videoAbuse => { | ||
86 | this.videoBlacklistService.blacklistVideo(videoAbuse.video.id, undefined, true) | ||
87 | .subscribe( | ||
88 | () => { | ||
89 | this.notifier.success(this.i18n('Video blacklisted.')) | ||
90 | |||
91 | this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED) | ||
92 | }, | ||
93 | |||
94 | err => this.notifier.error(err.message) | ||
95 | ) | ||
96 | } | ||
97 | } | ||
98 | ] | ||
69 | ] | 99 | ] |
70 | } | 100 | } |
71 | 101 | ||
diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts index 43b6863af..4e9965bee 100644 --- a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts +++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts | |||
@@ -18,7 +18,7 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit { | |||
18 | blacklist: (VideoBlacklist & { reasonHtml?: string })[] = [] | 18 | blacklist: (VideoBlacklist & { reasonHtml?: string })[] = [] |
19 | totalRecords = 0 | 19 | totalRecords = 0 |
20 | rowsPerPage = 10 | 20 | rowsPerPage = 10 |
21 | sort: SortMeta = { field: 'createdAt', order: 1 } | 21 | sort: SortMeta = { field: 'createdAt', order: -1 } |
22 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 22 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
23 | listBlacklistTypeFilter: VideoBlacklistType = undefined | 23 | listBlacklistTypeFilter: VideoBlacklistType = undefined |
24 | 24 | ||