Skip to content

Commit

Permalink
fix: analytics dashboard button position
Browse files Browse the repository at this point in the history
  • Loading branch information
Friedjof committed Oct 15, 2024
1 parent a015cd6 commit 2a3f658
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
5 changes: 2 additions & 3 deletions analytics/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def get_urls(self):

@staticmethod
def analytics_view(request):
chart_error = 'No error'
try:
charts = [
Diagrams.map_weekday_hour_diagram(),
Expand All @@ -63,9 +62,9 @@ def analytics_view(request):
Diagrams.machine_types_per_building(),
]
except Exception as e:
chart_error = e
print(e)
charts = []

# States per building

return render(request, 'admin/analytics.html', context={'charts': charts, 'chart_error': chart_error})
return render(request, 'admin/analytics.html', context={'charts': charts})
9 changes: 4 additions & 5 deletions templates/admin/analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
<script>
document.addEventListener("DOMContentLoaded", function() {
const charts = {{ charts|safe }};
const chart_error = {{ chart_error|safe }};
const container = document.getElementById('charts-container');

if (charts.length === 0 && chart_error !== 'No error') {
const noData = document.createElement('p');
noData.textContent = `Error: ${chart_error}`;
container.appendChild(noData);
if (charts.length === 0) {
const message = document.createElement('p');
message.textContent = 'No data available';
container.appendChild(message);
return;
}

Expand Down
18 changes: 12 additions & 6 deletions templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">LaundryTracker administration</a></h1>
<div class="vertical-separator"></div>
<h1 id="site-name"><a href="{% url 'admin:analytics' %}" class="button-link">Analytics</a></h1>
{% endblock %}

{% block nav-global %}
<div class="nav-global">
<ul>
<a href="{% url 'admin:analytics' %}">Analytics</a>
</ul>
</div>
{% block extrahead %}
{{ block.super }}
<style>
.vertical-separator {
border-left: 3px solid #000; /* Black line */
height: 100%; /* Full height of the container */
margin: 0 10px; /* Margin around the separator */
display: inline-block; /* Align with h1 elements */
}
</style>
{% endblock %}

0 comments on commit 2a3f658

Please sign in to comment.