parent
fe0cba9058
commit
abdc510305
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { apikey, api_endpoint, lang, page, clear } from "./store.js";
|
import { apikey, api_endpoint, lang, page, clear, laptime_track } from "./store.js";
|
||||||
import { addMessages, init } from "svelte-i18n";
|
import { addMessages, init } from "svelte-i18n";
|
||||||
import en from "./locales/en.json";
|
import en from "./locales/en.json";
|
||||||
import de from "./locales/de.json";
|
import de from "./locales/de.json";
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
import Beamershow from "./Beamershow.svelte";
|
import Beamershow from "./Beamershow.svelte";
|
||||||
import Login from "./Login.svelte";
|
import Login from "./Login.svelte";
|
||||||
import Settings from "./Settings.svelte";
|
import Settings from "./Settings.svelte";
|
||||||
$: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
|
$: is_configured = $apikey && $apikey !== "null" && $apikey !== "" && $laptime_track != 0 && $laptime_track != null;
|
||||||
$: settings_open = $page === "settings";
|
$: settings_open = $page === "settings";
|
||||||
init({
|
init({
|
||||||
fallbackLocale: "en-US",
|
fallbackLocale: "en-US",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import { fade, slide } from "svelte/transition";
|
import { fade, slide } from "svelte/transition";
|
||||||
import { apikey, api_endpoint, page, stationinfo } from "./store.js";
|
import { apikey, api_endpoint, laptime_track, page, stationinfo } from "./store.js";
|
||||||
function init(el) {
|
function init(el) {
|
||||||
el.focus();
|
el.focus();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
axios
|
axios
|
||||||
.request({
|
.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: $api_endpoint + "api/stats/runners/laptime",
|
url: $api_endpoint + "api/stats/runners/laptime?track="+$laptime_track,
|
||||||
headers: { Authorization: "Bearer " + $apikey },
|
headers: { Authorization: "Bearer " + $apikey },
|
||||||
})
|
})
|
||||||
.then(function ({ data }) {
|
.then(function ({ data }) {
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { apikey, lang, stationinfo, api_endpoint } from "./store.js";
|
import { apikey, lang, stationinfo, api_endpoint, laptime_track } from "./store.js";
|
||||||
import isURL from "validator/lib/isURL";
|
import isURL from "validator/lib/isURL";
|
||||||
import isUUID from "validator/lib/isUUID";
|
import isUUID from "validator/lib/isUUID";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { _, locale } from "svelte-i18n";
|
import { _, locale } from "svelte-i18n";
|
||||||
let token;
|
let token;
|
||||||
let api_endpoint_input = "";
|
let api_endpoint_input = "";
|
||||||
|
let track;
|
||||||
$: error = false;
|
$: error = false;
|
||||||
$: errormessage = "";
|
$: errormessage = "";
|
||||||
$: isTokenValid =
|
$: isTokenValid =
|
||||||
|
@ -61,12 +62,11 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if $api_endpoint}
|
{#if $api_endpoint && !$apikey}
|
||||||
<form
|
<form
|
||||||
class="flex flex-col pt-3 md:pt-8"
|
class="flex flex-col pt-3 md:pt-8"
|
||||||
onsubmit="event.preventDefault();"
|
onsubmit="event.preventDefault();"
|
||||||
on:submit={() => {
|
on:submit={() => {
|
||||||
// return
|
|
||||||
axios
|
axios
|
||||||
.request({
|
.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
@ -113,6 +113,37 @@
|
||||||
>{$_("configure")}</button
|
>{$_("configure")}</button
|
||||||
>
|
>
|
||||||
</form>
|
</form>
|
||||||
|
{:else if $api_endpoint && $apikey}
|
||||||
|
<form
|
||||||
|
class="flex flex-col pt-3 md:pt-8"
|
||||||
|
onsubmit="event.preventDefault();"
|
||||||
|
on:submit={() => {
|
||||||
|
laptime_track.set(track);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="flex flex-col pt-4">
|
||||||
|
<label for="track" class="text-lg">Track ID</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="track"
|
||||||
|
placeholder="Track"
|
||||||
|
bind:value={track}
|
||||||
|
class:border-red-500={!isTokenValid}
|
||||||
|
class:border-solid={!isTokenValid}
|
||||||
|
class:border-3={!isTokenValid}
|
||||||
|
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>
|
||||||
|
<button
|
||||||
|
disabled={!track}
|
||||||
|
class:cursor-pointer={track}
|
||||||
|
class:opacity-50={!track}
|
||||||
|
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>
|
||||||
{:else}
|
{:else}
|
||||||
<form
|
<form
|
||||||
class="flex flex-col pt-3 md:pt-8"
|
class="flex flex-col pt-3 md:pt-8"
|
||||||
|
|
|
@ -15,6 +15,11 @@ export const stationinfo = writable(stored_stationinfo);
|
||||||
stationinfo.subscribe((value) => {
|
stationinfo.subscribe((value) => {
|
||||||
localStorage.setItem('stationinfo', value);
|
localStorage.setItem('stationinfo', value);
|
||||||
});
|
});
|
||||||
|
const stored_laptime_track = localStorage.getItem('laptime_track');
|
||||||
|
export const laptime_track = writable(stored_laptime_track);
|
||||||
|
laptime_track.subscribe((value) => {
|
||||||
|
localStorage.setItem('laptime_track', value);
|
||||||
|
});
|
||||||
const stored_page = localStorage.getItem('page');
|
const stored_page = localStorage.getItem('page');
|
||||||
export const page = writable(stored_page);
|
export const page = writable(stored_page);
|
||||||
page.subscribe((value) => {
|
page.subscribe((value) => {
|
||||||
|
|
Loading…
Reference in New Issue