Compare commits

..

No commits in common. "16d9a6dda87c1aabe02f0d058d44b40292f9e8c6" and "c930d879003d27bccb5e7118ed151e3e20487172" have entirely different histories.

9 changed files with 45 additions and 114 deletions

View File

@ -1,7 +0,0 @@
languageIds:
- javascript
- svelte
- html
monopoly: false
refactorTemplates:
- "{$_('$1')}"

View File

@ -1,4 +0,0 @@
{
"i18n-ally.localesPaths": "app/src/locales",
"i18n-ally.keystyle": "nested"
}

View File

@ -8,7 +8,7 @@
"prepare": "husky install" "prepare": "husky install"
}, },
"devDependencies": { "devDependencies": {
"@svitejs/vite-plugin-svelte": "^0.11.1", "@svitejs/vite-plugin-svelte": "^0.11.0",
"@tsconfig/svelte": "^1.0.10", "@tsconfig/svelte": "^1.0.10",
"@types/html-minifier": "^4.0.0", "@types/html-minifier": "^4.0.0",
"axios": "^0.21.1", "axios": "^0.21.1",
@ -19,7 +19,7 @@
"prettier-plugin-svelte": "^2.2.0", "prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.35.0", "svelte": "^3.35.0",
"svelte-preprocess": "^4.6.9", "svelte-preprocess": "^4.6.9",
"vite": "^2.1.2", "vite": "^2.0.5",
"vite-plugin-windicss": "^0.9.2" "vite-plugin-windicss": "^0.8.2"
} }
} }

View File

