diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-20 11:19:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 7e9334c34db23e5ad1e118151b24c720dd985984 (patch) | |
tree | 154f5d1db44ff652b793d8e0b7dc1b00a3ddaec1 /client/src/app/+admin/follows | |
parent | 892211e8493b1f992fce7616cb1e48b7ff87a1dc (diff) | |
download | PeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.tar.gz PeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.tar.zst PeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.zip |
Add ability to unfollow a server
Diffstat (limited to 'client/src/app/+admin/follows')
4 files changed, 35 insertions, 5 deletions
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html index 24d75d2b3..549aacdf0 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.html +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html | |||
@@ -7,9 +7,9 @@ | |||
7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" | 7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" |
8 | > | 8 | > |
9 | <p-column field="id" header="ID"></p-column> | 9 | <p-column field="id" header="ID"></p-column> |
10 | <p-column field="host" header="Host"></p-column> | 10 | <p-column field="follower.host" header="Host"></p-column> |
11 | <p-column field="email" header="Email"></p-column> | 11 | <p-column field="email" header="Email"></p-column> |
12 | <p-column field="score" header="Score"></p-column> | 12 | <p-column field="follower.score" header="Score"></p-column> |
13 | <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> | 13 | <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> |
14 | </p-dataTable> | 14 | </p-dataTable> |
15 | </div> | 15 | </div> |
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 fbcebfaa7..dcc03f4a5 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 | |||
@@ -7,10 +7,15 @@ | |||
7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" | 7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" |
8 | > | 8 | > |
9 | <p-column field="id" header="ID"></p-column> | 9 | <p-column field="id" header="ID"></p-column> |
10 | <p-column field="host" header="Host"></p-column> | 10 | <p-column field="following.host" header="Host"></p-column> |
11 | <p-column field="email" header="Email"></p-column> | 11 | <p-column field="email" header="Email"></p-column> |
12 | <p-column field="score" header="Score"></p-column> | 12 | <p-column field="following.score" header="Score"></p-column> |
13 | <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> | 13 | <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> |
14 | <p-column header="Unfollow" styleClass="action-cell"> | ||
15 | <ng-template pTemplate="body" let-following="rowData"> | ||
16 | <span (click)="removeFollowing(following)" class="glyphicon glyphicon-remove glyphicon-black" title="Unfollow"></span> | ||
17 | </ng-template> | ||
18 | </p-column> | ||
14 | </p-dataTable> | 19 | </p-dataTable> |
15 | </div> | 20 | </div> |
16 | </div> | 21 | </div> |
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 a1dff1db3..411b8f640 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 | |||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core' | |||
2 | import { NotificationsService } from 'angular2-notifications' | 2 | import { NotificationsService } from 'angular2-notifications' |
3 | import { SortMeta } from 'primeng/primeng' | 3 | import { SortMeta } from 'primeng/primeng' |
4 | import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model' | 4 | import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model' |
5 | import { ConfirmService } from '../../../core/confirm/confirm.service' | ||
5 | import { RestPagination, RestTable } from '../../../shared' | 6 | import { RestPagination, RestTable } from '../../../shared' |
6 | import { FollowService } from '../shared' | 7 | import { FollowService } from '../shared' |
7 | 8 | ||
@@ -18,11 +19,29 @@ export class FollowingListComponent extends RestTable { | |||
18 | 19 | ||
19 | constructor ( | 20 | constructor ( |
20 | private notificationsService: NotificationsService, | 21 | private notificationsService: NotificationsService, |
22 | private confirmService: ConfirmService, | ||
21 | private followService: FollowService | 23 | private followService: FollowService |
22 | ) { | 24 | ) { |
23 | super() | 25 | super() |
24 | } | 26 | } |
25 | 27 | ||
28 | removeFollowing (follow: AccountFollow) { | ||
29 | this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow').subscribe( | ||
30 | res => { | ||
31 | if (res === false) return | ||
32 | |||
33 | this.followService.unfollow(follow).subscribe( | ||
34 | () => { | ||
35 | this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`) | ||
36 | this.loadData() | ||
37 | }, | ||
38 | |||
39 | err => this.notificationsService.error('Error', err.message) | ||
40 | ) | ||
41 | } | ||
42 | ) | ||
43 | } | ||
44 | |||
26 | protected loadData () { | 45 | protected loadData () { |
27 | this.followService.getFollowing(this.pagination, this.sort) | 46 | this.followService.getFollowing(this.pagination, this.sort) |
28 | .subscribe( | 47 | .subscribe( |
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts index f66ed477d..0bfbe8eb6 100644 --- a/client/src/app/+admin/follows/shared/follow.service.ts +++ b/client/src/app/+admin/follows/shared/follow.service.ts | |||
@@ -37,7 +37,7 @@ export class FollowService { | |||
37 | .catch(res => this.restExtractor.handleError(res)) | 37 | .catch(res => this.restExtractor.handleError(res)) |
38 | } | 38 | } |
39 | 39 | ||
40 | follow (notEmptyHosts: String[]) { | 40 | follow (notEmptyHosts: string[]) { |
41 | const body = { | 41 | const body = { |
42 | hosts: notEmptyHosts | 42 | hosts: notEmptyHosts |
43 | } | 43 | } |
@@ -46,4 +46,10 @@ export class FollowService { | |||
46 | .map(this.restExtractor.extractDataBool) | 46 | .map(this.restExtractor.extractDataBool) |
47 | .catch(res => this.restExtractor.handleError(res)) | 47 | .catch(res => this.restExtractor.handleError(res)) |
48 | } | 48 | } |
49 | |||
50 | unfollow (follow: AccountFollow) { | ||
51 | return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.id) | ||
52 | .map(this.restExtractor.extractDataBool) | ||
53 | .catch(res => this.restExtractor.handleError(res)) | ||
54 | } | ||
49 | } | 55 | } |