diff --git a/projects/tentacles/src/python/tentacles/__main__.py b/projects/tentacles/src/python/tentacles/__main__.py index 002897f..8db9dff 100644 --- a/projects/tentacles/src/python/tentacles/__main__.py +++ b/projects/tentacles/src/python/tentacles/__main__.py @@ -6,7 +6,7 @@ from pathlib import Path import click -from flask import Flask, request, session, current_app +from flask import Flask, request, current_app import tomllib from datetime import datetime diff --git a/projects/tentacles/src/python/tentacles/blueprints/api.py b/projects/tentacles/src/python/tentacles/blueprints/api.py index 43497e3..1a0111f 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/api.py +++ b/projects/tentacles/src/python/tentacles/blueprints/api.py @@ -3,7 +3,7 @@ """API endpoints supporting the 'ui'.""" -from flask import Blueprint, request, Request, redirect +from flask import Blueprint BLUEPRINT = Blueprint("api", __name__, url_prefix="/api") diff --git a/projects/tentacles/src/python/tentacles/blueprints/printer_ui.py b/projects/tentacles/src/python/tentacles/blueprints/printer_ui.py index 27e273e..d8e10db 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/printer_ui.py +++ b/projects/tentacles/src/python/tentacles/blueprints/printer_ui.py @@ -4,17 +4,12 @@ import logging -from click import group from flask import ( Blueprint, - current_app, request, - Request, redirect, render_template, - session, - url_for, flash, ) diff --git a/projects/tentacles/src/python/tentacles/blueprints/user_ui.py b/projects/tentacles/src/python/tentacles/blueprints/user_ui.py index 1a3c57d..30e2ea3 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/user_ui.py +++ b/projects/tentacles/src/python/tentacles/blueprints/user_ui.py @@ -8,16 +8,12 @@ import re from tentacles.globals import ctx -from click import group from flask import ( Blueprint, current_app, request, - Request, redirect, render_template, - session, - url_for, flash, ) diff --git a/projects/tentacles/src/python/tentacles/blueprints/util.py b/projects/tentacles/src/python/tentacles/blueprints/util.py index 84ee7aa..ee40282 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/util.py +++ b/projects/tentacles/src/python/tentacles/blueprints/util.py @@ -2,17 +2,10 @@ import logging -from click import group from flask import ( - Blueprint, current_app, - request, - Request, redirect, - render_template, - session, - url_for, flash, ) diff --git a/projects/tentacles/src/python/tentacles/static/css/style.scss b/projects/tentacles/src/python/tentacles/static/css/style.scss index 4b3bb49..23db6f5 100644 --- a/projects/tentacles/src/python/tentacles/static/css/style.scss +++ b/projects/tentacles/src/python/tentacles/static/css/style.scss @@ -307,3 +307,17 @@ form { border-radius: 1em; padding: 0.5em; } + +.keys ul li { + display: flex; + flex-direction: row; + + span { + margin-right: 1em; + } + + .key-key { + max-width: 20em; + overflow: clip; + } +} diff --git a/projects/tentacles/src/python/tentacles/templates/printers.html.j2 b/projects/tentacles/src/python/tentacles/templates/printers.html.j2 index f9bd4fb..cb6f57d 100644 --- a/projects/tentacles/src/python/tentacles/templates/printers.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/printers.html.j2 @@ -21,7 +21,7 @@ {% endfor %} </ul> {% else %} - No printers available. {% if request.is_admin %}<a href="/printers/add">Configure one!</a>{% else %}Ask the admin to configure one!{% endif %} + No printers available. {% if ctx.is_admin %}<a href="/printers/add">Configure one!</a>{% else %}Ask the admin to configure one!{% endif %} {% endif %} {% endwith %} </div> diff --git a/projects/tentacles/src/python/tentacles/templates/user.html.j2 b/projects/tentacles/src/python/tentacles/templates/user.html.j2 index a70290b..fdd9ca0 100644 --- a/projects/tentacles/src/python/tentacles/templates/user.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/user.html.j2 @@ -1,14 +1,14 @@ {% extends "base.html.j2" %} {% block content %} <h1>User settings</h1> -<div class=""> +<div class="keys"> <h2>API keys</h2> {% with keys = ctx.db.list_keys(ctx.uid) %} <ul> {% for id, name, exp in keys if name != 'web session' %} <li> - <span class="key-name">{{ name }}</span> - <span class="key-key">{{ id }}</span> + <span class="key-name">{{ name or 'anonymous' }}</span> + <span class="key-key">{{ id[:10] }}...</span> <span class="key-expiration">{{ 'Expires in' if exp else ''}} {{ exp - datetime.now() if exp else 'Never' }}</span> <form method="post"> <input type="hidden" name="action" value="revoke">