]>
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' |
d3840613 | 7 | import { Actor } from '@app/shared/actor/actor.model' |
65b21c96 C |
8 | |
9 | @Component({ | |
10 | selector: 'my-instance-account-blocklist', | |
e0a92917 | 11 | styleUrls: [ '../moderation.component.scss', './instance-account-blocklist.component.scss' ], |
65b21c96 C |
12 | templateUrl: './instance-account-blocklist.component.html' |
13 | }) | |
14 | export class InstanceAccountBlocklistComponent extends RestTable implements OnInit { | |
15 | blockedAccounts: AccountBlock[] = [] | |
16 | totalRecords = 0 | |
65b21c96 C |
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 | ||
d3840613 RK |
36 | switchToDefaultAvatar ($event: Event) { |
37 | ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() | |
38 | } | |
39 | ||
65b21c96 C |
40 | unblockAccount (accountBlock: AccountBlock) { |
41 | const blockedAccount = accountBlock.blockedAccount | |
42 | ||
43 | this.blocklistService.unblockAccountByInstance(blockedAccount) | |
44 | .subscribe( | |
45 | () => { | |
f8b2c1b4 | 46 | this.notifier.success( |
65b21c96 C |
47 | this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost }) |
48 | ) | |
49 | ||
50 | this.loadData() | |
51 | } | |
52 | ) | |
53 | } | |
54 | ||
55 | protected loadData () { | |
e0a92917 RK |
56 | return this.blocklistService.getInstanceAccountBlocklist({ |
57 | pagination: this.pagination, | |
58 | sort: this.sort, | |
59 | search: this.search | |
60 | }) | |
65b21c96 C |
61 | .subscribe( |
62 | resultList => { | |
63 | this.blockedAccounts = resultList.data | |
64 | this.totalRecords = resultList.total | |
65 | }, | |
66 | ||
f8b2c1b4 | 67 | err => this.notifier.error(err.message) |
65b21c96 C |
68 | ) |
69 | } | |
70 | } |