This commit is contained in:
@@ -83,17 +83,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
fileCount.textContent = count === 1 ? fileInput.files[0].name : `${count} files selected`;
|
||||
});
|
||||
|
||||
parseForm.addEventListener("htmx:afterRequest", async (event) => {
|
||||
const xhr = event.detail.xhr;
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
const detail = (xhr.responseText || "").trim();
|
||||
parseForm.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(parseForm);
|
||||
const res = await fetch("/api/manifests/parse", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
if (!res.ok) {
|
||||
const detail = (await res.text()).trim();
|
||||
const suffix = detail ? ` ${detail}` : " Check YAML syntax and try again.";
|
||||
setStatus(`Parse failed (${xhr.status}).${suffix}`, "error");
|
||||
setStatus(`Parse failed (${res.status}).${suffix}`, "error");
|
||||
renderParseIssues([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = JSON.parse(xhr.responseText);
|
||||
const payload = await res.json();
|
||||
const parseIssues = payload.summary?.issues || [];
|
||||
const issues = parseIssues.length;
|
||||
window.KubeViz.lastParsedResources = payload.summary?.resources || 0;
|
||||
|
||||
Reference in New Issue
Block a user