diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts index fd1fabcdb..e48c39cdf 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts | |||
@@ -1,59 +1,15 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { GenericAccountBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/api' | ||
6 | import { AccountBlock, BlocklistService } from '@app/shared/blocklist' | ||
7 | 3 | ||
8 | @Component({ | 4 | @Component({ |
9 | selector: 'my-account-blocklist', | 5 | selector: 'my-account-blocklist', |
10 | styleUrls: [ './my-account-blocklist.component.scss' ], | 6 | styleUrls: [ '../../shared/blocklist/account-blocklist.component.scss' ], |
11 | templateUrl: './my-account-blocklist.component.html' | 7 | templateUrl: '../../shared/blocklist/account-blocklist.component.html' |
12 | }) | 8 | }) |
13 | export class MyAccountBlocklistComponent extends RestTable implements OnInit { | 9 | export class MyAccountBlocklistComponent extends GenericAccountBlocklistComponent { |
14 | blockedAccounts: AccountBlock[] = [] | 10 | mode = BlocklistComponentType.Account |
15 | totalRecords = 0 | ||
16 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
17 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
18 | |||
19 | constructor ( | ||
20 | private notifier: Notifier, | ||
21 | private blocklistService: BlocklistService, | ||
22 | private i18n: I18n | ||
23 | ) { | ||
24 | super() | ||
25 | } | ||
26 | |||
27 | ngOnInit () { | ||
28 | this.initialize() | ||
29 | } | ||
30 | 11 | ||
31 | getIdentifier () { | 12 | getIdentifier () { |
32 | return 'MyAccountBlocklistComponent' | 13 | return 'MyAccountBlocklistComponent' |
33 | } | 14 | } |
34 | |||
35 | unblockAccount (accountBlock: AccountBlock) { | ||
36 | const blockedAccount = accountBlock.blockedAccount | ||
37 | |||
38 | this.blocklistService.unblockAccountByUser(blockedAccount) | ||
39 | .subscribe( | ||
40 | () => { | ||
41 | this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })) | ||
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 | |||
56 | err => this.notifier.error(err.message) | ||
57 | ) | ||
58 | } | ||
59 | } | 15 | } |