diff --git a/src/lib/services/toaster.service.ts b/src/lib/services/toaster.service.ts index bd22d05..138add1 100644 --- a/src/lib/services/toaster.service.ts +++ b/src/lib/services/toaster.service.ts @@ -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; 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 = { + 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 | undefined { + if (!this.#isIqserDevMode) { + return; + } + + return this.info(message, defaultDevToastOptions); + } + info(message: string, options?: Partial): ActiveToast { return this.#showToastNotification(message, NotificationType.INFO, options); }