add rst command

This commit is contained in:
Philipp Dormann 2023-02-05 13:29:35 +01:00
parent ea08127927
commit ee6af3e069
Signed by: philipp
GPG Key ID: 3BB9ADD52DCA4314
2 changed files with 22 additions and 11 deletions

View File

@ -27,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">
@ -67,6 +69,10 @@
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",
@ -117,6 +123,11 @@
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/")) { if (api_endpoint_input.includes("api/")) {
api_endpoint_input = api_endpoint_input.replace("api/", ""); api_endpoint_input = api_endpoint_input.replace("api/", "");
} }