Unverified Commit 167b01fa authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

link traewelling profile from travelynx profile; show traewelling status

parent ef325286
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1822,6 +1822,27 @@ sub startup {
					comment       => $in_transit->{user_data}{comment},
				};

				my $traewelling = $self->traewelling->get(
					uid => $uid,
					db  => $db
				);
				if ( $traewelling->{latest_run}
					>= epoch_to_dt( $in_transit->{checkin_ts} ) )
				{
					$ret->{traewelling} = $traewelling;
					if ( @{ $traewelling->{data}{log} // [] }
						and ( my $log_entry = $traewelling->{data}{log}[0] ) )
					{
						if ( $log_entry->[2] ) {
							$ret->{traewelling_status} = $log_entry->[2];
							$ret->{traewelling_url}
							  = 'https://traewelling.de/status/'
							  . $log_entry->[2];
						}
						$ret->{traewelling_log_latest} = $log_entry->[1];
					}
				}

				my @parsed_messages;
				for my $message ( @{ $ret->{messages} // [] } ) {
					my ( $ts, $msg ) = @{$message};
+4 −3
Original line number Diff line number Diff line
package Travelynx::Controller::Traewelling;

# Copyright (C) 2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
+4 −3
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ sub checkin {
				$self->{model}->log(
					uid     => $opt{uid},
					message =>
					  "Fehler bei $opt{train_type} $opt{train_no}: $err_msg",
"Checkin-Fehler bei $opt{train_type} $opt{train_no}: $err_msg",
					is_error => 1
				);
				return;
@@ -391,7 +391,8 @@ sub checkin {
			$self->{log}->debug("... error: $err");
			$self->{model}->log(
				uid     => $opt{uid},
				message  => "Fehler bei $opt{train_type} $opt{train_no}: $err",
				message =>
				  "Checkin-Fehler bei $opt{train_type} $opt{train_no}: $err",
				is_error => 1
			);
		}
+14 −0
Original line number Diff line number Diff line
@@ -278,6 +278,20 @@
						</ul>
					</p>
				% }
				% if ($journey->{traewelling}{errored} and $journey->{traewelling_log_latest}) {
					<p style="margin-bottom: 2ex;">
						<ul>
							<li> <i class="material-icons tiny">warning</i> Träwelling: <%= $journey->{traewelling_log_latest} %></li>
						</ul>
					</p>
				% }
				% if ($journey->{traewelling_url}) {
					<p style="margin-bottom: 2ex;">
						<ul>
							<li> <i class="material-icons tiny">sync</i> Träwelling: <a href="<%= $journey->{traewelling_url} %>"><%= $journey->{traewelling_log_latest} %></a></li>
						</ul>
					</p>
				% }
			</div>
			<div class="card-action">
				% my $url = 'https://marudor.de/details/' . $journey->{train_type} . ' ' . $journey->{train_no} . '/' . DateTime->now(time_zone => 'Europe/Berlin')->epoch . '000';
+6 −2
Original line number Diff line number Diff line
@@ -148,8 +148,12 @@
			% }
		</div>
		<div class="card-action">
			% if ($journey->{traewelling_url}) {
				<a style="margin-right: 0;" href="<%= $journey->{traewelling_url} %>"><i class="material-icons left">timeline</i> Träwelling</a>
			% } else {
				% my $url = 'https://marudor.de/details/' . $journey->{train_type} . ' ' . $journey->{train_no} . '/' . DateTime->now(time_zone => 'Europe/Berlin')->epoch . '000';
				<a style="margin-right: 0;" href="<%= $url %>"><i class="material-icons left">timeline</i> Zuglauf</a>
			% }
			% if ($journey->{extra_data}{trip_id}) {
				<a class="right" style="margin-right: 0;" href="https://dbf.finalrewind.org/map/<%= $journey->{extra_data}{trip_id} %>/<%= $journey->{train_line} || 0 %>?from=<%= $journey->{dep_name} %>&amp;to=<%= $journey->{arr_name} // '' %>"><i class="material-icons left">map</i> Karte</a>
			% }
Loading