|
|
|
@ -1,6 +1,7 @@ |
|
|
|
import { MessageService } from 'primeng/components/common/messageservice'; |
|
|
|
import { Observable, Subject } from 'rxjs'; |
|
|
|
import { Toaster } from '../models/toaster'; |
|
|
|
import { Config } from '@abp/ng.core'; |
|
|
|
|
|
|
|
export abstract class AbstractToaster<T = Toaster.Options> { |
|
|
|
status$: Subject<Toaster.Status>; |
|
|
|
@ -11,23 +12,28 @@ export abstract class AbstractToaster<T = Toaster.Options> { |
|
|
|
|
|
|
|
constructor(protected messageService: MessageService) {} |
|
|
|
|
|
|
|
info(message: string, title: string, options?: T): Observable<Toaster.Status> { |
|
|
|
info(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> { |
|
|
|
return this.show(message, title, 'info', options); |
|
|
|
} |
|
|
|
|
|
|
|
success(message: string, title: string, options?: T): Observable<Toaster.Status> { |
|
|
|
success(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> { |
|
|
|
return this.show(message, title, 'success', options); |
|
|
|
} |
|
|
|
|
|
|
|
warn(message: string, title: string, options?: T): Observable<Toaster.Status> { |
|
|
|
warn(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> { |
|
|
|
return this.show(message, title, 'warn', options); |
|
|
|
} |
|
|
|
|
|
|
|
error(message: string, title: string, options?: T): Observable<Toaster.Status> { |
|
|
|
error(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> { |
|
|
|
return this.show(message, title, 'error', options); |
|
|
|
} |
|
|
|
|
|
|
|
protected show(message: string, title: string, severity: Toaster.Severity, options?: T): Observable<Toaster.Status> { |
|
|
|
protected show( |
|
|
|
message: Config.LocalizationParam, |
|
|
|
title: Config.LocalizationParam, |
|
|
|
severity: Toaster.Severity, |
|
|
|
options?: T, |
|
|
|
): Observable<Toaster.Status> { |
|
|
|
this.messageService.clear(this.key); |
|
|
|
|
|
|
|
this.messageService.add({ |
|
|
|
@ -36,7 +42,7 @@ export abstract class AbstractToaster<T = Toaster.Options> { |
|
|
|
summary: title || '', |
|
|
|
...options, |
|
|
|
key: this.key, |
|
|
|
...(typeof (options || ({} as any)).sticky === 'undefined' && { sticky: this.sticky }) |
|
|
|
...(typeof (options || ({} as any)).sticky === 'undefined' && { sticky: this.sticky }), |
|
|
|
}); |
|
|
|
this.status$ = new Subject<Toaster.Status>(); |
|
|
|
return this.status$; |
|
|
|
|