2020-11-09 10:33:19 +00:00
|
|
|
function toast(msg, color, time) {
|
|
|
|
Toastify({
|
|
|
|
text: msg,
|
|
|
|
duration: time,
|
|
|
|
newWindow: true,
|
|
|
|
close: true,
|
|
|
|
gravity: "top",
|
|
|
|
position: "right",
|
|
|
|
backgroundColor: color,
|
|
|
|
stopOnFocus: true,
|
|
|
|
}).showToast();
|
|
|
|
}
|
|
|
|
|
2020-11-08 17:19:25 +00:00
|
|
|
function toastError(msg) {
|
2020-11-09 10:33:19 +00:00
|
|
|
toast(msg, "red", 5000);
|
2020-11-08 17:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toastInfo(msg) {
|
2020-11-09 10:33:19 +00:00
|
|
|
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);
|
|
|
|
});
|