summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-06-04 13:46:44 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-06-04 13:46:44 +0200
commitacea63b5d53594fc7672931f5894d93fbd2d9a14 (patch)
tree198376769a5ab968e62fed714a65cf7511709ad4
parentc86b0011ca3e9e8cc3f55f11ccf661e755688c6e (diff)
downloadbackoffice-acea63b5d53594fc7672931f5894d93fbd2d9a14.tar.gz
backoffice-acea63b5d53594fc7672931f5894d93fbd2d9a14.tar.bz2
backoffice-acea63b5d53594fc7672931f5894d93fbd2d9a14.zip
make use of red info bar for errors.
-rw-r--r--js/backoffice.js39
-rw-r--r--talerbackoffice/backoffice/templates/backoffice.html4
2 files changed, 42 insertions, 1 deletions
diff --git a/js/backoffice.js b/js/backoffice.js
index 8d680fa..c2fe86b 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -161,6 +161,39 @@ var track_transfer = function(exchange, wtid, cb){
req.send();
}
+
+/* Fill the information bar on the top of the page with
+ * error messages. */
+var show_error = function(response_text){
+
+ console.log("Filling info bar");
+ var msg;
+ try{
+ var parse = JSON.parse(response_text);
+ console.log("Response was at least JSON");
+ if (parse['error'])
+ msg = parse['error'];
+
+ /* Give precedence to 'hint' as it is usually
+ * human-friendlier */
+ if (parse['hint'])
+ msg = parse['hint'];
+
+ } catch (e) {
+ console.log("Must keep raw HTML-ish response");
+ msg = response_text;
+ }
+
+ /* msg is ready here. */
+
+ /* Get hold of the info bar. */
+ var info_bar = document.getElementById("information-bar");
+ info_bar.innerHTML = `<p>${msg}</p>`;
+ info_bar.style.visibility = "";
+
+ /* Info bar will disappear at next page load/reload. */
+}
+
/**
* Call /track/order API offered by the frontend. Once data
* arrives it calls a UI routine which fills the "entries table"
@@ -174,7 +207,11 @@ var track_order = function(order_id, cb){
req.open("GET", url, true);
req.onload = function(){
if (4 == req.readyState){
- cb(JSON.parse(req.responseText), req.status);
+ if ((200 == req.status) || (202 == req.status))
+ cb(JSON.parse(req.responseText), req.status);
+ else
+ console.log("Calling info bar filler");
+ show_error(req.responseText);
return;
}
}
diff --git a/talerbackoffice/backoffice/templates/backoffice.html b/talerbackoffice/backoffice/templates/backoffice.html
index 6c4a21e..363f467 100644
--- a/talerbackoffice/backoffice/templates/backoffice.html
+++ b/talerbackoffice/backoffice/templates/backoffice.html
@@ -13,6 +13,10 @@
</select>
</div>
+ <div id="information-bar"
+ stlye="visibility: hidden;">
+ </div>
+
<div>
<form action="">
<input type="text"