diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts | 57 |
1 files changed, 6 insertions, 51 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts index 483c11804..cfaba1c7b 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts | |||
@@ -1,60 +1,15 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { GenericServerBlocklistComponent, 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 { ServerBlock } from '../../../../../shared' | ||
7 | import { BlocklistService } from '@app/shared/blocklist' | ||
8 | 3 | ||
9 | @Component({ | 4 | @Component({ |
10 | selector: 'my-account-server-blocklist', | 5 | selector: 'my-account-server-blocklist', |
11 | styleUrls: [ './my-account-server-blocklist.component.scss' ], | 6 | styleUrls: [ '../../+admin/moderation/moderation.component.scss', '../../shared/blocklist/server-blocklist.component.scss' ], |
12 | templateUrl: './my-account-server-blocklist.component.html' | 7 | templateUrl: '../../shared/blocklist/server-blocklist.component.html' |
13 | }) | 8 | }) |
14 | export class MyAccountServerBlocklistComponent extends RestTable implements OnInit { | 9 | export class MyAccountServerBlocklistComponent extends GenericServerBlocklistComponent { |
15 | blockedServers: ServerBlock[] = [] | 10 | mode = BlocklistComponentType.Account |
16 | totalRecords = 0 | ||
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 | 11 | ||
32 | getIdentifier () { | 12 | getIdentifier () { |
33 | return 'MyAccountServerBlocklistComponent' | 13 | return 'MyAccountServerBlocklistComponent' |
34 | } | 14 | } |
35 | |||
36 | unblockServer (serverBlock: ServerBlock) { | ||
37 | const host = serverBlock.blockedServer.host | ||
38 | |||
39 | this.blocklistService.unblockServerByUser(host) | ||
40 | .subscribe( | ||
41 | () => { | ||
42 | this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host })) | ||
43 | |||
44 | this.loadData() | ||
45 | } | ||
46 | ) | ||
47 | } | ||
48 | |||
49 | protected loadData () { | ||
50 | return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort) | ||
51 | .subscribe( | ||
52 | resultList => { | ||
53 | this.blockedServers = resultList.data | ||
54 | this.totalRecords = resultList.total | ||
55 | }, | ||
56 | |||
57 | err => this.notifier.error(err.message) | ||
58 | ) | ||
59 | } | ||
60 | } | 15 | } |