Simplify dashboard

This commit is contained in:
Asher
2020-03-16 12:43:32 -05:00
parent d832f61d5b
commit d192726e80
14 changed files with 205 additions and 304 deletions

View File

@@ -1,4 +1,5 @@
import { getOptions } from "../../common/util"
import { getOptions, normalize } from "../../common/util"
import { ApiEndpoint } from "../../common/http"
import "./app.css"
import "./error.css"
@@ -9,4 +10,29 @@ import "./update.css"
const options = getOptions()
console.log(options)
const isInput = (el: Element): el is HTMLInputElement => {
return !!(el as HTMLInputElement).name
}
document.querySelectorAll("form").forEach((form) => {
if (!form.classList.contains("-x11")) {
return
}
form.addEventListener("submit", (event) => {
event.preventDefault()
const values: { [key: string]: string } = {}
Array.from(form.elements).forEach((element) => {
if (isInput(element)) {
values[element.name] = element.value
}
})
fetch(normalize(`${options.base}/api/${ApiEndpoint.process}`), {
method: "POST",
body: JSON.stringify(values),
})
})
})
// TEMP: Until we can get the real ready event.
const event = new CustomEvent("ide-ready")
window.dispatchEvent(event)