]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - 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
1import { Injectable } from '@angular/core'
2import { Subject } from 'rxjs/Subject'
3import 'rxjs/add/operator/first'
4import 'rxjs/add/operator/toPromise'
5
6type ConfirmOptions = {
7 title: string
8 message: string
9 inputLabel?: string
10 expectedInputValue?: string
11 confirmButtonText?: string
12}
13
14@Injectable()
15export class ConfirmService {
16 showConfirm = new Subject<ConfirmOptions>()
17 confirmResponse = new Subject<boolean>()
18
19 confirm (message: string, title = '', confirmButtonText?: string) {
20 this.showConfirm.next({ title, message, confirmButtonText })
21
22 return this.confirmResponse.asObservable().first().toPromise()
23 }
24
25 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
26 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
27
28 return this.confirmResponse.asObservable().first().toPromise()
29 }
30}