]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/confirm/confirm.service.ts
Bumped to version v0.0.29-alpha
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.service.ts
CommitLineData
df98563e
C
1import { Injectable } from '@angular/core'
2import { Subject } from 'rxjs/Subject'
3import 'rxjs/add/operator/first'
1f30a185 4import 'rxjs/add/operator/toPromise'
5769e1db
C
5
6@Injectable()
7export class ConfirmService {
1f30a185 8 showConfirm = new Subject<{ title: string, message: string, inputLabel?: string, expectedInputValue?: string }>()
df98563e 9 confirmResponse = new Subject<boolean>()
5769e1db 10
1f30a185 11 confirm (message: string, title = '') {
df98563e 12 this.showConfirm.next({ title, message })
5769e1db 13
1f30a185
C
14 return this.confirmResponse.asObservable().first().toPromise()
15 }
16
17 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '') {
18 this.showConfirm.next({ title, message, inputLabel, expectedInputValue })
19
20 return this.confirmResponse.asObservable().first().toPromise()
5769e1db
C
21 }
22}