mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-11 09:07:18 +01:00
toast changes
This commit is contained in:
parent
689b0db1a8
commit
a89eaafed7
6 changed files with 35 additions and 17 deletions
|
|
@ -1,20 +1,27 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Subject, zip } from 'rxjs';
|
||||
|
||||
export class Toast {
|
||||
|
||||
static make(title: string, content: string, delay?: number): Toast {
|
||||
static make(title: string, content: string, classname?: string, delay?: number): Toast {
|
||||
let t = new Toast()
|
||||
t.title = title
|
||||
t.content = content
|
||||
t.classname = classname
|
||||
if (delay) {
|
||||
t.delay = delay
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
static makeError(content: string) {
|
||||
return Toast.make("Error", content, null, 10000)
|
||||
}
|
||||
|
||||
title: string
|
||||
|
||||
classname: string
|
||||
|
||||
content: string
|
||||
|
||||
delay: number = 5000
|
||||
|
|
@ -30,23 +37,23 @@ export class ToastService {
|
|||
|
||||
private toasts: Toast[] = []
|
||||
|
||||
private toastSubject: Subject<Toast[]> = new Subject()
|
||||
private toastsSubject: Subject<Toast[]> = new Subject()
|
||||
|
||||
showToast(toast: Toast) {
|
||||
this.toasts.push(toast)
|
||||
this.toastSubject.next(this.toasts)
|
||||
this.toastsSubject.next(this.toasts)
|
||||
}
|
||||
|
||||
closeToast(toast: Toast) {
|
||||
let index = this.toasts.findIndex(t => t == toast)
|
||||
if (index > -1) {
|
||||
this.toasts.splice(index, 1)
|
||||
this.toastSubject.next(this.toasts)
|
||||
this.toastsSubject.next(this.toasts)
|
||||
}
|
||||
}
|
||||
|
||||
getToasts() {
|
||||
return this.toastSubject
|
||||
return this.toastsSubject
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue