show boarding countdown in departure overview
This commit is contained in:
parent
0439aa8b02
commit
c9592e3f76
2 changed files with 40 additions and 8 deletions
|
@ -2364,6 +2364,7 @@ sub startup {
|
|||
|
||||
my @route = @{ $in_transit->{route} // [] };
|
||||
my @route_after;
|
||||
my $dep_info;
|
||||
my $stop_before_dest;
|
||||
my $is_after = 0;
|
||||
for my $station (@route) {
|
||||
|
@ -2379,6 +2380,11 @@ sub startup {
|
|||
}
|
||||
if ( $station->[0] eq $in_transit->{dep_name} ) {
|
||||
$is_after = 1;
|
||||
$self->app->log->debug("is_after");
|
||||
if ( @{$station} > 1 ) {
|
||||
$self->app->log->debug("set dep_info");
|
||||
$dep_info = $station->[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
my $stop_after_dep = $route_after[0][0];
|
||||
|
@ -2396,6 +2402,7 @@ sub startup {
|
|||
train_line => $in_transit->{train_line},
|
||||
train_no => $in_transit->{train_no},
|
||||
train_id => $in_transit->{train_id},
|
||||
boarding_countdown => -1,
|
||||
sched_departure =>
|
||||
epoch_to_dt( $in_transit->{sched_dep_ts} ),
|
||||
real_departure => epoch_to_dt( $in_transit->{real_dep_ts} ),
|
||||
|
@ -2426,6 +2433,22 @@ sub startup {
|
|||
}
|
||||
$ret->{extra_data}{qos_msg} = [@parsed_messages];
|
||||
|
||||
if ( $dep_info and $dep_info->{sched_arr} ) {
|
||||
$self->app->log->debug(
|
||||
"dep_info has sched_arr. set countdown.");
|
||||
$dep_info->{sched_arr}
|
||||
= epoch_to_dt( $dep_info->{sched_arr} );
|
||||
$dep_info->{rt_arr} = $dep_info->{sched_arr}->clone;
|
||||
if ( $dep_info->{adelay}
|
||||
and $dep_info->{adelay} =~ m{^\d+$} )
|
||||
{
|
||||
$dep_info->{rt_arr}
|
||||
->add( minutes => $dep_info->{adelay} );
|
||||
}
|
||||
$dep_info->{rt_arr_countdown} = $ret->{boarding_countdown}
|
||||
= $dep_info->{rt_arr}->epoch - $epoch;
|
||||
}
|
||||
|
||||
for my $station (@route_after) {
|
||||
if ( @{$station} > 1 ) {
|
||||
my $times = $station->[1];
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
<div class="center-align countdown"
|
||||
data-duration="<%= $journey->{journey_duration} // 0 %>"
|
||||
data-arrival="<%= $journey->{real_arrival}->epoch %>">
|
||||
% if ($journey->{boarding_countdown} > 120) {
|
||||
Einfahrt in <%= sprintf('%.f', $journey->{boarding_countdown} / 60) %> Minuten<br/>
|
||||
% }
|
||||
% elsif ($journey->{boarding_countdown} > 60) {
|
||||
Einfahrt in einer Minute<br/>
|
||||
% }
|
||||
% elsif ($journey->{boarding_countdown} > 0) {
|
||||
Zug fährt ein<br/>
|
||||
% }
|
||||
% if ($journey->{departure_countdown} > 120) {
|
||||
Abfahrt in <%= sprintf('%.f', $journey->{departure_countdown} / 60) %> Minuten
|
||||
% }
|
||||
|
|
Loading…
Reference in a new issue