summaryrefslogtreecommitdiffstats
path: root/gui/odr-dabmux-gui.py
diff options
context:
space:
mode:
Diffstat (limited to 'gui/odr-dabmux-gui.py')
-rwxr-xr-xgui/odr-dabmux-gui.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/gui/odr-dabmux-gui.py b/gui/odr-dabmux-gui.py
index 84331b5..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 <http://www.gnu.org/licenses/>.
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()
@@ -62,6 +96,17 @@ def index():
version = conf.get_mux_version(),
services = conf.get_services())
+@route('/stats')
+def index():
+ conf.load()
+
+ return template('stats',
+ version = conf.get_mux_version())
+
+@route('/stats.json')
+def stats_json():
+ return conf.get_stats_dict()
+
@route('/static/<filename:path>')
def send_static(filename):