bullet-proof login ux
This commit is contained in:
parent
e0f400a800
commit
ea08127927
|
@ -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,
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</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();"
|
||||||
|
@ -117,6 +117,9 @@
|
||||||
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.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 + "/";
|
||||||
}
|
}
|
||||||
|
|
22
src/store.js
22
src/store.js
|
@ -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();
|
||||||
}
|
}
|
Loading…
Reference in New Issue