]>
Commit | Line | Data |
---|---|---|
af5767ff | 1 | import { Component, OnInit } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier } from '@app/core' |
af5767ff C |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
4 | import { RestPagination, RestTable } from '@app/shared' | |
5 | import { SortMeta } from 'primeng/components/common/sortmeta' | |
f8b2c1b4 | 6 | import { 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 | }) | |
13 | export 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 | } |