From 3bec3b312a1e235247f1431d4351db5efe7a785d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 23 Sep 2024 14:10:17 -0500 Subject: UI: Indicate currently active menu. --- uploader/base_routes.py | 10 ++++----- uploader/genotypes/views.py | 2 ++ uploader/samples/views.py | 16 +++++++-------- uploader/static/css/styles.css | 7 +++++++ uploader/templates/base.html | 46 ++++++++++++++++++++++++++---------------- uploader/ui.py | 1 + 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/uploader/base_routes.py b/uploader/base_routes.py index a20b7ff..742a254 100644 --- a/uploader/base_routes.py +++ b/uploader/base_routes.py @@ -2,15 +2,15 @@ import os from urllib.parse import urljoin -from flask import ( - Blueprint, - render_template, - current_app as app, - send_from_directory) +from flask import (Blueprint, + current_app as app, + send_from_directory) +from uploader.ui import make_template_renderer from uploader.oauth2.client import user_logged_in base = Blueprint("base", __name__) +render_template = make_template_renderer("home") @base.route("/favicon.ico", methods=["GET"]) diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 4158491..d69dc28 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -7,6 +7,7 @@ from flask import (flash, render_template, current_app as app) +from uploader.ui import make_template_renderer from uploader.authorisation import require_login from uploader.db_utils import database_connection from uploader.species.models import all_species, species_by_id @@ -20,6 +21,7 @@ from .models import (genotype_markers, genocode_by_population) genotypesbp = Blueprint("genotypes", __name__) +render_template = make_template_renderer("genotypes") @genotypesbp.route("populations/genotypes", methods=["GET"]) @require_login diff --git a/uploader/samples/views.py b/uploader/samples/views.py index fd3c601..9ba1df8 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -8,17 +8,16 @@ from typing import Iterator import MySQLdb as mdb from redis import Redis from MySQLdb.cursors import DictCursor -from flask import ( - flash, - request, - url_for, - redirect, - Blueprint, - render_template, - current_app as app) +from flask import (flash, + request, + url_for, + redirect, + Blueprint, + current_app as app) from uploader import jobs from uploader.files import save_file +from uploader.ui import make_template_renderer from uploader.authorisation import require_login from uploader.input_validation import is_integer_input from uploader.datautils import order_by_family, enumerate_sequence @@ -37,6 +36,7 @@ from uploader.population.models import(save_population, from .models import samples_by_species_and_population samplesbp = Blueprint("samples", __name__) +render_template = make_template_renderer("samples") @samplesbp.route("/samples", methods=["GET"]) @require_login diff --git a/uploader/static/css/styles.css b/uploader/static/css/styles.css index fab42b8..574f53e 100644 --- a/uploader/static/css/styles.css +++ b/uploader/static/css/styles.css @@ -118,3 +118,10 @@ input[type="submit"], .btn { border-color: #AAAAAA; padding: 0.5em; } + +.activemenu { + border-style: solid; + border-radius: 0.5em; + border-color: #AAAAAA; + background-color: #EFEFEF; +} diff --git a/uploader/templates/base.html b/uploader/templates/base.html index 171e8fa..74de77e 100644 --- a/uploader/templates/base.html +++ b/uploader/templates/base.html @@ -43,23 +43,35 @@ diff --git a/uploader/ui.py b/uploader/ui.py index 4115b02..1994056 100644 --- a/uploader/ui.py +++ b/uploader/ui.py @@ -8,6 +8,7 @@ def make_template_renderer(default): template, **{ **kwargs, + "activemenu": default, "activelink": kwargs.get("activelink", default) }) return render_template -- cgit v1.2.3