aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-20 11:19:23 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit7e9334c34db23e5ad1e118151b24c720dd985984 (patch)
tree154f5d1db44ff652b793d8e0b7dc1b00a3ddaec1 /client
parent892211e8493b1f992fce7616cb1e48b7ff87a1dc (diff)
downloadPeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.tar.gz
PeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.tar.zst
PeerTube-7e9334c34db23e5ad1e118151b24c720dd985984.zip
Add ability to unfollow a server
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.html4
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.html9
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.ts19
-rw-r--r--client/src/app/+admin/follows/shared/follow.service.ts8
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts8
5 files changed, 37 insertions, 11 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'
2import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
3import { SortMeta } from 'primeng/primeng' 3import { SortMeta } from 'primeng/primeng'
4import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model' 4import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model'
5import { ConfirmService } from '../../../core/confirm/confirm.service'
5import { RestPagination, RestTable } from '../../../shared' 6import { RestPagination, RestTable } from '../../../shared'
6import { FollowService } from '../shared' 7import { 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}
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts
index 6debf89be..1e8e1af49 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/users/user-list/user-list.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnInit } from '@angular/core' 1import { Component } from '@angular/core'
2import { SortMeta } from 'primeng/components/common/sortmeta' 2import { SortMeta } from 'primeng/components/common/sortmeta'
3 3
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
@@ -12,7 +12,7 @@ import { UserService } from '../shared'
12 templateUrl: './user-list.component.html', 12 templateUrl: './user-list.component.html',
13 styleUrls: [ './user-list.component.scss' ] 13 styleUrls: [ './user-list.component.scss' ]
14}) 14})
15export class UserListComponent extends RestTable implements OnInit { 15export class UserListComponent extends RestTable {
16 users: User[] = [] 16 users: User[] = []
17 totalRecords = 0 17 totalRecords = 0
18 rowsPerPage = 10 18 rowsPerPage = 10
@@ -27,10 +27,6 @@ export class UserListComponent extends RestTable implements OnInit {
27 super() 27 super()
28 } 28 }
29 29
30 ngOnInit () {
31 this.loadData()
32 }
33
34 removeUser (user: User) { 30 removeUser (user: User) {
35 if (user.username === 'root') { 31 if (user.username === 'root') {
36 this.notificationsService.error('Error', 'You cannot delete root.') 32 this.notificationsService.error('Error', 'You cannot delete root.')