new screens added for Plan, Db connections, and code refactor
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import Swal, { SweetAlertIcon, SweetAlertOptions } from 'sweetalert2';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationService {
|
||||
/**
|
||||
* Triggers a top-right SweetAlert notification programmatically.
|
||||
* Matches structure: position: 'top-end', showConfirmButton: false, timer: 1500
|
||||
*
|
||||
* @param message Dynamic message text to display
|
||||
* @param icon SweetAlert icon type ('success' | 'error' | 'warning' | 'info')
|
||||
* @param timer Notification display duration in ms (default 1500ms)
|
||||
*/
|
||||
notify(message: string, icon: SweetAlertIcon = 'success', timer = 1500): void {
|
||||
Swal.fire({
|
||||
position: 'top-end',
|
||||
icon: icon,
|
||||
title: message,
|
||||
showConfirmButton: false,
|
||||
timer: timer
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers top-right success notification
|
||||
*/
|
||||
success(message: string, timer = 1500): void {
|
||||
this.notify(message, 'success', timer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays Danger Sweetalert error modal centered on screen.
|
||||
* Matches template design: icon: 'error', title: 'Oops...', text: message & DangerSweetalert class
|
||||
*
|
||||
* @param message Dynamic error text
|
||||
* @param title Error title (defaults to 'Oops...')
|
||||
* @param footer Optional footer HTML link (defaults to null)
|
||||
*/
|
||||
error(
|
||||
message: string,
|
||||
title = 'Oops...',
|
||||
footer: string | null = null
|
||||
): void {
|
||||
Swal.fire({
|
||||
position: 'center',
|
||||
icon: 'error',
|
||||
title: title,
|
||||
text: message,
|
||||
...(footer ? { footer: footer } : {}),
|
||||
showConfirmButton: true,
|
||||
confirmButtonText: 'OK',
|
||||
customClass: {
|
||||
popup: 'DangerSweetalert'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers top-right warning notification
|
||||
*/
|
||||
warning(message: string, timer = 2500): void {
|
||||
this.notify(message, 'warning', timer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers top-right info notification
|
||||
*/
|
||||
info(message: string, timer = 2000): void {
|
||||
this.notify(message, 'info', timer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom SweetAlert call with top-right defaults preset
|
||||
*/
|
||||
custom(options: SweetAlertOptions): void {
|
||||
Swal.fire({
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 1500,
|
||||
...options
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user