27 Commits

Author SHA1 Message Date
f211e35517 Merge branch 'main' of https://git.odit.services/lfk/scanclient into main 2021-03-19 18:25:59 +01:00
cfd40d3f19 re-enable CI 2021-03-19 18:25:28 +01:00
76ccb2290e Merge pull request 'Husky pre-commit hooks 🐶' (#8) from dev into main
Reviewed-on: #8

close #4
close #5
2021-03-19 16:41:28 +00:00
5c117d6f48 Merge branch 'main' into dev 2021-03-19 16:40:32 +00:00
0296c26479 Merge branch 'feature/4-license-exporter' into dev
close #4 , close #5
2021-03-19 17:36:50 +01:00
d0facb2846 added husky formatting 🐶
ref #5
2021-03-19 17:33:23 +01:00
7deb0d26c4 added license:export script to pre-commit hook
ref #4
2021-03-19 17:32:54 +01:00
00b8a14bc3 husky 🐶 2021-03-19 17:24:39 +01:00
31ccf0758d Merge pull request 'dev' (#6) from dev into main
Reviewed-on: #6
2021-03-19 16:17:08 +00:00
116f9123e2 drop CI 2021-03-19 17:13:20 +01:00
1fd1b32d1a cleanup 🧹 2021-03-19 16:57:31 +01:00
81750dc8e1 move to client code only 2021-03-19 16:48:27 +01:00
f8e858971f Merge pull request 'feature/1-basic-scan-client' (#3) from feature/1-basic-scan-client into dev
Reviewed-on: #3

close #1
2021-03-18 17:54:40 +00:00
f7274378b8 🧹 cleanup 2021-03-18 18:43:37 +01:00
b3f7002556 🌎 all translations
ref #1
2021-03-18 18:40:36 +01:00
e087a8dc30 🌎 Login Translations done 2021-03-18 18:35:08 +01:00
0aea3c1e7c locale persistance
ref #1
2021-03-18 18:29:59 +01:00
ff99657ab3 drop husky 🐶 2021-03-18 18:19:57 +01:00
16d9a6dda8 basic i18n
ref #1
2021-03-18 18:15:54 +01:00
0ebabe239c working scans 🎉 2021-03-17 19:59:07 +01:00
c930d87900 Scanner - display total distance
ref #1
2021-03-17 19:06:53 +01:00
559842d2a6 basic Scanner working
ref #1
2021-03-17 18:55:50 +01:00
1fc0490590 scan error feedback
ref #1
2021-03-17 18:52:37 +01:00
f5537278ab display station info in settings view
ref #1
2021-03-17 18:52:17 +01:00
8a6521faa0 scanner ui + login error states
ref #1
2021-03-17 18:44:56 +01:00
82dd786210 add stationinfo persistence
ref #1
2021-03-17 18:44:10 +01:00
42b2390bd7 responsiveness of scanner component
ref #1
2021-03-16 14:39:57 +01:00
27 changed files with 5384 additions and 244 deletions

View File

@@ -4,30 +4,27 @@ name: gitea_token
get:
path: odit-git-bot
name: apikey
---
kind: pipeline
type: kubernetes
name: build
steps:
- name: run electron packager
- name: run build
depends_on: ["clone"]
image: node:15.11.0-alpine3.13
commands:
- apk add git zip -f
- yarn && cd app && yarn && cd ..
- yarn electron:package
- mkdir dist
- zip -r dist/@lfk-scanclient-linux-x64.zip out/@lfk-scanclient-linux-x64
- yarn
- yarn build
- zip -r out/dist.zip dist
- name: gitea_release
depends_on: ["run electron packager"]
depends_on: ["run build"]
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_token
base_url: https://git.odit.services
files: dist/*
files: out/*
checksum:
- md5
- sha1
@@ -37,7 +34,6 @@ steps:
- crc32
when:
event: tag
trigger:
branch:
- main

View File

@@ -2,3 +2,4 @@
. "$(dirname "$0")/_/husky.sh"
yarn format
yarn license:export

View File

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

4
.vscode/settings.json vendored Normal file
View File

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

View File

@@ -1,6 +1,5 @@
FROM node:15.11.0-alpine3.13
RUN apk add git -f
WORKDIR /app
COPY . .
RUN yarn && cd app && yarn && cd ..
RUN yarn electron:package
RUN yarn
RUN yarn build

View File

@@ -1,25 +1,20 @@
# @lfk/scanclient
## ✒️ Overview
This is an API client for @lfk/backend
This is an API client for [https://git.odit.services/lfk/backend](@lfk/backend)
- WebApp built with [Svelte](https://svelte.dev), [WindiCSS](https://windicss.org/) (to compile [TailwindCSS](https://tailwindcss.com/)) and [Vite](https://vitejs.dev).
- Served to clients via by [Electron](https://electronjs.org/).
## 🚀 Getting Started
```
yarn && cd app && yarn && cd ..
yarn
```
## WebApp Development
## Development
```
yarn dev
/
yarn dev --open
```
## Run in electron
## Build
```
yarn electron:start
```
# Package electron
```
yarn electron:package
yarn build
```

View File

@@ -1,25 +0,0 @@
{
"name": "@lfk/scanclient",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"format": "prettier --write --plugin-search-dir=. ./**/*.html ./**/*.svelte",
"prepare": "husky install"
},
"devDependencies": {
"@svitejs/vite-plugin-svelte": "^0.11.0",
"@tsconfig/svelte": "^1.0.10",
"@types/html-minifier": "^4.0.0",
"axios": "^0.21.1",
"glob": "^7.1.6",
"html-minifier": "^4.0.0",
"husky": "^5.1.3",
"prettier": "^2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.35.0",
"svelte-preprocess": "^4.6.9",
"vite": "^2.0.5",
"vite-plugin-windicss": "^0.8.2"
}
}

View File

@@ -1,17 +0,0 @@
<script>
import Scanner from "./Scanner.svelte";
import Login from "./Login.svelte";
import Settings from "./Settings.svelte";
import { apikey, lang, page } from "./store.js";
$: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
$: settings_open = $page === "settings";
console.log($page);
</script>
{#if settings_open && is_configured}
<Settings />
{:else if is_configured}
<Scanner />
{:else}
<Login />
{/if}

View File

@@ -1,79 +0,0 @@
<script>
import { apikey, lang, page } from "./store.js";
function init(el) {
el.focus();
}
let lastscan_time = "";
let lastscan_laptime = "";
let lastscan_totaldistance = "";
let card = "";
// live clock at the top
let time = new Date();
$: hours = (time.getHours() + "").padStart(2, "0");
$: minutes = (time.getMinutes() + "").padStart(2, "0");
$: seconds = (time.getSeconds() + "").padStart(2, "0");
const interval = setInterval(() => {
time = new Date();
}, 1000);
</script>
<div class="p-5 min-h-screen">
<h1 class="font-semibold w-full text-center text-gray-900">
Lauf Für Kaya! Scan 📷
</h1>
<h1 class="mr-6 text-6xl font-semibold text-center text-gray-900">
{hours}:{minutes}:{seconds}
</h1>
<section class="px-4 py-24 mx-auto max-w-7xl">
<div class="w-full mx-auto space-y-5 sm:w-8/12 md:w-12 lg:w-12 xl:w-12">
<form
class="space-y-4"
onsubmit="event.preventDefault();"
on:submit={() => {
if (card === "cnf") {
page.set("settings");
} else {
console.log(card);
//TODO: hit API for scan entry
lastscan_totaldistance = "400m";
let time = new Date();
const hours = (time.getHours() + "").padStart(2, "0");
const minutes = (time.getMinutes() + "").padStart(2, "0");
const seconds = (time.getSeconds() + "").padStart(2, "0");
lastscan_time = hours + ":" + minutes + ":" + seconds;
lastscan_laptime = "1min 30s";
}
card = "";
}}
>
{#if lastscan_totaldistance}
<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-3xl font-bold text-center">total distance</h1>
<h1 class="text-9xl font-bold text-center">
{lastscan_totaldistance}
</h1>
<h1 class="text-3xl font-bold text-center">lap time</h1>
<h1 class="text-9xl font-bold text-center">{lastscan_laptime}</h1>
{:else}
<h1 class="text-3xl font-bold text-center">please scan a card...</h1>
{/if}
<label class="block">
<span class="block mb-1 text-xs font-medium text-gray-700"
>Runner Card</span
>
<input
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mt-1 leading-tight focus:outline-none focus:shadow-outline"
type="text"
placeholder="123456789"
required
use:init
bind:value={card}
/>
</label>
<!-- <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>
</form>
</div>
</section>
</div>

View File

@@ -9,6 +9,7 @@
</head>
<body class="bg-white font-family-karla h-screen">
<script src="./env.js"></script>
<script type="module" src="./src/main.js"></script>
</body>
</html>

5004
licenses.md Normal file

File diff suppressed because it is too large Load Diff

39
main.js
View File

@@ -1,39 +0,0 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
function createWindow() {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
fullscreen: true
// webPreferences: {
// preload: path.join(__dirname, 'preload.js')
// }
});
mainWindow.loadFile('app/dist/index.html');
// mainWindow.removeMenu();
// mainWindow.webContents.openDevTools()
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createWindow();
app.on('activate', function() {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') app.quit();
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

16
order.js Normal file
View File

@@ -0,0 +1,16 @@
const fs = require('fs');
// get all language files
const files = fs.readdirSync('./src/locales/');
files.forEach((f) => {
// read file as object
const unordered = JSON.parse(fs.readFileSync(`src/locales/${f}`));
// order object by keys alpabetically A-Z
const ordered = Object.keys(unordered).sort().reduce((obj, key) => {
obj[key] = unordered[key];
return obj;
}, {});
// format output as json for commit diff compatibility
const out = JSON.stringify(ordered, 0, 4);
// write output file
fs.writeFileSync(`src/locales/${f}`, out);
});

View File

@@ -1,47 +1,27 @@
{
"name": "@lfk/scanclient",
"version": "0.0.0",
"description": "minimal electron application",
"main": "main.js",
"scripts": {
"dev": "cd app && yarn dev",
"electron:start": "cd app && yarn build && cd .. && electron-forge start",
"electron:package": "cd app && yarn build && cd .. && electron-forge package",
"dev": "vite",
"build": "vite build",
"format": "prettier --write --plugin-search-dir=. ./**/*.html ./**/*.svelte",
"prepare": "husky install",
"format": "cd app && yarn format"
"license:export": "license-exporter --markdown && git stage licenses.md"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.54",
"@electron-forge/maker-deb": "^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-zip": "^6.0.0-beta.54",
"electron-nightly": "14.0.0-nightly.20210311",
"husky": "^5.1.3"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-zip",
"platforms": [ "darwin" ],
"config": {
"name": "lfk__scanclient"
}
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
}
]
}
"@odit/license-exporter": "^0.0.11",
"@svitejs/vite-plugin-svelte": "^0.11.1",
"@tsconfig/svelte": "^1.0.10",
"@types/html-minifier": "^4.0.0",
"axios": "^0.21.1",
"html-minifier": "^4.0.0",
"husky": "^5.1.3",
"prettier": "^2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.35.0",
"svelte-preprocess": "^4.6.9",
"vite": "^2.1.2",
"vite-plugin-windicss": "^0.9.2",
"svelte-i18n": "^3.3.7"
}
}

3
public/env.js Normal file
View File

@@ -0,0 +1,3 @@
const config = {
endpoint: 'https://dev.lauf-fuer-kaya.de/'
};

3
public/env.sample.js Normal file
View File

@@ -0,0 +1,3 @@
const config = {
endpoint: 'https://dev.lauf-fuer-kaya.de/'
};

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

29
src/App.svelte Normal file
View File

@@ -0,0 +1,29 @@
<script>
console.log("app started with base url " + config.endpoint);
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 Login from "./Login.svelte";
import Settings from "./Settings.svelte";
import { apikey, lang, page } from "./store.js";
$: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
$: settings_open = $page === "settings";
init({
fallbackLocale: "en-US",
initialLocale: $lang,
});
</script>
{#if settings_open && is_configured}
<Settings />
{:else if is_configured}
<Scanner />
{:else}
<Login />
{/if}

View File

@@ -1,10 +1,17 @@
<script>
import { apikey, lang } from "./store.js";
import { apikey, lang, stationinfo } from "./store.js";
import axios from "axios";
import { _, locale } from "svelte-i18n";
let token;
$: error = false;
$: errormessage = "";
$: isTokenValid =
token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]);
function isLocale(l) {
return $locale == l;
}
function isUUID(uuid) {
let s = "" + uuid;
@@ -31,29 +38,68 @@
<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"
>
<p class="text-center text-3xl">Configuration</p>
<p class="text-center text-3xl">{$_("configuration")}</p>
<p class="text-center">
Please provide the scan client token.<br /><a
{$_("please_provide_the_scan_client_token")}<br /><a
target="_blank"
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>
{#if error}
{#if errormessage === "invalid_token"}
<div
class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2"
>
<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")}
</span>
</div>
{/if}
{#if errormessage === "station_disabled"}
<div
class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2"
>
<span class="inline-block align-middle">
<b class="capitalize">{$_("error")}</b><br />{$_(
"the_provided_scan_station_is_disabled"
)}
</span>
</div>
{/if}
{/if}
<form
class="flex flex-col pt-3 md:pt-8"
onsubmit="event.preventDefault();"
on:submit={() => {
// TODO: validate token with backend api
console.log(token);
apikey.set(token);
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;
});
}}
>
<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
type="text"
id="token"
placeholder="Client Token"
placeholder={$_("client_token")}
bind:value={token}
class:border-red-500={!isTokenValid}
class:border-solid={!isTokenValid}
@@ -62,7 +108,9 @@
/>
</div>
{#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}
<button
disabled={!isTokenValid}
@@ -71,7 +119,7 @@
id="configure"
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"
>Configure</button
>{$_("configure")}</button
>
</form>
<div class="text-center pt-12 pb-12">
@@ -98,15 +146,14 @@
</p>
</div>
</div>
<div class="w-full p-3">
<div class="inline-block mr-2 mt-2">
<button
on:click={() => {
lang.set("de-DE");
locale.set("de-DE");
}}
type="button"
class:bg-blue-700={$lang === "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"
>Deutsch
<svg
@@ -128,10 +175,10 @@
<div class="inline-block mr-2 mt-2">
<button
on:click={() => {
lang.set("en-EN");
lang.set("en-US");
locale.set("en-US");
}}
type="button"
class:bg-blue-700={$lang === "en-EN"}
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"
>English
<svg

132
src/Scanner.svelte Normal file
View File

@@ -0,0 +1,132 @@
<script>
import axios from "axios";
import { _ } from "svelte-i18n";
import { apikey, page, stationinfo } from "./store.js";
function init(el) {
el.focus();
}
let lastscan_error = "";
let lastscan_time = "";
let lastscan_laptime = "";
let lastscan_totaldistance = "";
let card = "";
// live clock at the top
let time = new Date();
$: hours = (time.getHours() + "").padStart(2, "0");
$: minutes = (time.getMinutes() + "").padStart(2, "0");
$: seconds = (time.getSeconds() + "").padStart(2, "0");
setInterval(() => {
time = new Date();
}, 1000);
</script>
<div class="min-h-screen">
<div class="bg-white shadow p-2">
<div class="flex flex-wrap -mx-1 overflow-hidden">
<div class="my-1 px-1 w-1/3 overflow-hidden text-center self-center">
<img src="/favicon.png" alt="" class="h-14 mx-auto" />
</div>
<div class="my-1 px-1 w-1/3 overflow-hidden text-center self-center">
Lauf Für Kaya! Scan 📷
</div>
<div class="my-1 px-1 w-1/3 overflow-hidden text-center self-center">
{JSON.parse($stationinfo).track.name} - #{JSON.parse($stationinfo).track
.id} - {JSON.parse($stationinfo).track.distance}m
</div>
</div>
</div>
<h1 class="mr-6 text-7xl font-semibold text-center text-gray-900">
{hours}:{minutes}:{seconds}
</h1>
<section class="px-4 py-24 mx-auto max-w-7xl">
<div class="mx-auto space-y-5 w-full md:w-1/2">
{#if lastscan_error}
<div
class="text-white px-6 py-4 border-0 rounded relative bg-red-500 mt-2"
>
<span class="inline-block align-middle">
<b class="capitalize">Error!</b><br />{lastscan_error}
</span>
</div>
{/if}
<form
class="space-y-4"
onsubmit="event.preventDefault();"
on:submit={() => {
if (card === "cnf") {
page.set("settings");
} else {
card = parseInt(card);
lastscan_error = "";
axios
.request({
method: "POST",
url: config.endpoint + "api/scans/trackscans",
headers: { Authorization: "Bearer " + $apikey },
data: { card },
})
.then((response) => {
const time = new Date();
const hours = (time.getHours() + "").padStart(2, "0");
const minutes = (time.getMinutes() + "").padStart(2, "0");
const seconds = (time.getSeconds() + "").padStart(2, "0");
lastscan_time = hours + ":" + minutes + ":" + seconds;
response.data.lapTime =
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) => {
lastscan_error = e.response.data.message;
});
}
card = "";
}}
>
<label class="block">
<span class="block mb-1 text-xs font-medium text-gray-700"
>{$_("runner_card")}</span
>
<input
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mt-1 leading-tight focus:outline-none focus:shadow-outline"
type="text"
placeholder="123456789"
required
use:init
bind:value={card}
/>
</label>
{#if lastscan_totaldistance}
<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-3xl font-bold text-center">total distance</h1>
<h1 class="text-8xl font-bold text-center">
{lastscan_totaldistance}
</h1>
<h1 class="text-3xl font-bold text-center">lap time</h1>
<h1 class="text-8xl font-bold text-center">{lastscan_laptime}</h1>
{:else}
<h1 class="text-3xl font-bold text-center">
{$_("please_scan_a_card")}
</h1>
{/if}
<button type="submit" class="hidden">{$_("scan")}</button>
</form>
</div>
</section>
</div>

View File

@@ -1,17 +1,43 @@
<!-- -->
<script>
import { apikey, lang, page } from "./store.js";
import { _ } from "svelte-i18n";
import { apikey, lang, page, stationinfo } from "./store.js";
</script>
<div class="p-5 min-h-screen">
<h1 class="font-bold text-3xl w-full text-center text-gray-900">
Lauf Für Kaya! Scan 📷
</h1>
<h1 class="text-3xl w-full text-center text-gray-900">Settings</h1>
<p class="block text-sm font-bold text-gray-700">API Key</p>
<h1 class="text-3xl w-full text-center text-gray-900">{$_("settings")}</h1>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("api_key")}</p>
<p class="block text-sm text-gray-700">{$apikey}</p>
<br />
<p class="block text-sm font-bold text-gray-700">Language</p>
<p class="block text-sm font-bold text-gray-700 mt-2">
{$_("station_description")}
</p>
<p class="block text-sm text-gray-700">
{JSON.parse($stationinfo).description}
</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("station_id")}</p>
<p class="block text-sm text-gray-700">{JSON.parse($stationinfo).id}</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("track_id")}</p>
<p class="block text-sm text-gray-700">{JSON.parse($stationinfo).track.id}</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("track_name")}</p>
<p class="block text-sm text-gray-700">
{JSON.parse($stationinfo).track.name}
</p>
<p class="block text-sm font-bold text-gray-700 mt-2">
{$_("track_distance")}
</p>
<p class="block text-sm text-gray-700">
{JSON.parse($stationinfo).track.distance}
</p>
<p class="block text-sm font-bold text-gray-700 mt-2">
{$_("minimum_lap_time")}
</p>
<p class="block text-sm text-gray-700">
{JSON.parse($stationinfo).track.minimumLapTime}s
</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("language")}</p>
<div class="w-full">
<div class="inline-block mr-2 mt-2">
<button
@@ -72,7 +98,7 @@
page.set("");
}}
class="mb-3 w-full py-3 border-black border-3 text-black focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
>Back to Scanner</button
>{$_("back_to_scanner")}</button
>
<button
on:click={() => {
@@ -80,6 +106,6 @@
page.set("");
}}
class="w-full py-3 bg-black text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
>Log Out from this Client</button
>{$_("log_out_from_this_client")}</button
>
</div>

