gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant-frontends] branch master updated (7cc0dfa -


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant-frontends] branch master updated (7cc0dfa -> 7194d36)
Date: Wed, 01 Mar 2017 20:27:41 +0100

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

marcello pushed a change to branch master
in repository merchant-frontends.

    from 7cc0dfa  Merge branch 'master' of taler.net:merchant-frontends
     new d5de7cd  /backoffice endpoint donations.
     new 7194d36  Donations backoffice mostly done.

The 2 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:
 talerfrontends/blog/blog.py                        |  2 +-
 talerfrontends/blog/static/backoffice.js           | 48 +++++---------
 talerfrontends/blog/static/web-common              |  2 +-
 talerfrontends/blog/templates/backoffice.html      |  6 +-
 talerfrontends/blog/templates/base.html            |  2 +-
 talerfrontends/donations/donations.py              | 44 ++++++++++++-
 .../{blog => donations}/static/backoffice.js       | 75 +++++++++-------------
 .../{blog => donations}/static/popup.css           |  0
 talerfrontends/donations/static/web-common         |  2 +-
 .../{blog => donations}/templates/backoffice.html  |  6 +-
 talerfrontends/donations/templates/base.html       |  1 +
 11 files changed, 102 insertions(+), 86 deletions(-)
 copy talerfrontends/{blog => donations}/static/backoffice.js (79%)
 copy talerfrontends/{blog => donations}/static/popup.css (100%)
 copy talerfrontends/{blog => donations}/templates/backoffice.html (83%)

