add link button to config and log

This commit is contained in:
Florian Bezannier
2021-10-14 22:05:01 +02:00
parent 086a56b4dd
commit a64243fc2c
3 changed files with 27 additions and 14 deletions
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3.34 17a10.018 10.018 0 0 1-.978-2.326 3 3 0 0 0 .002-5.347A9.99 9.99 0 0 1 4.865 4.99a3 3 0 0 0 4.631-2.674 9.99 9.99 0 0 1 5.007.002 3 3 0 0 0 4.632 2.672c.579.59 1.093 1.261 1.525 2.01.433.749.757 1.53.978 2.326a3 3 0 0 0-.002 5.347 9.99 9.99 0 0 1-2.501 4.337 3 3 0 0 0-4.631 2.674 9.99 9.99 0 0 1-5.007-.002 3 3 0 0 0-4.632-2.672A10.018 10.018 0 0 1 3.34 17zm5.66.196a4.993 4.993 0 0 1 2.25 2.77c.499.047 1 .048 1.499.001A4.993 4.993 0 0 1 15 17.197a4.993 4.993 0 0 1 3.525-.565c.29-.408.54-.843.748-1.298A4.993 4.993 0 0 1 18 12c0-1.26.47-2.437 1.273-3.334a8.126 8.126 0 0 0-.75-1.298A4.993 4.993 0 0 1 15 6.804a4.993 4.993 0 0 1-2.25-2.77c-.499-.047-1-.048-1.499-.001A4.993 4.993 0 0 1 9 6.803a4.993 4.993 0 0 1-3.525.565 7.99 7.99 0 0 0-.748 1.298A4.993 4.993 0 0 1 6 12c0 1.26-.47 2.437-1.273 3.334a8.126 8.126 0 0 0 .75 1.298A4.993 4.993 0 0 1 9 17.196zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+17 -11
View File
@@ -13,7 +13,7 @@ import dash_core_components as dcc
import dash_html_components as html
config = Config()
config_layout = dbc.Row(dbc.Col(className="col-md-12 col-lg-2 ml-2", children=[
login_config_layout = dbc.Row(dbc.Col(md=12, lg=2, children=[
html.H2('Config'),
dbc.Form([
dbc.FormGroup([
@@ -116,15 +116,22 @@ config_otp_layout = dbc.Row(dbc.Col(className="col-md-12 col-lg-2 ml-2", childre
def log_layout():
with open(LOG_FILE, "r") as f:
log_text = f.read()
return html.H3(children=["Log:", dbc.Textarea(
valid=True,
bs_size="sm",
className="mt-3",
style={"height": "80vh"},
placeholder="Log",
contentEditable=False,
value=log_text
)])
return html.H3(children=["Log:", dbc.Container(
fluid=True,
style={"height": "80vh",
"overflow": "auto",
"display": "flex",
"flex-direction": "column-reverse",
"white-space": "pre-line"},
children=log_text,
className="m-3 bg-light h5"),
html.Div(id="empty-div")])
config_layout = dbc.Tabs([
dbc.Tab([log_layout()], label="Log"),
dbc.Tab([login_config_layout], label="User config"),
dbc.Tab([config_otp_layout], label="OTP config")])
@dash_app.callback(
@@ -146,7 +153,6 @@ def connectPSA(n_clicks, app_name, email, password, countrycode): # pylint: dis
return dbc.Alert(res, color="danger")
else:
return ""
raise PreventUpdate()
@dash_app.callback(
+9 -3
View File
@@ -20,7 +20,7 @@ from web import figures
from web.app import app, dash_app
from web.db import Database
from web.view.config_views import config_layout, config_otp_layout, log_layout
from web.view.config_views import login_config_layout, config_otp_layout, log_layout, config_layout
from web.utils import diff_dashtable, dash_date_to_datetime
# pylint: disable=invalid-name
@@ -39,7 +39,11 @@ CONFIG = Config()
def add_header(el):
return html.H1('My car info'), el
return dbc.Row([dbc.Col(dcc.Link(html.H1('My car info'), href="/", style={"text-decoration": "none"})),
dbc.Col(dcc.Link(html.Img(src="assets/images/settings.svg", width="30veh"),
href="/config",
className="float-right"))],
className="justify-content-between"), el
@dash_app.callback(Output('page-content', 'children'),
@@ -51,10 +55,12 @@ def display_page(pathname, search):
no_header = query_params.get("header", None) == ["false"]
if pathname == "/config":
page = config_layout
elif pathname == "/config_login":
page = login_config_layout
elif pathname == "/log":
page = log_layout()
elif not CONFIG.is_good:
page = dcc.Location(pathname=dash_app.requests_pathname_external_prefix + "config", id="config_redirect")
page = dcc.Location(pathname=dash_app.requests_pathname_external_prefix + "config_login", id="config_redirect")
elif pathname == "/config_otp":
page = config_otp_layout
elif pathname == "/control":