]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/confirm/confirm.service.ts
Upgrade Angular first step
[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 5
22b59e80
C
6type ConfirmOptions = {
7 title: string
8 message: string
9 inputLabel?: string
10 expectedInputValue?: string
11 confirmButtonText?: string
12}
13
5769e1db
C
14@Injectable()
15export class ConfirmService {
22b59e80 16 showConfirm = new Subject<ConfirmOptions>()
df98563e 17 confirmResponse = new Subject<boolean>()
5769e1db 18
22b59e80
C
19 confirm (message: string, title = '', confirmButtonText?: string) {
20 this.showConfirm.next({ title, message, confirmButtonText })
5769e1db 21
1f30a185
C
22 return this.confirmResponse.asObservable().first().toPromise()
23 }
24
22b59e80
C
25 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
26 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
1f30a185
C
27
28 return this.confirmResponse.asObservable().first().toPromise()
5769e1db
C
29 }
30}