26
src/locales/de.json Normal file
View File

@@ -0,0 +1,26 @@
{
"api_key": "API Key",
"back_to_scanner": "Zurück zum Scanner",
"client_token": "Client Token",
"configuration": "Konfiguration",
"configure": "Konfigurieren",
"error": "Error!",
"language": "Sprache",
"log_out_from_this_client": "Von diesem Scanner abmelden",
"minimum_lap_time": "minimale Rundenzeit",
"please_check_your_token_and_try_again": "Bitte überprüfe den Token und versuche es erneut...",
"please_provide_a_valid_client_token": "Bitte gebe einen gültigen Client-Token an ...",
"please_provide_the_scan_client_token": "Bitte gebe den Scan-Client-Token an.",
"please_scan_a_card": "Bitte scanne eine Karte ...",
"runner_card": "Läuferkarte",
"scan": "Scannen!",
"see_our_configuration_guide": "Siehe dir unsere Konfigurationsanleitung an.",
"settings": "Einstellungen",
"station_description": "Beschreibung der Scanstation",
"station_id": "Scanstations-ID",
"the_provided_scan_station_is_disabled": "Die angegebene Scanstation ist deaktiviert.",
"the_provided_scan_station_token_is_invalid": "Der angegebene Scanstation-Token ist ungültig.",
"track_distance": "Länge des Tracks",
"track_id": "Track ID",
"track_name": "Track Name"
}

