summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-02-16 20:56:28 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-02-16 20:56:28 +0100
commit167b01fa4264a8193ff3cbd9d3f1741f5702235a (patch)
tree6b03555ced3c757269898f8f7ebf46506aa2b06a
parentef3252863e28905fe96a49a91e5a62c156c69e6e (diff)
link traewelling profile from travelynx profile; show traewelling status
-rwxr-xr-xlib/Travelynx.pm21
-rw-r--r--lib/Travelynx/Controller/Traewelling.pm7
-rw-r--r--lib/Travelynx/Helper/Traewelling.pm7
-rw-r--r--templates/_checked_in.html.ep14
-rw-r--r--templates/_public_status_card.html.ep8
-rw-r--r--templates/traewelling.html.ep6
6 files changed, 52 insertions, 11 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 8e29114..40ca0a5 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -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};
diff --git a/lib/Travelynx/Controller/Traewelling.pm b/lib/Travelynx/Controller/Traewelling.pm
index d3e6d6c..21fa3e9 100644
--- a/lib/Travelynx/Controller/Traewelling.pm
+++ b/lib/Travelynx/Controller/Traewelling.pm
@@ -1,4 +1,5 @@
package Travelynx::Controller::Traewelling;
+
# Copyright (C) 2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -78,10 +79,10 @@ sub settings {
elsif ( $self->param('action') and $self->param('action') eq 'config' ) {
$self->traewelling->set_sync(
uid => $uid,
- push_sync => $self->param('sync_source') eq 'travelynx' ? 1 : 0,
+ push_sync => $self->param('sync_source') eq 'travelynx' ? 1 : 0,
pull_sync => $self->param('sync_source') eq 'traewelling' ? 1 : 0,
- toot => $self->param('toot') ? 1 : 0,
- tweet => $self->param('tweet') ? 1 : 0,
+ toot => $self->param('toot') ? 1 : 0,
+ tweet => $self->param('tweet') ? 1 : 0,
);
$self->flash( success => 'traewelling' );
$self->redirect_to('account');
diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm
index 03db4d2..401d9a6 100644
--- a/lib/Travelynx/Helper/Traewelling.pm
+++ b/lib/Travelynx/Helper/Traewelling.pm
@@ -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;
@@ -390,8 +390,9 @@ sub checkin {
my ($err) = @_;
$self->{log}->debug("... error: $err");
$self->{model}->log(
- uid => $opt{uid},
- message => "Fehler bei $opt{train_type} $opt{train_no}: $err",
+ uid => $opt{uid},
+ message =>
+ "Checkin-Fehler bei $opt{train_type} $opt{train_no}: $err",
is_error => 1
);
}
diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep
index 76d11bc..d882501 100644
--- a/templates/_checked_in.html.ep
+++ b/templates/_checked_in.html.ep
@@ -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';
diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep
index 907427f..0f9019b 100644
--- a/templates/_public_status_card.html.ep
+++ b/templates/_public_status_card.html.ep
@@ -148,8 +148,12 @@
% }
</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';
- <a style="margin-right: 0;" href="<%= $url %>"><i class="material-icons left">timeline</i> Zuglauf</a>
+ % 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>
% }
diff --git a/templates/traewelling.html.ep b/templates/traewelling.html.ep
index a5e2ae5..b68d8c1 100644
--- a/templates/traewelling.html.ep
+++ b/templates/traewelling.html.ep
@@ -9,8 +9,7 @@
<div class="card purple">
<div class="card-content white-text">
<span class="card-title">Beta-Feature</span>
- <p>Die Verbindung von Checkinservices bietet viele Möglichkeiten für interessante Fehlerbilder.
- Falls etwas nicht klappt, bitte mit möglichst detaillierten Angaben zum Hergang einen Bug melden.
+ <p>
Bekannte Einschränkung: Hooks werden bei einem Checkin via Träwelling nicht ausgelöst.
</p>
</div>
@@ -101,7 +100,8 @@
Nahverkehrsmittel und Züge außerhalb des deutschen Schienennetzes
werden nicht unterstützt und ignoriert. Checkins, die vor dem
Verknüpfen der Accounts stattgefunden haben, werden nicht
- synchronisiert.
+ synchronisiert. Bei synchronisierten Checkins wird der zugehörige
+ Träwelling-Status von deiner travelynx-Statusseite aus verlinkt.
</p>
<p>
Mit E-Mail und Passwort wird ein Login über die Träwelling-API