Refactor web build process and update documentation
- Removed Node.js build artifacts from .gitignore and adjusted Makefile to reflect changes in web UI build process, now using server-rendered Go templates instead of React. - Updated README to clarify the new web UI architecture and output formats, emphasizing the removal of the Node.js build step. - Added a command to set the number of frames per render task in manager configuration, enhancing user control over rendering settings. - Improved Gitea workflow by removing unnecessary npm install step, streamlining the CI process.
This commit is contained in:
65
web/static/login.js
Normal file
65
web/static/login.js
Normal file
@@ -0,0 +1,65 @@
|
||||
(function () {
|
||||
const loginForm = document.getElementById("login-form");
|
||||
const registerForm = document.getElementById("register-form");
|
||||
const errorEl = document.getElementById("auth-error");
|
||||
|
||||
function setError(msg) {
|
||||
if (!errorEl) return;
|
||||
if (!msg) {
|
||||
errorEl.classList.add("hidden");
|
||||
errorEl.textContent = "";
|
||||
return;
|
||||
}
|
||||
errorEl.textContent = msg;
|
||||
errorEl.classList.remove("hidden");
|
||||
}
|
||||
|
||||
async function postJSON(url, payload) {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const body = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || "Request failed");
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
if (loginForm) {
|
||||
loginForm.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
const fd = new FormData(loginForm);
|
||||
try {
|
||||
await postJSON("/api/auth/local/login", {
|
||||
username: fd.get("username"),
|
||||
password: fd.get("password"),
|
||||
});
|
||||
window.location.href = "/jobs";
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (registerForm) {
|
||||
registerForm.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
const fd = new FormData(registerForm);
|
||||
try {
|
||||
await postJSON("/api/auth/local/register", {
|
||||
name: fd.get("name"),
|
||||
email: fd.get("email"),
|
||||
password: fd.get("password"),
|
||||
});
|
||||
window.location.href = "/jobs";
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user