From 7e9334c34db23e5ad1e118151b24c720dd985984 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 20 Nov 2017 11:19:23 +0100 Subject: Add ability to unfollow a server --- .../followers-list/followers-list.component.html | 4 ++-- .../following-list/following-list.component.html | 9 +++++++-- .../following-list/following-list.component.ts | 19 +++++++++++++++++++ .../src/app/+admin/follows/shared/follow.service.ts | 8 +++++++- 4 files changed, 35 insertions(+), 5 deletions(-) (limited to 'client/src/app/+admin/follows') 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 @@ sortField="createdAt" (onLazyLoad)="loadLazy($event)" > - + - + 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 @@ sortField="createdAt" (onLazyLoad)="loadLazy($event)" > - + - + + + + + + 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' import { NotificationsService } from 'angular2-notifications' import { SortMeta } from 'primeng/primeng' import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model' +import { ConfirmService } from '../../../core/confirm/confirm.service' import { RestPagination, RestTable } from '../../../shared' import { FollowService } from '../shared' @@ -18,11 +19,29 @@ export class FollowingListComponent extends RestTable { constructor ( private notificationsService: NotificationsService, + private confirmService: ConfirmService, private followService: FollowService ) { super() } + removeFollowing (follow: AccountFollow) { + this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow').subscribe( + res => { + if (res === false) return + + this.followService.unfollow(follow).subscribe( + () => { + this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`) + this.loadData() + }, + + err => this.notificationsService.error('Error', err.message) + ) + } + ) + } + protected loadData () { this.followService.getFollowing(this.pagination, this.sort) .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 { .catch(res => this.restExtractor.handleError(res)) } - follow (notEmptyHosts: String[]) { + follow (notEmptyHosts: string[]) { const body = { hosts: notEmptyHosts } @@ -46,4 +46,10 @@ export class FollowService { .map(this.restExtractor.extractDataBool) .catch(res => this.restExtractor.handleError(res)) } + + unfollow (follow: AccountFollow) { + return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.id) + .map(this.restExtractor.extractDataBool) + .catch(res => this.restExtractor.handleError(res)) + } } -- cgit v1.2.3