]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/confirm/confirm.component.ts
Support video quota on client
[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',
59aa1e5e
C
14 templateUrl: './confirm.component.html',
15 styles: [ '.button { padding: 0 13px; }' ]
5769e1db
C
16})
17export class ConfirmComponent implements OnInit {
df98563e 18 @ViewChild('confirmModal') confirmModal: ModalDirective
5769e1db 19
df98563e
C
20 title = ''
21 message = ''
5769e1db
C
22
23 constructor (private confirmService: ConfirmService) {
24 // Empty
25 }
26
df98563e 27 ngOnInit () {
5769e1db
C
28 this.confirmModal.config = {
29 backdrop: 'static',
30 keyboard: false
df98563e 31 }
5769e1db
C
32
33 this.confirmService.showConfirm.subscribe(
34 ({ title, message }) => {
df98563e
C
35 this.title = title
36 this.message = message
5769e1db 37
df98563e 38 this.showModal()
5769e1db 39 }
df98563e 40 )
5769e1db
C
41 }
42
43 @HostListener('keydown.enter')
df98563e
C
44 confirm () {
45 this.confirmService.confirmResponse.next(true)
46 this.hideModal()
5769e1db
C
47 }
48
49 @HostListener('keydown.esc')
6599f096 50 cancel () {
df98563e
C
51 this.confirmService.confirmResponse.next(false)
52 this.hideModal()
5769e1db
C
53 }
54
df98563e
C
55 showModal () {
56 this.confirmModal.show()
5769e1db
C
57 }
58
df98563e
C
59 hideModal () {
60 this.confirmModal.hide()
5769e1db
C
61 }
62}