From d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f Mon Sep 17 00:00:00 2001 From: Green-Star Date: Wed, 2 Aug 2017 21:50:42 +0200 Subject: 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 --- .../friends/friend-list/friend-list.component.html | 2 +- .../friends/friend-list/friend-list.component.ts | 30 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'client/src/app/+admin/friends/friend-list') 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 @@

Friends list

- + 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' import { ConfirmService } from '../../../core' import { Utils } from '../../../shared' import { FriendService } from '../shared' +import { Pod } from '../../../../../../shared' @Component({ selector: 'my-friend-list', @@ -15,6 +16,7 @@ import { FriendService } from '../shared' export class FriendListComponent { friendsSource = null tableSettings = { + mode: 'external', attr: { class: 'table-hover' }, @@ -23,7 +25,10 @@ export class FriendListComponent { position: 'right', add: false, edit: false, - delete: false + delete: true + }, + delete: { + deleteButtonContent: Utils.getRowDeleteButton() }, columns: { id: { @@ -71,8 +76,7 @@ export class FriendListComponent { this.friendService.quitFriends().subscribe( status => { - this.notificationsService.success('Sucess', 'Friends left!') - + this.notificationsService.success('Success', 'Friends left!') this.friendsSource.refresh() }, @@ -81,4 +85,24 @@ export class FriendListComponent { } ) } + + removeFriend ({ data }) { + const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.' + const friend: Pod = data + + this.confirmService.confirm(confirmMessage, 'Remove').subscribe( + res => { + if (res === false) return + + this.friendService.removeFriend(friend).subscribe( + status => { + this.notificationsService.success('Success', 'Friend removed') + this.friendsSource.refresh() + }, + + err => this.notificationsService.error('Error', err.text) + ) + } + ) + } } -- cgit v1.2.3