diff options
Diffstat (limited to 'client/src/app/+admin/moderation/instance-blocklist')
7 files changed, 180 insertions, 0 deletions
diff --git a/client/src/app/+admin/moderation/instance-blocklist/index.ts b/client/src/app/+admin/moderation/instance-blocklist/index.ts new file mode 100644 index 000000000..3e7a344bb --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './instance-account-blocklist.component' | ||
2 | export * from './instance-server-blocklist.component' | ||
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.html b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.html new file mode 100644 index 000000000..7797bc56e --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.html | |||
@@ -0,0 +1,22 @@ | |||
1 | <p-table | ||
2 | [value]="blockedAccounts" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
3 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" | ||
4 | > | ||
5 | |||
6 | <ng-template pTemplate="header"> | ||
7 | <tr> | ||
8 | <th i18n>Account</th> | ||
9 | <th i18n pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
10 | </tr> | ||
11 | </ng-template> | ||
12 | |||
13 | <ng-template pTemplate="body" let-accountBlock> | ||
14 | <tr> | ||
15 | <td>{{ accountBlock.blockedAccount.nameWithHost }}</td> | ||
16 | <td>{{ accountBlock.createdAt }}</td> | ||
17 | <td class="action-cell"> | ||
18 | <button class="unblock-button" (click)="unblockAccount(accountBlock)" i18n>Unmute</button> | ||
19 | </td> | ||
20 | </tr> | ||
21 | </ng-template> | ||
22 | </p-table> | ||
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.scss b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.scss new file mode 100644 index 000000000..6028b75ea --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.scss | |||
@@ -0,0 +1,7 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .unblock-button { | ||
5 | @include peertube-button; | ||
6 | @include grey-button; | ||
7 | } \ No newline at end of file | ||
diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts new file mode 100644 index 000000000..3f243aee4 --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts | |||
@@ -0,0 +1,59 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
6 | import { BlocklistService, AccountBlock } from '@app/shared/blocklist' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-instance-account-blocklist', | ||
10 | styleUrls: [ './instance-account-blocklist.component.scss' ], | ||
11 | templateUrl: './instance-account-blocklist.component.html' | ||
12 | }) | ||
13 | export class InstanceAccountBlocklistComponent extends RestTable implements OnInit { | ||
14 | blockedAccounts: AccountBlock[] = [] | ||
15 | totalRecords = 0 | ||
16 | rowsPerPage = 10 | ||
17 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
18 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
19 | |||
20 | constructor ( | ||
21 | private notificationsService: NotificationsService, | ||
22 | private blocklistService: BlocklistService, | ||
23 | private i18n: I18n | ||
24 | ) { | ||
25 | super() | ||
26 | } | ||
27 | |||
28 | ngOnInit () { | ||
29 | this.initialize() | ||
30 | } | ||
31 | |||
32 | unblockAccount (accountBlock: AccountBlock) { | ||
33 | const blockedAccount = accountBlock.blockedAccount | ||
34 | |||
35 | this.blocklistService.unblockAccountByInstance(blockedAccount) | ||
36 | .subscribe( | ||
37 | () => { | ||
38 | this.notificationsService.success( | ||
39 | this.i18n('Success'), | ||
40 | this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost }) | ||
41 | ) | ||
42 | |||
43 | this.loadData() | ||
44 | } | ||
45 | ) | ||
46 | } | ||
47 | |||
48 | protected loadData () { | ||
49 | return this.blocklistService.getInstanceAccountBlocklist(this.pagination, this.sort) | ||
50 | .subscribe( | ||
51 | resultList => { | ||
52 | this.blockedAccounts = resultList.data | ||
53 | this.totalRecords = resultList.total | ||
54 | }, | ||
55 | |||
56 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
57 | ) | ||
58 | } | ||
59 | } | ||
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 new file mode 100644 index 000000000..859c0f916 --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.html | |||
@@ -0,0 +1,23 @@ | |||
1 | <p-table | ||
2 | [value]="blockedAccounts" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
3 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" | ||
4 | > | ||
5 | |||
6 | <ng-template pTemplate="header"> | ||
7 | <tr> | ||
8 | <th i18n>Instance</th> | ||
9 | <th i18n pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
10 | <th></th> | ||
11 | </tr> | ||
12 | </ng-template> | ||
13 | |||
14 | <ng-template pTemplate="body" let-serverBlock> | ||
15 | <tr> | ||
16 | <td>{{ serverBlock.blockedServer.host }}</td> | ||
17 | <td>{{ serverBlock.createdAt }}</td> | ||
18 | <td class="action-cell"> | ||
19 | <button class="unblock-button" (click)="unblockServer(serverBlock)" i18n>Unmute</button> | ||
20 | </td> | ||
21 | </tr> | ||
22 | </ng-template> | ||
23 | </p-table> | ||
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 new file mode 100644 index 000000000..6028b75ea --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.scss | |||
@@ -0,0 +1,7 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .unblock-button { | ||
5 | @include peertube-button; | ||
6 | @include grey-button; | ||
7 | } \ No newline at end of file | ||
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 new file mode 100644 index 000000000..9459117a3 --- /dev/null +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts | |||
@@ -0,0 +1,60 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
6 | import { BlocklistService } from '@app/shared/blocklist' | ||
7 | import { ServerBlock } from '../../../../../../shared' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-instance-server-blocklist', | ||
11 | styleUrls: [ './instance-server-blocklist.component.scss' ], | ||
12 | templateUrl: './instance-server-blocklist.component.html' | ||
13 | }) | ||
14 | export class InstanceServerBlocklistComponent extends RestTable implements OnInit { | ||
15 | blockedAccounts: ServerBlock[] = [] | ||
16 | totalRecords = 0 | ||
17 | rowsPerPage = 10 | ||
18 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
19 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
20 | |||
21 | constructor ( | ||
22 | private notificationsService: NotificationsService, | ||
23 | private blocklistService: BlocklistService, | ||
24 | private i18n: I18n | ||
25 | ) { | ||
26 | super() | ||
27 | } | ||
28 | |||
29 | ngOnInit () { | ||
30 | this.initialize() | ||
31 | } | ||
32 | |||
33 | unblockServer (serverBlock: ServerBlock) { | ||
34 | const host = serverBlock.blockedServer.host | ||
35 | |||
36 | this.blocklistService.unblockServerByInstance(host) | ||
37 | .subscribe( | ||
38 | () => { | ||
39 | this.notificationsService.success( | ||
40 | this.i18n('Success'), | ||
41 | this.i18n('Instance {{host}} unmuted by your instance.', { host }) | ||
42 | ) | ||
43 | |||
44 | this.loadData() | ||
45 | } | ||
46 | ) | ||
47 | } | ||
48 | |||
49 | protected loadData () { | ||
50 | return this.blocklistService.getInstanceServerBlocklist(this.pagination, this.sort) | ||
51 | .subscribe( | ||
52 | resultList => { | ||
53 | this.blockedAccounts = resultList.data | ||
54 | this.totalRecords = resultList.total | ||
55 | }, | ||
56 | |||
57 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
58 | ) | ||
59 | } | ||
60 | } | ||