summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-01-06 00:27:47 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2018-01-06 00:27:47 +0100
commit5b5173da54e4a9f98e4fb76055a37a9034a2b4cf (patch)
treebe8cef42f7f5ed22e8f06020178a4a4a62c2bb25
parent3459dcf8c3373ee9c409975a66507afcd9755afa (diff)
downloadbackoffice-5b5173da54e4a9f98e4fb76055a37a9034a2b4cf.tar.gz
backoffice-5b5173da54e4a9f98e4fb76055a37a9034a2b4cf.tar.bz2
backoffice-5b5173da54e4a9f98e4fb76055a37a9034a2b4cf.zip
fix switching between instances
-rw-r--r--talerbackoffice/backoffice/static/backoffice.js45
-rw-r--r--talerbackoffice/backoffice/templates/base.html4
2 files changed, 29 insertions, 20 deletions
diff --git a/talerbackoffice/backoffice/static/backoffice.js b/talerbackoffice/backoffice/static/backoffice.js
index 43ae9a2..5f37ab3 100644
--- a/talerbackoffice/backoffice/static/backoffice.js
+++ b/talerbackoffice/backoffice/static/backoffice.js
@@ -117,12 +117,7 @@ function track_transfer(exchange, wtid){
switch(req.status){
case 200:
var tracks = JSON.parse(req.responseText);
- var table = document.getElementById("history");
- var tbody = xpath_get("tbody", table).snapshotItem(0);
- var tbody_children = xpath_get("tbody/*[position() > 1]", table);
- for(var i=0; i<tbody_children.snapshotLength; i++){
- tbody.removeChild(tbody_children.snapshotItem(i));
- }
+ clean_results();
close_popup();
fill_table(tracks.deposits_sums, tracks.execution_time);
@@ -143,9 +138,9 @@ function track_transfer(exchange, wtid){
req.send();
}
-function track_order(order_id, instance){
+function track_order(order_id){
var req = new XMLHttpRequest();
- req.open("GET", `/track/order?order_id=${order_id}&instance=${instance}`, true);
+ req.open("GET", `/track/order?order_id=${order_id}&instance=${INSTANCE}`, true);
req.onload = function(){
if (4 == req.readyState){
if(200 == req.status){
@@ -209,16 +204,18 @@ function xpath_get(xpath, ctx){
function fill_table(history, execution_time){
var table = document.getElementById("history");
var tbody = xpath_get("tbody", table).snapshotItem(0);
-
+ var nr = xpath_get("tr[@class='no-records']", tbody).snapshotItem(0)
if(0 == history.length){
+ nr.style.display = "block";
+ xpath_get("tr[@class='headers']", tbody).snapshotItem(0).style.visibility = "hidden";
window.setTimeout(remove_loader, 900);
+ console.log("Nothing gotten!");
return;
}
- /* remove "no records" message */
- var nr = xpath_get("tr[@class='no-records']", tbody).snapshotItem(0)
- if (nr)
- tbody.removeChild(nr);
+ /* hide "no records" message */
+ nr.style.display = "none";
+
/* Make table's header visible */
xpath_get("tr[@class='headers']", tbody).snapshotItem(0).style.visibility = "";
@@ -237,7 +234,7 @@ function fill_table(history, execution_time){
td_amount.className = "amount";
var td_date = document.createElement("td");
td_date.className = "date";
- td_order_id.innerHTML = `<a href="#${i}" onclick='track_order("${entry.order_id}", "FSF");'>${entry.order_id}</a>`;
+ td_order_id.innerHTML = `<a href="#${i}" onclick='track_order("${entry.order_id}");'>${entry.order_id}</a>`;
td_summary.className = "summary";
td_summary.innerHTML = entry.summary;
td_amount.innerHTML = amount_to_string(entry.amount || entry.deposit_value);
@@ -270,7 +267,7 @@ function track_cherry_pick(form){
var type = types.snapshotItem(i).value;
if ("order" == type){
var order_id = xpath_get("input[@class='order']", form).snapshotItem(0);
- track_order(order_id.value, INSTANCE);
+ track_order(order_id.value);
}
else{
var data = xpath_get("input[@class='transfer']", form);
@@ -315,17 +312,29 @@ function get_instance(){
}
/**
+ * Remove tracks from the main page table.
+ */
+function clean_results(){
+ var table = document.getElementById("history");
+ var tbody = xpath_get("tbody", table).snapshotItem(0);
+ var tbody_children = xpath_get("tbody/*[position() > 2]", table);
+ for(var i=0; i<tbody_children.snapshotLength; i++){
+ tbody.removeChild(tbody_children.snapshotItem(i));
+ }
+}
+/**
* Nullify curreny instance and triggers history for newly
* selected one.
*/
function change_instance(){
INSTANCE = null;
+ clean_results();
get_history();
}
/**
- * - scroll if true, the logic tries to retrieve the
- * "next page" of all the proposals known to the merchant.
+ * scroll if true, the logic tries to retrieve the
+ * "next page" of all the proposals known to the merchant.
*/
function get_history(scroll){
if (!INSTANCE)
@@ -349,7 +358,7 @@ function get_history(scroll){
return;
}
if(0 < history.length){
- console.log(req.respnseText);
+ console.log(history);
LAST = history[history.length - 1].row_id;
}
fill_table(history);
diff --git a/talerbackoffice/backoffice/templates/base.html b/talerbackoffice/backoffice/templates/base.html
index 755e72f..4ecd543 100644
--- a/talerbackoffice/backoffice/templates/base.html
+++ b/talerbackoffice/backoffice/templates/base.html
@@ -17,7 +17,7 @@
<html data-taler-nojs="true">
<head>
- <title>Taler Donation Demo</title>
+ <title>Taler Back-office interface</title>
<link rel="stylesheet" type="text/css" href="{{ url('/static/web-common/pure.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url('/static/web-common/demo.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url('/static/web-common/taler-fallback.css') }}" id="taler-presence-stylesheet" />
@@ -30,7 +30,7 @@
<body>
<div class="demobar">
<h1><span class="tt adorn-brackets">Taler Demo</span></h1>
- <h1><span class="it"><a href="{{ env('TALER_ENV_URL_MERCHANT_BLOG') }}">Shop</a></span></h1>
+ <h1><span class="it"><a href="/">Backoffice</a></span></h1>
<p>This is the Essay shop, you can buy articles using an imaginary currency (for now).</p>
<ul>
<li><a href="{{ env('TALER_ENV_URL_INTRO', '#') }}">Introduction</a></li>