]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/confirm/confirm.service.ts
Translated using Weblate (German)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.service.ts
CommitLineData
1378c0d3 1import { firstValueFrom, Subject } from 'rxjs'
df98563e 2import { Injectable } from '@angular/core'
5769e1db 3
22b59e80
C
4type ConfirmOptions = {
5 title: string
6 message: string
7 inputLabel?: string
8 expectedInputValue?: string
9 confirmButtonText?: string
10}
11
5769e1db
C
12@Injectable()
13export class ConfirmService {
22b59e80 14 showConfirm = new Subject<ConfirmOptions>()
df98563e 15 confirmResponse = new Subject<boolean>()
5769e1db 16
22b59e80
C
17 confirm (message: string, title = '', confirmButtonText?: string) {
18 this.showConfirm.next({ title, message, confirmButtonText })
5769e1db 19
1378c0d3 20 return firstValueFrom(this.confirmResponse.asObservable())
1f30a185
C
21 }
22
22b59e80
C
23 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
24 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
1f30a185 25
1378c0d3 26 return firstValueFrom(this.confirmResponse.asObservable())
5769e1db
C
27 }
28}