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/follows/following-add | |
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/follows/following-add')
4 files changed, 0 insertions, 119 deletions
diff --git a/client/src/app/+admin/follows/following-add/following-add.component.html b/client/src/app/+admin/follows/following-add/following-add.component.html deleted file mode 100644 index e08decb3f..000000000 --- a/client/src/app/+admin/follows/following-add/following-add.component.html +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> | ||
2 | |||
3 | <form (ngSubmit)="addFollowing()"> | ||
4 | <div class="form-group"> | ||
5 | <label i18n for="hosts">1 host (without "http://") per line</label> | ||
6 | |||
7 | <textarea | ||
8 | type="text" class="form-control" placeholder="example.com" id="hosts" name="hosts" | ||
9 | [(ngModel)]="hostsString" (ngModelChange)="onHostsChanged()" [ngClass]="{ 'input-error': hostsError }" | ||
10 | ></textarea> | ||
11 | |||
12 | <div *ngIf="hostsError" class="form-error"> | ||
13 | {{ hostsError }} | ||
14 | </div> | ||
15 | </div> | ||
16 | |||
17 | <div i18n *ngIf="httpEnabled() === false" class="alert alert-warning"> | ||
18 | It seems that you are not on a HTTPS server. Your webserver needs to have TLS activated in order to follow servers. | ||
19 | </div> | ||
20 | |||
21 | <input type="submit" i18n-value value="Add following" [disabled]="hostsError || !hostsString" class="btn btn-secondary"> | ||
22 | </form> | ||
diff --git a/client/src/app/+admin/follows/following-add/following-add.component.scss b/client/src/app/+admin/follows/following-add/following-add.component.scss deleted file mode 100644 index 7594b502c..000000000 --- a/client/src/app/+admin/follows/following-add/following-add.component.scss +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | textarea { | ||
5 | height: 250px; | ||
6 | } | ||
7 | |||
8 | input[type=submit] { | ||
9 | @include peertube-button; | ||
10 | @include orange-button; | ||
11 | } | ||
diff --git a/client/src/app/+admin/follows/following-add/following-add.component.ts b/client/src/app/+admin/follows/following-add/following-add.component.ts deleted file mode 100644 index 308bbb0c5..000000000 --- a/client/src/app/+admin/follows/following-add/following-add.component.ts +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | import { Router } from '@angular/router' | ||
3 | import { Notifier } from '@app/core' | ||
4 | import { ConfirmService } from '../../../core' | ||
5 | import { validateHost } from '../../../shared' | ||
6 | import { FollowService } from '@app/shared/instance/follow.service' | ||
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-following-add', | ||
11 | templateUrl: './following-add.component.html', | ||
12 | styleUrls: [ './following-add.component.scss' ] | ||
13 | }) | ||
14 | export class FollowingAddComponent { | ||
15 | hostsString = '' | ||
16 | hostsError: string = null | ||
17 | error: string = null | ||
18 | |||
19 | constructor ( | ||
20 | private router: Router, | ||
21 | private notifier: Notifier, | ||
22 | private confirmService: ConfirmService, | ||
23 | private followService: FollowService, | ||
24 | private i18n: I18n | ||
25 | ) {} | ||
26 | |||
27 | httpEnabled () { | ||
28 | return window.location.protocol === 'https:' | ||
29 | } | ||
30 | |||
31 | onHostsChanged () { | ||
32 | this.hostsError = null | ||
33 | |||
34 | const newHostsErrors = [] | ||
35 | const hosts = this.getNotEmptyHosts() | ||
36 | |||
37 | for (const host of hosts) { | ||
38 | if (validateHost(host) === false) { | ||
39 | newHostsErrors.push(this.i18n('{{host}} is not valid', { host })) | ||
40 | } | ||
41 | } | ||
42 | |||
43 | if (newHostsErrors.length !== 0) { | ||
44 | this.hostsError = newHostsErrors.join('. ') | ||
45 | } | ||
46 | } | ||
47 | |||
48 | async addFollowing () { | ||
49 | this.error = '' | ||
50 | |||
51 | const hosts = this.getNotEmptyHosts() | ||
52 | if (hosts.length === 0) { | ||
53 | this.error = this.i18n('You need to specify hosts to follow.') | ||
54 | } | ||
55 | |||
56 | if (!this.isHostsUnique(hosts)) { | ||
57 | this.error = this.i18n('Hosts need to be unique.') | ||
58 | return | ||
59 | } | ||
60 | |||
61 | const confirmMessage = this.i18n('If you confirm, you will send a follow request to:<br /> - ') + hosts.join('<br /> - ') | ||
62 | const res = await this.confirmService.confirm(confirmMessage, this.i18n('Follow new server(s)')) | ||
63 | if (res === false) return | ||
64 | |||
65 | this.followService.follow(hosts).subscribe( | ||
66 | () => { | ||
67 | this.notifier.success(this.i18n('Follow request(s) sent!')) | ||
68 | |||
69 | setTimeout(() => this.router.navigate([ '/admin/follows/following-list' ]), 500) | ||
70 | }, | ||
71 | |||
72 | err => this.notifier.error(err.message) | ||
73 | ) | ||
74 | } | ||
75 | |||
76 | private isHostsUnique (hosts: string[]) { | ||
77 | return hosts.every(host => hosts.indexOf(host) === hosts.lastIndexOf(host)) | ||
78 | } | ||
79 | |||
80 | private getNotEmptyHosts () { | ||
81 | return this.hostsString | ||
82 | .split('\n') | ||
83 | .filter(host => host && host.length !== 0) // Eject empty hosts | ||
84 | } | ||
85 | } | ||
diff --git a/client/src/app/+admin/follows/following-add/index.ts b/client/src/app/+admin/follows/following-add/index.ts deleted file mode 100644 index 1b1897ffa..000000000 --- a/client/src/app/+admin/follows/following-add/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './following-add.component' | ||