added scheduling

This commit is contained in:
Joren de Graaf
2026-10-10 16:03:14 +02:00
parent e967fc391e
commit 7220dd564f
53 changed files with 769 additions and 67 deletions
+13 -5
View File
@@ -24,13 +24,17 @@
const bounds = L.latLngBounds([]);
h3Cells.forEach((cell) => {
const hasManual = cell.manual_reports > 0;
const hasSensor = cell.sensor_reports > 0;
const color = hasManual && hasSensor ? "#a78bfa" : hasSensor ? "#22d3ee" : "#f59e0b";
const polygon = L.polygon(cell.boundary, {
color: "#f59e0b", weight: 2, fillColor: "#f59e0b", fillOpacity: 0.25,
color, weight: 2, fillColor: color, fillOpacity: 0.25,
}).addTo(map);
polygon.bindPopup(
"<span class=\"popup-title\">H3 " + cell.cell + "</span>" +
"<span class=\"popup-meta\">" + cell.reports + " " + (cell.reports === 1 ? (t.report || "report") : (t.reports || "reports")) + " · " + cell.occurrences +
" " + (cell.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) + " · " + (t.resolution || "resolution") + " " + h3Resolution + "</span>"
" " + (cell.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) + " · " + (t.resolution || "resolution") + " " + h3Resolution +
"<br>" + cell.manual_reports + " " + (t.manualReport || "Manual report") + " · " + cell.sensor_reports + " " + (t.sensorEvent || "Sensor event") + "</span>"
);
bounds.extend(L.latLngBounds(cell.boundary));
});
@@ -60,7 +64,11 @@
const reportIcon = L.divIcon({
className: "", html: "<div class=\"report-icon\">✦</div>", iconSize: [37, 37], iconAnchor: [19, 19],
});
const sensorIcon = L.divIcon({
className: "", html: "<div class=\"sensor-icon\">S</div>", iconSize: [37, 37], iconAnchor: [19, 19],
});
reports.forEach((report) => {
const isSensor = report.source_type === "sensor";
const visualStatus = report.visually_confirmed ? (t.visuallyConfirmed || "Visually confirmed") : (t.notVisuallyConfirmed || "Not visually confirmed");
let detail = report.occurrences + " " + (report.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) +
" · " + visualStatus + "<br>" + (t.reported || "Reported") + " " + report.reported_on;
@@ -70,8 +78,8 @@
detail += " (±" + Math.round(report.direction_accuracy_degrees) + "°)";
}
}
L.marker(report.center, { icon: reportIcon }).addTo(map).bindPopup(
"<span class=\"popup-title\">" + (t.manualReport || "Manual report") + " · H3 " + report.cell + "</span>" +
L.marker(report.center, { icon: isSensor ? sensorIcon : reportIcon }).addTo(map).bindPopup(
"<span class=\"popup-title\">" + (isSensor ? (t.sensorEvent || "Sensor event") : (t.manualReport || "Manual report")) + " · H3 " + report.cell + "</span>" +
"<span class=\"popup-meta\">" + detail + "</span>"
);
@@ -98,4 +106,4 @@
input.addEventListener("change", () => { range.value = "custom"; });
});
}
+16
View File
@@ -21,6 +21,10 @@
const reportTime = document.querySelector("#manual-report-time");
const reportHours = document.querySelector("#report-clock-hours");
const reportMinutes = document.querySelector("#report-clock-minutes");
const occurredAt = document.querySelector("#manual-occurred-at");
const useNow = document.querySelector("#manual-use-now");
const burstStatus = document.querySelector("#manual-burst-status");
const burstDuration = document.querySelector("#manual-burst-duration");
let orientationListener;
let compassUnavailableTimeout;
let compassRotation = null;
@@ -47,6 +51,11 @@
updateReportTime();
if (reportTime) window.setInterval(updateReportTime, 60000);
const idleSubmitLabel = submitLabel?.textContent || "I heard fireworks";
useNow?.addEventListener("click", () => {
const now = new Date();
const local = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
occurredAt.value = local.toISOString().slice(0, 16);
});
const setSubmissionState = (next, message = "") => {
manualForm.dataset.state = next;
@@ -70,16 +79,23 @@
return successful;
};
const showBurstState = () => {
const burst = Number(occurrences.value) >= 3;
if (burstStatus) burstStatus.textContent = burst ? (t.burstEvent || "Burst Event") : (t.ordinaryReport || "Ordinary report");
if (burstDuration) burstDuration.hidden = !burst;
};
const setCount = (value) => {
const count = Number.parseInt(value, 10);
occurrences.value = String(Math.min(1000, Math.max(1, Number.isFinite(count) ? count : 1)));
decrease.disabled = occurrences.value === "1";
increase.disabled = occurrences.value === "1000";
showBurstState();
};
setCount(occurrences.value);
decrease.addEventListener("click", () => setCount(Number(occurrences.value) - 1));
increase.addEventListener("click", () => setCount(Number(occurrences.value) + 1));
occurrences.addEventListener("change", () => setCount(occurrences.value));
occurrences.addEventListener("input", showBurstState);
const stopCompassReading = () => {
if (orientationListener) window.removeEventListener("deviceorientation", orientationListener);
@@ -6,6 +6,67 @@
--manual-report-section-gap: 1rem;
}
.manual-report__occurrence, .manual-report__duration {
display: grid;
gap: .55rem;
max-width: 36rem;
margin-bottom: var(--manual-report-section-gap);
padding: .85rem 1rem;
border: 1px solid #584891;
border-radius: 1rem;
background: #151932;
color: #e9def8;
input[type="datetime-local"], input[type="number"] {
width: 100%;
min-height: 2.75rem;
padding: .45rem .65rem;
border: 1px solid #725da4;
border-radius: .55rem;
color: #f5f0ff;
background: #211d3d;
font: inherit;
color-scheme: dark;
}
small { color: #cbbce5; }
}
.manual-report__duration[hidden] { display: none; }
.manual-report__time-row {
display: flex;
gap: .5rem;
align-items: center;
input { min-width: 0; flex: 1; }
button { flex: none; }
}
@media (max-width: 30rem) {
.manual-report__time-row { flex-direction: column; align-items: stretch; }
.manual-report__time-row button { align-self: flex-start; }
}
.manual-report__occurrence button {
justify-self: start;
padding: .35rem .75rem;
border: 1px solid #725da4;
border-radius: .55rem;
color: #f5f0ff;
background: #302553;
cursor: pointer;
}
.manual-report__check {
display: flex;
align-items: center;
gap: .5rem;
color: #e9def8;
}
.manual-report__burst-status { margin: .5rem 0 0; color: #ffbf72; font-weight: 750; }
.manual-submission__edit {
display: grid;
gap: .4rem;
max-width: 18rem;
margin-top: 1rem;
input[type="number"] { min-height: 2.5rem; padding: .4rem; border-radius: .5rem; }
button { min-height: 2.5rem; cursor: pointer; }
}
.manual-report__primary {
display: grid;
gap: var(--manual-report-section-gap);
+37
View File
@@ -258,6 +258,14 @@ body {
background: #8b5cf633;
}
.legend-sensor {
width: .85rem;
height: .85rem;
border: 2px solid #a5f3fc;
border-radius: .2rem;
background: #0891b2;
}
.legend-line {
width: 1.1rem;
border-top: 2px dashed #644b9c;
@@ -277,6 +285,20 @@ body {
box-shadow: 0 .3rem 1rem #a84f2670;
}
.sensor-icon {
display: grid;
width: 2.3rem;
height: 2.3rem;
place-items: center;
border: 2px solid #cffafe;
border-radius: .55rem;
color: #ecfeff;
font-size: 1rem;
font-weight: 900;
background: #087e97;
box-shadow: 0 .3rem 1rem #06465a88;
}
.source-icon {
display: grid;
width: 2.45rem;
@@ -388,6 +410,18 @@ body {
font-size: .78rem;
}
@media (max-width:80rem) {
.filters {
grid-template-columns: repeat(5,minmax(0,1fr));
.filter-submit {
grid-column: 1/3;
}
.map-tag {
grid-column: 5;
}
}
}
@media (max-width:52rem) {
.shell {
width: min(100% - 1.25rem,80rem);
@@ -405,6 +439,9 @@ body {
.filter:first-child {
grid-column: 1/-1;
}
.filter-submit, .map-tag {
grid-column: auto;
}
}
.map {
height: 32rem;