messy filter support
This commit is contained in:
parent
6773e6ae30
commit
b7ec6a292f
15 changed files with 445 additions and 103 deletions
|
|
@ -73,6 +73,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
<div style="display: flex; align-items: center;">
|
||||
{% call scope::route_symbol(route) %}
|
||||
{% endcall %}
|
||||
<h1 style="margin-left: 15px;">{{ route.name }}</h1>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -10,19 +10,91 @@
|
|||
{% for route in routes %}
|
||||
<div style="margin-right: 5px">
|
||||
{% call scope::route_symbol(route) %}
|
||||
{% endcall %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{#{% if let libseptastic::stop::StopType::MultiPlatform(platforms) = stop.platforms %}
|
||||
<div>
|
||||
<p>Platforms at this station:</p>
|
||||
{% for platform in platforms %}
|
||||
<p><a href="/stop/{{ platform.id }}">{{ platform.name }}</a></p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}#}
|
||||
<details>
|
||||
<summary><p style="font-weight: bold; font-size: large;">Filters</p></summary>
|
||||
<form hx-trigger="submit" hx-get="/stop/{{ stop.id }}/table" hx-target="#nta-table" hx-swap="outerHTML" hx-push-url="/stop/{{ stop.id}}">
|
||||
<div style="margin: 5px; padding: 10px; background-color: #eee;">
|
||||
<div style="display: flex; flex-wrap: wrap;">
|
||||
<fieldset style="flex-grow: 1;">
|
||||
<legend>Route</legend>
|
||||
{% for route in routes %}
|
||||
{% for dir in route.directions %}
|
||||
{% if let Some(fil) = filters && let Some(rts) = fil.routes %}
|
||||
{% let route_filter_id = format!("{},{}", route.id, dir.direction) %}
|
||||
<input type="checkbox" class="route-checkbox" name="routes" id="{{ route.id }},{{ dir.direction }}" value="{{ route.id }},{{ dir.direction}}" checked="{{ rts.contains(&*route_filter_id) }}">
|
||||
{% else %}
|
||||
<input type="checkbox" class="route-checkbox" name="routes" id="{{ route.id }},{{ dir.direction }}" value="{{ route.id }},{{ dir.direction}}" checked="true">
|
||||
{% endif %}
|
||||
|
||||
<div hx-get="/stop/{{ stop.id }}/table" hx-trigger="every 5s">
|
||||
{% call stop_table::stop_table(trips, current_time) %}
|
||||
<label for="{{ route.id }},{{ dir.direction }}">
|
||||
<b>{{ route.short_name }}</b>: {{ dir.direction_destination }}
|
||||
</label>
|
||||
<br>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
<input type="checkbox" id="master"
|
||||
hx-on:click="document.querySelectorAll('.route-checkbox').forEach(c => c.checked = this.checked)">
|
||||
<label for="master">Select/Deselect All</label>
|
||||
</fieldset>
|
||||
<div style="flex-grow: 1;">
|
||||
<fieldset>
|
||||
<legend>Ride Options</legend>
|
||||
{% if let Some(fil) = filters && let Some(lt) = fil.live_tracked %}
|
||||
<input type="checkbox" name="live_tracked" id="live_tracked" value="true" checked="{{ lt }}">
|
||||
{% else %}
|
||||
<input type="checkbox" name="live_tracked" id="live_tracked" value="true" checked="true">
|
||||
{% endif %}
|
||||
<label for="live-tracked">
|
||||
Live Tracked
|
||||
</label>
|
||||
<br>
|
||||
{% if let Some(fil) = filters && let Some(sc) = fil.scheduled %}
|
||||
<input type="checkbox" name="scheduled" id="scheduled" value="true" checked="{{ sc }}">
|
||||
{% else %}
|
||||
<input type="checkbox" name="scheduled" id="scheduled" value="true" checked="true">
|
||||
{% endif %}
|
||||
<label for="scheduled">
|
||||
Scheduled
|
||||
</label>
|
||||
<br>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Crowding</legend>
|
||||
{% for avail in SeatAvailability::iter() %}
|
||||
|
||||
{% if let Some(fil) = filters && let Some(crd) = fil.crowding %}
|
||||
<input type="checkbox" name="crowding" id="{{ avail.to_string() }}" value="{{ avail.to_string() }}" checked="{{ crd.contains(&avail) }}">
|
||||
{% else %}
|
||||
<input type="checkbox" name="crowding" id="{{ avail.to_string() }}" value="{{ avail.to_string() }}" checked="true">
|
||||
{% endif %}
|
||||
<label for="{{ avail.to_string() }}">
|
||||
{{ avail.to_human_string() }}
|
||||
</label>
|
||||
<br>
|
||||
{% endfor %}
|
||||
|
||||
{% if let Some(fil) = filters && let Some(uc) = fil.unknown_crowding %}
|
||||
<input type="checkbox" name="unknown_crowding" id="unknown_crowding" value="true" checked="{{ uc }}">
|
||||
{% else %}
|
||||
<input type="checkbox" name="unknown_crowding" id="unknown_crowding" value="true" checked="true">
|
||||
{% endif %}
|
||||
<label for="scheduled">
|
||||
Unknown
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="Apply">
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
<div style="overflow-x: scroll; max-width: 100%;">
|
||||
{% call stop_table::stop_table(trips, current_time, stop.id, query_str) %}
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,51 +1,73 @@
|
|||
{%- import "route_symbol.html" as scope -%}
|
||||
|
||||
{% macro stop_table(trips, current_time) %}
|
||||
<table class="train-direction-table">
|
||||
<tr>
|
||||
<th>ROUTE</th>
|
||||
<th>DESTINATION</th>
|
||||
<th>BOARDING AREA</th>
|
||||
<th>TIME</th>
|
||||
<th>VEHICLE</th>
|
||||
</tr>
|
||||
{% for trip in trips %}
|
||||
<tr>
|
||||
<td>
|
||||
{% call scope::route_symbol(trip.trip.route) %}
|
||||
</td>
|
||||
<td>
|
||||
<p>{{ trip.trip.direction.direction_destination }}</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>{{ trip.perspective_stop.platform.name }}</p>
|
||||
</td>
|
||||
{% if let Tracked(tracked_trip) = trip.trip.tracking_data %}
|
||||
<td style="color: #008800">
|
||||
<p style="font-size: small;">{{ &trip.perspective_stop.get_arrival_time(&tracked_trip) | format_time }}</p>
|
||||
<p style="font-size: x-small; font-style: italic;">{{ ( trip.perspective_stop.get_arrival_time(&tracked_trip) - current_time) / 60 }} mins</p>
|
||||
</td>
|
||||
{% else %}
|
||||
<td>
|
||||
<p style="font-size: small;">{{ trip.perspective_stop.arrival_time | format_time }}</p>
|
||||
<p style="font-size: x-small; font-style: italic;">{{ (trip.perspective_stop.arrival_time - current_time) / 60 }} mins</p>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if let Tracked(tracked_trip) = trip.trip.tracking_data %}
|
||||
{% macro stop_table(trips, current_time, stop_id, query_str) %}
|
||||
<div id="nta-table" hx-get="/stop/{{ stop_id }}/table?{{ query_str }}" hx-trigger="every 5s" hx-swap="outer-html">
|
||||
<table class="train-direction-table">
|
||||
<tr>
|
||||
<th>ROUTE</th>
|
||||
<th>DESTINATION</th>
|
||||
<th>BOARDING AREA</th>
|
||||
<th>TIME</th>
|
||||
<th>VEHICLE</th>
|
||||
<th>TRIP</th>
|
||||
<th>CROWDING</th>
|
||||
</tr>
|
||||
{% for trip in trips %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ tracked_trip.vehicle_ids.join(", ") }}
|
||||
{% call scope::route_symbol(trip.trip.route) %}
|
||||
{% endcall %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td>
|
||||
-
|
||||
<p>{{ trip.trip.direction.direction_destination }}</p>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<p>Updated at: {{ current_time | format_time_with_seconds }}</p>
|
||||
<td>
|
||||
<p>{{ trip.perspective_stop.platform.name }}</p>
|
||||
</td>
|
||||
{% if let Tracked(tracked_trip) = trip.trip.tracking_data %}
|
||||
<td style="color: #008800">
|
||||
<p style="font-size: small;">{{ &trip.perspective_stop.get_arrival_time(&tracked_trip) | format_time }}</p>
|
||||
<p style="font-size: x-small; font-style: italic;">{{ ( trip.perspective_stop.get_arrival_time(&tracked_trip) - current_time) / 60 }} mins</p>
|
||||
<p style="font-size: x-small; font-style: italic;">{{ tracked_trip.delay.round() }} late</p>
|
||||
</td>
|
||||
{% else %}
|
||||
<td>
|
||||
<p style="font-size: small;">{{ trip.perspective_stop.arrival_time | format_time }}</p>
|
||||
<p style="font-size: x-small; font-style: italic;">{{ (trip.perspective_stop.arrival_time - current_time) / 60 }} mins</p>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if let Tracked(tracked_trip) = trip.trip.tracking_data %}
|
||||
<td>
|
||||
{{ tracked_trip.vehicle_ids.join(", ") }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% else %}
|
||||
<td>
|
||||
-
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>{{ trip.trip.trip_id }}</td>
|
||||
{% if let Tracked(tracked_trip) = trip.trip.tracking_data %}
|
||||
{% if let Some(seat_avail) = tracked_trip.seat_availability %}
|
||||
<td>
|
||||
{{ seat_avail.to_human_string() }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td>
|
||||
N/A
|
||||
</td>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<td>
|
||||
-
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<p>Updated at: {{ current_time | format_time_with_seconds }}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{%- import "stop_table.html" as stop_table -%}
|
||||
|
||||
{% call stop_table::stop_table(trips, current_time) %}
|
||||
{% call stop_table::stop_table(trips, current_time, stop_id, query_str) %}
|
||||
{% endcall %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue