Single-binary self-hosted website analytics on Rust axum: collector API, dashboards, world map, and PDF reports.
analyticsaxumdockerrustself-hostedsqliteviteweb-analytics
1// Toggles the property's public flag. The form's `action` attribute holds the
2// correct endpoint (`/properties/{id}/public`).
3document.addEventListener("DOMContentLoaded", function () {
4 const form = document.getElementById("is-public-form");
5 if (!form) return;
6
7 form.addEventListener("change", function () {
8 fetch(form.action, {
9 method: "POST",
10 headers: { "Content-Type": "application/json" },
11 })
12 .then((r) => {
13 if (!r.ok) throw new Error(`${form.action} returned HTTP ${r.status}`);
14 window.location.reload();
15 })
16 .catch((err) => {
17 console.error("public toggle failed:", err);
18 });
19 });
20});