]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts
Update translations
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / instance-blocklist / instance-account-blocklist.component.ts
CommitLineData
65b21c96 1import { Component, OnInit } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
65b21c96
C
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RestPagination, RestTable } from '@app/shared'
f77eb73b 5import { SortMeta } from 'primeng/api'
f8b2c1b4 6import { AccountBlock, BlocklistService } from '@app/shared/blocklist'
65b21c96
C
7
8@Component({
9 selector: 'my-instance-account-blocklist',
10 styleUrls: [ './instance-account-blocklist.component.scss' ],
11 templateUrl: './instance-account-blocklist.component.html'
12})
13export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
14 blockedAccounts: AccountBlock[] = []
15 totalRecords = 0
16 rowsPerPage = 10
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
f8b2c1b4 21 private notifier: Notifier,
65b21c96
C
22 private blocklistService: BlocklistService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31
8e11a1b3
C
32 getIdentifier () {
33 return 'InstanceAccountBlocklistComponent'
34 }
35
65b21c96
C
36 unblockAccount (accountBlock: AccountBlock) {
37 const blockedAccount = accountBlock.blockedAccount
38
39 this.blocklistService.unblockAccountByInstance(blockedAccount)
40 .subscribe(
41 () => {
f8b2c1b4 42 this.notifier.success(
65b21c96
C
43 this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost })
44 )
45
46 this.loadData()
47 }
48 )
49 }
50
51 protected loadData () {
52 return this.blocklistService.getInstanceAccountBlocklist(this.pagination, this.sort)
53 .subscribe(
54 resultList => {
55 this.blockedAccounts = resultList.data
56 this.totalRecords = resultList.total
57 },
58
f8b2c1b4 59 err => this.notifier.error(err.message)
65b21c96
C
60 )
61 }
62}