Commit 5a41f843 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

show zugbildung (if available); show scheduled wagon order for nightjets too

parent 2016a340
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ sub startup {
			spare   => $ENV{DBFAKEDISPLAY_SPARE}   // 2,
			workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
		},
		version => $ENV{DBFAKEDISPLAY_VERSION} // qx{git describe --dirty} // '???',
		version => $ENV{DBFAKEDISPLAY_VERSION} // qx{git describe --dirty}
		  // '???',
	);

	chomp $self->config->{version};
@@ -103,10 +104,11 @@ sub startup {
			my $ice_type_map = JSON->new->utf8->decode(
				scalar read_file('share/zugbildungsplan.json') );
			my $ret;
			while ( my ( $k, $v ) = each %{$ice_type_map} ) {
			while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) {
				if ( $v->{type} ) {
					$ret->{$k}
					  = [ $v->{type}, $v->{short}, exists $v->{wagon} ? 1 : 0 ];
					  = [ $v->{type}, $v->{short},
						exists $v->{wagons} ? 1 : 0 ];
				}
			}
			return $ret;
@@ -116,7 +118,7 @@ sub startup {
	$self->attr(
		train_details_db => sub {
			return JSON->new->utf8->decode(
				scalar read_file('share/zugbildungsplan.json') );
				scalar read_file('share/zugbildungsplan.json') )->{train};
		}
	);

+3 −1
Original line number Diff line number Diff line
@@ -673,6 +673,8 @@ sub render_train {
				departure => $departure,
				linetype  => $linetype,
				icetype => $self->app->ice_type_map->{ $departure->{train_no} },
				details =>
				  $self->app->train_details_db->{ $departure->{train_no} },
				dt_now       => DateTime->now( time_zone => 'Europe/Berlin' ),
				station_name => $station_name,
				nav_link     => '/' . $station_name,
+11 −3
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ package DBInfoscreen::Controller::Wagenreihung;

use Mojo::Base 'Mojolicious::Controller';

use utf8;

use Travel::Status::DE::DBWagenreihung;
use Travel::Status::DE::DBWagenreihung::Wagon;

@@ -24,11 +26,12 @@ sub zugbildung_db {

	my @wagons;

	for my $wagon_number ( sort { $a <=> $b } keys %{ $details->{wagon} } ) {
	for my $wagon ( @{ $details->{wagons} } ) {
		my ( $wagon_type, $wagon_number ) = @{$wagon};
		my %wagon = (
			fahrzeugnummer      => "",
			fahrzeugtyp         => $details->{wagon}{$wagon_number},
			kategorie           => "",
			fahrzeugtyp         => $wagon_type,
			kategorie           => $wagon_type =~ m{^[0-9.]+$} ? 'LOK' : '',
			train_no            => $train_no,
			wagenordnungsnummer => $wagon_number,
			positionamhalt      => {
@@ -56,10 +59,15 @@ sub zugbildung_db {
	my $train_type = $details->{raw};
	$train_type =~ s{ - .* }{}x;

	my $route_start = $details->{route}{start} // $details->{route}{preStart};
	my $route_end   = $details->{route}{end}   // $details->{route}{postEnd};
	my $route       = "${route_start}${route_end}";

	$self->render(
		'zugbildung_db',
		wr_error  => undef,
		title     => $train_type . ' ' . $train_no,
		route     => $route,
		zb        => $details,
		train_no  => $train_no,
		wagons    => [@wagons],
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+41 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@
        <a class="smallbutton" href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>"><i class="material-icons" aria-hidden="true">train</i> Wagenreihung
        </a>
%     }
%     elsif ($icetype and $icetype->[2] and $linetype eq 'fern') {
%     elsif ($icetype and $icetype->[2] and ($linetype eq 'fern' or $departure->{train_type} =~ m{NJ})) {
        <a class="smallbutton" href="/wr/<%= $departure->{train_no} %>"><i class="material-icons" aria-hidden="true">train</i> Plan: <%= $icetype->[0] %></a>
%     }
%     elsif ($icetype and $icetype->[1] and $linetype eq 'fern') {
@@ -227,5 +227,45 @@
          </li>
%       }
      </ul> <!-- mroute -->
%   }
%   if ($details and not $departure->{arrival}) {
%     if (my $s = $details->{route}{preStart}) {
        Zug wird voraussichtlich aus <%= $s %> eingesetzt.<br/><br/>
%     }
%     if ($details->{cycle}{from}) {
        Bildung möglicherweise aus
        <ul>
%         for my $train_no (sort {$a <=> $b} @{ $details->{cycle}{from} // [] }) {
%           my $train = app->train_details_db->{$train_no};
%           my $tt = $train->{type} // $train->{raw} // 'Zug';
%           $tt =~ s{ .*|[0-9]}{};
            <li><%= $tt %> <%= $train_no %>
%             if ($train->{route}{start} and $train->{route}{end}) {
                <%= $train->{route}{start} %> → <%= $train->{route}{end} %>
%             }
            </li>
%         }
        </ul>
%     }
%   }
%   elsif ($details and not $departure->{departure}) {
%     if (my $e = $details->{route}{postEnd}) {
        Zug wird voraussichtlich in <%= $e %> abgestellt.<br/><br/>
%     }
%     if ($details->{cycle}{to}) {
        Weiterfahrt möglicherweise als
        <ul>
%         for my $train_no (sort {$a <=> $b} @{ $details->{cycle}{to} // [] }) {
%           my $train = app->train_details_db->{$train_no};
%           my $tt = $train->{type} // $train->{raw} // 'Zug';
%           $tt =~ s{ .*|[0-9]}{};
            <li><%= $tt %> <%= $train_no %>
%             if ($train->{route}{start} and $train->{route}{end}) {
                <%= $train->{route}{start} %> → <%= $train->{route}{end} %>
%             }
            </li>
%         }
        </ul>
%     }
%   }
    </div> <!-- mfooter -->
Loading