aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/follows
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/follows')
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.ts2
-rw-r--r--client/src/app/+admin/follows/following-add/following-add.component.html22
-rw-r--r--client/src/app/+admin/follows/following-add/following-add.component.scss11
-rw-r--r--client/src/app/+admin/follows/following-add/following-add.component.ts85
-rw-r--r--client/src/app/+admin/follows/following-add/index.ts1
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.html8
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.scss6
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.ts22
-rw-r--r--client/src/app/+admin/follows/follows.component.html2
-rw-r--r--client/src/app/+admin/follows/follows.routes.ts8
-rw-r--r--client/src/app/+admin/follows/index.ts1
11 files changed, 34 insertions, 134 deletions
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts
index aff59a691..585902827 100644
--- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts
+++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts
@@ -15,7 +15,7 @@ export class FollowersListComponent extends RestTable implements OnInit {
15 followers: ActorFollow[] = [] 15 followers: ActorFollow[] = []
16 totalRecords = 0 16 totalRecords = 0
17 rowsPerPage = 10 17 rowsPerPage = 10
18 sort: SortMeta = { field: 'createdAt', order: 1 } 18 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20 20
21 constructor ( 21 constructor (
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
4textarea {
5 height: 250px;
6}
7
8input[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 @@
1import { Component } from '@angular/core'
2import { Router } from '@angular/router'
3import { Notifier } from '@app/core'
4import { ConfirmService } from '../../../core'
5import { validateHost } from '../../../shared'
6import { FollowService } from '@app/shared/instance/follow.service'
7import { 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})
14export 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 @@
1export * from './following-add.component'
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html
index 01aba0c11..cb62d52dd 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.html
+++ b/client/src/app/+admin/follows/following-list/following-list.component.html
@@ -4,12 +4,16 @@
4> 4>
5 <ng-template pTemplate="caption"> 5 <ng-template pTemplate="caption">
6 <div class="caption"> 6 <div class="caption">
7 <div> 7 <div class="ml-auto">
8 <input 8 <input
9 type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..." 9 type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..."
10 (keyup)="onSearch($event)" 10 (keyup)="onSearch($event)"
11 > 11 >
12 </div> 12 </div>
13 <a class="ml-2 follow-button" (click)="addDomainsToFollow()" (key.enter)="addDomainsToFollow()">
14 <my-global-icon iconName="add"></my-global-icon>
15 <ng-container i18n>Follow domain</ng-container>
16 </a>
13 </div> 17 </div>
14 </ng-template> 18 </ng-template>
15 19
@@ -42,3 +46,5 @@
42 </tr> 46 </tr>
43 </ng-template> 47 </ng-template>
44</p-table> 48</p-table>
49
50<my-batch-domains-modal #batchDomainsModal i18n-action action="Follow domains" (domains)="addFollowing($event)"></my-batch-domains-modal>
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.scss b/client/src/app/+admin/follows/following-list/following-list.component.scss
index a6f0656b8..f4656b88d 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.scss
+++ b/client/src/app/+admin/follows/following-list/following-list.component.scss
@@ -7,4 +7,8 @@
7 input { 7 input {
8 @include peertube-input-text(250px); 8 @include peertube-input-text(250px);
9 } 9 }
10} \ No newline at end of file 10}
11
12.follow-button {
13 @include create-button;
14}
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts
index dd7629ead..477a6c0d7 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.ts
+++ b/client/src/app/+admin/follows/following-list/following-list.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit, ViewChild } from '@angular/core'
2import { Notifier } from '@app/core' 2import { Notifier } from '@app/core'
3import { SortMeta } from 'primeng/api' 3import { SortMeta } from 'primeng/api'
4import { ActorFollow } from '../../../../../../shared/models/actors/follow.model' 4import { ActorFollow } from '../../../../../../shared/models/actors/follow.model'
@@ -6,6 +6,7 @@ import { ConfirmService } from '../../../core/confirm/confirm.service'
6import { RestPagination, RestTable } from '../../../shared' 6import { RestPagination, RestTable } from '../../../shared'
7import { FollowService } from '@app/shared/instance/follow.service' 7import { FollowService } from '@app/shared/instance/follow.service'
8import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { BatchDomainsModalComponent } from '@app/+admin/config/shared/batch-domains-modal.component'
9 10
10@Component({ 11@Component({
11 selector: 'my-followers-list', 12 selector: 'my-followers-list',
@@ -13,10 +14,12 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
13 styleUrls: [ './following-list.component.scss' ] 14 styleUrls: [ './following-list.component.scss' ]
14}) 15})
15export class FollowingListComponent extends RestTable implements OnInit { 16export class FollowingListComponent extends RestTable implements OnInit {
17 @ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent
18
16 following: ActorFollow[] = [] 19 following: ActorFollow[] = []
17 totalRecords = 0 20 totalRecords = 0
18 rowsPerPage = 10 21 rowsPerPage = 10
19 sort: SortMeta = { field: 'createdAt', order: 1 } 22 sort: SortMeta = { field: 'createdAt', order: -1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 23 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 24
22 constructor ( 25 constructor (
@@ -36,6 +39,21 @@ export class FollowingListComponent extends RestTable implements OnInit {
36 return 'FollowingListComponent' 39 return 'FollowingListComponent'
37 } 40 }
38 41
42 addDomainsToFollow () {
43 this.batchDomainsModal.openModal()
44 }
45
46 async addFollowing (hosts: string[]) {
47 this.followService.follow(hosts).subscribe(
48 () => {
49 this.notifier.success(this.i18n('Follow request(s) sent!'))
50 this.loadData()
51 },
52
53 err => this.notifier.error(err.message)
54 )
55 }
56
39 async removeFollowing (follow: ActorFollow) { 57 async removeFollowing (follow: ActorFollow) {
40 const res = await this.confirmService.confirm( 58 const res = await this.confirmService.confirm(
41 this.i18n('Do you really want to unfollow {{host}}?', { host: follow.following.host }), 59 this.i18n('Do you really want to unfollow {{host}}?', { host: follow.following.host }),
diff --git a/client/src/app/+admin/follows/follows.component.html b/client/src/app/+admin/follows/follows.component.html
index 46581daf9..7b5bcc2db 100644
--- a/client/src/app/+admin/follows/follows.component.html
+++ b/client/src/app/+admin/follows/follows.component.html
@@ -4,8 +4,6 @@
4 <div class="admin-sub-nav"> 4 <div class="admin-sub-nav">
5 <a i18n routerLink="following-list" routerLinkActive="active">Following</a> 5 <a i18n routerLink="following-list" routerLinkActive="active">Following</a>
6 6
7 <a i18n routerLink="following-add" routerLinkActive="active">Follow</a>
8
9 <a i18n routerLink="followers-list" routerLinkActive="active">Followers</a> 7 <a i18n routerLink="followers-list" routerLinkActive="active">Followers</a>
10 8
11 <a i18n routerLink="video-redundancies-list" routerLinkActive="active">Video redundancies</a> 9 <a i18n routerLink="video-redundancies-list" routerLinkActive="active">Video redundancies</a>
diff --git a/client/src/app/+admin/follows/follows.routes.ts b/client/src/app/+admin/follows/follows.routes.ts
index 298733eb0..8270ae444 100644
--- a/client/src/app/+admin/follows/follows.routes.ts
+++ b/client/src/app/+admin/follows/follows.routes.ts
@@ -2,7 +2,6 @@ import { Routes } from '@angular/router'
2 2
3import { UserRightGuard } from '../../core' 3import { UserRightGuard } from '../../core'
4import { FollowsComponent } from './follows.component' 4import { FollowsComponent } from './follows.component'
5import { FollowingAddComponent } from './following-add'
6import { FollowersListComponent } from './followers-list' 5import { FollowersListComponent } from './followers-list'
7import { UserRight } from '../../../../../shared' 6import { UserRight } from '../../../../../shared'
8import { FollowingListComponent } from './following-list/following-list.component' 7import { FollowingListComponent } from './following-list/following-list.component'
@@ -42,12 +41,7 @@ export const FollowsRoutes: Routes = [
42 }, 41 },
43 { 42 {
44 path: 'following-add', 43 path: 'following-add',
45 component: FollowingAddComponent, 44 redirectTo: 'following-list'
46 data: {
47 meta: {
48 title: 'Add follow'
49 }
50 }
51 }, 45 },
52 { 46 {
53 path: 'video-redundancies-list', 47 path: 'video-redundancies-list',
diff --git a/client/src/app/+admin/follows/index.ts b/client/src/app/+admin/follows/index.ts
index 4fcb35cb1..285955468 100644
--- a/client/src/app/+admin/follows/index.ts
+++ b/client/src/app/+admin/follows/index.ts
@@ -1,4 +1,3 @@
1export * from './following-add'
2export * from './followers-list' 1export * from './followers-list'
3export * from './following-list' 2export * from './following-list'
4export * from './video-redundancies-list' 3export * from './video-redundancies-list'