aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-06-15 13:18:22 +0200
committerGitHub <noreply@github.com>2020-06-15 13:18:22 +0200
commit228393302d98136d4dc35c5f197edc8cebd5d64f (patch)
treef92b3ad80bcc9c89088ff1d4de5ebff76a3f46ed /client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
parent7dfe35288613967f5ac69cd46901ec60c5050b93 (diff)
downloadPeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.tar.gz
PeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.tar.zst
PeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.zip
factorize account/server blocklists for users and instance (#2875)
Diffstat (limited to 'client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts57
1 files changed, 6 insertions, 51 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
index 483c11804..cfaba1c7b 100644
--- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
+++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
@@ -1,60 +1,15 @@
1import { Component, OnInit } from '@angular/core' 1import { Component } from '@angular/core'
2import { Notifier } from '@app/core' 2import { GenericServerBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RestPagination, RestTable } from '@app/shared'
5import { SortMeta } from 'primeng/api'
6import { ServerBlock } from '../../../../../shared'
7import { BlocklistService } from '@app/shared/blocklist'
8 3
9@Component({ 4@Component({
10 selector: 'my-account-server-blocklist', 5 selector: 'my-account-server-blocklist',
11 styleUrls: [ './my-account-server-blocklist.component.scss' ], 6 styleUrls: [ '../../+admin/moderation/moderation.component.scss', '../../shared/blocklist/server-blocklist.component.scss' ],
12 templateUrl: './my-account-server-blocklist.component.html' 7 templateUrl: '../../shared/blocklist/server-blocklist.component.html'
13}) 8})
14export class MyAccountServerBlocklistComponent extends RestTable implements OnInit { 9export class MyAccountServerBlocklistComponent extends GenericServerBlocklistComponent {
15 blockedServers: ServerBlock[] = [] 10 mode = BlocklistComponentType.Account
16 totalRecords = 0
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
21 private notifier: Notifier,
22 private blocklistService: BlocklistService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31 11
32 getIdentifier () { 12 getIdentifier () {
33 return 'MyAccountServerBlocklistComponent' 13 return 'MyAccountServerBlocklistComponent'
34 } 14 }
35
36 unblockServer (serverBlock: ServerBlock) {
37 const host = serverBlock.blockedServer.host
38
39 this.blocklistService.unblockServerByUser(host)
40 .subscribe(
41 () => {
42 this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host }))
43
44 this.loadData()
45 }
46 )
47 }
48
49 protected loadData () {
50 return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort)
51 .subscribe(
52 resultList => {
53 this.blockedServers = resultList.data
54 this.totalRecords = resultList.total
55 },
56
57 err => this.notifier.error(err.message)
58 )
59 }
60} 15}