diff options
author | Green-Star <Green-Star@users.noreply.github.com> | 2017-08-02 21:50:42 +0200 |
---|---|---|
committer | Bigard Florian <florian.bigard@gmail.com> | 2017-08-02 21:50:42 +0200 |
commit | d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f (patch) | |
tree | bc945e1b6ab0f9cb36a481fea56cdfdaa8b1a341 /client/src/app/+admin | |
parent | 291e8d3eed88fe714fb74ad897ac2c67347a85ff (diff) | |
download | PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.gz PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.zst PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.zip |
Remove one pod (#76)
* Client: Fix typo
* Client: Add removeFriend feature
* Server: Add removeFriend feature
* Server: Update method name
* Fix rebase onto develop issues
* Server: Fix error message
* Server: Remove useless methods in removeFriend method
* Server: Finish remove on pod feature after rebase
* Server: Type pod parameter
* Fix Travis build
* Add friend-basic test for the remove one pod feature
* Add check-params tests for the remove one pod feature
* Fix typos
* Add friend-advanced test for the remove one pod feature
* Client: Trailing new line
* Move to promises
* Add undefined id test
* Use find method instead of a for loop to find the friend to remove
* Remove setTimeout method
* Server: Remove requestScheduler operations
* Server: Fix logging messages
* Server: Remove sign request parameter
Diffstat (limited to 'client/src/app/+admin')
3 files changed, 36 insertions, 5 deletions
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.html b/client/src/app/+admin/friends/friend-list/friend-list.component.html index 45695f7c8..7b9fff304 100644 --- a/client/src/app/+admin/friends/friend-list/friend-list.component.html +++ b/client/src/app/+admin/friends/friend-list/friend-list.component.html | |||
@@ -2,7 +2,7 @@ | |||
2 | <div class="content-padding"> | 2 | <div class="content-padding"> |
3 | <h3>Friends list</h3> | 3 | <h3>Friends list</h3> |
4 | 4 | ||
5 | <ng2-smart-table [settings]="tableSettings" [source]="friendsSource"></ng2-smart-table> | 5 | <ng2-smart-table [settings]="tableSettings" [source]="friendsSource" (delete)="removeFriend($event)"></ng2-smart-table> |
6 | 6 | ||
7 | <a *ngIf="hasFriends()" class="btn btn-danger pull-left" (click)="quitFriends()"> | 7 | <a *ngIf="hasFriends()" class="btn btn-danger pull-left" (click)="quitFriends()"> |
8 | Quit friends | 8 | Quit friends |
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts index 9f0256d7f..822a112cc 100644 --- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts +++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts | |||
@@ -6,6 +6,7 @@ import { ServerDataSource } from 'ng2-smart-table' | |||
6 | import { ConfirmService } from '../../../core' | 6 | import { ConfirmService } from '../../../core' |
7 | import { Utils } from '../../../shared' | 7 | import { Utils } from '../../../shared' |
8 | import { FriendService } from '../shared' | 8 | import { FriendService } from '../shared' |
9 | import { Pod } from '../../../../../../shared' | ||
9 | 10 | ||
10 | @Component({ | 11 | @Component({ |
11 | selector: 'my-friend-list', | 12 | selector: 'my-friend-list', |
@@ -15,6 +16,7 @@ import { FriendService } from '../shared' | |||
15 | export class FriendListComponent { | 16 | export class FriendListComponent { |
16 | friendsSource = null | 17 | friendsSource = null |
17 | tableSettings = { | 18 | tableSettings = { |
19 | mode: 'external', | ||
18 | attr: { | 20 | attr: { |
19 | class: 'table-hover' | 21 | class: 'table-hover' |
20 | }, | 22 | }, |
@@ -23,7 +25,10 @@ export class FriendListComponent { | |||
23 | position: 'right', | 25 | position: 'right', |
24 | add: false, | 26 | add: false, |
25 | edit: false, | 27 | edit: false, |
26 | delete: false | 28 | delete: true |
29 | }, | ||
30 | delete: { | ||
31 | deleteButtonContent: Utils.getRowDeleteButton() | ||
27 | }, | 32 | }, |
28 | columns: { | 33 | columns: { |
29 | id: { | 34 | id: { |
@@ -71,8 +76,7 @@ export class FriendListComponent { | |||
71 | 76 | ||
72 | this.friendService.quitFriends().subscribe( | 77 | this.friendService.quitFriends().subscribe( |
73 | status => { | 78 | status => { |
74 | this.notificationsService.success('Sucess', 'Friends left!') | 79 | this.notificationsService.success('Success', 'Friends left!') |
75 | |||
76 | this.friendsSource.refresh() | 80 | this.friendsSource.refresh() |
77 | }, | 81 | }, |
78 | 82 | ||
@@ -81,4 +85,24 @@ export class FriendListComponent { | |||
81 | } | 85 | } |
82 | ) | 86 | ) |
83 | } | 87 | } |
88 | |||
89 | removeFriend ({ data }) { | ||
90 | const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.' | ||
91 | const friend: Pod = data | ||
92 | |||
93 | this.confirmService.confirm(confirmMessage, 'Remove').subscribe( | ||
94 | res => { | ||
95 | if (res === false) return | ||
96 | |||
97 | this.friendService.removeFriend(friend).subscribe( | ||
98 | status => { | ||
99 | this.notificationsService.success('Success', 'Friend removed') | ||
100 | this.friendsSource.refresh() | ||
101 | }, | ||
102 | |||
103 | err => this.notificationsService.error('Error', err.text) | ||
104 | ) | ||
105 | } | ||
106 | ) | ||
107 | } | ||
84 | } | 108 | } |
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index 79de4470e..8bc0239ab 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts | |||
@@ -6,6 +6,7 @@ import 'rxjs/add/operator/map' | |||
6 | import { ServerDataSource } from 'ng2-smart-table' | 6 | import { ServerDataSource } from 'ng2-smart-table' |
7 | 7 | ||
8 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' | 8 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' |
9 | import { Pod } from '../../../../../../shared' | ||
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
11 | export class FriendService { | 12 | export class FriendService { |
@@ -20,7 +21,7 @@ export class FriendService { | |||
20 | return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL) | 21 | return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL) |
21 | } | 22 | } |
22 | 23 | ||
23 | makeFriends (notEmptyHosts) { | 24 | makeFriends (notEmptyHosts: String[]) { |
24 | const body = { | 25 | const body = { |
25 | hosts: notEmptyHosts | 26 | hosts: notEmptyHosts |
26 | } | 27 | } |
@@ -35,4 +36,10 @@ export class FriendService { | |||
35 | .map(res => res.status) | 36 | .map(res => res.status) |
36 | .catch((res) => this.restExtractor.handleError(res)) | 37 | .catch((res) => this.restExtractor.handleError(res)) |
37 | } | 38 | } |
39 | |||
40 | removeFriend (friend: Pod) { | ||
41 | return this.authHttp.delete(FriendService.BASE_FRIEND_URL + friend.id) | ||
42 | .map(this.restExtractor.extractDataBool) | ||
43 | .catch((res) => this.restExtractor.handleError(res)) | ||
44 | } | ||
38 | } | 45 | } |