diff --git a/talerfrontends/blog/blog.py b/talerfrontends/blog/blog.py
index e7cd8a7..8a0e6c7 100644
--- a/talerfrontends/blog/blog.py
+++ b/talerfrontends/blog/blog.py
@@ -21,7 +21,7 @@ Implement URL handlers and payment logic for the blog 
merchant.
 """
 
 import flask
-from urllib.parse import urljoin, urlencode, quote, parse_qsl, urlsplit
+from urllib.parse import urljoin, urlencode, quote, parse_qsl
 import requests
 import logging
 import os
diff --git a/talerfrontends/blog/static/backoffice.js 
b/talerfrontends/blog/static/backoffice.js
index fe1e7e5..62686fe 100644
--- a/talerfrontends/blog/static/backoffice.js
+++ b/talerfrontends/blog/static/backoffice.js
@@ -120,16 +120,21 @@ function track_order(order_id, instance){
   req.send();
 }
 
+function xpath_get(xpath, ctx){
+  var ret = document.evaluate(xpath,
+                              ctx,
+                              null,
+                              XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
+                              null);
+  return ret.snapshotItem(0);
+}
+
 /**
  * Append results to the table showing results.
  */
 function fill_table(history){
   var table = document.getElementById("history");
-  var tbody = document.evaluate("tbody",
-                                table,
-                                null,
-                                XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
-                                null).snapshotItem(0);
+  var tbody = xpath_get("tbody", table);
   for (var i=0; i<history.length; i++){
     var entry = history[i];
     var row = document.createElement("tr");
@@ -156,12 +161,11 @@ function fill_table(history){
   window.setTimeout(remove_loader, 900);
 }
 
-function get_more_history(){
-  /*FIXME: do add one week to TIMESTAMP*/
-  START += 20;
-
+function get_history(scroll){
   var loader = document.getElementsByClassName("loader")[0]; 
   loader.style.visibility = "visible";
+  if(scroll)
+    START += 20;
   var req = new XMLHttpRequest();
   req.open("GET", 
`/history?timestamp=${TIMESTAMP}&instance=${INSTANCE}&start=${START}`, true);
   req.onload = function(){
@@ -180,27 +184,5 @@ function get_more_history(){
   req.send();
 }
 
-function get_history(){
-
-  var req = new XMLHttpRequest();
-  req.open("GET", `/history?timestamp=${TIMESTAMP}&instance=${INSTANCE}`, 
true);
-  req.onload = function(){
-    if(req.readyState == 4 && req.status == 200){
-      var history = JSON.parse(req.responseText); 
-      if(!history)
-        console.log("Got invalid JSON");
-      if(0 == history.length){
-        console.log("Got no transactions");
-        return;
-      }
-      fill_table(history);
-    }
-    else{
-      console.log("error: status != 200");
-    }
-  }
-  req.send();
-}
-
-document.addEventListener("DOMContentLoaded", get_history);
-document.addEventListener("scroll", get_more_history);
+document.addEventListener("DOMContentLoaded", () => get_history(false));
+document.addEventListener("scroll", () => get_history(true));
diff --git a/talerfrontends/blog/static/web-common 
b/talerfrontends/blog/static/web-common
index 0be9ac9..aae7c0a 160000
--- a/talerfrontends/blog/static/web-common
+++ b/talerfrontends/blog/static/web-common
@@ -1 +1 @@
-Subproject commit 0be9ac9264a3bd9f495c37abf1ac864562e8c598
+Subproject commit aae7c0a87a9ff1640c3cd72dd4df0ac590f8b0e4
diff --git a/talerfrontends/blog/templates/backoffice.html 
b/talerfrontends/blog/templates/backoffice.html
index c57e213..719d4b6 100644
--- a/talerfrontends/blog/templates/backoffice.html
+++ b/talerfrontends/blog/templates/backoffice.html
@@ -34,9 +34,13 @@
       </div>
     </div>
   </div>
-  <a href="#" onclick="get_more_history();" style="margin-left: 90%;">Fake 
scroll</a>
+  <a href="#" onclick="get_history(true);" style="margin-left: 90%;">Fake 
scroll</a>
 {% endblock main %}
 
+{% block styles %}
+  <link rel="stylesheet" type="text/css" href="{{ url("/static/popup.css") }}">
+{% endblock styles %}
+
 {% block scripts %}
   <script src="{{ url('/static/backoffice.js') }}" 
type="application/javascript"></script>
 {% endblock scripts %}
diff --git a/talerfrontends/blog/templates/base.html 
b/talerfrontends/blog/templates/base.html
index 140222a..d65d14b 100644
--- a/talerfrontends/blog/templates/base.html
+++ b/talerfrontends/blog/templates/base.html
@@ -20,10 +20,10 @@
   <link rel="stylesheet" type="text/css" href="{{ 
url("/static/web-common/style.css") }}">
   <link rel="stylesheet" type="text/css" href="{{ 
url("/static/web-common/lang.css") }}">
   <link rel="stylesheet" type="text/css" href="{{ 
url("/static/web-common/taler-fallback.css") }}" id="taler-presence-stylesheet">
-  <link rel="stylesheet" type="text/css" href="{{ url("/static/popup.css") }}">
   <script src="{{ url("/static/web-common/taler-wallet-lib.js") }}" 
type="application/javascript"></script>
   <script src="{{ url("/static/web-common/lang.js") }}" 
type="application/javascript"></script>
   <meta http-equiv="content-type" content="text/html;CHARSET=utf-8">
+  {% block styles %}{% endblock %}
   {% block scripts %}{% endblock %}
 </head>
 
diff --git a/talerfrontends/donations/donations.py 
b/talerfrontends/donations/donations.py
index 8a5affa..25e7c34 100644
--- a/talerfrontends/donations/donations.py
+++ b/talerfrontends/donations/donations.py
@@ -16,7 +16,7 @@
 # @author Marcello Stanisci
 
 import flask
-from urllib.parse import urljoin, urlencode, quote
+from urllib.parse import urljoin, urlencode, quote, parse_qsl
 import requests
 import logging
 import os
@@ -31,7 +31,7 @@ from talerfrontends.errors import BackendError
 from talerfrontends.helpers import (make_url,
 expect_parameter, amount_to_string,
 amount_from_float, amount_to_float,
-join_urlparts)
+join_urlparts, get_query_string)
 
 logger = logging.getLogger(__name__)
 
@@ -172,3 +172,43 @@ def pay():
     print("received payment for", order_id)
 
     return r.text, 200
+
address@hidden("/backoffice")
+def track():
+    response = 
flask.make_response(flask.render_template("templates/backoffice.html"))
+    return response
+
+
address@hidden("/history")
+def history():
+    # FIXME now JS needs to give a *timestamp*, NOT
+    # days anymore..
+    qs = get_query_string().decode("utf-8")
+    url = urljoin(BACKEND_URL, "history")
+    r = requests.get(url, params=dict(parse_qsl(qs)))
+    if r.status_code != 200:
+        logger.error("failed to GET to '%s'", url)
+        raise BackendError(r.status_code, r.text)
+    return r.text
+
address@hidden("/track/order")
+def track_order():
+
+    instance = expect_parameter("instance")
+    order_id = expect_parameter("order_id")
+
+    url = urljoin(BACKEND_URL, 'track/transaction')
+    r = requests.get(url, params=dict(order_id=order_id, instance=instance))
+
+    if r.status_code not in [200, 202, 424]:
+        logger.error("failed to GET to '%s'", url)
+        raise BackendError(r.status_code, r.text)
+    if 202 == r.status_code:
+        return flask.jsonify(r.json()), 202
+    if 404 == r.status_code:
+        raise CustomError(r.code, "Unknown order_id", s.status_code)
+    if 424 == r.status_code:
+        raise TrackTransactionConflictError(r.status_code, order_id, r.text)
+
+    return flask.jsonify(r.json())
+
diff --git a/talerfrontends/blog/static/backoffice.js 
b/talerfrontends/donations/static/backoffice.js
similarity index 79%
copy from talerfrontends/blog/static/backoffice.js
copy to talerfrontends/donations/static/backoffice.js
index fe1e7e5..f7a2003 100644
--- a/talerfrontends/blog/static/backoffice.js
+++ b/talerfrontends/donations/static/backoffice.js
@@ -30,7 +30,7 @@
 var FRACTION = 100000000;
 var TIMESTAMP = 0;
 var START = 0;
-var INSTANCE = "FSF";
+var INSTANCES = ["GNUnet", "Tor", "Taler"];
 
 function amount_to_string(amount){
   var number = Number(amount.value) + (Number(amount.fraction)/FRACTION);
@@ -71,6 +71,15 @@ function track_transfer(wtid){
   console.log("Tracking", wtid);
 }
 
+function xpath_get(xpath, ctx){
+  var ret = document.evaluate(xpath,
+                              ctx,
+                              null,
+                              XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
+                              null);
+  return ret.snapshotItem(0);
+}
+
 function track_order(order_id, instance){
   var req = new XMLHttpRequest();
   req.open("GET", `/track/order?order_id=${order_id}&instance=${instance}`, 
true);
@@ -88,11 +97,7 @@ function track_order(order_id, instance){
         var entry = tracks[i];
         var overlay = document.getElementsByClassName("overlay")[0];
         var track_content = 
document.getElementsByClassName("track-content")[0];
-        var table = document.evaluate("table/tbody",
-                                      track_content,
-                                      null,
-                                      XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
-                                      null).snapshotItem(0);
+        var table = xpath_get("table/tbody", track_content);
         toggle_visible(overlay);
         for(var j=0; j<entry.coins.length; j++){
           var coin = entry.coins[j];
@@ -156,51 +161,31 @@ function fill_table(history){
   window.setTimeout(remove_loader, 900);
 }
 
-function get_more_history(){
-  /*FIXME: do add one week to TIMESTAMP*/
-  START += 20;
-
+function get_history(scroll){
   var loader = document.getElementsByClassName("loader")[0]; 
   loader.style.visibility = "visible";
-  var req = new XMLHttpRequest();
-  req.open("GET", 
`/history?timestamp=${TIMESTAMP}&instance=${INSTANCE}&start=${START}`, true);
-  req.onload = function(){
-    if(req.readyState == 4 && req.status == 200){
-      var history = JSON.parse(req.responseText); 
-      if(!history){
-        console.log("Got invalid JSON");
-        return;
+  if(scroll)
+    START +=20;
+  var req = new Array(3);
+  for(var i=0; i<INSTANCES.length; i++){
+    req[i] = new XMLHttpRequest();
+    req[i].open("GET", 
`/history?timestamp=${TIMESTAMP}&instance=${INSTANCES[i]}&start=${START}`, 
true);
+    req[i].onload = function(){
+      if(this.readyState == 4 && this.status == 200){
+        var history = JSON.parse(this.responseText); 
+        if(!history){
+          console.log("Got invalid JSON");
+          return;
+        }
+        fill_table(history);
       }
-      fill_table(history);
-    }
-    else{
-      console.log("error: status != 200");
-    }
-  }
-  req.send();
-}
-
-function get_history(){
-
-  var req = new XMLHttpRequest();
-  req.open("GET", `/history?timestamp=${TIMESTAMP}&instance=${INSTANCE}`, 
true);
-  req.onload = function(){
-    if(req.readyState == 4 && req.status == 200){
-      var history = JSON.parse(req.responseText); 
-      if(!history)
-        console.log("Got invalid JSON");
-      if(0 == history.length){
-        console.log("Got no transactions");
-        return;
+      else{
+        console.log("error: status != 200");
       }
-      fill_table(history);
-    }
-    else{
-      console.log("error: status != 200");
     }
+    req[i].send();
   }
-  req.send();
 }
 
 document.addEventListener("DOMContentLoaded", get_history);
-document.addEventListener("scroll", get_more_history);
+document.addEventListener("scroll", () => get_history(true));
diff --git a/talerfrontends/blog/static/popup.css 
b/talerfrontends/donations/static/popup.css
similarity index 100%
copy from talerfrontends/blog/static/popup.css
copy to talerfrontends/donations/static/popup.css
diff --git a/talerfrontends/donations/static/web-common 
b/talerfrontends/donations/static/web-common
index 0be9ac9..aae7c0a 160000
--- a/talerfrontends/donations/static/web-common
+++ b/talerfrontends/donations/static/web-common
@@ -1 +1 @@
-Subproject commit 0be9ac9264a3bd9f495c37abf1ac864562e8c598
+Subproject commit aae7c0a87a9ff1640c3cd72dd4df0ac590f8b0e4
diff --git a/talerfrontends/blog/templates/backoffice.html 
b/talerfrontends/donations/templates/backoffice.html
similarity index 83%
copy from talerfrontends/blog/templates/backoffice.html
copy to talerfrontends/donations/templates/backoffice.html
index c57e213..719d4b6 100644
--- a/talerfrontends/blog/templates/backoffice.html
+++ b/talerfrontends/donations/templates/backoffice.html
@@ -34,9 +34,13 @@
       </div>
     </div>
   </div>
-  <a href="#" onclick="get_more_history();" style="margin-left: 90%;">Fake 
scroll</a>
+  <a href="#" onclick="get_history(true);" style="margin-left: 90%;">Fake 
scroll</a>
 {% endblock main %}
 
+{% block styles %}
+  <link rel="stylesheet" type="text/css" href="{{ url("/static/popup.css") }}">
+{% endblock styles %}
+
 {% block scripts %}
   <script src="{{ url('/static/backoffice.js') }}" 
type="application/javascript"></script>
 {% endblock scripts %}
diff --git a/talerfrontends/donations/templates/base.html 
b/talerfrontends/donations/templates/base.html
index 32dbad7..0d02b11 100644
--- a/talerfrontends/donations/templates/base.html
+++ b/talerfrontends/donations/templates/base.html
@@ -22,6 +22,7 @@
   <link rel="stylesheet" type="text/css" href="{{ 
url("/static/web-common/lang.css") }}">
   <script src="{{ url("/static/web-common/taler-wallet-lib.js") }}" 
type="application/javascript"></script>
   <script src="{{ url("/static/web-common/lang.js") }}" 
type="application/javascript"></script>
+  {% block styles %}{% endblock %}
   {% block scripts %}{% endblock %}
 </head>
 

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



reply via email to

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