Compare commits
	
		
			2 Commits
		
	
	
		
			703168081c
			...
			v0.0.0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f211e35517 | |||
| 76ccb2290e | 
@@ -16,7 +16,6 @@ steps:
 | 
			
		||||
      - apk add git zip -f
 | 
			
		||||
      - yarn
 | 
			
		||||
      - yarn build
 | 
			
		||||
      - mkdir out
 | 
			
		||||
      - zip -r out/dist.zip dist
 | 
			
		||||
  - name: gitea_release
 | 
			
		||||
    depends_on: ["run build"]
 | 
			
		||||
@@ -36,5 +35,7 @@ steps:
 | 
			
		||||
    when:
 | 
			
		||||
      event: tag
 | 
			
		||||
trigger:
 | 
			
		||||
  branch:
 | 
			
		||||
    - main
 | 
			
		||||
  event:
 | 
			
		||||
    - tag
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								public/env.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								public/env.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
const config = {
 | 
			
		||||
	endpoint: 'https://dev.lauf-fuer-kaya.de/'
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										3
									
								
								public/env.sample.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								public/env.sample.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
const config = {
 | 
			
		||||
	endpoint: 'https://dev.lauf-fuer-kaya.de/'
 | 
			
		||||
};
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<script>
 | 
			
		||||
  import { apikey, api_endpoint, lang, page } from "./store.js";
 | 
			
		||||
  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";
 | 
			
		||||
@@ -11,13 +11,13 @@
 | 
			
		||||
  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,
 | 
			
		||||
  });
 | 
			
		||||
  console.log("app started with base url " + $api_endpoint);
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
{#if settings_open && is_configured}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,27 +1,16 @@
 | 
			
		||||
<script>
 | 
			
		||||
  import { apikey, lang, stationinfo, api_endpoint } from "./store.js";
 | 
			
		||||
  import { apikey, lang, stationinfo } from "./store.js";
 | 
			
		||||
  import axios from "axios";
 | 
			
		||||
  import { _, locale } from "svelte-i18n";
 | 
			
		||||
  let token;
 | 
			
		||||
  let api_endpoint_input;
 | 
			
		||||
  $: error = false;
 | 
			
		||||
  $: errormessage = "";
 | 
			
		||||
  $: isTokenValid =
 | 
			
		||||
    token?.length === 44 &&
 | 
			
		||||
    token.split(".")[0].length === 7 &&
 | 
			
		||||
    isUUID(token.split(".")[1]);
 | 
			
		||||
  $: isEndpointValid = validURL(api_endpoint_input);
 | 
			
		||||
  function validURL(str) {
 | 
			
		||||
    var pattern = new RegExp(
 | 
			
		||||
      "^(https?:\\/\\/)?" + // protocol
 | 
			
		||||
        "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
 | 
			
		||||
        "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
 | 
			
		||||
        "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
 | 
			
		||||
        "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
 | 
			
		||||
        "(\\#[-a-z\\d_]*)?$",
 | 
			
		||||
      "i"
 | 
			
		||||
    ); // fragment locator
 | 
			
		||||
    return !!pattern.test(str);
 | 
			
		||||
  function isLocale(l) {
 | 
			
		||||
    return $locale == l;
 | 
			
		||||
  }
 | 
			
		||||
  function isUUID(uuid) {
 | 
			
		||||
    let s = "" + uuid;
 | 
			
		||||
@@ -82,7 +71,7 @@
 | 
			
		||||
          </div>
 | 
			
		||||
        {/if}
 | 
			
		||||
      {/if}
 | 
			
		||||
      {#if $api_endpoint}
 | 
			
		||||
 | 
			
		||||
      <form
 | 
			
		||||
        class="flex flex-col pt-3 md:pt-8"
 | 
			
		||||
        onsubmit="event.preventDefault();"
 | 
			
		||||
@@ -90,7 +79,7 @@
 | 
			
		||||
          axios
 | 
			
		||||
            .request({
 | 
			
		||||
              method: "GET",
 | 
			
		||||
                url: $api_endpoint + "api/stations/me",
 | 
			
		||||
              url: config.endpoint + "api/stations/me",
 | 
			
		||||
              headers: { Authorization: "Bearer " + token },
 | 
			
		||||
            })
 | 
			
		||||
            .then(function (response) {
 | 
			
		||||
@@ -133,48 +122,6 @@
 | 
			
		||||
          >{$_("configure")}</button
 | 
			
		||||
        >
 | 
			
		||||
      </form>
 | 
			
		||||
      {:else}
 | 
			
		||||
        <form
 | 
			
		||||
          class="flex flex-col pt-3 md:pt-8"
 | 
			
		||||
          onsubmit="event.preventDefault();"
 | 
			
		||||
          on:submit={() => {
 | 
			
		||||
            if (api_endpoint_input.substr(-1) !== "/") {
 | 
			
		||||
              api_endpoint_input = api_endpoint_input + "/";
 | 
			
		||||
            }
 | 
			
		||||
            api_endpoint.set(api_endpoint_input);
 | 
			
		||||
          }}
 | 
			
		||||
        >
 | 
			
		||||
          <div class="flex flex-col pt-4">
 | 
			
		||||
            <label for="api_endpoint" class="text-lg"
 | 
			
		||||
              >{$_("api_endpoint")}</label
 | 
			
		||||
            >
 | 
			
		||||
            <input
 | 
			
		||||
              type="text"
 | 
			
		||||
              id="api_endpoint"
 | 
			
		||||
              placeholder={$_("api_endpoint")}
 | 
			
		||||
              bind:value={api_endpoint_input}
 | 
			
		||||
              class:border-red-500={!isEndpointValid}
 | 
			
		||||
              class:border-solid={!isEndpointValid}
 | 
			
		||||
              class:border-3={!isEndpointValid}
 | 
			
		||||
              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"
 | 
			
		||||
            />
 | 
			
		||||
          </div>
 | 
			
		||||
          {#if !isEndpointValid}
 | 
			
		||||
            <span class="text-sm"
 | 
			
		||||
              >{$_("please_provide_a_valid_client_api_endpoint")}</span
 | 
			
		||||
            >
 | 
			
		||||
          {/if}
 | 
			
		||||
          <button
 | 
			
		||||
            disabled={!isEndpointValid}
 | 
			
		||||
            class:cursor-pointer={isEndpointValid}
 | 
			
		||||
            class:opacity-50={!isEndpointValid}
 | 
			
		||||
            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
 | 
			
		||||
          >
 | 
			
		||||
        </form>
 | 
			
		||||
      {/if}
 | 
			
		||||
      <div class="text-center pt-12 pb-12">
 | 
			
		||||
        <p>
 | 
			
		||||
          <svg
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<script>
 | 
			
		||||
  import axios from "axios";
 | 
			
		||||
  import { _ } from "svelte-i18n";
 | 
			
		||||
  import { apikey, api_endpoint, page, stationinfo } from "./store.js";
 | 
			
		||||
  import { apikey, page, stationinfo } from "./store.js";
 | 
			
		||||
  function init(el) {
 | 
			
		||||
    el.focus();
 | 
			
		||||
  }
 | 
			
		||||
@@ -9,7 +9,6 @@
 | 
			
		||||
  let lastscan_time = "";
 | 
			
		||||
  let lastscan_laptime = "";
 | 
			
		||||
  let lastscan_totaldistance = "";
 | 
			
		||||
  let lastscan_valid = true;
 | 
			
		||||
  let card = "";
 | 
			
		||||
  // live clock at the top
 | 
			
		||||
  let time = new Date();
 | 
			
		||||
@@ -65,7 +64,7 @@
 | 
			
		||||
            axios
 | 
			
		||||
              .request({
 | 
			
		||||
                method: "POST",
 | 
			
		||||
                url: $api_endpoint + "api/scans/trackscans",
 | 
			
		||||
                url: config.endpoint + "api/scans/trackscans",
 | 
			
		||||
                headers: { Authorization: "Bearer " + $apikey },
 | 
			
		||||
                data: { card },
 | 
			
		||||
              })
 | 
			
		||||
@@ -84,7 +83,6 @@
 | 
			
		||||
                  ) +
 | 
			
		||||
                  "s";
 | 
			
		||||
                lastscan_laptime = response.data.lapTime;
 | 
			
		||||
                lastscan_valid = response.data.valid;
 | 
			
		||||
                lastscan_totaldistance =
 | 
			
		||||
                  Math.floor(response.data.runner.distance / 1000) +
 | 
			
		||||
                  "km " +
 | 
			
		||||
@@ -114,44 +112,14 @@
 | 
			
		||||
          />
 | 
			
		||||
        </label>
 | 
			
		||||
        {#if lastscan_totaldistance}
 | 
			
		||||
          {#if !lastscan_valid || lastscan_error}
 | 
			
		||||
            <svg
 | 
			
		||||
              xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
              width="20rem"
 | 
			
		||||
              height="20rem"
 | 
			
		||||
              class="ml-auto mr-auto"
 | 
			
		||||
              version="1.0"
 | 
			
		||||
              title="Invalid"
 | 
			
		||||
              viewBox="0 0 100 100"
 | 
			
		||||
              ><g fill="none" stroke="red"
 | 
			
		||||
                ><path d="M6 6l88 88" stroke-width="18.1" /><path
 | 
			
		||||
                  d="M6 94L94 6"
 | 
			
		||||
                  stroke-width="17.8"
 | 
			
		||||
                /></g
 | 
			
		||||
              ></svg
 | 
			
		||||
            >
 | 
			
		||||
          {:else}
 | 
			
		||||
            <svg
 | 
			
		||||
              xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
              width="20rem"
 | 
			
		||||
              height="20rem"
 | 
			
		||||
              class="ml-auto mr-auto"
 | 
			
		||||
              title="Valid"
 | 
			
		||||
              viewBox="0 0 600 600"
 | 
			
		||||
              ><path
 | 
			
		||||
                d="M8 405s115 129 138 182h99c41-126 203-429 341-535 28-37-43-52-102-27-87 36-252 317-283 384-44 12-90-74-90-74z"
 | 
			
		||||
                fill="#181"
 | 
			
		||||
              /></svg
 | 
			
		||||
            >
 | 
			
		||||
          {/if}
 | 
			
		||||
          <h1 class="text-2xl font-bold text-center">{$_("total-distance")}</h1>
 | 
			
		||||
          <h1 class="text-6xl font-bold text-center">
 | 
			
		||||
          <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-2xl font-bold text-center">{$_("lap-time")}</h1>
 | 
			
		||||
          <h1 class="text-6xl font-bold text-center">{lastscan_laptime}</h1>
 | 
			
		||||
          <h1 class="text-2xl 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">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")}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<script>
 | 
			
		||||
  import { _ } from "svelte-i18n";
 | 
			
		||||
 | 
			
		||||
  import { apikey, api_endpoint, lang, page, stationinfo } from "./store.js";
 | 
			
		||||
  import { apikey, lang, page, stationinfo } from "./store.js";
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<div class="p-5 min-h-screen">
 | 
			
		||||
@@ -103,7 +103,6 @@
 | 
			
		||||
  <button
 | 
			
		||||
    on:click={() => {
 | 
			
		||||
      apikey.set("");
 | 
			
		||||
      api_endpoint.set("");
 | 
			
		||||
      page.set("");
 | 
			
		||||
    }}
 | 
			
		||||
    class="w-full py-3 bg-black text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,4 @@
 | 
			
		||||
{
 | 
			
		||||
    "api_endpoint": "API-Endpunkt",
 | 
			
		||||
    "api_key": "API Key",
 | 
			
		||||
    "back_to_scanner": "Zurück zum Scanner",
 | 
			
		||||
    "client_token": "Client Token",
 | 
			
		||||
@@ -7,12 +6,9 @@
 | 
			
		||||
    "configure": "Konfigurieren",
 | 
			
		||||
    "error": "Error!",
 | 
			
		||||
    "language": "Sprache",
 | 
			
		||||
    "lap-time": "Rundenzeit",
 | 
			
		||||
    "last-scan": "Letzter Scan um",
 | 
			
		||||
    "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_api_endpoint": "Bitte gebe einen gültigen API-Endpunkt an ...",
 | 
			
		||||
    "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 ...",
 | 
			
		||||
@@ -24,7 +20,6 @@
 | 
			
		||||
    "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.",
 | 
			
		||||
    "total-distance": "Gesamtdistanz",
 | 
			
		||||
    "track_distance": "Länge des Tracks",
 | 
			
		||||
    "track_id": "Track ID",
 | 
			
		||||
    "track_name": "Track Name"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,4 @@
 | 
			
		||||
{
 | 
			
		||||
    "api_endpoint": "API Endpoint",
 | 
			
		||||
    "api_key": "API Key",
 | 
			
		||||
    "back_to_scanner": "Back to Scanner",
 | 
			
		||||
    "client_token": "Client Token",
 | 
			
		||||
@@ -7,12 +6,9 @@
 | 
			
		||||
    "configure": "Configure",
 | 
			
		||||
    "error": "Error!",
 | 
			
		||||
    "language": "Language",
 | 
			
		||||
    "lap-time": "lap time",
 | 
			
		||||
    "last-scan": "last scan",
 | 
			
		||||
    "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_api_endpoint": "Please provide a valid api endpoint...",
 | 
			
		||||
    "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...",
 | 
			
		||||
@@ -24,7 +20,6 @@
 | 
			
		||||
    "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.",
 | 
			
		||||
    "total-distance": "total distance",
 | 
			
		||||
    "track_distance": "Track Distance",
 | 
			
		||||
    "track_id": "Track ID",
 | 
			
		||||
    "track_name": "Track Name"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,5 @@
 | 
			
		||||
import { writable } from 'svelte/store';
 | 
			
		||||
 | 
			
		||||
const stored_api_endpoint = localStorage.getItem('api_endpoint')||"";
 | 
			
		||||
export const api_endpoint = writable(stored_api_endpoint);
 | 
			
		||||
api_endpoint.subscribe((value) => {
 | 
			
		||||
	localStorage.setItem('api_endpoint', value);
 | 
			
		||||
});
 | 
			
		||||
const stored_apikey = localStorage.getItem('apikey');
 | 
			
		||||
export const apikey = writable(stored_apikey);
 | 
			
		||||
apikey.subscribe((value) => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user