diff --git a/InvenTree/static/script/notification.js b/InvenTree/static/script/notification.js index 58f1bfa3a1..8e45434bff 100644 --- a/InvenTree/static/script/notification.js +++ b/InvenTree/static/script/notification.js @@ -5,4 +5,33 @@ function showAlert(target, message, timeout=5000) { $(target).delay(timeout).slideUp(200, function() { $(this).alert(close); }); +} + +function showCachedAlerts() { + + // Success Message + if (sessionStorage.getItem("alert-success")) { + showAlert("#alert-success", sessionStorage.getItem("alert-success")); + sessionStorage.removeItem("alert-success"); + } + + // Info Message + if (sessionStorage.getItem("alert-info")) { + showAlert("#alert-info", sessionStorage.getItem("alert-info")); + sessionStorage.removeItem("alert-info"); + } + + // Warning Message + if (sessionStorage.getItem("alert-warning")) { + showAlert("#alert-warning", sessionStorage.getItem("alert-warning")); + sessionStorage.removeItem("alert-warning"); + } + + // Danger Message + if (sessionStorage.getItem("alert-danger")) { + showAlert("#alert-danger", sessionStorage.getItem("alert-danger")); + sessionStorage.removeItem("alert-danger"); + } + + sessionStorage.setItem("alert-danger", 'test'); } \ No newline at end of file diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 5681010605..2e80c8bcd6 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -76,6 +76,8 @@ $(document).ready(function () { {% endblock %} + showCachedAlerts(); + }); diff --git a/InvenTree/templates/notification.html b/InvenTree/templates/notification.html index 2b91006404..4ed2864e0a 100644 --- a/InvenTree/templates/notification.html +++ b/InvenTree/templates/notification.html @@ -1,3 +1,4 @@ +
\ No newline at end of file