From 594cb2691debaa7562fd7d76d3b224701ec087ea Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 3 Dec 2018 16:39:31 +0100 Subject: GUI: a few fixes, sort rc entries --- gui/api/__init__.py | 3 ++- gui/configuration.py | 2 +- gui/static/js/odr-rcvalues.js | 20 +++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gui/api/__init__.py b/gui/api/__init__.py index 70a4eff..77faa10 100755 --- a/gui/api/__init__.py +++ b/gui/api/__init__.py @@ -23,6 +23,7 @@ import cherrypy from cherrypy.lib.httputil import parse_query_string +import json import urllib import os @@ -88,7 +89,7 @@ class API: if cherrypy.request.method == 'POST': cl = cherrypy.request.headers['Content-Length'] rawbody = cherrypy.request.body.read(int(cl)) - params = json.loads(rawbody) + params = json.loads(rawbody.decode()) try: self.mod_rc.set_param_value(params['controllable'], params['param'], params['value']) except ValueError as e: diff --git a/gui/configuration.py b/gui/configuration.py index 6e37cd1..4af1abd 100644 --- a/gui/configuration.py +++ b/gui/configuration.py @@ -30,7 +30,7 @@ class Configuration: self.config = None try: - fd = open(configfilename, "rb") + fd = open(configfilename, "r") self.config = json.load(fd) except json.JSONDecodeError: pass diff --git a/gui/static/js/odr-rcvalues.js b/gui/static/js/odr-rcvalues.js index 81d895c..f49674c 100644 --- a/gui/static/js/odr-rcvalues.js +++ b/gui/static/js/odr-rcvalues.js @@ -30,9 +30,19 @@ function requestStatus() { $('#rctable > tbody').empty(); doApiRequestGET("/api/rc_parameters", function(data) { - $.each( data, function( key1, controllable ) { - $.each( controllable, function( key2, param ) { - var key = key1 + "_" + key2; + console.log(data); + let keys = Object.keys(data); + keys.sort(); + + var key1; + for (key1 in keys) { + let keys2 = Object.keys(data[keys[key1]]); + keys2.sort(); + + var key2; + for (key2 in keys2) { + var param = data[keys[key1]][keys2[key2]]; + var key = keys[key1] + "_" + keys2[key2]; var valueentry = '' + '