]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/core/confirm/confirm.service.ts
Merge branch 'release/3.2.0' into develop
[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()
22 .pipe(first())
23 .toPromise()
24 }
25
26 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
27 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
28
29 return this.confirmResponse.asObservable()
30 .pipe(first())
31 .toPromise()
32 }
33}