aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-blocklist/my-account-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-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-blocklist.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts56
1 files changed, 6 insertions, 50 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
index fd1fabcdb..e48c39cdf 100644
--- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
+++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
@@ -1,59 +1,15 @@
1import { Component, OnInit } from '@angular/core' 1import { Component } from '@angular/core'
2import { Notifier } from '@app/core' 2import { GenericAccountBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RestPagination, RestTable } from '@app/shared'
5import { SortMeta } from 'primeng/api'
6import { AccountBlock, BlocklistService } from '@app/shared/blocklist'
7 3
8@Component({ 4@Component({
9 selector: 'my-account-blocklist', 5 selector: 'my-account-blocklist',
10 styleUrls: [ './my-account-blocklist.component.scss' ], 6 styleUrls: [ '../../shared/blocklist/account-blocklist.component.scss' ],
11 templateUrl: './my-account-blocklist.component.html' 7 templateUrl: '../../shared/blocklist/account-blocklist.component.html'
12}) 8})
13export class MyAccountBlocklistComponent extends RestTable implements OnInit { 9export class MyAccountBlocklistComponent extends GenericAccountBlocklistComponent {
14 blockedAccounts: AccountBlock[] = [] 10 mode = BlocklistComponentType.Account
15 totalRecords = 0
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18
19 constructor (
20 private notifier: Notifier,
21 private blocklistService: BlocklistService,
22 private i18n: I18n
23 ) {
24 super()
25 }
26
27 ngOnInit () {
28 this.initialize()
29 }
30 11
31 getIdentifier () { 12 getIdentifier () {
32 return 'MyAccountBlocklistComponent' 13 return 'MyAccountBlocklistComponent'
33 } 14 }
34
35 unblockAccount (accountBlock: AccountBlock) {
36 const blockedAccount = accountBlock.blockedAccount
37
38 this.blocklistService.unblockAccountByUser(blockedAccount)
39 .subscribe(
40 () => {
41 this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost }))
42
43 this.loadData()
44 }
45 )
46 }
47
48 protected loadData () {
49 return this.blocklistService.getUserAccountBlocklist(this.pagination, this.sort)
50 .subscribe(
51 resultList => {
52 this.blockedAccounts = resultList.data
53 this.totalRecords = resultList.total
54 },
55
56 err => this.notifier.error(err.message)
57 )
58 }
59} 15}