add a devInfo method to toaster service
This commit is contained in:
parent
fa80d067bd
commit
3b6406517a
@ -7,6 +7,7 @@ import { ActiveToast, ToastrService } from 'ngx-toastr';
|
||||
import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config';
|
||||
import { filter, tap } from 'rxjs/operators';
|
||||
import { ErrorMessageService } from './error-message.service';
|
||||
import { isIqserDevMode } from './iqser-user-preference.service';
|
||||
|
||||
const enum NotificationType {
|
||||
SUCCESS = 'SUCCESS',
|
||||
@ -26,6 +27,7 @@ export interface ToasterOptions extends IndividualConfig {
|
||||
*/
|
||||
readonly params?: Record<string, string | number>;
|
||||
readonly actions?: ToasterActions[];
|
||||
readonly useRaw?: boolean;
|
||||
}
|
||||
|
||||
export interface ErrorToasterOptions extends ToasterOptions {
|
||||
@ -35,10 +37,19 @@ export interface ErrorToasterOptions extends ToasterOptions {
|
||||
readonly error?: HttpErrorResponse;
|
||||
}
|
||||
|
||||
const defaultDevToastOptions: Partial<ToasterOptions> = {
|
||||
timeOut: 10000,
|
||||
easing: 'ease-in-out',
|
||||
easeTime: 500,
|
||||
useRaw: true,
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class Toaster {
|
||||
readonly #isIqserDevMode = isIqserDevMode();
|
||||
|
||||
constructor(
|
||||
router: Router,
|
||||
private readonly _toastr: ToastrService,
|
||||
@ -69,6 +80,14 @@ export class Toaster {
|
||||
return this._toastr.error(message, undefined, config);
|
||||
}
|
||||
|
||||
devInfo(message: string): ActiveToast<unknown> | undefined {
|
||||
if (!this.#isIqserDevMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.info(message, defaultDevToastOptions);
|
||||
}
|
||||
|
||||
info(message: string, options?: Partial<ToasterOptions>): ActiveToast<unknown> {
|
||||
return this.#showToastNotification(message, NotificationType.INFO, options);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user