From 2a55a8f7c6b5a8d3b8619b5014389d9ad2c99937 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 31 Oct 2022 16:37:32 +0100 Subject: train details: show operator and additional HIM messages --- lib/DBInfoscreen/Controller/Stationboard.pm | 24 +++++++++++++++++++++--- templates/_train_details.html.ep | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 735cbe7..c2a5f80 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -676,7 +676,8 @@ sub render_train { sub { my ( $route_ts, $journey ) = @_; - $departure->{trip_id} = $journey->id; + $departure->{trip_id} = $journey->id; + $departure->{operator} = $journey->operator; if ( my $load = $route_ts->{$station_name}{load} ) { if ( %{$load} ) { @@ -755,8 +756,14 @@ sub render_train { } my @him_messages; + my @him_details; for my $message ( $journey->messages ) { - if ( not $message->code ) { + if ( $message->code ) { + push( @him_details, + [ $message->short // q{}, { text => $message->text } ] + ); + } + else { push( @him_messages, [ $message->short // q{}, { text => $message->text } ] ); @@ -775,6 +782,7 @@ sub render_train { $m->[0] =~ s{(?!<)->}{ → }; } unshift( @{ $departure->{moreinfo} }, @him_messages ); + unshift( @{ $departure->{details} }, @him_details ); } )->catch( sub { @@ -1010,6 +1018,7 @@ sub train_details { $res->{origin} = $journey->route_start; $res->{destination} = $journey->route_end; + $res->{operator} = $journey->operator; $res->{route_post_diff} = [ map { { name => $_->{name} } } $journey->route ]; @@ -1020,8 +1029,14 @@ sub train_details { } my @him_messages; + my @him_details; for my $message ( $journey->messages ) { - if ( not $message->code ) { + if ( $message->code ) { + push( @him_details, + [ $message->short // q{}, { text => $message->text } ] + ); + } + else { push( @him_messages, [ $message->short // q{}, { text => $message->text } ] ); @@ -1041,6 +1056,9 @@ sub train_details { if (@him_messages) { $res->{moreinfo} = [@him_messages]; } + if (@him_details) { + $res->{details} = [@him_details]; + } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', diff --git a/templates/_train_details.html.ep b/templates/_train_details.html.ep index 9a440ef..2d61939 100644 --- a/templates/_train_details.html.ep +++ b/templates/_train_details.html.ep @@ -288,6 +288,31 @@ % } % } +% if ($departure->{operator}) { +
Betrieb: <%= $departure->{operator} %>
+% } +% if ($departure->{details} and @{$departure->{details}}) { + Details: + +% } % if ($departure->{has_cycle}) {
Umlaufplan (ggf. fehlerhaft)
-- cgit v1.2.3