Add location templates

This commit is contained in:
2023-11-24 01:33:33 +01:00
parent e04be4fbdd
commit 85a91b340a
7 changed files with 223 additions and 1 deletions

View File

@ -0,0 +1,94 @@
{% extends "base_list.html" %}
{% load urlreplace %}
{% block title %}Locations{% endblock %}
{% block head_extra %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<style>
#map { height: 580px; }
</style>
{% endblock %}
{% block extra_js %}
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<script>
var map = L.map('map').setView([{{latest.lat}}, {{latest.lon}}], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var marker = L.marker([{{latest.lat}}, {{latest.lon}}]).addTo(map);
var latest_path = [
{% for l in object_list %}
[{{l.lat}}, {{l.lon}}]{% if not forloop.last %},{% endif %}
{% endfor %}
]
var path = L.polyline(latest_path, {color: 'red'}).addTo(map);
</script>
{% endblock %}
{% block lists %}
<div class="row">
<div id="map"></div>
</div>
<div class="row">
<p class="pagination">
<span class="page-links">
{% if page_obj.has_previous %}
<a href="?{% urlreplace page=page_obj.previous_page_number %}">prev</a>
{% endif %}
<span class="page-current">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
<a href="?{% urlreplace page=page_obj.next_page_number %}">next</a>
{% endif %}
</span>
</p>
<hr />
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Scrobbles</th>
<th scope="col">Point</th>
</tr>
</thead>
<tbody>
{% for location in object_list %}
<tr>
<td>{{location.scrobbles.count}}</td>
<td><a href="{{location.get_absolute_url}}">{{location.lat}}x{{location.lon}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="pagination" style="margin-bottom:50px;">
<span class="page-links">
{% if page_obj.has_previous %}
<a href="?{% urlreplace page=page_obj.previous_page_number %}">prev</a>
{% endif %}
<span class="page-current">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
<a href="?{% urlreplace page=page_obj.next_page_number %}">next</a>
{% endif %}
</span>
</div>
</div>
{% endblock %}