@ -1,12 +1,4 @@
<script> <script>
import { addMessages, init } from "svelte-i18n";
import en from "./locales/en.json";
import de from "./locales/de.json";
addMessages("en", en);
addMessages("en-US", en);
addMessages("de", de);
addMessages("de-DE", de);
//
import Scanner from "./Scanner.svelte"; import Scanner from "./Scanner.svelte";
import Login from "./Login.svelte"; import Login from "./Login.svelte";
import Settings from "./Settings.svelte"; import Settings from "./Settings.svelte";
@ -14,11 +6,6 @@
$: is_configured = $apikey && $apikey !== "null" && $apikey !== ""; $: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
$: settings_open = $page === "settings"; $: settings_open = $page === "settings";
console.log($page); console.log($page);
//
init({
fallbackLocale: "en-US",
initialLocale: $lang
});
</script> </script>
{#if settings_open && is_configured} {#if settings_open && is_configured}

View File

@ -1,7 +1,6 @@
<script> <script>
import { apikey, lang, stationinfo } from "./store.js"; import { apikey, lang, stationinfo } from "./store.js";
import axios from "axios"; import axios from "axios";
import { _ ,locale} from "svelte-i18n";
let token; let token;
$: error = false; $: error = false;
$: errormessage = ""; $: errormessage = "";
@ -9,9 +8,6 @@ import { _ ,locale} from "svelte-i18n";
token?.length === 44 && token?.length === 44 &&
token.split(".")[0].length === 7 && token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]); isUUID(token.split(".")[1]);
function isLocale(l){
return $locale == l;
}
function isUUID(uuid) { function isUUID(uuid) {
let s = "" + uuid; let s = "" + uuid;
@ -38,12 +34,12 @@ return $locale == l;
<div <div
class="flex flex-col justify-center md:justify-start my-auto pt-8 md:pt-0 px-8 md:px-24 lg:px-32" class="flex flex-col justify-center md:justify-start my-auto pt-8 md:pt-0 px-8 md:px-24 lg:px-32"
> >
<p class="text-center text-3xl">{$_('configuration')}</p> <p class="text-center text-3xl">Configuration</p>
<p class="text-center"> <p class="text-center">
{$_('please_provide_the_scan_client_token')}<br /><a Please provide the scan client token.<br /><a
target="_blank" target="_blank"
class="underline" class="underline"
href="https://docs.lauf-fuer-kaya.de/">{$_('see_our_configuration_guide')}</a href="https://docs.lauf-fuer-kaya.de/">See our configuration guide.</a
> >
</p> </p>
{#if error} {#if error}
@ -52,7 +48,8 @@ return $locale == l;
class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2" class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2"
> >
<span class="inline-block align-middle"> <span class="inline-block align-middle">
<b class="capitalize">{$_('error')}</b><br />{$_('the_provided_scan_station_token_is_invalid')}<br />{$_('please_check_your_token_and_try_again')} <b class="capitalize">Error!</b><br />The provided scan station
token is invalid.<br />Please check your token and try again...
</span> </span>
</div> </div>
{/if} {/if}
@ -61,7 +58,8 @@ return $locale == l;
class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2" class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2"
> >
<span class="inline-block align-middle"> <span class="inline-block align-middle">
<b class="capitalize">{$_('error')}</b><br />{$_('the_provided_scan_station_is_disabled')} <b class="capitalize">Error!</b><br />The provided scan station is
disabled.
</span> </span>
</div> </div>
{/if} {/if}
@ -92,11 +90,11 @@ return $locale == l;
}} }}
> >
<div class="flex flex-col pt-4"> <div class="flex flex-col pt-4">
<label for="token" class="text-lg">{$_('client_token')}</label> <label for="token" class="text-lg">Client Token</label>
<input <input
type="text" type="text"
id="token" id="token"
:placeholder={$_('client_token')} placeholder="Client Token"
bind:value={token} bind:value={token}
class:border-red-500={!isTokenValid} class:border-red-500={!isTokenValid}
class:border-solid={!isTokenValid} class:border-solid={!isTokenValid}
@ -105,7 +103,7 @@ return $locale == l;
/> />
</div> </div>
{#if !isTokenValid} {#if !isTokenValid}
<span class="text-sm">{$_('please_provide_a_valid_client_token')}</span> <span class="text-sm">Please provide a valid client token...</span>
{/if} {/if}
<button <button
disabled={!isTokenValid} disabled={!isTokenValid}
@ -114,7 +112,7 @@ return $locale == l;
id="configure" id="configure"
type="submit" type="submit"
class="bg-black text-white font-bold text-lg hover:bg-gray-700 p-2 mt-8 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black" class="bg-black text-white font-bold text-lg hover:bg-gray-700 p-2 mt-8 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
>{$_('configure')}</button >Configure</button
> >
</form> </form>
<div class="text-center pt-12 pb-12"> <div class="text-center pt-12 pb-12">
@ -141,19 +139,16 @@ return $locale == l;
</p> </p>
</div> </div>
</div> </div>
{$locale}
{JSON.stringify($locale)}
<div class="w-full p-3"> <div class="w-full p-3">
<div class="inline-block mr-2 mt-2"> <div class="inline-block mr-2 mt-2">
<button <button
on:click={() => { on:click={() => {
// lang.set("de-DE"); lang.set("de-DE");
locale.set("de-DE");
}} }}
type="button" type="button"
class:bg-black={$locale !== "de-DE"} class:bg-blue-700={$lang === "de-DE"}
class:bg-blue-700={JSON.stringify($locale) == "de-DE"} class="bg-black focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-white text-sm py-2.5 px-5 rounded-md hover:bg-blue-700"
class="focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-white text-sm py-2.5 px-5 rounded-md hover:bg-blue-700"
>Deutsch >Deutsch
<svg <svg
class="h-4 inline" class="h-4 inline"
@ -174,13 +169,11 @@ return $locale == l;
<div class="inline-block mr-2 mt-2"> <div class="inline-block mr-2 mt-2">
<button <button
on:click={() => { on:click={() => {
// lang.set("en-US"); lang.set("en-EN");
locale.set("en-US");
}} }}
type="button" type="button"
class:bg-black={$locale !== "en-US"} class:bg-blue-700={$lang === "en-EN"}
class:bg-blue-700={$locale !== "en-US"} class="bg-black focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-white text-sm py-2.5 px-5 rounded-md hover:bg-blue-700"
class="focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-white text-sm py-2.5 px-5 rounded-md hover:bg-blue-700"
>English >English
<svg <svg
class="h-4 inline" class="h-4 inline"

View File

@ -1,6 +1,5 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import { _ } from "svelte-i18n";
import { apikey, lang, page, stationinfo } from "./store.js"; import { apikey, lang, page, stationinfo } from "./store.js";
function init(el) { function init(el) {
el.focus(); el.focus();
@ -20,7 +19,6 @@ import { _ } from "svelte-i18n";
}, 1000); }, 1000);
</script> </script>
<div class="min-h-screen">
<div class="bg-white shadow p-2"> <div class="bg-white shadow p-2">
<div class="flex flex-wrap -mx-1 overflow-hidden"> <div class="flex flex-wrap -mx-1 overflow-hidden">
<div class="my-1 px-1 w-1/3 overflow-hidden text-center self-center"> <div class="my-1 px-1 w-1/3 overflow-hidden text-center self-center">
@ -38,6 +36,7 @@ import { _ } from "svelte-i18n";
</div> </div>
</div> </div>
<div class="p-5 min-h-screen">
<h1 class="mr-6 text-7xl font-semibold text-center text-gray-900"> <h1 class="mr-6 text-7xl font-semibold text-center text-gray-900">
{hours}:{minutes}:{seconds} {hours}:{minutes}:{seconds}
</h1> </h1>
@ -66,30 +65,17 @@ import { _ } from "svelte-i18n";
method: "POST", method: "POST",
url: "https://dev.lauf-fuer-kaya.de/api/scans/trackscans", url: "https://dev.lauf-fuer-kaya.de/api/scans/trackscans",
headers: { Authorization: "Bearer " + $apikey }, headers: { Authorization: "Bearer " + $apikey },
data: { card }, data: { card, station: JSON.parse($stationinfo).id },
}) })
.then((response) => { .then((response) => {
console.log(response.data.runner);
lastscan_totaldistance = response.data.runner.distance + "m";
const time = new Date(); const time = new Date();
const hours = (time.getHours() + "").padStart(2, "0"); const hours = (time.getHours() + "").padStart(2, "0");
const minutes = (time.getMinutes() + "").padStart(2, "0"); const minutes = (time.getMinutes() + "").padStart(2, "0");
const seconds = (time.getSeconds() + "").padStart(2, "0"); const seconds = (time.getSeconds() + "").padStart(2, "0");
lastscan_time = hours + ":" + minutes + ":" + seconds; lastscan_time = hours + ":" + minutes + ":" + seconds;
response.data.lapTime = lastscan_laptime = response.data.lapTime + "s";
Math.floor(response.data.lapTime / 60) +
"min " +
(Math.floor(response.data.lapTime % 60) + "").padStart(
2,
"0"
) +
"s";
lastscan_laptime = response.data.lapTime;
lastscan_totaldistance =
Math.floor(response.data.runner.distance / 1000) +
"km " +
(
Math.floor(response.data.runner.distance % 1000) + ""
).padStart(3, "0") +
"m";
}) })
.catch((e) => { .catch((e) => {
lastscan_error = e.response.data.message; lastscan_error = e.response.data.message;
@ -115,14 +101,15 @@ import { _ } from "svelte-i18n";
<h1 class="text-3xl font-bold text-center">last scan</h1> <h1 class="text-3xl font-bold text-center">last scan</h1>
<h1 class="text-5xl font-bold text-center">{lastscan_time}</h1> <h1 class="text-5xl font-bold text-center">{lastscan_time}</h1>
<h1 class="text-3xl font-bold text-center">total distance</h1> <h1 class="text-3xl font-bold text-center">total distance</h1>
<h1 class="text-8xl font-bold text-center"> <h1 class="text-9xl font-bold text-center">
{lastscan_totaldistance} {lastscan_totaldistance}
</h1> </h1>
<h1 class="text-3xl font-bold text-center">lap time</h1> <h1 class="text-3xl font-bold text-center">lap time</h1>
<h1 class="text-8xl font-bold text-center">{lastscan_laptime}</h1> <h1 class="text-9xl font-bold text-center">{lastscan_laptime}</h1>
{:else} {:else}
<h1 class="text-3xl font-bold text-center">please scan a card...</h1> <h1 class="text-3xl font-bold text-center">please scan a card...</h1>
{/if} {/if}
<!-- <button type="submit" class="w-full py-3 bg-black text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black">Scan!</button> -->
<button type="submit" class="hidden">Scan!</button> <button type="submit" class="hidden">Scan!</button>
</form> </form>
</div> </div>

View File

@ -1,9 +0,0 @@
{
"english": "Englisch",
"the_provided_scan_station_token_is_invalid": "",
"configuration": "Konfiguration",
"please_provide_the_scan_client_token": "Bitte gebe den Scan-Client-Token an.",
"the_provided_scan_station_is_disabled": "Die angegebene Scanstation ist deaktiviert.",
"see_our_configuration_guide": "Siehe dir unsere Konfigurationsanleitung an.",
"please_provide_a_valid_client_token": "Bitte gebe einen gültigen Client-Token an ..."
}

View File

@ -1,14 +0,0 @@
{
"please_provide_the_scan_client_token": "Please provide the scan client token.",
"configuration": "Configuration",
"see_our_configuration_guide": "See our configuration guide.",
"error": "Error!",
"the_provided_scan_station_token_is_invalid": "The provided scan station token is invalid.",
"please_check_your_token_and_try_again": "Please check your token and try again...",
"the_provided_scan_station_is_disabled": "The provided scan station is disabled.",
"client_token": "Client Token",
"please_provide_a_valid_client_token": "Please provide a valid client token...",
"configure": "Configure",
"german": "Deutsch",
"english": "English"
}

View File

@ -16,11 +16,11 @@
"@electron-forge/maker-rpm": "^6.0.0-beta.54", "@electron-forge/maker-rpm": "^6.0.0-beta.54",
"@electron-forge/maker-squirrel": "^6.0.0-beta.54", "@electron-forge/maker-squirrel": "^6.0.0-beta.54",
"@electron-forge/maker-zip": "^6.0.0-beta.54", "@electron-forge/maker-zip": "^6.0.0-beta.54",
"electron-nightly": "14.0.0-nightly.20210318" "electron-nightly": "14.0.0-nightly.20210311",
"husky": "^5.1.3"
}, },
"dependencies": { "dependencies": {
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0"
"svelte-i18n": "^3.3.7"
}, },
"config": { "config": {
"forge": { "forge": {
@ -28,9 +28,7 @@
"makers": [ "makers": [
{ {
"name": "@electron-forge/maker-zip", "name": "@electron-forge/maker-zip",
"platforms": [ "platforms": [ "darwin" ],
"darwin"
],
"config": { "config": {
"name": "lfk__scanclient" "name": "lfk__scanclient"
} }