summaryrefslogtreecommitdiff
path: root/templates/traewelling.html.ep
blob: d4e4ffdc15f1f58bb24380ce4b23764946f9bbb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
% if (my $invalid = stash('invalid')) {
	%= include '_invalid_input', invalid => $invalid
% }

<h1>Träwelling</h1>

<div class="row">
	<div class="col s12">
		<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>
				<p>
					Bekannte Probleme: Hooks werden bei einem Checkin via Träwelling nicht ausgelöst.
				</p>
			</div>
			<div class="card-action">
				<a href="https://github.com/derf/travelynx/issues" class="waves-effect waves-light btn-flat white-text">
					<i class="material-icons left">bug_report</i>Bug melden
				</a>
			</div>
		</div>
	</div>
</div>

% if (stash('new_traewelling')) {
	<div class="row">
		<div class="col s12">
			% if ($traewelling->{token}) {
				<div class="card success-color">
					<div class="card-content white-text">
						<span class="card-title">Träwelling verknüpft</span>
						% my $user = $traewelling->{data}{user_name} // $traewelling->{email};
						<p>Dein travelynx-Account hat nun ein Jahr lang Zugriff auf 
							den Träwelling-Account <b>@<%= $user %></b>.</p>
					</div>
				</div>
			% }
			% elsif (my $login_err = stash('login_error')) {
				<div class="card caution-color">
					<div class="card-content white-text">
						<span class="card-title">Login-Fehler</span>
						<p>Der Login bei Träwelling ist fehlgeschlagen: <%= $login_err %></p>
					</div>
				</div>
			% }
			% elsif (my $logout_err = stash('logout_error')) {
				<div class="card caution-color">
					<div class="card-content white-text">
						<span class="card-title">Logout-Fehler</span>
						<p>Der Logout bei Träwelling ist fehlgeschlagen: <%= $logout_err %>.
							Dein Login-Token bei travelynx wurde dennoch gelöscht, so
							dass nun kein Zugriff von travelynx auf Träwelling mehr
							möglich ist. In den <a
							href="https://traewelling.de/settings">Träwelling-Einstellungen</a>
							kannst du ihn vollständig löschen.</p>
					</div>
				</div>
			% }
		</div>
	</div>
% }

