From 51548b31815c6f96f314ae96588a9adca150519d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 10:10:41 +0100 Subject: Add follow tabs Following Follow Followers --- .../app/+admin/follows/shared/follow.service.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 client/src/app/+admin/follows/shared/follow.service.ts (limited to 'client/src/app/+admin/follows/shared/follow.service.ts') diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts new file mode 100644 index 000000000..622c33cea --- /dev/null +++ b/client/src/app/+admin/follows/shared/follow.service.ts @@ -0,0 +1,49 @@ +import { Injectable } from '@angular/core' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Observable } from 'rxjs/Observable' +import 'rxjs/add/operator/catch' +import 'rxjs/add/operator/map' + +import { SortMeta } from 'primeng/primeng' + +import { RestExtractor, RestPagination, RestService } from '../../../shared' +import { Pod, ResultList } from '../../../../../../shared' + +@Injectable() +export class FollowService { + private static BASE_APPLICATION_URL = API_URL + '/api/v1/application' + + constructor ( + private authHttp: HttpClient, + private restService: RestService, + private restExtractor: RestExtractor + ) {} + + getFollowing (pagination: RestPagination, sort: SortMeta): Observable> { + let params = new HttpParams() + params = this.restService.addRestGetParams(params, pagination, sort) + + return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/following', { params }) + .map(res => this.restExtractor.convertResultListDateToHuman(res)) + .catch(res => this.restExtractor.handleError(res)) + } + + getFollowers (pagination: RestPagination, sort: SortMeta): Observable> { + let params = new HttpParams() + params = this.restService.addRestGetParams(params, pagination, sort) + + return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) + .map(res => this.restExtractor.convertResultListDateToHuman(res)) + .catch(res => this.restExtractor.handleError(res)) + } + + follow (notEmptyHosts: String[]) { + const body = { + hosts: notEmptyHosts + } + + return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/follow', body) + .map(this.restExtractor.extractDataBool) + .catch(res => this.restExtractor.handleError(res)) + } +} -- cgit v1.2.3