]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
replace title with video name in moderation listings
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-blocklist / my-account-blocklist.component.ts
CommitLineData
af5767ff 1import { Component, OnInit } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
af5767ff
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'
af5767ff
C
7
8@Component({
9 selector: 'my-account-blocklist',
10 styleUrls: [ './my-account-blocklist.component.scss' ],
11 templateUrl: './my-account-blocklist.component.html'
12})
13export class MyAccountBlocklistComponent extends RestTable implements OnInit {
14 blockedAccounts: AccountBlock[] = []
15 totalRecords = 0
af5767ff
C
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18
19 constructor (
f8b2c1b4 20 private notifier: Notifier,
af5767ff
C
21 private blocklistService: BlocklistService,
22 private i18n: I18n
23 ) {
24 super()
25 }
26
27 ngOnInit () {
28 this.initialize()
29 }
30
8e11a1b3
C
31 getIdentifier () {
32 return 'MyAccountBlocklistComponent'
33 }
34
af5767ff
C
35 unblockAccount (accountBlock: AccountBlock) {
36 const blockedAccount = accountBlock.blockedAccount
37
38 this.blocklistService.unblockAccountByUser(blockedAccount)
39 .subscribe(
40 () => {
f8b2c1b4 41 this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost }))
af5767ff
C
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
f8b2c1b4 56 err => this.notifier.error(err.message)
af5767ff
C
57 )
58 }
59}