dataforth/testdatadb: wire UI presets + publish buttons; add /api/search sort/dir

Backend (deployed live on AD2, service restarted, + repo copy resynced — it was
far behind the deployed server):
- /api/search: add whitelisted sort/dir (NULLS LAST) so sortable headers and the
  "Latest uploads" preset work. web_status filter and POST /api/upload already
  existed on the server; the stale repo copy now matches live.

Frontend (redesign prototype):
- "Latest uploads" preset (web_status=on + sort=api_uploaded_at desc) and
  "Not yet published" (web_status=off) are now active presets.
- Push to Web (inspector) + Re-push (multi-select) wired to POST /api/upload
  behind a confirm() gate; refresh WEB status after. Validated idempotently on a
  published record (unchanged:1, errors:0).
- "Retested units" stays disabled — needs a retest flag in the pipeline (next).

tools/preview-proxy.py: forward POST so the publish buttons work in same-origin preview.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 10:08:38 -07:00
parent c2335e859d
commit 84c7579a3d
3 changed files with 408 additions and 171 deletions

View File

@@ -37,6 +37,23 @@ class H(http.server.BaseHTTPRequestHandler):
else:
self._send(404, "text/plain", b"not found")
def do_POST(self):
if self.path.startswith("/api/"):
n = int(self.headers.get("Content-Length", 0))
body = self.rfile.read(n) if n else b""
req = urllib.request.Request(
TARGET + self.path, data=body, method="POST",
headers={"Content-Type": self.headers.get("Content-Type", "application/json")})
try:
with urllib.request.urlopen(req, timeout=120) as r:
self._send(200, r.headers.get("Content-Type", "application/json"), r.read())
except urllib.error.HTTPError as e:
self._send(e.code, "application/json", e.read())
except Exception as e:
self._send(502, "text/plain", str(e).encode())
else:
self._send(404, "text/plain", b"not found")
def _send(self, code, ct, body):
self.send_response(code)
self.send_header("Content-Type", ct)