Improve service interface

This commit is contained in:
R. Miles McCain
2020-04-17 14:06:12 -04:00
parent 654b628fc9
commit fc2919d642
8 changed files with 50 additions and 37 deletions

View File

@@ -3,7 +3,7 @@
<a class="card ~neutral !low service mb-6 p-0" href="{% url 'dashboard:service' object.uuid %}">
{% with stats=object.stats %}
<div class="p-4 md:flex justify-between">
<div class="md:w-4/12 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-purple-600">
{{object.name}}
</h3>

View File

@@ -5,13 +5,5 @@
<span class="chip ~positive !high">
{{stats.currently_online|intcomma}} online
</span>
{% elif stats.online == True %}
<span class="chip ~positive !high">
Online
</span>
{% elif stats.online == False %}
<span class="chip ~critical !high">
Offline
</span>
{% endif %}
{% endwith %}

View File

@@ -105,6 +105,24 @@
</tbody>
</table>
</div>
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
<tr>
<th>Country</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for country in stats.countries %}
<tr>
<td>{{country.country|flag_emoji}} {{country.country|country_name}}</td>
<td class="rf">{{country.count|intcomma}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
@@ -141,24 +159,6 @@
</tbody>
</table>
</div>
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
<tr>
<th>Device</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for device in stats.devices %}
<tr>
<td>{{device.device|default:"Unknown"}}</td>
<td class="rf">{{device.count|intcomma}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">

View File

@@ -45,7 +45,7 @@
</div>
<div>
<p>Country</p>
<p class="label">{{session.country|flag_emoji}} {{session.country|default:"Unknown"}}</p>
<p class="label">{{session.country|flag_emoji}} {{session.country|country_name}}</p>
</div>
<div>
<p>Location</p>

View File

@@ -1,5 +1,5 @@
from urllib.parse import urlparse
import pycountry
import flag
from django import template
from django.utils import timezone
@@ -30,6 +30,12 @@ def flag_emoji(isocode):
except:
return ""
@register.filter
def country_name(isocode):
try:
return pycountry.countries.get(alpha_2=isocode).name
except:
return "Unknown"
@register.filter
def startswith(text, starts):