diff --git a/TEMPLATE.env b/TEMPLATE.env index 7b76ace..c7e66ba 100644 --- a/TEMPLATE.env +++ b/TEMPLATE.env @@ -70,3 +70,6 @@ SHOW_SHYNET_VERSION=True # that you have a separate queue consumer running somewhere via `celeryworker.sh`. # CELERY_TASK_ALWAYS_EAGER=False # CELERY_BROKER_URL=redis://redis.default.svc.cluster.local/1 + +# Should Shynet show third-party icons in the dashboard? +SHOW_THIRD_PARTY_ICONS=True \ No newline at end of file diff --git a/shynet/dashboard/templates/base.html b/shynet/dashboard/templates/base.html index c4648f2..b2f22bc 100644 --- a/shynet/dashboard/templates/base.html +++ b/shynet/dashboard/templates/base.html @@ -41,7 +41,7 @@ {% for service in user.owning_services.all %} {% url 'dashboard:service' service.uuid as url %} - {% include 'dashboard/includes/sidebar_portal.html' with label=service.name|truncatechars:20 url=url %} + {% include 'dashboard/includes/sidebar_portal.html' with label=service.name|truncatechars:20 url=url icon=service.link|iconify %} {% endfor %} {% endif %} diff --git a/shynet/dashboard/templates/dashboard/includes/service_overview.html b/shynet/dashboard/templates/dashboard/includes/service_overview.html index 60455da..57e81f4 100644 --- a/shynet/dashboard/templates/dashboard/includes/service_overview.html +++ b/shynet/dashboard/templates/dashboard/includes/service_overview.html @@ -4,7 +4,8 @@ {% with stats=object.stats %}
-

+

+ {{object.link|iconify}} {{object.name}}

{% include 'dashboard/includes/stats_status_chip.html' %} diff --git a/shynet/dashboard/templates/dashboard/includes/sidebar_portal.html b/shynet/dashboard/templates/dashboard/includes/sidebar_portal.html index 193b27f..4cfc613 100644 --- a/shynet/dashboard/templates/dashboard/includes/sidebar_portal.html +++ b/shynet/dashboard/templates/dashboard/includes/sidebar_portal.html @@ -1,6 +1,6 @@ {% load helpers %}
- {{label}} + {{icon}} {{label}}
\ No newline at end of file diff --git a/shynet/dashboard/templates/dashboard/pages/service.html b/shynet/dashboard/templates/dashboard/pages/service.html index 1fa3d5c..8a0dec0 100644 --- a/shynet/dashboard/templates/dashboard/pages/service.html +++ b/shynet/dashboard/templates/dashboard/pages/service.html @@ -17,18 +17,18 @@

Sessions

{{stats.session_count|intcomma}} -

- {% compare stats.compare.session_count stats.session_count "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.session_count stats.session_count "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

Hits

{{stats.hit_count|intcomma}} -

- {% compare stats.compare.hit_count stats.hit_count "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.hit_count stats.hit_count "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

@@ -39,9 +39,9 @@ {% else %} ? {% endif %} -
- {% compare stats.compare.avg_load_time stats.avg_load_time "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.avg_load_time stats.avg_load_time "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

@@ -52,9 +52,9 @@ {% else %} ? {% endif %} -
- {% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

@@ -65,9 +65,9 @@ {% else %} ? {% endif %} -
- {% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

@@ -78,9 +78,9 @@ {% else %} ? {% endif %} -
- {% compare stats.compare.avg_hits_per_session stats.avg_hits_per_session "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} -
+
+ {% compare stats.compare.avg_hits_per_session stats.avg_hits_per_session "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %} +

{% endwith %} @@ -166,7 +166,7 @@ {% for os in stats.operating_systems %} - {{os.os|default:"Unknown"}} + {{os.os|iconify}}{{os.os|default:"Unknown"}} {{os.count|intcomma}} {% empty %} @@ -188,7 +188,8 @@ {% for browser in stats.browsers %} - {{browser.browser|default:"Unknown"}} + + {{browser.browser|iconify}}{{browser.browser|default:"Unknown"}} {{browser.count|intcomma}} {% empty %} @@ -225,7 +226,8 @@
{% include 'dashboard/includes/session_list.html' %}
- View more sessions + View more + sessions →
{% endblock %} \ No newline at end of file diff --git a/shynet/dashboard/templates/dashboard/service_base.html b/shynet/dashboard/templates/dashboard/service_base.html index 86ae861..3ce009d 100644 --- a/shynet/dashboard/templates/dashboard/service_base.html +++ b/shynet/dashboard/templates/dashboard/service_base.html @@ -8,6 +8,7 @@

+ {{object.link|iconify}} {{object.name}}

diff --git a/shynet/dashboard/templatetags/helpers.py b/shynet/dashboard/templatetags/helpers.py index 418f971..df1823e 100644 --- a/shynet/dashboard/templatetags/helpers.py +++ b/shynet/dashboard/templatetags/helpers.py @@ -84,8 +84,7 @@ def percent_change_display(start, end): @register.inclusion_tag("dashboard/includes/sidebar_footer.html") def sidebar_footer(): - return {"version": settings.VERSION if settings.SHOW_SHYNET_VERSION - else ""} + return {"version": settings.VERSION if settings.SHOW_SHYNET_VERSION else ""} @register.inclusion_tag("dashboard/includes/stat_comparison.html") @@ -116,12 +115,42 @@ def startswith(text, starts): return False +@register.filter +def iconify(text): + if not settings.SHOW_THIRD_PARTY_ICONS: + return "" + + text = text.lower() + icons = { + "chrome": "chrome.com", + "safari": "www.apple.com", + "windows": "windows.com", + "edge": "microsoft.com", + "firefox": "firefox.com", + "opera": "opera.com", + "unknown": "example.com", + } + + domain = None + if text.startswith("http"): + domain = urlparse(text).netloc + elif text in icons: + domain = icons[text] + else: + # This fallback works better than you'd think! + domain = text + ".com" + + return SafeString( + f'' + ) + + @register.filter def urldisplay(url): if url.startswith("http"): display_url = url.replace("http://", "").replace("https://", "") return SafeString( - f"{escape(display_url if len(display_url) < 40 else display_url[:40] + '...')}" + f"{iconify(url)} {escape(display_url if len(display_url) < 40 else display_url[:40] + '...')}" ) else: return url diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index 28a5f1a..3661120 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -318,3 +318,6 @@ SESSION_MEMORY_TIMEOUT = int(os.getenv("SESSION_MEMORY_TIMEOUT", "1800")) # Should the Shynet version information be displayed? SHOW_SHYNET_VERSION = os.getenv("SHOW_SHYNET_VERSION", "True") == "True" + +# Should Shynet show third-party icons in the dashboard? +SHOW_THIRD_PARTY_ICONS = os.getenv("SHOW_THIRD_PARTY_ICONS", "True") == "True" \ No newline at end of file