From 1328d62f9d3a2eb9f089d531614302005c29ec37 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 21 Jun 2015 21:56:59 +0200 Subject: Replace MGMT socket by ZMQ, make services shared_ptr --- gui/odr-dabmux-gui.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'gui/odr-dabmux-gui.py') diff --git a/gui/odr-dabmux-gui.py b/gui/odr-dabmux-gui.py index 19f3ae8..caa4ea7 100755 --- a/gui/odr-dabmux-gui.py +++ b/gui/odr-dabmux-gui.py @@ -28,13 +28,46 @@ # along with ODR-DabMux. If not, see . from muxconfig import * -from bottle import route, run, template, static_file +from bottle import route, run, template, static_file, request import json conf = ConfigurationHandler('localhost') @route('/config') def config(): + """Show the JSON ptree in a textbox for editing""" + + conf.load() + + return template('configeditor', + version = conf.get_mux_version(), + config = conf.get_full_configuration(), + message = "") + +@route('/config', method="POST") +def config_json_post(): + """Update the ODR-DabMux configuration with the JSON ptree + given as POST data""" + + new_config = request.forms.get('config') + print("New config %s" % new_config) + + success = conf.set_full_configuration(new_config) + + if success: + successmessage = "Success" + else: + successmessage = "Failure" + + conf.load() + + return template('configeditor', + version = conf.get_mux_version(), + config = conf.get_full_configuration(), + message = successmessage) + +@route('/config.json', method="GET") +def config_json_get(): """Return a application/json containing the full ptree of the mux""" @@ -43,6 +76,7 @@ def config(): return {'version': conf.get_mux_version(), 'config': conf.get_full_configuration()} + @route('/') def index(): conf.load() -- cgit v1.2.3