travelynx/templates/account.html.ep
2019-05-02 10:05:15 +02:00

260 lines
6.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

% if (my $invalid = stash('invalid')) {
%= include '_invalid_input', invalid => $invalid
% }
% if (my $success = flash('success')) {
<div class="row">
<div class="col s12">
<div class="card green darken-4">
<div class="card-content white-text">
% if ($success eq 'mail') {
<span class="card-title">Mail-Adresse erfolgreich geändert</span>
% }
% elsif ($success eq 'password') {
<span class="card-title">Passwort erfolgreich geändert</span>
% }
</div>
</div>
</div>
</div>
% }
<h1>Account</h1>
% my $acc = current_user();
<div class="row">
<div class="col s12">
<table class="striped">
<tr>
<th scope="row">Name</th>
<td><%= $acc->{name} %></td>
</tr>
<tr>
<th scope="row">Mail</th>
<td><a href="/change_mail"><i class="material-icons">edit</i></a><%= $acc->{email} %></td>
</tr>
<tr>
<th scope="row">Passwort</th>
<td><a href="/change_password"><i class="material-icons">edit</i></a></td>
</tr>
<tr>
<th scope="row">Öffentliche Daten</th>
<td>
<a href="/account/privacy"><i class="material-icons">edit</i></a>
% if ($acc->{is_public} == 0) {
Keine
% }
% if ($acc->{is_public} & 0x02) {
Aktueller Status
% }
</td>
</tr>
<tr>
<th scope="row">Registriert am</th>
<td><%= $acc->{registered_at}->strftime('%d.%m.%Y %H:%M') %></td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col s12 m12 l12 center-align">
%= form_for 'logout' => begin
%= csrf_field
<button class="btn waves-effect waves-light" type="submit" name="action" value="logout">
Abmelden
</button>
%= end
</div>
</div>
% my $token = get_api_token();
<div class="row">
<div class="col s12">
<h2>API</h2>
<p>
Die folgenden API-Token erlauben den passwortlosen automatisierten Zugriff auf
API-Endpunkte. Bitte umsichtig behandeln sobald ein Token gesetzt
ist, können damit ohne Logindaten alle zugehörigen API-Aktionen
ausgeführt werden.
</p>
<table class="striped">
<tr>
<th scope="row">Status</th>
<td>
% if ($token->{status}) {
%= $acc->{id} . '-' . $token->{status}
% }
% else {
% }
</td>
<td>
%= form_for 'set_token' => begin
%= csrf_field
%= hidden_field 'token' => 'status'
<button class="btn waves-effect waves-light" type="submit" name="action" value="generate">
Generieren
</button>
<button class="btn waves-effect waves-light red" type="submit" name="action" value="delete">
Löschen
</button>
%= end
</td>
</tr><!--
<tr>
<th scope="row">History</th>
<td>
% if ($token->{history}) {
%= $acc->{id} . '-' . $token->{history}
% }
% else {
% }
</td>
<td>
%= form_for 'set_token' => begin
%= csrf_field
%= hidden_field 'token' => 'history'
<button class="btn waves-effect waves-light" type="submit" name="action" value="generate">
Generieren
</button>
<button class="btn waves-effect waves-light red" type="submit" name="action" value="delete">
Löschen
</button>
%= end
</td>
</tr>
<tr>
<th scope="row">Travel</th>
<td>
% if ($token->{action}) {
%= $acc->{id} . '-' . $token->{action}
% }
% else {
% }
</td>
<td>
%= form_for 'set_token' => begin
%= csrf_field
%= hidden_field 'token' => 'action'
<button class="btn waves-effect waves-light" type="submit" name="action" value="generate">
Generieren
</button>
<button class="btn waves-effect waves-light red" type="submit" name="action" value="delete">
Löschen
</button>
%= end
</td>
</tr> -->
</table>
</div>
</div>
% my $api_root = $self->url_for('/api/v1')->to_abs->scheme('https');
<h3>Status</h3>
<div class="row">
<div class="col s12">
<p style="font-family: Monospace;">
% if ($token->{status}) {
curl <%= $api_root %>/status/<%= $acc->{id} %>-<%= $token->{status} // 'TOKEN' %>
% }
% else {
curl <%= $api_root %>/status/TOKEN
% }
</p>
<p>
Beispiel / Layout:
</p>
<p style="font-family: Monospace;">
{<br/>
"deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/>
"checkedIn" : true / false,<br/>
"fromStation" : { (letzter Checkin)<br/>
"name" : "Essen Hbf",<br/>
"ds100" : "EE",<br/>
"uic" : 8000098,<br/>
"latitude" : 51.451355,<br/>
"longitude" : 7.014793,<br/>
"scheduledTime": 1556083680,<br/>
"realTime": 1556083680,<br/>
},<br/>
"fromStation" : { (zugehöriger Checkout. Wenn noch nicht eingetragen, sind alle Felder null)<br/>
"name" : "Essen Stadtwald",<br/>
"ds100" : "EESA",<br/>
"uic" : 8001896,<br/>
"latitude" : 51.422853,<br/>
"longitude" : 7.023296,<br/>
"scheduledTime": 1556083980, (ggf. null)<br/>
"realTime": 1556083980, (ggf. null)<br/>
},<br/>
"train" : {<br/>
"type" : "S", (aktueller / letzter Zugtyp)<br/>
"line" : "6", (Linie als String, nicht immer numerisch, ggf. null)<br/>
"no" : "30634", (Zugnummer als String)<br/>
"id" : "7512500863736016593", (IRIS-spezifische Zug-ID)<br/>
},<br/>
"actionTime" : 1234567, (UNIX-Timestamp des letzten Checkin/Checkout)<br/>
}
</p>
<p>
Im Fehlerfall: <span style="font-family: Monospace;">{ "error" : "Begründung" }</span>
</p>
</div>
</div>
<!--
<h3>History</h3>
<div class="row">
<div class="col s12">
<p>
Coming soon.
</p>
</div>
</div>
<h3>Travel</h3>
<div class="row">
<div class="col s12">
<p>
Ein- und Auschecken per API. Coming soon.
</p>
</div>
</div>
-->
<h2>Export</h2>
<div class="row">
<div class="col s12">
<ul>
<li><a href="/export.json">Rohdaten</a> (Kein API-Ersatz, das Format kann sich jederzeit ändern)</li>
</ul>
</div>
</div>
% if (not $acc->{deletion_requested}) {
<h2>Löschen</h2>
<div class="row">
<div class="col s12">
<p>
Der Löschauftrag wird vorgemerkt und erst nach drei Tagen
umgesetzt, bis dahin kann er jederzeit zurückgenommen werden. Nach
Ablauf der drei Tage wird der Account mit allen zugehörigen
Reisedaten ohne weitere Rückfragen entfernt.
</p>
</div>
</div>
<div class="row">
%= form_for 'delete' => begin
<div class="input-field col s12 m12 l8">
<i class="material-icons prefix">lock</i>
%= password_field 'password', id => 'password', class => 'validate', required => undef, autocomplete => 'current-password'
<label for="password">Passwort</label>
</div>
<div class="input-field col s12 m12 l4 center-align">
%= csrf_field
<button class="btn waves-effect waves-light red" type="submit" name="action" value="delete">
Account löschen
</button>
</div>
%= end
</div>
% }