gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-backoffice] branch master updated (c86b001 -> 7a7c67


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated (c86b001 -> 7a7c675)
Date: Mon, 04 Jun 2018 14:40:34 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository backoffice.

    from c86b001  fix hole in the documentation.
     new acea63b  make use of red info bar for errors.
     new bb7f175  Track transfer also calls the info bar filler function
     new 7a7c675  info bar gets red.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 js/backoffice.js                                   | 44 +++++++++++++++++++---
 talerbackoffice/backoffice/static/backoffice.css   |  7 ++++
 .../backoffice/templates/backoffice.html           |  5 +++
 3 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/js/backoffice.js b/js/backoffice.js
index 8d680fa..4af24dd 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -150,17 +150,47 @@ var track_transfer = function(exchange, wtid, cb){
         var tracks = JSON.parse(req.responseText);
         cb(true, tracks.deposits_sums, tracks.execution_time, wtid);
         break;
-      case 400:
-        console.log("Bad request, check submitted data!");
-        break;
       default:
-        console.log(`Status: ${req.status}, not handled.`);
+        show_error(req.responseText);
       }
     }
   }
   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 = "visible"; 
+
+  /* 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 +204,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/static/backoffice.css 
b/talerbackoffice/backoffice/static/backoffice.css
index 1278d04..910e6b9 100644
--- a/talerbackoffice/backoffice/static/backoffice.css
+++ b/talerbackoffice/backoffice/static/backoffice.css
@@ -11,6 +11,13 @@
   z-index: 2;
 }
 
+#information-bar {
+  border-radius: 8px;
+  padding: 1px;
+  background: #ff8566;
+  visibility: hidden;
+}
+
 #history-container {
   margin-bottom: 10cm;
 }
diff --git a/talerbackoffice/backoffice/templates/backoffice.html 
b/talerbackoffice/backoffice/templates/backoffice.html
index 6c4a21e..72ab74e 100644
--- a/talerbackoffice/backoffice/templates/backoffice.html
+++ b/talerbackoffice/backoffice/templates/backoffice.html
@@ -5,6 +5,11 @@
   the user can see the money flow from Taler transactions to
   wire transfers and viceversa.</p>
 
+  <div id="information-bar">
+    <!-- programmatically filled.  -->
+  </div>
+
+  <br />
   <div>
     <select id="instance" onchange="change_instance();">
       {% for instance in instances %}

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]