diff options
author | marc <mlasch@mailbox.org> | 2019-08-15 14:15:47 +0200 |
---|---|---|
committer | marc <mlasch@mailbox.org> | 2019-08-15 14:15:47 +0200 |
commit | 5f60e7ba37e50964827e59f2a9079408bd0113b8 (patch) | |
tree | ccb7423c806a5ca7c2a7e64f3874ea391d5bbc46 /guard/templates.py | |
parent | e4e413ede34a2ae306ddd130324435d0e735f064 (diff) | |
download | influxdb-guard-5f60e7ba37e50964827e59f2a9079408bd0113b8.tar.gz influxdb-guard-5f60e7ba37e50964827e59f2a9079408bd0113b8.zip |
Added random token generator button
Diffstat (limited to 'guard/templates.py')
-rw-r--r-- | guard/templates.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/guard/templates.py b/guard/templates.py index e8d63a0..3cc1373 100644 --- a/guard/templates.py +++ b/guard/templates.py @@ -7,19 +7,19 @@ from lxml import etree from flask import url_for -def _html(title: str, body: etree.Element) -> str: +def _html(head: etree.Element, body: etree.Element) -> str: return etree.tostring(E.html( - E.head(E.title(title)), - E.body(body) + head, + body ), encoding='utf-8') def login() -> str: - return _html("Login", E.form( + return _html(E.head(E.titile("Login")), E.body(E.form( E.input(type="password", name="secret", placeholder="Secret admin token"), E.button("login", type="submit"), method="POST" - )) + ))) def _index_access(accesses: Iterable[model.Access]): @@ -40,8 +40,11 @@ def _index_access(accesses: Iterable[model.Access]): def index(serverport: str, cookiename: str) -> str: return _html( - "Manage access tokens", - E.div( + E.head( + E.title("Manage access tokens"), + E.script("", src="static/main.js") + ), + E.body(E.div( E.p(E.a("Logout", href=url_for("logout"))), E.p("Call the write-service like: ", E.pre("http://thisMachine:{}/write".format(serverport)), @@ -50,10 +53,12 @@ def index(serverport: str, cookiename: str) -> str: E.pre("http://thisMachine:{}/write/<token>".format(serverport))), E.form( E.input(type="hidden", name="action", value="create"), - E.input(name="token", placeholder="Token secret"), + E.input(name="token", placeholder="Token secret", id="tokenField"), + E.input(value="↻", type="button", onclick="genToken()"), E.input(name="pattern", placeholder="Paths pattern"), E.input(name="comment", placeholder="Comment"), - E.button("Create", type="submit"), method="POST"), + E.button("Create", type="submit"), + method="POST"), E.hr(), E.table( E.tr( @@ -61,5 +66,5 @@ def index(serverport: str, cookiename: str) -> str: E.th("Create Date"), E.th("Comment"), E.th() ), border="1", style="width: 100%", *_index_access(model.Access.select().order_by(model.Access.create_date)) - )) + ))) ) |