aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/follows/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/follows/shared')
-rw-r--r--client/src/app/+admin/follows/shared/follow.service.ts12
-rw-r--r--client/src/app/+admin/follows/shared/redundancy-checkbox.component.html3
-rw-r--r--client/src/app/+admin/follows/shared/redundancy-checkbox.component.scss2
-rw-r--r--client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts42
-rw-r--r--client/src/app/+admin/follows/shared/redundancy.service.ts29
5 files changed, 82 insertions, 6 deletions
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts
index 87ea5fb0c..27169a9cd 100644
--- a/client/src/app/+admin/follows/shared/follow.service.ts
+++ b/client/src/app/+admin/follows/shared/follow.service.ts
@@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { SortMeta } from 'primeng/primeng' 4import { SortMeta } from 'primeng/primeng'
5import { Observable } from 'rxjs' 5import { Observable } from 'rxjs'
6import { AccountFollow, ResultList } from '../../../../../../shared' 6import { ActorFollow, ResultList } from '../../../../../../shared'
7import { environment } from '../../../../environments/environment' 7import { environment } from '../../../../environments/environment'
8import { RestExtractor, RestPagination, RestService } from '../../../shared' 8import { RestExtractor, RestPagination, RestService } from '../../../shared'
9 9
@@ -18,22 +18,22 @@ export class FollowService {
18 ) { 18 ) {
19 } 19 }
20 20
21 getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { 21 getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<ActorFollow>> {
22 let params = new HttpParams() 22 let params = new HttpParams()
23 params = this.restService.addRestGetParams(params, pagination, sort) 23 params = this.restService.addRestGetParams(params, pagination, sort)
24 24
25 return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) 25 return this.authHttp.get<ResultList<ActorFollow>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
26 .pipe( 26 .pipe(
27 map(res => this.restExtractor.convertResultListDateToHuman(res)), 27 map(res => this.restExtractor.convertResultListDateToHuman(res)),
28 catchError(res => this.restExtractor.handleError(res)) 28 catchError(res => this.restExtractor.handleError(res))
29 ) 29 )
30 } 30 }
31 31
32 getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { 32 getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<ActorFollow>> {
33 let params = new HttpParams() 33 let params = new HttpParams()
34 params = this.restService.addRestGetParams(params, pagination, sort) 34 params = this.restService.addRestGetParams(params, pagination, sort)
35 35
36 return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) 36 return this.authHttp.get<ResultList<ActorFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
37 .pipe( 37 .pipe(
38 map(res => this.restExtractor.convertResultListDateToHuman(res)), 38 map(res => this.restExtractor.convertResultListDateToHuman(res)),
39 catchError(res => this.restExtractor.handleError(res)) 39 catchError(res => this.restExtractor.handleError(res))
@@ -52,7 +52,7 @@ export class FollowService {
52 ) 52 )
53 } 53 }
54 54
55 unfollow (follow: AccountFollow) { 55 unfollow (follow: ActorFollow) {
56 return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) 56 return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
57 .pipe( 57 .pipe(
58 map(this.restExtractor.extractDataBool), 58 map(this.restExtractor.extractDataBool),
diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html
new file mode 100644
index 000000000..8a57d65f0
--- /dev/null
+++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html
@@ -0,0 +1,3 @@
1<my-peertube-checkbox
2 [inputName]="host + '-redundancy-allowed'" [(ngModel)]="redundancyAllowed" (ngModelChange)="updateRedundancyState()"
3></my-peertube-checkbox> \ No newline at end of file
diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.scss b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.scss
new file mode 100644
index 000000000..5e6774739
--- /dev/null
+++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.scss
@@ -0,0 +1,2 @@
1@import '_variables';
2@import '_mixins';
diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
new file mode 100644
index 000000000..ff4725e91
--- /dev/null
+++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
@@ -0,0 +1,42 @@
1import { Component, Input } from '@angular/core'
2import { AuthService } from '@app/core'
3import { RestExtractor } from '@app/shared/rest'
4import { RedirectService } from '@app/core/routing/redirect.service'
5import { NotificationsService } from 'angular2-notifications'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { RedundancyService } from '@app/+admin/follows/shared/redundancy.service'
8
9@Component({
10 selector: 'my-redundancy-checkbox',
11 templateUrl: './redundancy-checkbox.component.html',
12 styleUrls: [ './redundancy-checkbox.component.scss' ]
13})
14export class RedundancyCheckboxComponent {
15 @Input() redundancyAllowed: boolean
16 @Input() host: string
17
18 constructor (
19 private authService: AuthService,
20 private restExtractor: RestExtractor,
21 private redirectService: RedirectService,
22 private notificationsService: NotificationsService,
23 private redundancyService: RedundancyService,
24 private i18n: I18n
25 ) { }
26
27 updateRedundancyState () {
28 this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
29 .subscribe(
30 () => {
31 const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
32
33 this.notificationsService.success(
34 this.i18n('Success'),
35 this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel })
36 )
37 },
38
39 err => this.notificationsService.error(this.i18n('Error'), err.message)
40 )
41 }
42}
diff --git a/client/src/app/+admin/follows/shared/redundancy.service.ts b/client/src/app/+admin/follows/shared/redundancy.service.ts
new file mode 100644
index 000000000..96b29faab
--- /dev/null
+++ b/client/src/app/+admin/follows/shared/redundancy.service.ts
@@ -0,0 +1,29 @@
1import { catchError, map } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { RestExtractor, RestService } from '@app/shared'
5import { environment } from '../../../../environments/environment'
6
7@Injectable()
8export class RedundancyService {
9 static BASE_USER_SUBSCRIPTIONS_URL = environment.apiUrl + '/api/v1/server/redundancy'
10
11 constructor (
12 private authHttp: HttpClient,
13 private restExtractor: RestExtractor,
14 private restService: RestService
15 ) { }
16
17 updateRedundancy (host: string, redundancyAllowed: boolean) {
18 const url = RedundancyService.BASE_USER_SUBSCRIPTIONS_URL + '/' + host
19
20 const body = { redundancyAllowed }
21
22 return this.authHttp.put(url, body)
23 .pipe(
24 map(this.restExtractor.extractDataBool),
25 catchError(err => this.restExtractor.handleError(err))
26 )
27 }
28
29}