From 5f60e7ba37e50964827e59f2a9079408bd0113b8 Mon Sep 17 00:00:00 2001 From: marc Date: Thu, 15 Aug 2019 14:15:47 +0200 Subject: Added random token generator button --- guard/templates.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'guard/templates.py') 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/".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)) - )) + ))) ) -- cgit v1.2.1