]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/core/confirm/confirm.service.ts
Add messages about privacy concerns (P2P)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.service.ts
1 import { Injectable } from '@angular/core'
2 import { Subject } from 'rxjs/Subject'
3 import 'rxjs/add/operator/first'
4 import 'rxjs/add/operator/toPromise'
5
6 type ConfirmOptions = {
7 title: string
8 message: string
9 inputLabel?: string
10 expectedInputValue?: string
11 confirmButtonText?: string
12 }
13
14 @Injectable()
15 export 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 }