add dashboard to home

This commit is contained in:
Joren de Graaf
2026-10-01 17:29:29 +02:00
parent 66db97b6f7
commit b676f35f0a
24 changed files with 214 additions and 82 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
/* empty css */import"./fireworks-home.js-BAmW5fGZ.js";import"./map.js-DCafyyWY.js";import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
@@ -0,0 +1 @@
/* empty css */import"./fireworks-home.js-BAmW5fGZ.js";import"./map.js-DCafyyWY.js";import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
@@ -0,0 +1 @@
import"../../../theme-BwRovl8e.js";import"../../../manual-report-BMn4sn8O.js";
@@ -0,0 +1 @@
/* empty css */import"../../../theme-BwRovl8e.js";const p=document.getElementById("event-map"),g=p.dataset.h3Resolution,o=L.map(p,{zoomControl:!1,scrollWheelZoom:!1}).setView([52.1326,5.2913],7);L.control.zoom({position:"bottomleft"}).addTo(o);const u=L.control({position:"topright"});u.onAdd=()=>{const t=L.DomUtil.create("div","map-compass");return t.setAttribute("role","img"),t.setAttribute("aria-label","Map compass: north is up"),t.innerHTML='<span class="compass-n">N</span><span class="compass-e">E</span><span class="compass-s">S</span><span class="compass-w">W</span><span class="compass-needle">↑</span>',L.DomEvent.disableClickPropagation(t),t};u.addTo(o);L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png",{maxZoom:18,attribution:"&copy; OpenStreetMap contributors"}).addTo(o);const f=JSON.parse(document.getElementById("h3-cells-data").textContent),M=JSON.parse(document.getElementById("map-events-data").textContent),r=L.latLngBounds([]);f.forEach(t=>{L.polygon(t.boundary,{color:"#f59e0b",weight:2,fillColor:"#f59e0b",fillOpacity:.25}).addTo(o).bindPopup('<span class="popup-title">H3 '+t.cell+'</span><span class="popup-meta">'+t.reports+" reports · "+t.occurrences+" occurrences · resolution "+g+"</span>"),r.extend(L.latLngBounds(t.boundary))});function y(t){return["N","NE","E","SE","S","SW","W","NW"][Math.floor((t+22.5)%360/45)]}function b(t,e,n){const s=e*Math.PI/180,c=t[0]*Math.PI/180,m=t[1]*Math.PI/180,i=n/6378137,d=Math.asin(Math.sin(c)*Math.cos(i)+Math.cos(c)*Math.sin(i)*Math.cos(s)),h=m+Math.atan2(Math.sin(s)*Math.sin(i)*Math.cos(c),Math.cos(i)-Math.sin(c)*Math.sin(d));return[d*180/Math.PI,h*180/Math.PI]}const v=L.divIcon({className:"",html:'<div class="report-icon">✦</div>',iconSize:[37,37],iconAnchor:[19,19]});M.forEach(t=>{const e=t.visually_confirmed?"Visually confirmed":"Not visually confirmed";let n=t.occurrences+" occurrence"+(t.occurrences===1?"":"s")+" · "+e+"<br>Reported "+t.reported_on;if(t.direction_degrees!==null&&(n+="<br>Compass direction "+Math.round(t.direction_degrees)+"° ("+y(t.direction_degrees)+")",t.direction_accuracy_degrees!==null&&(n+=" (±"+Math.round(t.direction_accuracy_degrees)+"°)")),L.marker(t.center,{icon:v}).addTo(o).bindPopup('<span class="popup-title">Manual report · H3 '+t.cell+'</span><span class="popup-meta">'+n+"</span>"),t.direction_degrees!==null){const a=b(t.center,t.direction_degrees,900);L.polyline([t.center,a],{color:"#fff7e6",weight:9,opacity:.8}).addTo(o),L.polyline([t.center,a],{color:"#6d45a0",weight:5,opacity:1}).addTo(o);const s=L.divIcon({className:"",html:'<div class="direction-marker"><span style="transform:rotate('+t.direction_degrees+'deg)">↑</span></div>',iconSize:[56,56],iconAnchor:[28,28]});L.marker(a,{icon:s,interactive:!1}).addTo(o)}});r.isValid()&&o.fitBounds(r.pad(.18));const l=document.getElementById("range");l&&document.querySelectorAll("#from-date, #to-date").forEach(t=>{t.addEventListener("change",()=>{l.value="custom"})});
@@ -0,0 +1 @@
const a=document.querySelector("#manual-report-form"),m=document.querySelector("#manual-submit"),g=document.querySelector("#manual-submission"),C=document.querySelector("#manual-latitude"),b=document.querySelector("#manual-longitude"),w=document.querySelector("#manual-direction-degrees"),y=document.querySelector("#manual-direction-accuracy"),c=document.querySelector("#manual-capture-direction"),t=document.querySelector("#manual-direction-status"),v=document.querySelector("#manual-direction-panel"),f=/Android|iPhone|iPad|iPod|IEMobile|Opera Mini/.test(navigator.userAgent)||navigator.userAgent.includes("Macintosh")&&navigator.maxTouchPoints>1;f&&(v.hidden=!1);let o,r;const l=e=>Number.isFinite(e),S=e=>["N","NE","E","SE","S","SW","W","NW"][Math.floor((e+22.5)%360/45)],p=e=>Number(e.toFixed(1)).toString(),s=()=>{o&&window.removeEventListener("deviceorientation",o),window.clearTimeout(r),o=null,r=null},x=(e,i)=>{const n=i===null?"Accuracy unavailable":"Accuracy: ±"+p(i)+"°";t.innerHTML="<strong>"+p(e)+"° · "+S(e)+"</strong><br>"+n,c.textContent="Stop direction capture"},h=()=>{s(),t.textContent="Point the top of your phone toward the sound — direction will update live.",o=e=>{const i="webkitCompassHeading"in e,n=l(e.webkitCompassHeading)?e.webkitCompassHeading:!i&&e.absolute&&l(e.alpha)?(360-e.alpha)%360:null;if(n===null||n<0||n>=360)return;const u=l(e.webkitCompassAccuracy)&&e.webkitCompassAccuracy>=0?e.webkitCompassAccuracy:null;w.value=n,y.value=u===null?"":u,x(n,u),window.clearTimeout(r)},window.addEventListener("deviceorientation",o),r=window.setTimeout(()=>{s(),c.textContent="Capture direction",t.textContent="Compass unavailable on this device."},15e3)},q=async()=>{if(o){s(),c.textContent="Capture again";return}if(!window.isSecureContext){t.textContent="Compass capture requires a secure HTTPS connection.";return}if(typeof window.DeviceOrientationEvent>"u"){t.textContent="Compass unavailable on this device.";return}if(typeof DeviceOrientationEvent.requestPermission=="function"){t.textContent="Requesting compass permission…";try{if(await DeviceOrientationEvent.requestPermission(!0)!=="granted"){t.textContent="Compass permission denied.";return}}catch{t.textContent="Compass permission denied.";return}}h()},d=()=>{s(),m.disabled=!0,window.htmx?htmx.ajax("POST",a.action,{source:a,target:"#manual-submission",swap:"outerHTML"}):a.submit()};c.addEventListener("click",q);m.addEventListener("click",()=>{if(!navigator.geolocation){d();return}g.textContent="Requesting your optional location…",navigator.geolocation.getCurrentPosition(e=>{C.value=e.coords.latitude,b.value=e.coords.longitude,d()},()=>d(),{enableHighAccuracy:!1,maximumAge:3e5,timeout:1e4})});document.body.addEventListener("htmx:afterRequest",e=>{e.detail.elt===a&&(m.disabled=!1)});