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 { ServerBlock } from '../../../../../shared'
7 import { BlocklistService } from '@app/shared/blocklist'
10 selector: 'my-account-server-blocklist',
11 styleUrls: [ './my-account-server-blocklist.component.scss' ],
12 templateUrl: './my-account-server-blocklist.component.html'
14 export class MyAccountServerBlocklistComponent extends RestTable implements OnInit {
15 blockedServers: ServerBlock[] = []
18 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22 private notifier: Notifier,
23 private blocklistService: BlocklistService,
33 unblockServer (serverBlock: ServerBlock) {
34 const host = serverBlock.blockedServer.host
36 this.blocklistService.unblockServerByUser(host)
39 this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host }))
46 protected loadData () {
47 return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort)
50 this.blockedServers = resultList.data
51 this.totalRecords = resultList.total
54 err => this.notifier.error(err.message)