From 75ba4f064a65ebad77d130f160b9469418e49c9f Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 9 Jan 2019 12:21:21 +0100 Subject: GUI: Add ability to restore previous DPD settings --- python/gui/api.py | 18 ++++-- python/gui/static/js/odr-predistortion.js | 98 ++++++++++++------------------- python/gui/templates/predistortion.html | 23 +++++++- 3 files changed, 70 insertions(+), 69 deletions(-) (limited to 'python/gui') diff --git a/python/gui/api.py b/python/gui/api.py index 42c89c9..c0effde 100755 --- a/python/gui/api.py +++ b/python/gui/api.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2018 +# Copyright (C) 2019 # Matthias P. Braendli, matthias.braendli@mpb.li # # http://www.opendigitalradio.org @@ -125,12 +125,20 @@ class API: @cherrypy.expose @cherrypy.tools.json_out() - def dpd_settings(self, setting: str, value: str, **kwargs): + def dpd_restore_dump(self, **kwargs): if cherrypy.request.method == 'POST': - data = {'setting': setting, 'value': value} - return self._wrap_dpd("set_setting", data) + cl = cherrypy.request.headers['Content-Length'] + rawbody = cherrypy.request.body.read(int(cl)) + params = json.loads(rawbody.decode()) + if 'dump_id' in params: + data = {'dump_id': params['dump_id']} + return self._wrap_dpd("restore_dump", data) + else: + cherrypy.response.status = 400 + return send_error("Missing dump_id") else: - return self._wrap_dpd("get_settings") + cherrypy.response.status = 400 + return send_error("POST only") @cherrypy.expose @cherrypy.tools.json_out() diff --git a/python/gui/static/js/odr-predistortion.js b/python/gui/static/js/odr-predistortion.js index b5f29ea..4dae068 100644 --- a/python/gui/static/js/odr-predistortion.js +++ b/python/gui/static/js/odr-predistortion.js @@ -1,4 +1,4 @@ -// Copyright (C) 2018 +// Copyright (C) 2019 // Matthias P. Braendli, matthias.braendli@mpb.li // // http://www.opendigitalradio.org @@ -18,6 +18,8 @@ // You should have received a copy of the GNU General Public License // along with ODR-DabMod. If not, see . +var adapt_dumps = []; + function resultrefresh() { var jqxhr = doApiRequestGET("/api/dpd_results", function(data) { var summary = ""; @@ -51,6 +53,8 @@ function resultrefresh() { else { $('#dpdmodelplot').attr('src', ""); } + + adapt_dumps = data['adapt_dumps']; }); jqxhr.always(function() { @@ -58,6 +62,30 @@ function resultrefresh() { }); } +function adaptdumpsrefresh() { + $('#dpdadaptdumps').html(""); + + $.each(adapt_dumps, function(i, item) { + console.log(item); + + if (isNaN(+item)) { + $('#dpdadaptdumps').append($('