diff options
author | Robin ALEXANDER <colisee@hotmail.com> | 2022-02-05 22:19:42 +0100 |
---|---|---|
committer | Robin ALEXANDER <colisee@hotmail.com> | 2022-02-05 22:19:42 +0100 |
commit | b6376fb8f1379bebd3241f29e356eb0076adfcbd (patch) | |
tree | 59cd1047c817bdb9ac92e16d262fe74597c1123f | |
parent | 852665779c24880e97c1a560e8f19a11f2ee28a3 (diff) | |
download | dabmux-b6376fb8f1379bebd3241f29e356eb0076adfcbd.tar.gz dabmux-b6376fb8f1379bebd3241f29e356eb0076adfcbd.tar.bz2 dabmux-b6376fb8f1379bebd3241f29e356eb0076adfcbd.zip |
Switch to Jinja2 from SimpleTemplate
-rwxr-xr-x | gui/odr-dabmux-gui.py | 5 | ||||
-rw-r--r-- | gui/views/index.tpl | 22 | ||||
-rw-r--r-- | gui/views/rcparam.tpl | 18 |
3 files changed, 23 insertions, 22 deletions
diff --git a/gui/odr-dabmux-gui.py b/gui/odr-dabmux-gui.py index df6b81f..5a35007 100755 --- a/gui/odr-dabmux-gui.py +++ b/gui/odr-dabmux-gui.py @@ -29,7 +29,8 @@ from muxconfig import * from muxrc import * -from bottle import * +from bottle import route, run, request, static_file, jinja2_template as template +import jinja2 import json import argparse @@ -167,4 +168,4 @@ if __name__ == '__main__': paramStr = paramFile.read() paramObj = json.loads(paramStr) - run(host=cli_args.host, port=int(cli_args.port), debug=True, reloader=False) + run(host=cli_args.host, port=int(cli_args.port), debug=True, reloader=False)
\ No newline at end of file diff --git a/gui/views/index.tpl b/gui/views/index.tpl index a554095..7d7f886 100644 --- a/gui/views/index.tpl +++ b/gui/views/index.tpl @@ -58,14 +58,14 @@ <th>Label</th> <th>Short label</th> </tr> - % for s in services: + {% for s in services %} <tr> <td>{{s.name}}</td> <td>{{s.id}}</td> <td>{{s.label}}</td> <td>{{s.shortlabel}}</td> </tr> - % end + {% endfor %} </table> </div> <div id="subchannels" class="w3-responsive w3-card-4"> @@ -77,14 +77,14 @@ <th>Input file</th> <th>Bit rate (Kbps)</th> </tr> - % for s in subchannels: + {% for s in subchannels %} <tr> <td>{{s.name}}</td> <td>{{s.type}}</td> <td>{{s.inputfile}}</td> <td>{{s.bitrate}}</td> </tr> - % end + {% endfor %} </table> </div> <div id="components" class="w3-responsive w3-card-4"> @@ -98,7 +98,7 @@ <th>Sub-channel</th> <th>Fig type</th> </tr> - % for s in components: + {% for s in components %} <tr> <td>{{s.name}}</td> <td>{{s.label}}</td> @@ -107,22 +107,22 @@ <td>{{s.subchannel}}</td> <td>{{s.figtype}}</td> </tr> - % end + {% endfor %} </table> </div> <div id="rcmodules" class="w3-responsive w3-card-4"> <br /><br /> <ul class="w3-ul"> <li class="w3-blue-grey"><b>RC Modules</b></li> - % for m in rcmodules: + {% for m in rcmodules %} <li class="w3-light-grey"><b>{{m.name}}</b> <ul class="w3-ul"> - % for p in m.parameters: - <li class="w3-white"><a href="/rc/{{m.name}}/{{p.param}}" class="w3-hover-blue-grey">{{p.param}}</a> : {{p.value}}</li> - % end + {% for p in m.parameters %} + <li class="w3-white"><a href="/rc/{{m.name}}/{{p.param.decode()}}" class="w3-hover-blue-grey">{{p.param.decode()}}</a> : {{p.value.decode()}}</li> + {% endfor %} </ul> </li> - % end + {% endfor %} </ul> </div> </div> diff --git a/gui/views/rcparam.tpl b/gui/views/rcparam.tpl index c415d7a..369e8c9 100644 --- a/gui/views/rcparam.tpl +++ b/gui/views/rcparam.tpl @@ -14,21 +14,21 @@ <div class="w3-card-4"> <form class="w3-container" ic-on-error="alert(str)" ic-post-to="/rc/{{module}}/{{param}}"> <p /> - % if (len(list) == 0): + {% if not list %} <label>{{param}}:</label> - <input name="newvalue" type="text" value="{{value}}" autofocus> - % else: + <input name="newvalue" type="text" value="{{value.decode()}}" autofocus> + {% else %} <label>{{label}}:</label> <select id="newvalue" name="newvalue"> - % for l in list: - % if (bytes(l["value"], 'utf-8') == value): + {% for l in list %} + {% if (l["value"] == value.decode()) %} <option selected value={{l["value"]}}>{{l["desc"]}}</option> - % else: + {% else %} <option value={{l["value"]}}>{{l["desc"]}}</option> - % end - % end + {% endif %} + {% endfor %} </select> - % end + {% endif %} <p /> <button class="w3-button w3-blue-grey">Update</button> <p /> |