You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
5.3 KiB
137 lines
5.3 KiB
5 years ago
|
{% extends 'base.html' %}
|
||
|
|
||
5 years ago
|
{% block head %}
|
||
|
{{ super() }}
|
||
5 years ago
|
<link rel="stylesheet" href="{{ url_for('static', filename='assets/leaflet/leaflet.css') }}" />
|
||
|
<script src="{{ url_for('static', filename='assets/leaflet/leaflet.js') }}"></script>
|
||
5 years ago
|
{% endblock %}
|
||
|
|
||
5 years ago
|
{% block app_content %}
|
||
5 years ago
|
<h1>{{ game.name }} Dashboard</h1>
|
||
5 years ago
|
|
||
|
<h2>Players:</h2>
|
||
5 years ago
|
<p><a href="{{ url_for('main.add_player', game_name = game.name) }}">Add player</a></p>
|
||
5 years ago
|
<div class="table-responsive">
|
||
|
<table class="table">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th scope="col">Player Name</th>
|
||
|
<th scope="col">Role</th>
|
||
|
<th scope="col">Objectives found</th>
|
||
|
<th scope="col">Bunnies Caught</th>
|
||
5 years ago
|
<th scope="col">Been Caught</th>
|
||
5 years ago
|
<th scope="col">Last location</th>
|
||
5 years ago
|
<th scope="col"></th>
|
||
5 years ago
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
{% for player in game.players %}
|
||
|
<tr>
|
||
5 years ago
|
<td><a href="{{ url_for('main.game_player', game_name = game.name, player_name = player.name) }}">{{ player.name }}</a></td>
|
||
5 years ago
|
{% for gameplayer in player.player_games if gameplayer.game == game %}
|
||
|
<td>{{ gameplayer.role.name }}</td>
|
||
|
{% endfor %}
|
||
5 years ago
|
<td>{{ player.found_objectives | selectattr('game', '==', game)|list|length}}</td>
|
||
|
<td>{{ player.caught_players | selectattr('game', '==', game)|list|length}}</td>
|
||
|
<td>{{ player.caught_by_players | selectattr('game', '==', game)|list|length}}</td>
|
||
5 years ago
|
<td>{% with location = player.last_location(game) %}
|
||
|
{% if location %}{{ moment(location.timestamp).fromNow()}}: {% endif %}
|
||
|
{{ location }}
|
||
5 years ago
|
{% endwith %}</td>
|
||
5 years ago
|
<td><a href="{{ url_for('main.remove_player', game_name=game.name, player_name=player.name) }}">
|
||
5 years ago
|
<button class="btn btn-danger">Delete</button></a>
|
||
|
</td>
|
||
5 years ago
|
</tr>
|
||
|
{% endfor %}
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
5 years ago
|
<h2>Objectives:</h2>
|
||
5 years ago
|
<p><a href="{{ url_for('main.add_objective', game_name = game.name) }}">Add new objective</a></p>
|
||
5 years ago
|
{% if game.objectives %}
|
||
|
<div class="table-responsive">
|
||
|
<table class="table">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th scope="col">Objective Name</th>
|
||
|
<th scope="col">Latitude</th>
|
||
|
<th scope="col">Longitude</th>
|
||
5 years ago
|
<th scope="col">Times found</th>
|
||
5 years ago
|
<th scope="col">Hash</th>
|
||
|
<th scope="col"></th>
|
||
5 years ago
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
{% for objective in game.objectives %}
|
||
|
<tr>
|
||
|
<td>{{ objective.name }}</td>
|
||
|
<td>{{ objective.latitude }}</td>
|
||
|
<td>{{ objective.longitude }}</td>
|
||
5 years ago
|
<td>{{ objective.found_by|length }}</td>
|
||
5 years ago
|
<td><a href="{{ url_for('main.objective', objective_hash = objective.hash) }}">{{ objective.hash }}</a></td>
|
||
|
<td><a href="{{ url_for('main.delete_objective', objective_hash = objective.hash) }}">
|
||
5 years ago
|
<button class="btn btn-danger">Delete</button></a>
|
||
|
</td>
|
||
5 years ago
|
</tr>
|
||
|
{% endfor %}
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
5 years ago
|
<div id="map" style=" height: 500px; border-radius: 10px; " class="col-md-6 col-xs-12"></div>
|
||
5 years ago
|
{% endif %}
|
||
5 years ago
|
|
||
|
|
||
5 years ago
|
{% endblock %}
|
||
|
|
||
|
{% block scripts %}
|
||
|
{{ super() }}
|
||
5 years ago
|
{{ moment.include_moment() }}
|
||
5 years ago
|
<script type="text/javascript", crossorigin="anonymous">
|
||
|
// Leaflet Map
|
||
|
var map = L.map( 'map', {
|
||
|
center: [52.2, 5.3],
|
||
|
minZoom: 6,
|
||
|
maxZoom: 19,
|
||
|
bounds: [[50.5, 3.25], [54, 7.6]],
|
||
|
zoom: 8
|
||
|
});
|
||
|
L.control.scale().addTo(map);
|
||
|
|
||
|
L.tileLayer( 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaartpastel/EPSG:3857/{z}/{x}/{y}.png', {
|
||
|
attribution: 'Kaartgegevens © <a href="kadaster.nl">Kadaster</a>'
|
||
|
}).addTo( map );
|
||
|
|
||
5 years ago
|
var objectives = JSON.parse('{{ json.dumps(game.objectives, cls=objective_encoder)|safe }}')
|
||
5 years ago
|
|
||
|
for (var i = 0; i < objectives.length; i++){
|
||
|
var objectiveMarker = L.marker([
|
||
|
objectives[i]['latitude'],
|
||
|
objectives[i]['longitude']
|
||
|
]).addTo(map);
|
||
|
objectiveMarker.bindTooltip(`<b>${objectives[i]['name']}</b><br>
|
||
|
${objectives[i]['hash']}`).openPopup();
|
||
|
}
|
||
|
|
||
5 years ago
|
var greenIcon = new L.Icon({
|
||
|
iconUrl: "{{ url_for('static', filename='assets/leaflet/images/marker-icon-2x-green.png') }}",
|
||
|
shadowUrl: "{{ url_for('static', filename='assets/leaflet/images/marker-shadow.png') }}",
|
||
|
iconSize: [25, 41],
|
||
|
iconAnchor: [12, 41],
|
||
|
popupAnchor: [1, -34],
|
||
|
shadowSize: [41, 41]
|
||
|
});
|
||
|
|
||
|
var players = JSON.parse('{{ json.dumps(game.last_player_locations(), cls=location_encoder)|safe }}')
|
||
|
for (var i = 0; i < players.length; i++){
|
||
|
var playerMarker = L.marker([
|
||
|
players[i]['latitude'],
|
||
|
players[i]['longitude']
|
||
|
], {icon: greenIcon}).addTo(map);
|
||
|
var timestamp_utc = moment.utc(players[i]['timestamp_utc']).toDate()
|
||
|
var timestamp_local = moment(timestamp_utc).local().format('YYYY-MM-DD HH:mm');
|
||
|
playerMarker.bindTooltip(`<b>${players[i]['player_name']}</b><br>
|
||
|
${timestamp_local}`).openPopup();
|
||
|
}
|
||
5 years ago
|
|
||
|
</script>
|
||
5 years ago
|
{% endblock %}
|