aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-03 16:39:31 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-03 16:39:31 +0100
commit594cb2691debaa7562fd7d76d3b224701ec087ea (patch)
treec2e3668ca4e9180c125cc2432a9037b2460de83c /gui
parent878923ab610af66789531937278ed1aa58f1ebd7 (diff)
downloaddabmod-594cb2691debaa7562fd7d76d3b224701ec087ea.tar.gz
dabmod-594cb2691debaa7562fd7d76d3b224701ec087ea.tar.bz2
dabmod-594cb2691debaa7562fd7d76d3b224701ec087ea.zip
GUI: a few fixes, sort rc entries
Diffstat (limited to 'gui')
-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);
});
- });
- });
+ }
+ }
});
}