From e749bd08958a462f57b8492721a04128468656d0 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 5 Dec 2018 12:12:45 +0100 Subject: Get calibration to work with GUI --- python/gui/api.py | 3 +- python/gui/static/js/odr-predistortion.js | 30 ++++++++++--------- python/gui/static/js/odr.js | 48 ++++++++++++------------------- python/gui/templates/predistortion.html | 19 ++++-------- 4 files changed, 43 insertions(+), 57 deletions(-) (limited to 'python/gui') diff --git a/python/gui/api.py b/python/gui/api.py index 0d24bac..bff224e 100755 --- a/python/gui/api.py +++ b/python/gui/api.py @@ -134,5 +134,6 @@ class API: if cherrypy.request.method == 'POST': return self._wrap_dpd("calibrate") else: - return self._wrap_dpd("get_calibration_result") + cherrypy.response.status = 400 + return send_error("POST only") diff --git a/python/gui/static/js/odr-predistortion.js b/python/gui/static/js/odr-predistortion.js index b2f1d22..04d2773 100644 --- a/python/gui/static/js/odr-predistortion.js +++ b/python/gui/static/js/odr-predistortion.js @@ -20,7 +20,15 @@ function resultrefresh() { var jqxhr = doApiRequestGET("/api/dpd_results", function(data) { - $('#dpdresults').text(data['summary']); + var summary = ""; + console.log(data); + for (k in data['summary']) { + summary += data['summary'][k]; + summary += "
"; + } + $('#dpdresults').html(summary); + + $('#dpdstatus').text(data['state']); }); jqxhr.always(function() { @@ -30,6 +38,13 @@ function resultrefresh() { $(function(){ setTimeout(resultrefresh, 2000); + + $('#calibratebtn').click(function() { + doApiRequestPOST("/api/dpd_calibrate", {}, function(data) { + console.log("calibrate succeeded: " + JSON.stringify(data)); + }); + }); + }); /* @@ -47,7 +62,6 @@ function calibraterefresh() { } $(function(){ - $('#calibraterefreshbtn').click(calibraterefresh); $('#refreshframesbtn').click(function() { var d = new Date(); var n = d.getTime(); @@ -55,18 +69,6 @@ $(function(){ $('#rxframeimg').src = "dpd/rxframe.png?cachebreak=" + n; }); - $('#calibratebtn').click(function() { - doApiRequestPOST("/api/calibrate", {}, function(data) { - console.log("calibrate succeeded: " + JSON.stringify(data)); - - $('#calibrationresults').text("Processing..."); - - setTimeout(function() { - calibraterefresh(); - }, 3000); - }); - }); - $('#capturebutton').click(function() { doApiRequestPOST("/api/trigger_capture", {}, function(data) { console.log("trigger_capture succeeded: " + JSON.stringify(data)); diff --git a/python/gui/static/js/odr.js b/python/gui/static/js/odr.js index 0bf7729..50c321c 100644 --- a/python/gui/static/js/odr.js +++ b/python/gui/static/js/odr.js @@ -27,19 +27,14 @@ function doApiRequestGET(uri, callback) { dataType: 'json', error: function(data) { - if (data.status == 500) { - var errorWindow = window.open("", "_self"); - errorWindow.document.write(data.responseText); - } - else { - console.log(data.responseText); + console.log(data.responseText); - $.gritter.add({ title: 'API', - text: "AJAX failed: " + data.statusText, - image: '/fonts/warning.png', - sticky: true, - }); - } + $.gritter.add({ title: 'API', + text: "AJAX failed: " + data.statusText, + image: '/fonts/warning.png', + sticky: false, + time: 4000, + }); }, success: function(data) { if (data.status == 'ok') { @@ -50,7 +45,8 @@ function doApiRequestGET(uri, callback) { title: 'API', text: "API ERROR: " + data.reason, image: '/fonts/warning.png', - sticky: true, + sticky: false, + time: 4000, }); } } @@ -66,22 +62,15 @@ function doApiRequestPOST(uri, data, callback) { data: JSON.stringify(data), error: function(data) { - if (data.status == 500) { - var windowObjectReference; - var winFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes"; - var errorWindow = window.open("", "Error 500", winFeatures); - errorWindow.document.write(data.responseText); - } - else { - console.log(data.responseText); + console.log(data.responseText); - $.gritter.add({ - title: 'API', - text: "AJAX failed: " + data.statusText, - image: '/fonts/warning.png', - sticky: true, - }); - } + $.gritter.add({ + title: 'API', + text: "AJAX failed: " + data.statusText, + image: '/fonts/warning.png', + sticky: false, + time: 4000, + }); }, success: function(data_in) { @@ -93,7 +82,8 @@ function doApiRequestPOST(uri, data, callback) { title: 'API', text: "API ERROR: " + data_in.reason, image: '/fonts/warning.png', - sticky: true, + sticky: false, + time: 4000, }); } } diff --git a/python/gui/templates/predistortion.html b/python/gui/templates/predistortion.html index ac68537..cc5ecb0 100644 --- a/python/gui/templates/predistortion.html +++ b/python/gui/templates/predistortion.html @@ -29,27 +29,20 @@ along with ODR-DabMod. If not, see .
-
Status
+
Status and calibration
-
Current DPDCE status: -
N/A
+
Current DPDCE status: N/A +
N/A
-
-
-