]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/confirm/confirm.component.ts
Client: Fix Javascript OOM error during webpack compilation (#89)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.component.ts
CommitLineData
df98563e 1import { Component, HostListener, OnInit, ViewChild } from '@angular/core'
5769e1db 2
df98563e 3import { ModalDirective } from 'ngx-bootstrap/modal'
5769e1db 4
df98563e 5import { ConfirmService } from './confirm.service'
5769e1db
C
6
7export interface ConfigChangedEvent {
df98563e
C
8 columns: { [id: string]: { isDisplayed: boolean } }
9 config: { resultsPerPage: number }
5769e1db
C
10}
11
12@Component({
13 selector: 'my-confirm',
14 templateUrl: './confirm.component.html'
15})
16export class ConfirmComponent implements OnInit {
df98563e 17 @ViewChild('confirmModal') confirmModal: ModalDirective
5769e1db 18
df98563e
C
19 title = ''
20 message = ''
5769e1db
C
21
22 constructor (private confirmService: ConfirmService) {
23 // Empty
24 }
25
df98563e 26 ngOnInit () {
5769e1db
C
27 this.confirmModal.config = {
28 backdrop: 'static',
29 keyboard: false
df98563e 30 }
5769e1db
C
31
32 this.confirmService.showConfirm.subscribe(
33 ({ title, message }) => {
df98563e
C
34 this.title = title
35 this.message = message
5769e1db 36
df98563e 37 this.showModal()
5769e1db 38 }
df98563e 39 )
5769e1db
C
40 }
41
42 @HostListener('keydown.enter')
df98563e
C
43 confirm () {
44 this.confirmService.confirmResponse.next(true)
45 this.hideModal()
5769e1db
C
46 }
47
48 @HostListener('keydown.esc')
df98563e
C
49 abort () {
50 this.confirmService.confirmResponse.next(false)
51 this.hideModal()
5769e1db
C
52 }
53
df98563e
C
54 showModal () {
55 this.confirmModal.show()
5769e1db
C
56 }
57
df98563e
C
58 hideModal () {
59 this.confirmModal.hide()
5769e1db
C
60 }
61}