From 51a2cc9a453f97a6ff8aa27730895875ae5beb84 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Mon, 6 Apr 2020 21:00:05 +0200 Subject: [PATCH] add config editor elements to ihr web --- screenless/bureau/ihr/ihrweb.py | 15 ++++++--- screenless/bureau/ihr/web_config.html | 44 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 screenless/bureau/ihr/web_config.html diff --git a/screenless/bureau/ihr/ihrweb.py b/screenless/bureau/ihr/ihrweb.py index 0af998f..5225fb4 100644 --- a/screenless/bureau/ihr/ihrweb.py +++ b/screenless/bureau/ihr/ihrweb.py @@ -4,6 +4,7 @@ import configparser import os from bottle import Bottle, request +import mako class IhrApp(Bottle): def __init__(self): @@ -13,10 +14,12 @@ class IhrApp(Bottle): self.route("/config/", callback=self.bureau_config) self.route("/config/", callback=self.bureau_config, method="POST") self.bureaus = [] + self.tdir = def index(self): # return a list of active bureaus with links # TODO: allow (de)activation of non-essential bureaus + templfile = "web_index.html" out = """

The Screenless Office

Config Manager

@@ -34,14 +37,18 @@ class IhrApp(Bottle): def bureau_config(self, bureau): # parse the config and make it into a form - out = "

config file for " + bureau + "

\n" + templfile = "web_config.html" + template = mako.template.Template(filename=templfile) basedir = os.path.expanduser("~/.screenless") if bureau == "mgmt": cfgfile = "mgmt.ini" + mode = "ini" elif bureau == "printers": - cfgfile = printers.cfg + cfgfile = "printers.cfg" + mode = "ini" else: cfgfile = bureau + ".yml" + mode = "yaml" cfgfile = os.path.join(basedir, cfgfile) if request.method == "POST": #save all the request.forms stuff to the config @@ -51,8 +58,8 @@ class IhrApp(Bottle): pass #parse and show the config as a form with open(cfgfile) as cfg: - out += cfg.read() - return out + cfgdata += cfg.read() + return template.render_unicode(bureau=bureau, cfgfile=cfgfile, mode=mode, cfgdata=cfgdata) def register_bureau(self, bureau): self.bureaus.append(bureau) diff --git a/screenless/bureau/ihr/web_config.html b/screenless/bureau/ihr/web_config.html new file mode 100644 index 0000000..494aa87 --- /dev/null +++ b/screenless/bureau/ihr/web_config.html @@ -0,0 +1,44 @@ + + + + Screenless Office - config file editor + + + +

The Screenless Office

+

edit config file $cfgfile

+
$cfgdata
+
+ + +
+ + #BUTTON + + #FIELD for CFGDATA and CFGFILE + #JAVASCRIPT to confirm and submit data + + + + + +