26
src/locales/en.json Normal file
View File

@@ -0,0 +1,26 @@
{
"api_key": "API Key",
"back_to_scanner": "Back to Scanner",
"client_token": "Client Token",
"configuration": "Configuration",
"configure": "Configure",
"error": "Error!",
"language": "Language",
"log_out_from_this_client": "Log Out from this Client",
"minimum_lap_time": "minimum lap time",
"please_check_your_token_and_try_again": "Please check your token and try again...",
"please_provide_a_valid_client_token": "Please provide a valid client token...",
"please_provide_the_scan_client_token": "Please provide the scan client token.",
"please_scan_a_card": "please scan a card...",
"runner_card": "Runner Card",
"scan": "Scan!",
"see_our_configuration_guide": "See our configuration guide.",
"settings": "Settings",
"station_description": "Station Description",
"station_id": "Scanstation ID",
"the_provided_scan_station_is_disabled": "The provided scan station is disabled.",
"the_provided_scan_station_token_is_invalid": "The provided scan station token is invalid.",
"track_distance": "Track Distance",
"track_id": "Track ID",
"track_name": "Track Name"
}

View File

@@ -5,6 +5,11 @@ export const apikey = writable(stored_apikey);
apikey.subscribe((value) => {
localStorage.setItem('apikey', value);
});
const stored_stationinfo = localStorage.getItem('stationinfo');
export const stationinfo = writable(stored_stationinfo);
stationinfo.subscribe((value) => {
localStorage.setItem('stationinfo', value);
});
const stored_page = localStorage.getItem('page');
export const page = writable(stored_page);
page.subscribe((value) => {