Add icons to dashboard
This commit is contained in:
parent
ac5c743390
commit
cc094fe04e
@ -70,3 +70,6 @@ SHOW_SHYNET_VERSION=True
|
|||||||
# that you have a separate queue consumer running somewhere via `celeryworker.sh`.
|
# that you have a separate queue consumer running somewhere via `celeryworker.sh`.
|
||||||
# CELERY_TASK_ALWAYS_EAGER=False
|
# CELERY_TASK_ALWAYS_EAGER=False
|
||||||
# CELERY_BROKER_URL=redis://redis.default.svc.cluster.local/1
|
# CELERY_BROKER_URL=redis://redis.default.svc.cluster.local/1
|
||||||
|
|
||||||
|
# Should Shynet show third-party icons in the dashboard?
|
||||||
|
SHOW_THIRD_PARTY_ICONS=True
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
{% for service in user.owning_services.all %}
|
{% for service in user.owning_services.all %}
|
||||||
{% url 'dashboard:service' service.uuid as url %}
|
{% 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 %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
{% with stats=object.stats %}
|
{% with stats=object.stats %}
|
||||||
<div class="p-4 md:flex justify-between">
|
<div class="p-4 md:flex justify-between">
|
||||||
<div class="flex items-center mb-4 md:mb-0">
|
<div class="flex items-center mb-4 md:mb-0">
|
||||||
<h3 class="heading text-xl md:text-2xl mr-2 mb-1 text-urge-600">
|
<h3 class="heading text-xl md:text-2xl mr-2 mb-1 text-urge-600 flex items-center">
|
||||||
|
{{object.link|iconify}}
|
||||||
{{object.name}}
|
{{object.name}}
|
||||||
</h3>
|
</h3>
|
||||||
{% include 'dashboard/includes/stats_status_chip.html' %}
|
{% include 'dashboard/includes/stats_status_chip.html' %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a class="portal !low {% if request.get_full_path|startswith:url %}~urge active bg-neutral-100{% endif %}"
|
<a class="portal !low {% if request.get_full_path|startswith:url %}~urge active bg-neutral-100{% endif %} flex items-center"
|
||||||
{% if disable_turbolinks %}data-turbolinks="false"{% endif %} href="{{url}}">{{label}}</a>
|
{% if disable_turbolinks %}data-turbolinks="false"{% endif %} href="{{url}}">{{icon}} {{label}}</a>
|
||||||
</div>
|
</div>
|
@ -166,7 +166,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for os in stats.operating_systems %}
|
{% for os in stats.operating_systems %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{os.os|default:"Unknown"}}</td>
|
<td class="flex items-center">{{os.os|iconify}}<span>{{os.os|default:"Unknown"}}</span></td>
|
||||||
<td class="rf">{{os.count|intcomma}}</td>
|
<td class="rf">{{os.count|intcomma}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
@ -188,7 +188,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for browser in stats.browsers %}
|
{% for browser in stats.browsers %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{browser.browser|default:"Unknown"}}</td>
|
<td class="flex items-center">
|
||||||
|
{{browser.browser|iconify}}<span>{{browser.browser|default:"Unknown"}}</span></td>
|
||||||
<td class="rf">{{browser.count|intcomma}}</td>
|
<td class="rf">{{browser.count|intcomma}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
@ -225,7 +226,8 @@
|
|||||||
<div class="card ~neutral !low limited-height py-2">
|
<div class="card ~neutral !low limited-height py-2">
|
||||||
{% include 'dashboard/includes/session_list.html' %}
|
{% include 'dashboard/includes/session_list.html' %}
|
||||||
<hr class="sep h-8">
|
<hr class="sep h-8">
|
||||||
<a href="{% url 'dashboard:service_session_list' service.uuid %}" class="button ~neutral w-auto mb-2">View more sessions
|
<a href="{% url 'dashboard:service_session_list' service.uuid %}" class="button ~neutral w-auto mb-2">View more
|
||||||
|
sessions
|
||||||
→</a>
|
→</a>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -8,6 +8,7 @@
|
|||||||
<div class="md:flex justify-between items-center" id="heading">
|
<div class="md:flex justify-between items-center" id="heading">
|
||||||
<a class="flex items-center mb-4 md:mb-0" href="{% url 'dashboard:service' object.uuid %}">
|
<a class="flex items-center mb-4 md:mb-0" href="{% url 'dashboard:service' object.uuid %}">
|
||||||
<h3 class="heading leading-none mr-4">
|
<h3 class="heading leading-none mr-4">
|
||||||
|
{{object.link|iconify}}
|
||||||
{{object.name}}
|
{{object.name}}
|
||||||
</h3>
|
</h3>
|
||||||
<div class='text-3xl'>
|
<div class='text-3xl'>
|
||||||
|
@ -84,8 +84,7 @@ def percent_change_display(start, end):
|
|||||||
|
|
||||||
@register.inclusion_tag("dashboard/includes/sidebar_footer.html")
|
@register.inclusion_tag("dashboard/includes/sidebar_footer.html")
|
||||||
def sidebar_footer():
|
def sidebar_footer():
|
||||||
return {"version": settings.VERSION if settings.SHOW_SHYNET_VERSION
|
return {"version": settings.VERSION if settings.SHOW_SHYNET_VERSION else ""}
|
||||||
else ""}
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag("dashboard/includes/stat_comparison.html")
|
@register.inclusion_tag("dashboard/includes/stat_comparison.html")
|
||||||
@ -116,12 +115,42 @@ def startswith(text, starts):
|
|||||||
return False
|
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'<span class="icon mr-1"><img src="https://icons.duckduckgo.com/ip3/{domain}.ico"></span>'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def urldisplay(url):
|
def urldisplay(url):
|
||||||
if url.startswith("http"):
|
if url.startswith("http"):
|
||||||
display_url = url.replace("http://", "").replace("https://", "")
|
display_url = url.replace("http://", "").replace("https://", "")
|
||||||
return SafeString(
|
return SafeString(
|
||||||
f"<a href='{url}' title='{url}' rel='nofollow'>{escape(display_url if len(display_url) < 40 else display_url[:40] + '...')}</a>"
|
f"<a href='{url}' title='{url}' rel='nofollow' class='flex items-center'>{iconify(url)} {escape(display_url if len(display_url) < 40 else display_url[:40] + '...')}</a>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return url
|
return url
|
||||||
|
@ -318,3 +318,6 @@ SESSION_MEMORY_TIMEOUT = int(os.getenv("SESSION_MEMORY_TIMEOUT", "1800"))
|
|||||||
|
|
||||||
# Should the Shynet version information be displayed?
|
# Should the Shynet version information be displayed?
|
||||||
SHOW_SHYNET_VERSION = os.getenv("SHOW_SHYNET_VERSION", "True") == "True"
|
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"
|
Loading…
Reference in New Issue
Block a user