diff --git a/index.html b/index.html index d9f09cb..506820a 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,6 @@ - diff --git a/public/env.js b/public/env.js deleted file mode 100644 index d10fe2d..0000000 --- a/public/env.js +++ /dev/null @@ -1,3 +0,0 @@ -const config = { - endpoint: 'https://dev.lauf-fuer-kaya.de/' -}; diff --git a/public/env.sample.js b/public/env.sample.js deleted file mode 100644 index d10fe2d..0000000 --- a/public/env.sample.js +++ /dev/null @@ -1,3 +0,0 @@ -const config = { - endpoint: 'https://dev.lauf-fuer-kaya.de/' -}; diff --git a/src/App.svelte b/src/App.svelte index 0b4f082..b724017 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,5 +1,5 @@ {#if settings_open && is_configured} diff --git a/src/Login.svelte b/src/Login.svelte index 60dfd0f..c168aa9 100644 --- a/src/Login.svelte +++ b/src/Login.svelte @@ -1,16 +1,18 @@
@@ -59,57 +61,99 @@
{/if} {/if} - -
{ - axios - .request({ - method: "GET", - url: config.endpoint + "api/stations/me", - headers: { Authorization: "Bearer " + token }, - }) - .then(function (response) { - error = false; - errormessage = ""; - apikey.set(token); - stationinfo.set(JSON.stringify(response.data)); - }) - .catch(function (e) { - error = true; - errormessage = e.response.data.short; - }); - }} - > -
- - -
- {#if !isTokenValid} - {$_("please_provide_a_valid_client_token")} - {/if} - { + axios + .request({ + method: "GET", + url: $api_endpoint + "api/stations/me", + headers: { Authorization: "Bearer " + token }, + }) + .then(function (response) { + error = false; + errormessage = ""; + apikey.set(token); + stationinfo.set(JSON.stringify(response.data)); + }) + .catch(function (e) { + error = true; + errormessage = e.response.data.short; + }); + }} > -
+
+ + +
+ {#if !isTokenValid} + {$_("please_provide_a_valid_client_token")} + {/if} + + + {:else} +
{ + if (api_endpoint_input.substr(-1) !== "/") { + api_endpoint_input = api_endpoint_input + "/"; + } + api_endpoint.set(api_endpoint_input); + }} + > +
+ + +
+ {#if !isEndpointValid} + {$_("please_provide_a_valid_client_api_endpoint")} + {/if} + +
+ {/if}

import axios from "axios"; import { _ } from "svelte-i18n"; - import { apikey, page, stationinfo } from "./store.js"; + import { apikey, api_endpoint, page, stationinfo } from "./store.js"; function init(el) { el.focus(); } @@ -9,6 +9,7 @@ let lastscan_time = ""; let lastscan_laptime = ""; let lastscan_totaldistance = ""; + let lastscan_valid = true; let card = ""; // live clock at the top let time = new Date(); @@ -64,7 +65,7 @@ axios .request({ method: "POST", - url: config.endpoint + "api/scans/trackscans", + url: $api_endpoint + "api/scans/trackscans", headers: { Authorization: "Bearer " + $apikey }, data: { card }, }) @@ -83,6 +84,7 @@ ) + "s"; lastscan_laptime = response.data.lapTime; + lastscan_valid = response.data.valid; lastscan_totaldistance = Math.floor(response.data.runner.distance / 1000) + "km " + @@ -112,14 +114,44 @@ /> {#if lastscan_totaldistance} -

last scan

-

{lastscan_time}

-

total distance

-

+ {#if !lastscan_valid || lastscan_error} + + {:else} + + {/if} +

{$_("total-distance")}

+

{lastscan_totaldistance}

-

lap time

-

{lastscan_laptime}

+

{$_("lap-time")}

+

{lastscan_laptime}

+

{$_("last-scan")}

+

{lastscan_time}

{:else}

{$_("please_scan_a_card")} diff --git a/src/Settings.svelte b/src/Settings.svelte index 0e8476d..5e8e6a9 100644 --- a/src/Settings.svelte +++ b/src/Settings.svelte @@ -1,7 +1,7 @@
@@ -103,6 +103,7 @@