Improve service page when no hits are recorded

This commit is contained in:
R. Miles McCain 2021-04-24 17:06:32 +00:00
parent fef531efa9
commit 68945df17d
2 changed files with 4 additions and 5 deletions

View File

@ -13,15 +13,12 @@
{% block service_content %}
{% if not stats.has_hits %}
<div class="content mb-6">
<h5>Get started</h5>
<p>
It seems that you have not recorded any data yet!
<br>
Get started by placing the following snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.
This service hasn't collected any data yet. To get started, place the following code snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.
</p>
{% include 'dashboard/includes/service_snippet.html' %}
</div>
{% endif %}
{% else %}
<div class="grid grid-cols-2 gap-6 md:flex justify-between mb-6 card ~neutral !high px-6" id="stats">
{% with classes="text-sm font-semibold" good_classes="text-positive-400" bad_classes="text-critical-400" neutral_classes="text-gray-400" %}
<article class="">
@ -96,6 +93,7 @@
</article>
{% endwith %}
</div>
{% endif %}
<div class="card ~neutral !low py-0 mb-6">
{% include 'dashboard/includes/time_chart.html' with data=stats.session_chart_data %}
</div>

View File

@ -66,6 +66,7 @@ class ServiceView(
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data["script_protocol"] = "https://" if settings.SCRIPT_USE_HTTPS else "http://"
data["stats"] = self.object.get_core_stats(data["start_date"], data["end_date"])
data["object_list"] = Session.objects.filter(
service=self.get_object(),