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") {
modal_open = false;
}
if (e.keyCode === 13) {
if (createbtnenabled === true) {
createbtnenabled = false;
submit();
}
}
// if (e.keyCode === 13) {
// if (createbtnenabled === true) {
// createbtnenabled = false;
// submit();
// }
// }
if (command === "" && e.key === "c") {
command = "c";
} else if (command === "c" && e.key === "n") {

View File

@ -1,5 +1,5 @@
<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 isUUID from "validator/lib/isUUID";
import axios from "axios";
@ -10,10 +10,12 @@
$: error = false;
$: errormessage = "";
$: isTokenValid =
token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]);
$: isEndpointValid = isURL(api_endpoint_input);
token === "rst" ||
(token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]));
$: isEndpointValid =
api_endpoint_input === "rst" || isURL(api_endpoint_input);
</script>
<div class="w-full flex flex-wrap">
@ -67,6 +69,10 @@
class="flex flex-col pt-3 md:pt-8"
onsubmit="event.preventDefault();"
on:submit={() => {
if (token === "rst") {
clear();
return;
}
axios
.request({
method: "GET",
@ -117,6 +123,11 @@
class="flex flex-col pt-3 md:pt-8"
onsubmit="event.preventDefault();"
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/", "");
}