% if (not $traewelling->{token}) {
	<div class="row">
		<div class="col s12">
			<p>
				Hier hast du die Möglichkeit, deinen travelynx-Account mit einem
				Account bei <a href="https://traewelling.de">Träwelling</a> zu
				verknüpfen. Dies erlaubt die automatische Übernahme von Checkins
				zwischen den beiden Diensten. Träwelling-Checkins in
				Nahverkehrsmittel und Züge außerhalb des deutschen Schienennetzes
				werden nicht unterstützt und ignoriert.
			</p>
			<p>
				Mit E-Mail und Passwort wird ein Login über die Träwelling-API
				durchgeführt. Die E-Mail und das dabei generierte Token werden
				von travelynx gespeichert. Das Passwort wird ausschließlich für
				den Login verwendet und nicht gespeichert. Der Login kann jederzeit
				sowohl auf dieser Seite als auch über die <a
				href="https://traewelling.de/settings">Träwelling-Einstellungen</a>
				widerrufen werden. Nach einem Jahr läuft er automatisch ab.
			</p>
		</div>
	</div>
	<div class="row">
		%= form_for '/account/traewelling' => (method => 'POST') => begin
			%= csrf_field
			<div class="input-field col s12">
				<i class="material-icons prefix">account_circle</i>
				%= text_field 'email', id => 'email', class => 'validate', required => undef, maxlength => 250
				<label for="email">E-Mail</label>
			</div>
			<div class="input-field col s12">
				<i class="material-icons prefix">lock</i>
				%= password_field 'password', id => 'password', class => 'validate', required => undef
				<label for="password">Passwort</label>
			</div>
			<div class="col s12 center-align">
				<button class="btn waves-effect waves-light" type="submit" name="action" value="login">
					Verknüpfen
					<i class="material-icons right">send</i>
				</button>
			</div>
		%= end
	</div>
% }
% else {
	<div class="row">
		<div class="col s12">
			<p>
				Dieser travelynx-Account ist mit dem Träwelling-Account
				% if (my $user = $traewelling->{data}{user_name}) {
					<a href="https://traewelling.de/profile/<%= $user %>"><%= $user %></a>
				% }
				% else {
					%= $traewelling->{email}
				% }
				verknüpft.
			</p>
		</div>
	</div>
	%= form_for '/account/traewelling' => (method => 'POST') => begin
		<div class="row">
			%= csrf_field
			<div class="input-field col s12">
				<div>
					<label>
						%= radio_button sync_source => 'none'
						<span>Keine Synchronisierung</span>
					</label>
				</div>
			</div>
			<div class="input-field col s12">
				<div>
					<label>
						%= radio_button sync_source => 'travelynx'
						<span>Checkin-Synchronisierung travelynx → Träwelling</span>
					</label>
				</div>
				<p>Die Synchronisierung erfolgt spätestens drei Minuten nach der
					Zielwahl.  Träwelling-Checkins können von travelynx noch nicht
					rückgängig gemacht werden. Eine nachträgliche Änderung der
					Zielstation wird nicht übernommen.</p>
			</div>
			<div class="input-field col s12">
				<div>
					<label>
						%= radio_button sync_source => 'traewelling'
						<span>Checkin-Synchronisierung Träwelling → travelynx</span>
					</label>
				</div>
				<p>Alle drei Minuten wird dein Status auf Träwelling abgefragt.
					Falls du gerade in einen Zug eingecheckt bist, wird dieser von
					travelynx übernommen.  Träwelling-Checkins in Nahverkehrsmittel
					und Züge außerhalb des deutschen Schienennetzes werden nicht
					unterstützt.</p>
			</div>
		</div>
		<div class="row hide-on-small-only">
			<div class="col s12 m6 l6 center-align">
				<button class="btn waves-effect waves-light red" type="submit" name="action" value="logout">
					Abmelden
					<i class="material-icons right" aria-hidden="true">sync_disabled</i>
				</button>
			</div>
			<div class="col s12 m6 l6 center-align">
				<button class="btn waves-effect waves-light" type="submit" name="action" value="config">
					Speichern
					<i class="material-icons right" aria-hidden="true">send</i>
				</button>
			</div>
		</div>
		<div class="row hide-on-med-and-up">
			<div class="col s12 m6 l6 center-align">
				<button class="btn waves-effect waves-light" type="submit" name="action" value="config">
					Speichern
					<i class="material-icons right" aria-hidden="true">send</i>
				</button>
			</div>
			<div class="col s12 m6 l6 center-align" style="margin-top: 1em;">
				<button class="btn waves-effect waves-light red" type="submit" name="action" value="logout">
					Abmelden
					<i class="material-icons right" aria-hidden="true">sync_disabled</i>
				</button>
			</div>
		</div>
	%= end
	<h2>Status</h2>
	<div class="row">
		<div class="col s12"">
			% if ($traewelling->{latest_run}->epoch) {
				Letzter Checkin <%= $traewelling->{latest_run}->strftime('am %d.%m.%Y um %H:%M:%S') %><br/>
				% if ($traewelling->{errored}) {
					<i class="material-icons left">error</i>
					Fehler: <%= $traewelling->{data}{error} %>
				% }
			% }
			% else {
				Bisher wurde noch kein Checkin übernommen.
			% }
		</div>
	</div>
	<h2>Log</h2>
	<div class="row">
		<div class="col s12"">
			<ul>
				% for my $log_entry (@{$traewelling->{data}{log} // []}) {
					<li>
						<%= $log_entry->[0]->strftime('%d.%m.%Y %H:%M:%S') %> –
						% if ($log_entry->[2]) {
							Träwelling <a href="https://traewelling.de/status/<%= $log_entry->[2] %>">#<%= $log_entry->[2] %></a> –
						% }
						%= $log_entry->[1]
					</li>
				% }
			</ul>
		</div>
	</div>
% }