Skip to content

Commit

Permalink
GUI: a few fixes, sort rc entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbraendli committed Dec 3, 2018
1 parent 878923a commit 594cb26
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion gui/api/__init__.py
Expand Up @@ -23,6 +23,7 @@
import cherrypy
from cherrypy.lib.httputil import parse_query_string

import json
import urllib
import os

Expand Down Expand Up @@ -88,7 +89,7 @@ def parameter(self, **kwargs):
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:
Expand Down
2 changes: 1 addition & 1 deletion gui/configuration.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, configfilename="ui-config.json"):
self.config = None

try:
fd = open(configfilename, "rb")
fd = open(configfilename, "r")
self.config = json.load(fd)
except json.JSONDecodeError:
pass
Expand Down
20 changes: 15 additions & 5 deletions gui/static/js/odr-rcvalues.js
Expand Up @@ -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"' +
Expand All @@ -46,8 +56,8 @@ function requestStatus() {
$('#button'+key).click(function() {
buttonSetRc("input"+key, key1, key2);
});
});
});
}
}
});
}

Expand Down

0 comments on commit 594cb26

Please sign in to comment.