agenda/templates/trip/list.html

237 lines
7.8 KiB
HTML
Raw Normal View History

{% extends "base.html" %}
{% from "macros.html" import trip_link, display_date_no_year, display_date, display_datetime, display_time, format_distance with context %}
2024-05-18 15:43:06 +01:00
{% block title %}{{ heading }} - Edward Betts{% endblock %}
{% block style %}
<link rel="stylesheet" href="{{ url_for("static", filename="leaflet/leaflet.css") }}">
<style>
2024-05-20 17:33:53 +01:00
body, html {
height: 100%;
margin: 0;
}
.container-fluid {
height: calc(100% - 56px); /* Subtracting the height of the navbar */
}
.text-content {
overflow-y: scroll;
height: 100%;
}
.map-container {
position: sticky;
top: 56px; /* Adjust to be below the navbar */
height: calc(100vh - 56px); /* Subtracting the height of the navbar */
}
.half-map {
height: 100vh;
}
.full-window-map {
position: fixed; /* Make the map fixed position */
top: 60px;
left: 0;
right: 0;
bottom: 0;
z-index: 9999; /* Make sure it sits on top */
}
#toggleMapSize {
position: fixed; /* Fixed position */
top: 70px; /* 10px from the top */
right: 10px; /* 10px from the right */
z-index: 10000; /* Higher than the map's z-index */
2024-05-20 17:33:53 +01:00
}
@media (max-width: 767.98px) {
.container-fluid {
display: block;
height: auto;
}
.map-container {
position: relative;
top: 0;
height: 50vh; /* Adjust as needed */
}
.text-content {
height: auto;
overflow-y: auto;
}
}
</style>
{% endblock %}
{% macro section(heading, item_list) %}
{% set items = item_list | list %}
<div class="heading"><h2>{{ heading }}</h2></div>
<p><a href="{{ url_for("trip_stats") }}">Trip statistics</a></p>
<p>{{ items | count }} trips</p>
{% if item_list %}
<div>Total distance: {{ format_distance(total_distance) }}</div>
{% for transport_type, distance in distances_by_transport_type %}
<div>
{{ transport_type | title }}
distance: {{format_distance(distance) }}
</div>
{% endfor %}
{% for trip in items %}
2024-05-18 15:44:18 +01:00
{% set distances_by_transport_type = trip.distances_by_transport_type() %}
{% set total_distance = trip.total_distance() %}
{% set end = trip.end %}
<div class="border border-2 rounded mb-2 p-2">
<h3>
{{ trip_link(trip) }}
<small class="text-muted">({{ display_date(trip.start) }})</small></h3>
2024-05-18 15:44:18 +01:00
<ul class="list-unstyled">
{% for c in trip.countries %}
<li>
{{ c.name }}
{{ c.flag }}
</li>
{% endfor %}
</ul>
{% if end %}
<div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
{% else %}
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
{% endif %}
{% if total_distance %}
<div>
Total distance:
{{ format_distance(total_distance) }}
</div>
{% endif %}
2024-05-18 15:44:18 +01:00
{% if distances_by_transport_type %}
{% for transport_type, distance in distances_by_transport_type %}
<div>
{{ transport_type | title }}
distance: {{format_distance(distance) }}
2024-05-18 15:44:18 +01:00
</div>
{% endfor %}
{% endif %}
2024-05-20 17:32:49 +01:00
{{ conference_list(trip) }}
{% for day, elements in trip.elements_grouped_by_day() %}
<h4>{{ display_date_no_year(day) }}</h4>
{% set accommodation_label = {"check-in": "check-in from", "check-out": "check-out by"} %}
{% for e in elements %}
{% if e.element_type in accommodation_label %}
{% set c = get_country(e.detail.country) %}
2024-05-18 15:53:38 +01:00
<div>
{{ e.get_emoji() }} {{ e.title }} {{ c.flag }}
2024-05-27 09:57:46 +01:00
({{ accommodation_label[e.element_type] }} {{ display_time(e.start_time) }})
2024-05-18 15:53:38 +01:00
</div>
2024-05-18 15:44:18 +01:00
{% else %}
<div>
2024-05-18 15:44:18 +01:00
{{ e.get_emoji() }}
2024-05-27 09:57:46 +01:00
{{ display_time(e.start_time) }}
2024-05-18 17:02:35 +01:00
&ndash;
{{ e.start_loc }} {{ e.start_country.flag }}
2024-05-27 09:57:46 +01:00
{{ display_time(e.end_time) }}
&ndash;
{{ e.end_loc }} {{ e.end_country.flag }}
2024-05-20 19:56:14 +01:00
{% if e.element_type == "flight" %}
2024-06-02 19:01:18 +01:00
{% set full_flight_number = e.detail.airline + e.detail.flight_number %}
{% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %}
2024-05-20 19:56:14 +01:00
<span class="text-nowrap"><strong>airline:</strong> {{ e.detail.airline_name }}</span>
<span class="text-nowrap"><strong>flight number:</strong> {{ e.detail.airline }}{{ e.detail.flight_number }}</span>
{% if e.detail.duration %}
<span class="text-nowrap"><strong>duration:</strong> {{ e.detail.duration }}</span>
{% endif %}
2024-05-20 19:56:14 +01:00
{# <pre>{{ e.detail | pprint }}</pre> #}
{% endif %}
{% if e.detail.distance %}
<span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span>
{% endif %}
2024-06-02 19:01:18 +01:00
{% if e.element_type == "flight" %}
<a href="https://www.flightradar24.com/data/flights/{{ full_flight_number | lower }}">flightradar24</a>
| <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number | replace("U2", "EZY") }}">FlightAware</a>
| <a href="{{ radarbox_url }}">radarbox</a>
{% endif %}
</div>
2024-05-18 15:44:18 +01:00
{% endif %}
{% endfor %}
{% endfor %}
</div>
{% endfor %}
{% endif %}
{% endmacro %}
2024-05-20 17:32:49 +01:00
{% macro conference_list(trip) %}
{% for item in trip.conferences %}
{% set country = get_country(item.country) if item.country else None %}
<div class="card my-1">
<div class="card-body">
<h5 class="card-title">
<a href="{{ item.url }}">{{ item.name }}</a>
<small class="text-muted">
{{ display_date_no_year(item.start) }} to {{ display_date_no_year(item.end) }}
</small>
</h5>
<p class="card-text">
Topic: {{ item.topic }}
| Venue: {{ item.venue }}
| Location: {{ item.location }}
{% if country %}
{{ country.flag }}
{% elif item.online %}
💻 Online
{% else %}
<span class="text-bg-danger p-2">
country code <strong>{{ item.country }}</strong> not found
</span>
{% endif %}
{% if item.free %}
| <span class="badge bg-success text-nowrap">free to attend</span>
{% elif item.price and item.currency %}
| <span class="badge bg-info text-nowrap">price: {{ item.price }} {{ item.currency }}</span>
{% endif %}
</p>
</div>
</div>
{% endfor %}
{% endmacro %}
{% block content %}
<div class="container-fluid d-flex flex-column flex-md-row">
<div class="map-container col-12 col-md-6 order-1 order-md-2">
<button id="toggleMapSize" class="btn btn-primary mb-2">Toggle map size</button>
<div id="map" class="map half-map"></div>
</div>
<div class="text-content col-12 col-md-6 order-2 order-md-1 pe-3">
{{ section(heading, trips) }}
</div>
</div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for("static", filename="leaflet/leaflet.js") }}"></script>
<script src="{{ url_for("static", filename="leaflet-geodesic/leaflet.geodesic.umd.min.js") }}"></script>
<script src="{{ url_for("static", filename="js/map.js") }}"></script>
<script>
var coordinates = {{ coordinates | tojson }};
var routes = {{ routes | tojson }};
build_map("map", coordinates, routes);
</script>
{% endblock %}