diff options
Diffstat (limited to 'client/src/app/+admin/moderation/instance-blocklist')
3 files changed, 46 insertions, 2 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( |