From 6d39db75e1d349d1227c6c8116571b71606f787c Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 31 Oct 2016 22:08:23 +0100 Subject: [PATCH] Remove group prefix when showing params in web interface Make groups collapsable --- scripts/boxesserver | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/boxesserver b/scripts/boxesserver index 285080c..9247248 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -74,12 +74,16 @@ class BServer: def __init__(self): self.boxes = {b.__name__ : b() for b in boxes.generators.getAllBoxGenerators().values() if b.webinterface} - def arg2html(self, a): + def arg2html(self, a, prefix): name = a.option_strings[0].replace("-", "") if isinstance(a, argparse._HelpAction): return "" + viewname = name + if prefix and name.startswith(prefix + '_'): + viewname = name[len(prefix)+1:] + row = """%s%%s%s\n""" % \ - (name, a.help or "") + (viewname, a.help or "") if (isinstance(a, argparse._StoreAction) and isinstance(a.type, boxes.ArgparseEdgeType)): input = a.type.html(name, a.default) @@ -111,6 +115,18 @@ class BServer: + + + @@ -143,14 +159,17 @@ flex cuts, holes and slots for screws and more high level functions.

""", box.__doc__ or "", """

""" % (action)] + groupid = 0 for group in box.argparser._action_groups[2:] + box.argparser._action_groups[:2]: + groupid += 1 if not group._group_actions: continue - result.append("

%s

\n\n" % group.title) + prefix = getattr(group, "prefix", None) + result.append('

%s >

\n
\n' % (groupid, group.title, groupid)) for a in group._group_actions: if a.dest in ("input", "output"): continue - result.append(self.arg2html(a)) + result.append(self.arg2html(a, prefix)) result.append("
") result.append("""