diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-04-23 18:08:07 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-04-23 18:08:07 +0200 |
commit | e168d9cd39c38b8e5a1994c8bf11376d26e9ea77 (patch) | |
tree | dee321d330a8fc9c106c18863db179972c9abac6 /templates | |
parent | 812be4f0cbeb74db379a2c931ceb2c88bd9fabf7 (diff) |
Use one row per journey instead of split checkin/checkout entries
Whether a user is in transit or not is now determined by an entry in the
in_transit table instead of a dangling checkin.
All completed journeys are stored in the "journeys" table.
This does most of the work needed for automatic checkout. However, note that
the corresponding worker process is not implemented yet.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_history_trains.html.ep | 72 | ||||
-rw-r--r-- | templates/departures.html.ep | 12 | ||||
-rw-r--r-- | templates/edit_journey.html.ep | 2 | ||||
-rw-r--r-- | templates/journey.html.ep | 2 | ||||
-rw-r--r-- | templates/landingpage.html.ep | 86 | ||||
-rw-r--r-- | templates/layouts/default.html.ep | 2 |
6 files changed, 117 insertions, 59 deletions
diff --git a/templates/_history_trains.html.ep b/templates/_history_trains.html.ep index def83d6..2328285 100644 --- a/templates/_history_trains.html.ep +++ b/templates/_history_trains.html.ep @@ -11,46 +11,44 @@ </thead> <tbody> % for my $travel (@{$journeys}) { - % if ($travel->{completed}) { - % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{ids}->[1]; - <tr> - <td><%= $travel->{sched_departure}->strftime('%d.%m.') %></td> - <td><a href="<%= $detail_link %>"><%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %></a></td> - <td> - <a href="<%= $detail_link %>" class="unmarked"> - % if (param('cancelled')) { - %= $travel->{sched_departure}->strftime('%H:%M') + % my $detail_link = '/journey/' . $travel->{id}; + <tr> + <td><%= $travel->{sched_departure}->strftime('%d.%m.') %></td> + <td><a href="<%= $detail_link %>"><%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %></a></td> + <td> + <a href="<%= $detail_link %>" class="unmarked"> + % if (param('cancelled')) { + %= $travel->{sched_departure}->strftime('%H:%M') + % } + % else { + <%= $travel->{rt_departure}->strftime('%H:%M') %> + % if ($travel->{sched_departure} != $travel->{rt_departure}) { + (<%= sprintf('%+d', ($travel->{rt_departure}->epoch - $travel->{sched_departure}->epoch) / 60) %>) % } - % else { - <%= $travel->{rt_departure}->strftime('%H:%M') %> - % if ($travel->{sched_departure} != $travel->{rt_departure}) { - (<%= sprintf('%+d', ($travel->{rt_departure}->epoch - $travel->{sched_departure}->epoch) / 60) %>) + % } + <br/> + <%= $travel->{from_name} %> + </a> + </td> + <td> + <a href="<%= $detail_link %>" class="unmarked"> + % if (param('cancelled') and $travel->{sched_arrival}->epoch != 0) { + %= $travel->{sched_arrival}->strftime('%H:%M') + % } + % else { + % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { + <i class="material-icons">timer_off</i> + % } else { + %= $travel->{rt_arrival}->strftime('%H:%M'); + % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { + (<%= sprintf('%+d', ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60) %>) % } % } - <br/> - <%= $travel->{from_name} %> - </a> - </td> - <td> - <a href="<%= $detail_link %>" class="unmarked"> - % if (param('cancelled') and $travel->{sched_arrival}->epoch != 0) { - %= $travel->{sched_arrival}->strftime('%H:%M') - % } - % else { - % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { - <i class="material-icons">timer_off</i> - % } else { - %= $travel->{rt_arrival}->strftime('%H:%M'); - % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { - (<%= sprintf('%+d', ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60) %>) - % } - % } - % } - <br/> - <%= $travel->{to_name} %> - </a></td> - </tr> - % } + % } + <br/> + <%= $travel->{to_name} %> + </a></td> + </tr> % } </tbody> </table> diff --git a/templates/departures.html.ep b/templates/departures.html.ep index 1240d1d..7d33417 100644 --- a/templates/departures.html.ep +++ b/templates/departures.html.ep @@ -6,10 +6,10 @@ <div class="card-content white-text"> <span class="card-title">Aktuell eingecheckt</span> <p>In <%= $status->{train_type} %> <%= $status->{train_no} %> - ab <%= $status->{station_name} %></p> + ab <%= $status->{dep_name} %></p> </div> <div class="card-action"> - <a class="action-checkout" data-station="<%= $ds100 %>"> + <a class="action-checkout" data-station="<%= $ds100 %>" data-force="1"> Hier auschecken </a> </div> @@ -20,10 +20,10 @@ <div class="card-content white-text"> <span class="card-title">Ausgecheckt</span> <p>Aus <%= $status->{train_type} %> <%= $status->{train_no} %> - bis <%= $status->{station_name} %></p> + bis <%= $status->{arr_name} %></p> </div> <div class="card-action"> - <a class="action-undo" data-id="<%= $status->{action_id} %>"> + <a class="action-undo" data-id="<%= $status->{journey_id} %>"> <i class="material-icons">undo</i> Rückgängig? </a> </div> @@ -38,8 +38,8 @@ – Zug auswählen zum Einchecken. % } % else { - – Keine Abfahrten gefunden. Ein Checkin ist frühestens 10 Minuten vor - und maximal 180 Minuten nach Abfahrt möglich. + – Keine Abfahrten gefunden. Ein Checkin ist frühestens 30 Minuten vor + und maximal 120 Minuten nach Abfahrt möglich. % } <br/> <table class="striped"> diff --git a/templates/edit_journey.html.ep b/templates/edit_journey.html.ep index 0418d52..c37adba 100644 --- a/templates/edit_journey.html.ep +++ b/templates/edit_journey.html.ep @@ -80,7 +80,7 @@ </div> <div class="row"> <div class="col s6 m6 l6 center-align"> - <a href="/journey/<%= current_user()->{id} %>-<%= param('journey_id') %>" class="waves-effect waves-light btn"> + <a href="/journey/<%= param('journey_id') %>" class="waves-effect waves-light btn"> Abbrechen </a> </div> diff --git a/templates/journey.html.ep b/templates/journey.html.ep index 1e0ccc7..4af9694 100644 --- a/templates/journey.html.ep +++ b/templates/journey.html.ep @@ -161,7 +161,7 @@ <div class="row"> <div class="col s6 m6 l6 center-align"> <a class="waves-effect waves-light red btn action-delete" - data-id="<%= join(q{,}, @{$journey->{ids}}) %>" + data-id="<%= $journey->{id} %>" data-checkin="<%= $journey->{checkin}->epoch %>" data-checkout="<%= $journey->{checkout}->epoch %>"> <i class="material-icons left">delete_forever</i> diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index 5f69fd1..cd14f5c 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -14,26 +14,84 @@ <div class="row"> <div class="col s12"> % my $status = get_user_status(); + % my $now = DateTime->now(time_zone => 'Europe/Berlin'); + % my $dep_wait = ($status->{real_departure}->epoch - $now->epoch)/60; + % my $arr_wait = undef; + % if ($status->{real_arrival}->epoch) { + % $arr_wait = ($status->{real_arrival}->epoch - $now->epoch)/60; + % } % if ($status->{checked_in}) { <div class="card green darken-4"> <div class="card-content white-text"> - <span class="card-title">Hallo, <%= current_user()->{name} %>!</span> - <p>Du bist gerade eingecheckt in - <%= $status->{train_type} %> <%= $status->{train_no} %> - ab <%= $status->{station_name} %>. - % if ($status->{timestamp_delta} < 180) { - <a class="action-undo" data-id="<%= $status->{action_id} %>"><i class="material-icons">undo</i> Rückgängig</a> + <span class="card-title">Eingecheckt</span> + <p> + In <b><%= $status->{train_type} %> <%= $status->{train_no} %></b> + % if ($status->{arr_name}) { + von <b><%= $status->{dep_name} %></b> nach <b><%= $status->{arr_name} %></b>. % } - </p> - <p>Bei Ankunft: Station auswählen zum Auschecken.</p> + % else { + ab <b><%= $status->{dep_name} %></b>. + % } + </p> + <p> + Abfahrt + % if ($dep_wait > 0) { + in <%= int(($status->{real_departure}->epoch - $now->epoch)/60) %> Minute<%= $dep_wait >= 2 ? 'n' : '' %> + % } + um <b><%= $status->{real_departure}->strftime('%H:%M') %></b> + % if ($status->{real_departure}->epoch != $status->{sched_departure}->epoch) { + (+<%= int(($status->{real_departure}->epoch - $status->{sched_departure}->epoch)/60) %>) + % } + </p> + <p> + % if ($status->{real_arrival}->epoch) { + Voraussichtliche Ankunft um <b><%= $status->{real_arrival}->strftime('%H:%M') %></b> + % if ($status->{real_arrival}->epoch != $status->{sched_arrival}->epoch) { + (+<%= int(($status->{real_arrival}->epoch - $status->{sched_arrival}->epoch)/60) %>) + % } + % } + % else { + Ankunft: noch nicht bekannt + % } + </p> + <p> + <b>Achtung:</b> Automatischer Checkout ist noch nicht + implementiert. Bitte spätestens eine Stunde nach Ankunft + am Ziel manuell auschecken. + </p> + % if ($status->{arr_name}) { + <p>Zielstation ändern?</p> + % } + % else { + <p>Zielstation wählen:</p> + % } <table> <tbody> % my $is_after = 0; % for my $station (@{$status->{route_after}}) { - <tr><td><a class="action-checkout" data-station="<%= $station %>"><%= $station %></a></td></tr> + % if ($status->{arr_name} and $station eq $status->{arr_name}) { + <tr><td><b><a class="action-checkout" data-station="<%= $station %>"><%= $station %></a></b></td></tr> + % } + % else { + <tr><td><a class="action-checkout" data-station="<%= $station %>"><%= $station %></a></td></tr> + % } % } </tbody> </table> + % if ($status->{arr_name}) { + <p> + Falls das Backend ausgefallen ist oder der Zug aus anderen + Gründen verloren ging: <a class="action-checkout" + data-force="1" data-station="<%= $status->{arr_name} + %>">Ohne Echtzeitdaten in <%= $status->{arr_name} %> + auschecken</a>. + </p> + % } + </div> + <div class="card-action"> + <a class="action-undo" data-id="in_transit"> + <i class="material-icons">undo</i> Checkin Rückgängig? + </a> </div> </div> % } @@ -44,9 +102,6 @@ <p>Prinzipiell wärest du nun eingecheckt in <%= $status->{train_type} %> <%= $status->{train_no} %> ab <%= $status->{station_name} %>, doch dieser Zug fällt aus. - % if ($status->{timestamp_delta} < 180) { - <a class="action-undo" data-id="<%= $status->{action_id} %>"><i class="material-icons">undo</i> Checkinversuch rückgängig</a> - % } </p> <p>Falls du den Zugausfall z.B. für ein Fahrgastrechteformular dokumentieren möchtest, wähle bitte jetzt deine geplante @@ -62,6 +117,11 @@ </tbody> </table> </div> + <div class="card-action"> + <a class="action-undo" data-id="in_transit"> + <i class="material-icons">undo</i> Checkinversuch Rückgängig? + </a> + </div> </div> % } % else { @@ -91,7 +151,7 @@ </div> </div> <h1>Letzte Fahrten</h1> - %= include '_history_trains', journeys => [get_user_travels(limit => 1)]; + %= include '_history_trains', journeys => [get_user_travels(limit => 5)]; % } % else { <div class="row"> diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 9ab9269..cdd624a 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -5,7 +5,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="theme-color" content="#673ab7"> - % my $av = 'v5'; # asset version + % my $av = 'v6'; # asset version %= stylesheet "/static/${av}/css/materialize.min.css" %= stylesheet "/static/${av}/css/material-icons.css" %= stylesheet "/static/${av}/css/local.css" |