]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/core/confirm/confirm.service.ts
Merge pull request #1105 from BO41/unused-imports
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.service.ts
... / ...
CommitLineData
1import { first } from 'rxjs/operators'
2import { Injectable } from '@angular/core'
3import { Subject } from 'rxjs'
4
5type ConfirmOptions = {
6 title: string
7 message: string
8 inputLabel?: string
9 expectedInputValue?: string
10 confirmButtonText?: string
11}
12
13@Injectable()
14export class ConfirmService {
15 showConfirm = new Subject<ConfirmOptions>()
16 confirmResponse = new Subject<boolean>()
17
18 confirm (message: string, title = '', confirmButtonText?: string) {
19 this.showConfirm.next({ title, message, confirmButtonText })
20
21 return this.confirmResponse.asObservable().pipe(first()).toPromise()
22 }
23
24 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
25 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
26
27 return this.confirmResponse.asObservable().pipe(first()).toPromise()
28 }
29}