aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgui/api/__init__.py3
-rw-r--r--gui/configuration.py2
-rw-r--r--gui/static/js/odr-rcvalues.js20
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 = '<input type="text" id="input'+key+'" ' +
'value="' + param['value'] + '">' +
'<button type="button" class="btn btn-xs btn-warning"' +
@@ -46,8 +56,8 @@ function requestStatus() {
$('#button'+key).click(function() {
buttonSetRc("input"+key, key1, key2);
});
- });
- });
+ }
+ }
});
}