]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
Fix player width with playlist
[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'
5import { SortMeta } from 'primeng/components/common/sortmeta'
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
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,
af5767ff
C
22 private blocklistService: BlocklistService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31
32 unblockAccount (accountBlock: AccountBlock) {
33 const blockedAccount = accountBlock.blockedAccount
34
35 this.blocklistService.unblockAccountByUser(blockedAccount)
36 .subscribe(
37 () => {
f8b2c1b4 38 this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost }))
af5767ff
C
39
40 this.loadData()
41 }
42 )
43 }
44
45 protected loadData () {
46 return this.blocklistService.getUserAccountBlocklist(this.pagination, this.sort)
47 .subscribe(
48 resultList => {
49 this.blockedAccounts = resultList.data
50 this.totalRecords = resultList.total
51 },
52
f8b2c1b4 53 err => this.notifier.error(err.message)
af5767ff
C
54 )
55 }
56}