1 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
3 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
5 import { splitAndGetNotEmpty, UNIQUE_HOSTS_VALIDATOR } from '../form-validators/host-validators'
8 selector: 'my-batch-domains-modal',
9 templateUrl: './batch-domains-modal.component.html',
10 styleUrls: [ './batch-domains-modal.component.scss' ]
12 export class BatchDomainsModalComponent extends FormReactive implements OnInit {
13 @ViewChild('modal', { static: true }) modal: NgbModal
14 @Input() placeholder = 'example.com'
15 @Input() action: string
16 @Output() domains = new EventEmitter<string[]>()
18 private openedModal: NgbModalRef
21 protected formValidatorService: FormValidatorService,
22 private modalService: NgbModal
28 if (!this.action) this.action = $localize`Process domains`
31 hosts: UNIQUE_HOSTS_VALIDATOR
36 this.openedModal = this.modalService.open(this.modal, { centered: true })
40 this.openedModal.close()
44 this.domains.emit(splitAndGetNotEmpty(this.form.controls['hosts'].value))