mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-10 16:46:50 +01:00
added paperless ui
This commit is contained in:
parent
d5a1a4916e
commit
131533d9eb
173 changed files with 18693 additions and 0 deletions
52
src-ui/src/app/services/toast.service.ts
Normal file
52
src-ui/src/app/services/toast.service.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
export class Toast {
|
||||
|
||||
static make(title: string, content: string, delay?: number): Toast {
|
||||
let t = new Toast()
|
||||
t.title = title
|
||||
t.content = content
|
||||
if (delay) {
|
||||
t.delay = delay
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
title: string
|
||||
|
||||
content: string
|
||||
|
||||
delay: number = 5000
|
||||
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ToastService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
private toasts: Toast[] = []
|
||||
|
||||
private toastSubject: Subject<Toast[]> = new Subject()
|
||||
|
||||
showToast(toast: Toast) {
|
||||
this.toasts.push(toast)
|
||||
this.toastSubject.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)
|
||||
}
|
||||
}
|
||||
|
||||
getToasts() {
|
||||
return this.toastSubject
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue