From 0dc647775881eb1378b213a530996cd096de24ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Apr 2019 15:47:44 +0200 Subject: Add delete/manual approval instance followers in client --- .../edit-custom-config.component.html | 27 +++++++++ .../edit-custom-config.component.ts | 8 ++- .../followers-list/followers-list.component.html | 20 +++++-- .../followers-list/followers-list.component.scss | 8 ++- .../followers-list/followers-list.component.ts | 64 ++++++++++++++++++++-- .../app/+admin/follows/shared/follow.service.ts | 30 ++++++++++ .../my-account-ownership.component.html | 13 ++--- 7 files changed, 149 insertions(+), 21 deletions(-) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 00a0d98f8..637484622 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -84,6 +84,7 @@ +
Signup
@@ -111,6 +112,7 @@ +
Users
@@ -139,6 +141,7 @@ +
Import
@@ -161,6 +164,7 @@ +
Auto-blacklist
@@ -178,6 +182,29 @@ + +
Instance followers
+ + + + +
+ +
+ +
+ +
+
+
+ +
Administrator
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index d8eb55da7..e64750713 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -5,7 +5,7 @@ import { CustomConfigValidatorsService, FormReactive, UserValidatorsService } fr import { Notifier } from '@app/core' import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' import { I18n } from '@ngx-translate/i18n-polyfill' -import { BuildFormDefaultValues, FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' @Component({ selector: 'my-edit-custom-config', @@ -124,6 +124,12 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { enabled: null } } + }, + followers: { + instance: { + enabled: null, + manualApproval: null + } } } 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 fc022bdb4..da0ba95e3 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 @@ -14,25 +14,33 @@ ID - Score - Name - Host + Follower handle State + Score Created + {{ follow.id }} - {{ follow.score }} - {{ follow.follower.name }} - {{ follow.follower.host }} + {{ follow.follower.name + '@' + follow.follower.host }} Accepted Pending + {{ follow.score }} {{ follow.createdAt }} + + + + + + + + + diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.scss b/client/src/app/+admin/follows/followers-list/followers-list.component.scss index a6f0656b8..964b3f99b 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.scss +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.scss @@ -7,4 +7,10 @@ input { @include peertube-input-text(250px); } -} \ No newline at end of file +} + +.action-cell { + my-button:first-child { + margin-right: 10px; + } +} diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 9a8848bfb..b78cdf656 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core' - -import { Notifier } from '@app/core' +import { ConfirmService, Notifier } from '@app/core' import { SortMeta } from 'primeng/primeng' import { ActorFollow } from '../../../../../../shared/models/actors/follow.model' import { RestPagination, RestTable } from '../../../shared' @@ -20,9 +19,10 @@ export class FollowersListComponent extends RestTable implements OnInit { pagination: RestPagination = { count: this.rowsPerPage, start: 0 } constructor ( + private confirmService: ConfirmService, private notifier: Notifier, - private followService: FollowService, - private i18n: I18n + private i18n: I18n, + private followService: FollowService ) { super() } @@ -31,6 +31,62 @@ export class FollowersListComponent extends RestTable implements OnInit { this.initialize() } + acceptFollower (follow: ActorFollow) { + follow.state = 'accepted' + + this.followService.acceptFollower(follow) + .subscribe( + () => { + const handle = follow.follower.name + '@' + follow.follower.host + this.notifier.success(this.i18n('{{handle}} accepted in instance followers', { handle })) + }, + + err => { + follow.state = 'pending' + this.notifier.error(err.message) + } + ) + } + + async rejectFollower (follow: ActorFollow) { + const message = this.i18n('Do you really want to reject this follower?') + const res = await this.confirmService.confirm(message, this.i18n('Reject')) + if (res === false) return + + this.followService.rejectFollower(follow) + .subscribe( + () => { + const handle = follow.follower.name + '@' + follow.follower.host + this.notifier.success(this.i18n('{{handle}} rejected from instance followers', { handle })) + + this.loadData() + }, + + err => { + follow.state = 'pending' + this.notifier.error(err.message) + } + ) + } + + async deleteFollower (follow: ActorFollow) { + const message = this.i18n('Do you really want to delete this follower?') + const res = await this.confirmService.confirm(message, this.i18n('Delete')) + if (res === false) return + + this.followService.removeFollower(follow) + .subscribe( + () => { + const handle = follow.follower.name + '@' + follow.follower.host + this.notifier.success(this.i18n('{{handle}} removed from instance followers', { handle })) + + this.loadData() + }, + + err => this.notifier.error(err.message) + ) + } + protected loadData () { this.followService.getFollowers(this.pagination, this.sort, this.search) .subscribe( diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts index a2904179e..c2b8ef006 100644 --- a/client/src/app/+admin/follows/shared/follow.service.ts +++ b/client/src/app/+admin/follows/shared/follow.service.ts @@ -63,4 +63,34 @@ export class FollowService { catchError(res => this.restExtractor.handleError(res)) ) } + + acceptFollower (follow: ActorFollow) { + const handle = follow.follower.name + '@' + follow.follower.host + + return this.authHttp.post(`${FollowService.BASE_APPLICATION_URL}/followers/${handle}/accept`, {}) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(res => this.restExtractor.handleError(res)) + ) + } + + rejectFollower (follow: ActorFollow) { + const handle = follow.follower.name + '@' + follow.follower.host + + return this.authHttp.post(`${FollowService.BASE_APPLICATION_URL}/followers/${handle}/reject`, {}) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(res => this.restExtractor.handleError(res)) + ) + } + + removeFollower (follow: ActorFollow) { + const handle = follow.follower.name + '@' + follow.follower.host + + return this.authHttp.delete(`${FollowService.BASE_APPLICATION_URL}/followers/${handle}`) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(res => this.restExtractor.handleError(res)) + ) + } } diff --git a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html index 5709e9f54..c5fd3ccb9 100644 --- a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html +++ b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html @@ -30,8 +30,7 @@ - + {{ videoChangeOwnership.video.name }} @@ -39,16 +38,12 @@ {{ videoChangeOwnership.status }} - - Refuse + + - \ No newline at end of file + -- cgit v1.2.3