From 67ed6552b831df66713bac9e672738796128d33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:10:17 +0200 Subject: Reorganize client shared modules --- .../shared/blocklist/server-blocklist.component.ts | 101 --------------------- 1 file changed, 101 deletions(-) delete mode 100644 client/src/app/shared/blocklist/server-blocklist.component.ts (limited to 'client/src/app/shared/blocklist/server-blocklist.component.ts') diff --git a/client/src/app/shared/blocklist/server-blocklist.component.ts b/client/src/app/shared/blocklist/server-blocklist.component.ts deleted file mode 100644 index f2b36badc..000000000 --- a/client/src/app/shared/blocklist/server-blocklist.component.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { OnInit, ViewChild } from '@angular/core' -import { Notifier } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { RestPagination, RestTable } from '@app/shared/rest' -import { SortMeta } from 'primeng/api' -import { BlocklistService, BlocklistComponentType } from './blocklist.service' -import { ServerBlock } from '../../../../../shared/models/blocklist/server-block.model' -import { BatchDomainsModalComponent } from '@app/+admin/config/shared/batch-domains-modal.component' - -export class GenericServerBlocklistComponent extends RestTable implements OnInit { - @ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent - - // @ts-ignore: "Abstract methods can only appear within an abstract class" - public abstract mode: BlocklistComponentType - - blockedServers: ServerBlock[] = [] - totalRecords = 0 - sort: SortMeta = { field: 'createdAt', order: -1 } - pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - - constructor ( - protected notifier: Notifier, - protected blocklistService: BlocklistService, - protected i18n: I18n - ) { - super() - } - - ngOnInit () { - this.initialize() - } - - // @ts-ignore: "Abstract methods can only appear within an abstract class" - public abstract getIdentifier (): string - - unblockServer (serverBlock: ServerBlock) { - const operation = (host: string) => this.mode === BlocklistComponentType.Account - ? this.blocklistService.unblockServerByUser(host) - : this.blocklistService.unblockServerByInstance(host) - const host = serverBlock.blockedServer.host - - operation(host).subscribe( - () => { - this.notifier.success( - this.mode === BlocklistComponentType.Account - ? this.i18n('Instance {{host}} unmuted.', { host }) - : this.i18n('Instance {{host}} unmuted by your instance.', { host }) - ) - - this.loadData() - } - ) - } - - addServersToBlock () { - this.batchDomainsModal.openModal() - } - - onDomainsToBlock (domains: string[]) { - const operation = (domain: string) => this.mode === BlocklistComponentType.Account - ? this.blocklistService.blockServerByUser(domain) - : this.blocklistService.blockServerByInstance(domain) - - domains.forEach(domain => { - operation(domain).subscribe( - () => { - this.notifier.success( - this.mode === BlocklistComponentType.Account - ? this.i18n('Instance {{domain}} muted.', { domain }) - : this.i18n('Instance {{domain}} muted by your instance.', { domain }) - ) - - this.loadData() - } - ) - }) - } - - protected loadData () { - const operation = this.mode === BlocklistComponentType.Account - ? this.blocklistService.getUserServerBlocklist({ - pagination: this.pagination, - sort: this.sort, - search: this.search - }) - : this.blocklistService.getInstanceServerBlocklist({ - pagination: this.pagination, - sort: this.sort, - search: this.search - }) - - return operation.subscribe( - resultList => { - this.blockedServers = resultList.data - this.totalRecords = resultList.total - }, - - err => this.notifier.error(err.message) - ) - } -} -- cgit v1.2.3