diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:10:17 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 67ed6552b831df66713bac9e672738796128d33f (patch) | |
tree | 59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/shared-moderation/batch-domains-modal.component.ts | |
parent | 0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff) | |
download | PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip |
Reorganize client shared modules
Diffstat (limited to 'client/src/app/shared/shared-moderation/batch-domains-modal.component.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/batch-domains-modal.component.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts new file mode 100644 index 000000000..fdd4a79a9 --- /dev/null +++ b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts | |||
@@ -0,0 +1,52 @@ | |||
1 | import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | ||
2 | import { BatchDomainsValidatorsService, 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 { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | |||
7 | @Component({ | ||
8 | selector: 'my-batch-domains-modal', | ||
9 | templateUrl: './batch-domains-modal.component.html', | ||
10 | styleUrls: [ './batch-domains-modal.component.scss' ] | ||
11 | }) | ||
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[]>() | ||
17 | |||
18 | private openedModal: NgbModalRef | ||
19 | |||
20 | constructor ( | ||
21 | protected formValidatorService: FormValidatorService, | ||
22 | private modalService: NgbModal, | ||
23 | private batchDomainsValidatorsService: BatchDomainsValidatorsService, | ||
24 | private i18n: I18n | ||
25 | ) { | ||
26 | super() | ||
27 | } | ||
28 | |||
29 | ngOnInit () { | ||
30 | if (!this.action) this.action = this.i18n('Process domains') | ||
31 | |||
32 | this.buildForm({ | ||
33 | domains: this.batchDomainsValidatorsService.DOMAINS | ||
34 | }) | ||
35 | } | ||
36 | |||
37 | openModal () { | ||
38 | this.openedModal = this.modalService.open(this.modal, { centered: true }) | ||
39 | } | ||
40 | |||
41 | hide () { | ||
42 | this.openedModal.close() | ||
43 | } | ||
44 | |||
45 | submit () { | ||
46 | this.domains.emit( | ||
47 | this.batchDomainsValidatorsService.getNotEmptyHosts(this.form.controls['domains'].value) | ||
48 | ) | ||
49 | this.form.reset() | ||
50 | this.hide() | ||
51 | } | ||
52 | } | ||