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, 56 insertions, 0 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 new file mode 100644 index 000000000..e3025dec4 --- /dev/null +++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts | |||
@@ -0,0 +1,56 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { Notifier } from '@app/core' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
6 | import { AccountBlock, BlocklistService } from '@app/shared/blocklist' | ||
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 ( | ||
21 | private notifier: Notifier, | ||
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 | () => { | ||
38 | this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })) | ||
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 | |||
53 | err => this.notifier.error(err.message) | ||
54 | ) | ||
55 | } | ||
56 | } | ||