tstor/assets/js/toasts.js
Antonio Navarro Perez ab7d379408
Improve info when config is reloaded. (#16)
- Using toasts as message outputs (still a lot of room for improvement)

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2020-11-09 11:33:19 +01:00

29 lines
533 B
JavaScript

function toast(msg, color, time) {
Toastify({
text: msg,
duration: time,
newWindow: true,
close: true,
gravity: "top",
position: "right",
backgroundColor: color,
stopOnFocus: true,
}).showToast();
}
function toastError(msg) {
toast(msg, "red", 5000);
}
function toastInfo(msg) {
toast(msg, "green", 5000);
}
function toastMessage(msg) {
toast(msg, "grey", 10000);
}
var stream = new EventSource("/api/events");
stream.addEventListener("event", function (e) {
toastMessage(e.data);
});