From 14d4eb7ce28ec01fe5702d228fb172c42341b83b Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 8 Nov 2023 17:01:41 +0100 Subject: [PATCH] add signal reception icon --- .../common/templates/icons/reception.html | 17 +++++++++++++++++ .../common/templatetags/common_extras.py | 11 +++++++++++ scipost_django/templates/bi/reception-0.html | 8 ++++++++ scipost_django/templates/bi/reception-1.html | 8 ++++++++ scipost_django/templates/bi/reception-2.html | 8 ++++++++ scipost_django/templates/bi/reception-3.html | 8 ++++++++ scipost_django/templates/bi/reception-4.html | 8 ++++++++ 7 files changed, 68 insertions(+) create mode 100644 scipost_django/common/templates/icons/reception.html create mode 100644 scipost_django/templates/bi/reception-0.html create mode 100644 scipost_django/templates/bi/reception-1.html create mode 100644 scipost_django/templates/bi/reception-2.html create mode 100644 scipost_django/templates/bi/reception-3.html create mode 100644 scipost_django/templates/bi/reception-4.html diff --git a/scipost_django/common/templates/icons/reception.html b/scipost_django/common/templates/icons/reception.html new file mode 100644 index 000000000..c601353cb --- /dev/null +++ b/scipost_django/common/templates/icons/reception.html @@ -0,0 +1,17 @@ +{% load common_extras %} + +{% with strength=value|multiply:5|int_divide:max %} + + {% if strength == 0 %} + <span title="{{ value }}" class="text-secondary">{% include "bi/reception-0.html" %}</span> + {% elif strength == 1 %} + <span title="{{ value }}" class="text-success">{% include "bi/reception-1.html" %}</span> + {% elif strength == 2 %} + <span title="{{ value }}" class="text-primary">{% include "bi/reception-2.html" %}</span> + {% elif strength == 3 %} + <span title="{{ value }}" class="text-warning">{% include "bi/reception-3.html" %}</span> + {% elif strength >= 4 %} + <span title="{{ value }}" class="text-danger">{% include "bi/reception-4.html" %}</span> + {% endif %} + +{% endwith %} diff --git a/scipost_django/common/templatetags/common_extras.py b/scipost_django/common/templatetags/common_extras.py index f8707d147..f01460fee 100644 --- a/scipost_django/common/templatetags/common_extras.py +++ b/scipost_django/common/templatetags/common_extras.py @@ -31,3 +31,14 @@ def rstrip_minutes(text): if "day" in text or "hour" in text: return re.split("[0-9]+\xa0minutes", text, 1)[0].rstrip(", ") return text + + +# Math +@register.filter +def int_divide(a, b): + return a // b + + +@register.filter +def multiply(a, b): + return a * b diff --git a/scipost_django/templates/bi/reception-0.html b/scipost_django/templates/bi/reception-0.html new file mode 100644 index 000000000..f2d813aae --- /dev/null +++ b/scipost_django/templates/bi/reception-0.html @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-reception-0" + viewBox="0 0 16 16"> + <path d="M0 13.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z" /> +</svg> diff --git a/scipost_django/templates/bi/reception-1.html b/scipost_django/templates/bi/reception-1.html new file mode 100644 index 000000000..6792e973e --- /dev/null +++ b/scipost_django/templates/bi/reception-1.html @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-reception-1" + viewBox="0 0 16 16"> + <path d="M0 11.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2zm4 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z" /> +</svg> diff --git a/scipost_django/templates/bi/reception-2.html b/scipost_django/templates/bi/reception-2.html new file mode 100644 index 000000000..77cc2b0cd --- /dev/null +++ b/scipost_django/templates/bi/reception-2.html @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-reception-2" + viewBox="0 0 16 16"> + <path d="M0 11.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-5zm4 5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm4 0a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z" /> +</svg> diff --git a/scipost_django/templates/bi/reception-3.html b/scipost_django/templates/bi/reception-3.html new file mode 100644 index 000000000..438b39519 --- /dev/null +++ b/scipost_django/templates/bi/reception-3.html @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-reception-3" + viewBox="0 0 16 16"> + <path d="M0 11.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-5zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-8zm4 8a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z" /> +</svg> diff --git a/scipost_django/templates/bi/reception-4.html b/scipost_django/templates/bi/reception-4.html new file mode 100644 index 000000000..c6066d2d9 --- /dev/null +++ b/scipost_django/templates/bi/reception-4.html @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-reception-4" + viewBox="0 0 16 16"> + <path d="M0 11.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-5zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-8zm4-3a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-11z" /> +</svg> -- GitLab