From 8cdc5af4538e5b2845da649a61c5a1c4241ff0b8 Mon Sep 17 00:00:00 2001 From: colcrunch Date: Sat, 16 Apr 2022 15:44:53 -0400 Subject: [PATCH 1/2] Improve celery bar by using decimalized width values (2 decimal places) to reduce likelyhood of an empty portion of the bar. --- .../allianceauth/admin-status/celery_bar_partial.html | 5 +++-- allianceauth/templatetags/admin_status.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html b/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html index 8939d8b3..baf68e69 100644 --- a/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html +++ b/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html @@ -1,11 +1,12 @@ {% load humanize %} +{% load admin_status %}
+ style="width: {% decimal_widthratio tasks_count tasks_total 100 %}%;"> {% widthratio tasks_count tasks_total 100 %}%
diff --git a/allianceauth/templatetags/admin_status.py b/allianceauth/templatetags/admin_status.py index dd610630..73ee909b 100644 --- a/allianceauth/templatetags/admin_status.py +++ b/allianceauth/templatetags/admin_status.py @@ -36,6 +36,11 @@ GITLAB_AUTH_ANNOUNCEMENT_ISSUES_URL = ( logger = logging.getLogger(__name__) +@register.simple_tag() +def decimal_widthratio(this_value, max_value, max_width) -> str: + return str(round(this_value/max_value * max_width, 2)) + + @register.inclusion_tag('allianceauth/admin-status/overview.html') def status_overview() -> dict: response = { From 54085617dc89762a8ff0dd576c74c4aebe57685e Mon Sep 17 00:00:00 2001 From: colcrunch Date: Sat, 16 Apr 2022 15:46:01 -0400 Subject: [PATCH 2/2] Add a few pixels of `margin-top` to bar labels to better center them. --- .../templates/allianceauth/admin-status/celery_bar_partial.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html b/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html index baf68e69..9f43203d 100644 --- a/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html +++ b/allianceauth/templates/allianceauth/admin-status/celery_bar_partial.html @@ -8,5 +8,5 @@ aria-valuemin="0" aria-valuemax="100" style="width: {% decimal_widthratio tasks_count tasks_total 100 %}%;"> - {% widthratio tasks_count tasks_total 100 %}% +

{% widthratio tasks_count tasks_total 100 %}%