Compare commits

...

5 Commits
0.1.3 ... 0.1.4

7 changed files with 6053 additions and 59 deletions

View File

@ -2,8 +2,18 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [0.1.4](https://git.odit.services/lfk/beamershow/compare/0.1.3...0.1.4)
- cleanup invalid track stuff (leftovers from scanclient) [`c485898`](https://git.odit.services/lfk/beamershow/commit/c485898b7db7ae09f6e405e12aa6d458833f2dcf)
- bullet-proof login ux [`ea08127`](https://git.odit.services/lfk/beamershow/commit/ea08127927e2b1ebcbcd7907fbf51a66a43da421)
- add rst command [`ee6af3e`](https://git.odit.services/lfk/beamershow/commit/ee6af3e06921ef33651076b8767149c2df3a1f2d)
- Settings: reload on lang change [`e0f400a`](https://git.odit.services/lfk/beamershow/commit/e0f400a800f2652cf3edf2ac0a5f802b65d0c460)
#### [0.1.3](https://git.odit.services/lfk/beamershow/compare/0.1.2...0.1.3) #### [0.1.3](https://git.odit.services/lfk/beamershow/compare/0.1.2...0.1.3)
> 8 April 2021
- 🚀Bumped version to 0.1.3 [`80f5c38`](https://git.odit.services/lfk/beamershow/commit/80f5c38c364c02d70a99f0e06ea9153e10438bfb)
- Fixed image name [`205e09e`](https://git.odit.services/lfk/beamershow/commit/205e09e2fc6a2a49251278a8ead31e1718ac7e44) - Fixed image name [`205e09e`](https://git.odit.services/lfk/beamershow/commit/205e09e2fc6a2a49251278a8ead31e1718ac7e44)
#### [0.1.2](https://git.odit.services/lfk/beamershow/compare/0.1.1...0.1.2) #### [0.1.2](https://git.odit.services/lfk/beamershow/compare/0.1.1...0.1.2)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@lfk/beamershow", "name": "@lfk/beamershow",
"version": "0.1.3", "version": "0.1.4",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",

View File

@ -12,12 +12,10 @@
import Login from "./Login.svelte"; import Login from "./Login.svelte";
import Settings from "./Settings.svelte"; import Settings from "./Settings.svelte";
export let settings_open = false; export let settings_open = false;
$: is_configured = $: is_configured = $apikey?.length === 44 && $api_endpoint?.includes("://");
$apikey && // &&
$apikey !== "null" && // $laptime_track != 0 &&
$apikey !== "" && // $laptime_track != null;
$laptime_track != 0 &&
$laptime_track != null;
init({ init({
fallbackLocale: "en-US", fallbackLocale: "en-US",
initialLocale: $lang, initialLocale: $lang,
@ -29,12 +27,12 @@
if (e.key === "Escape") { if (e.key === "Escape") {
modal_open = false; modal_open = false;
} }
if (e.keyCode === 13) { // if (e.keyCode === 13) {
if (createbtnenabled === true) { // if (createbtnenabled === true) {
createbtnenabled = false; // createbtnenabled = false;
submit(); // submit();
} // }
} // }
if (command === "" && e.key === "c") { if (command === "" && e.key === "c") {
command = "c"; command = "c";
} else if (command === "c" && e.key === "n") { } else if (command === "c" && e.key === "n") {

View File

@ -1,5 +1,5 @@
<script> <script>
import { apikey, lang, api_endpoint, laptime_track } from "./store.js"; import { apikey, lang, api_endpoint, laptime_track, clear } 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";
@ -10,10 +10,12 @@
$: error = false; $: error = false;
$: errormessage = ""; $: errormessage = "";
$: isTokenValid = $: isTokenValid =
token?.length === 44 && token === "rst" ||
token.split(".")[0].length === 7 && (token?.length === 44 &&
isUUID(token.split(".")[1]); token.split(".")[0].length === 7 &&
$: isEndpointValid = isURL(api_endpoint_input); isUUID(token.split(".")[1]));
$: isEndpointValid =
api_endpoint_input === "rst" || isURL(api_endpoint_input);
</script> </script>
<div class="w-full flex flex-wrap"> <div class="w-full flex flex-wrap">
@ -62,11 +64,15 @@
</div> </div>
{/if} {/if}
{/if} {/if}
{#if $api_endpoint && !$apikey} {#if $api_endpoint?.includes("://") && (!$apikey || $apikey == null)}
<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={() => {
if (token === "rst") {
clear();
return;
}
axios axios
.request({ .request({
method: "GET", method: "GET",
@ -112,42 +118,19 @@
>{$_("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"
onsubmit="event.preventDefault();" onsubmit="event.preventDefault();"
on:submit={() => { on:submit={() => {
if (api_endpoint_input === "rst") {
clear();
api_endpoint_input = "";
return;
}
if (api_endpoint_input.includes("api/")) {
api_endpoint_input = api_endpoint_input.replace("api/", "");
}
if (api_endpoint_input.substr(-1) !== "/") { if (api_endpoint_input.substr(-1) !== "/") {
api_endpoint_input = api_endpoint_input + "/"; api_endpoint_input = api_endpoint_input + "/";
} }

View File

@ -13,14 +13,13 @@
<p class="block text-sm text-gray-700">{$api_endpoint}</p> <p class="block text-sm text-gray-700">{$api_endpoint}</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("api_key")}</p> <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> <p class="block text-sm text-gray-700">{$apikey}</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("track_id")}</p>
<p class="block text-sm text-gray-700">{$laptime_track}</p>
<p class="block text-sm font-bold text-gray-700 mt-2">{$_("language")}</p> <p class="block text-sm font-bold text-gray-700 mt-2">{$_("language")}</p>
<div class="w-full"> <div class="w-full">
<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");
location.reload();
}} }}
type="button" type="button"
class:bg-blue-700={$lang === "de-DE"} class:bg-blue-700={$lang === "de-DE"}
@ -46,6 +45,7 @@
<button <button
on:click={() => { on:click={() => {
lang.set("en-EN"); lang.set("en-EN");
location.reload();
}} }}
type="button" type="button"
class:bg-blue-700={$lang === "en-EN"} class:bg-blue-700={$lang === "en-EN"}

View File

@ -1,29 +1,39 @@
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
const stored_api_endpoint = localStorage.getItem('api_endpoint')||""; const stored_api_endpoint = localStorage.getItem('api_endpoint');
export const api_endpoint = writable(stored_api_endpoint); export const api_endpoint = writable(stored_api_endpoint);
api_endpoint.subscribe((value) => { api_endpoint.subscribe((value) => {
localStorage.setItem('api_endpoint', value); if (value != null) {
localStorage.setItem('api_endpoint', value);
}
}); });
const stored_apikey = localStorage.getItem('apikey'); const stored_apikey = localStorage.getItem('apikey');
export const apikey = writable(stored_apikey); export const apikey = writable(stored_apikey);
apikey.subscribe((value) => { apikey.subscribe((value) => {
localStorage.setItem('apikey', value); if (value != null) {
localStorage.setItem('apikey', value);
}
}); });
const stored_laptime_track = localStorage.getItem('laptime_track'); const stored_laptime_track = localStorage.getItem('laptime_track');
export const laptime_track = writable(stored_laptime_track); export const laptime_track = writable(stored_laptime_track);
laptime_track.subscribe((value) => { laptime_track.subscribe((value) => {
localStorage.setItem('laptime_track', value); if (value != null) {
localStorage.setItem('laptime_track', value);
}
}); });
const stored_lang = localStorage.getItem('lang') === 'null' ? navigator.language : localStorage.getItem('lang'); const stored_lang = localStorage.getItem('lang') === 'null' ? navigator.language : localStorage.getItem('lang');
export const lang = writable(stored_lang); export const lang = writable(stored_lang);
lang.subscribe((value) => { lang.subscribe((value) => {
localStorage.setItem('lang', value); if (value != null) {
localStorage.setItem('lang', value);
}
}); });
export function clear(){ export function clear() {
api_endpoint.set(null) api_endpoint.set(null)
api_endpoint.set("")
apikey.set(null); apikey.set(null);
apikey.set("");
laptime_track.set(null) laptime_track.set(null)
localStorage.clear(); localStorage.clear();
} }