first commit

This commit is contained in:
JLEROY
2025-06-24 10:55:12 +02:00
commit 5da61af76e
13 changed files with 263 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { Alert } from '../models/alert';
type AlertParams = Partial<Omit<Alert, 'resolve'>>;
@Injectable({ providedIn: 'root' })
export class AlertService {
private alertSubject = new Subject<Alert>();
alerts() {
return this.alertSubject.asObservable();
}
confirm({
type = 'question',
title = 'Êtes-vous sûr ?',
text = 'Cette action est irréversible.',
confirmText = 'Confirmer',
cancelText = 'Annuler',
timeout,
backdropOpacity = 0.1,
}: AlertParams): Promise<boolean> {
return new Promise((resolve) => {
this.alertSubject.next({
type,
title,
text,
confirmText,
cancelText,
timeout,
backdropOpacity,
resolve,
});
});
}
}