]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Notify user on module loading failure 2483/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Tue, 11 Sep 2018 17:31:27 +0000 (20:31 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Tue, 11 Sep 2018 17:31:27 +0000 (20:31 +0300)
interface/css/rspamd.css
interface/js/main.js

index 0628a25bc8ec9820431acfb6e7dad060b4aca1f8..14bb4e6693e536c6faccbd18fcbf846b6d64d869 100644 (file)
@@ -526,6 +526,10 @@ td.maps-cell {
 }
 
 /* Some spacing tweaks */
+.notification-area div > button:not(.close) {
+       margin-right: 9px;
+}
+
 #learning p > button {
     margin-top: 10px;
     }
index 5ed33137d784396c21ad60d93608ec090e7c5819..db9c52942a0506919428f74f9847134aaf42b4c6 100644 (file)
@@ -32,6 +32,21 @@ define("d3.global", ["d3"], function (d3global) { // eslint-disable-line strict
     d3 = d3global;
 });
 
+// Notify user on module loading failure
+requirejs.onError = function (e) {
+    "use strict";
+    document.getElementsByClassName("notification-area")[0].innerHTML =
+        "<div class=\"alert alert-error\">" +
+            "<strong>Module loading error: " + e.requireType + ", module: " + e.requireModules + "</strong>" +
+            "<button type=\"button\" class=\"btn btn-info btn-xs pull-right\" " +
+                "onClick=\"window.location.reload(); this.parentNode.parentNode.removeChild(this.parentNode);\" " +
+                "title=\"Reload current page\">" +
+                "<i class=\"glyphicon glyphicon-repeat\"></i> Reload" +
+            "</button>" +
+        "</div>";
+    throw e;
+};
+
 // Load main UI
 require(["app/rspamd"],
     function (rspamd) {