mirror of
https://github.com/derf/travelynx
synced 2024-11-10 06:54:17 +00:00
link traewelling profile from travelynx profile; show traewelling status
This commit is contained in:
parent
ef3252863e
commit
167b01fa42
6 changed files with 52 additions and 11 deletions
|
@ -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};
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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} %>&to=<%= $journey->{arr_name} // '' %>"><i class="material-icons left">map</i> Karte</a>
|
||||
% }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue