]>
Commit | Line | Data |
---|---|---|
65b21c96 | 1 | import { Component, OnInit } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier } from '@app/core' |
65b21c96 C |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
4 | import { RestPagination, RestTable } from '@app/shared' | |
f77eb73b | 5 | import { SortMeta } from 'primeng/api' |
f8b2c1b4 | 6 | import { 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 | }) | |
13 | export 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 | ||
32 | unblockAccount (accountBlock: AccountBlock) { | |
33 | const blockedAccount = accountBlock.blockedAccount | |
34 | ||
35 | this.blocklistService.unblockAccountByInstance(blockedAccount) | |
36 | .subscribe( | |
37 | () => { | |
f8b2c1b4 | 38 | this.notifier.success( |
65b21c96 C |
39 | this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost }) |
40 | ) | |
41 | ||
42 | this.loadData() | |
43 | } | |
44 | ) | |
45 | } | |
46 | ||
47 | protected loadData () { | |
48 | return this.blocklistService.getInstanceAccountBlocklist(this.pagination, this.sort) | |
49 | .subscribe( | |
50 | resultList => { | |
51 | this.blockedAccounts = resultList.data | |
52 | this.totalRecords = resultList.total | |
53 | }, | |
54 | ||
f8b2c1b4 | 55 | err => this.notifier.error(err.message) |
65b21c96 C |
56 | ) |
57 | } | |
58 | } |