diff --git a/internal/httpserver/server.go b/internal/httpserver/server.go index 462a5c9..22bb005 100644 --- a/internal/httpserver/server.go +++ b/internal/httpserver/server.go @@ -74,7 +74,7 @@ func (s *Server) middleware(next http.Handler) http.Handler { w.Header().Set("X-Content-Type-Options", "nosniff") w.Header().Set("Referrer-Policy", "same-origin") - w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self' https://unpkg.com https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self';") + w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self';") if r.TLS != nil || strings.EqualFold(r.Header.Get("X-Forwarded-Proto"), "https") { w.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains") } diff --git a/internal/httpserver/ui/static/app.js b/internal/httpserver/ui/static/app.js index 7aaacbb..604d955 100644 --- a/internal/httpserver/ui/static/app.js +++ b/internal/httpserver/ui/static/app.js @@ -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; diff --git a/internal/httpserver/ui/templates/index.html b/internal/httpserver/ui/templates/index.html index 3f878c8..0b56c60 100644 --- a/internal/httpserver/ui/templates/index.html +++ b/internal/httpserver/ui/templates/index.html @@ -5,7 +5,6 @@ {{ .Title }} - @@ -28,7 +27,7 @@
-
+ @@ -97,7 +96,7 @@
- +

Quick Filters