Move mock status to replace live status

This commit is contained in:
Eli Ribble 2026-02-03 17:54:21 +00:00
parent 8d96055ba1
commit eb3d09c989
No known key found for this signature in database
5 changed files with 127 additions and 176 deletions

View file

@ -30,6 +30,18 @@ type Contact struct {
Name string
Phone string
}
type ContentStatus struct {
Error string
MapboxToken string
ReportID string
URL ContentURL
}
type ContentStatusByID struct {
MapboxToken string
Report Report
URL ContentURL
}
type Image struct {
Location string
URL string
@ -47,15 +59,6 @@ type Report struct {
Type string
}
type ContentStatus struct {
Error string
ReportID string
}
type ContentStatusByID struct {
MapboxToken string
Report Report
}
var (
Status = buildTemplate("status", "base")
StatusByID = buildTemplate("status-by-id", "base")
@ -83,28 +86,21 @@ func formatReportID(s string) string {
func getStatus(w http.ResponseWriter, r *http.Request) {
report_id_str := r.URL.Query().Get("report")
content := ContentStatus{
Error: "",
MapboxToken: config.MapboxToken,
ReportID: "",
URL: makeContentURL(nil),
}
if report_id_str == "" {
html.RenderOrError(
w,
Status,
ContentStatus{
Error: "",
ReportID: "",
},
)
html.RenderOrError(w, Status, content)
return
}
report_id := sanitizeReportID(report_id_str)
report_id_str = formatReportID(report_id)
//some_report, e := report.FindSomeReport(r.Context(), report_id)
html.RenderOrError(
w,
Status,
ContentStatus{
Error: "Sorry, we can't find that report",
ReportID: report_id_str,
},
)
content.Error = "Sorry, we can't find that report"
html.RenderOrError(w, Status, content)
}
func contentFromNuisance(ctx context.Context, report_id string) (result ContentStatusByID, err error) {
nuisance, err := models.PublicreportNuisances.Query(
@ -206,6 +202,7 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) {
content, err = contentFromQuick(ctx, report_id)
}
content.MapboxToken = config.MapboxToken
content.URL = makeContentURL(nil)
html.RenderOrError(
w,
StatusByID,

View file

@ -8,35 +8,6 @@
<script src="/static/js/map-multipoint.js"></script>
<script src="/static/js/report-table.js"></script>
<style>
.map-container {
background-color: #e9ecef;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
height: 500px;
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
}
#map {
height: 500px;
width:100%;
margin-bottom: 10px;
}
#map img {
max-width: none;
min-width: 0px;
height: auto;
}
.search-box {
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
border-radius: 8px;
}
@media (max-width: 768px) {
.map-container {
height: 300px;
}
}
</style>
<script>
const MAPBOX_ACCESS_TOKEN = '{{.MapboxToken}}';

View file

@ -2,38 +2,12 @@
{{define "title"}}Status{{end}}
{{define "extraheader"}}
<script src='https://api.mapbox.com/mapbox-gl-js/v3.17.0-beta.1/mapbox-gl.js'></script>
<script src="/static/js/geocode.js"></script>
<script src="/static/js/location.js"></script>
<script src="/static/js/map-multipoint.js"></script>
<script src="/static/js/report-table.js"></script>
<style>
.option-card {
transition: transform 0.3s;
height: 100%;
}
.option-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.district-logo {
max-height: 80px;
width: auto;
}
.divider {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.divider-line {
border-left: 1px solid #dee2e6;
height: 80%;
}
@media (max-width: 767.98px) {
.divider-line {
border-left: none;
border-top: 1px solid #dee2e6;
width: 80%;
height: auto;
margin: 2rem 0;
}
}
</style>
<script>
function formatReportID(inputElement) {
@ -74,102 +48,80 @@ document.addEventListener('DOMContentLoaded', function() {
</script>
{{end}}
{{define "content"}}
<main>
<!-- Page Title -->
<section class="py-4 bg-primary text-white">
<div class="container">
<h2 class="text-center mb-0">Check Status or Follow-up</h2>
</div>
</section>
<!-- Lookup Options -->
<section class="py-5">
<div class="container">
<div class="row">
<div class="col-12 mb-4">
<p class="lead text-center">
Choose one of the following options to check on mosquito activity or follow up on a previous report.
</p>
</div>
</div>
<div class="row g-4">
<!-- Report ID Lookup -->
<div class="col-md-5">
<div class="card option-card h-100">
<div class="card-body p-4">
<div class="text-center mb-4">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" fill="currentColor" class="bi bi-file-earmark-text" viewBox="0 0 16 16">
<path d="M5.5 7a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1h-5zM5 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z"/>
<path d="M9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.5L9.5 0zm0 1v2A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5z"/>
</svg>
</div>
<h4 class="card-title text-center mb-4">Look up by Report ID</h4>
<p class="card-text">
If you have a report ID from a previous request, enter it below to view the details and current status.
</p>
<form action="/status" method="GET">
<div class="mb-3">
<label for="report" class="form-label">Report ID</label>
<input type="text" class="form-control" id="report" name="report" placeholder="Enter your report ID" value="{{.ReportID}}" required>
<div class="form-text">Example: ABCD-1234-5678</div>
{{ if ne .Error "" }}
<div class="alert alert-warning" role="alert">
{{ .Error }}
</div>
{{ end }}
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-success w-100 submit-btn">View Report Details</button>
</div>
</form>
</div>
<div class="container my-4">
<!-- Search Box -->
<div class="card search-box mb-4">
<div class="card-body">
<form class="row g-3 align-items-center">
<div class="col-md-9">
<label for="addressSearch" class="visually-hidden">Search by address</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-search"></i></span>
<input type="text" class="form-control form-control-lg" id="addressSearch"
placeholder="Enter a report ID, address, neighborhood, or zip code">
</div>
</div>
<!-- Divider for visual separation -->
<div class="col-md-2 divider">
<div class="divider-line"></div>
<div class="col-md-3">
<button type="submit" class="btn btn-primary btn-lg w-100">Search</button>
</div>
<!-- Location Lookup -->
<div class="col-md-5">
<div class="card option-card h-100">
<div class="card-body p-4">
<div class="text-center mb-4">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" fill="currentColor" class="bi bi-geo-alt" viewBox="0 0 16 16">
<path d="M12.166 8.94c-.524 1.062-1.234 2.12-1.96 3.07A31.493 31.493 0 0 1 8 14.58a31.481 31.481 0 0 1-2.206-2.57c-.726-.95-1.436-2.008-1.96-3.07C3.304 7.867 3 6.862 3 6a5 5 0 0 1 10 0c0 .862-.305 1.867-.834 2.94zM8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10z"/>
<path d="M8 8a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm0 1a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</svg>
</div>
<h4 class="card-title text-center mb-4">Look up by Location</h4>
<p class="card-text">
Don't have a report ID? You can check mosquito activity and reports in your area by providing your location information.
</p>
<p class="card-text mb-4">
This option will guide you through selecting your location to find relevant information about mosquito activity near you.
</p>
<div class="d-grid gap-2 mt-auto">
<a href="/search" class="btn btn-primary">Search by Location</a>
</div>
</div>
<div class="col-12">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="mosquitoNuisance" checked>
<label class="form-check-label" for="mosquitoNuisance">Mosquito Nuisance</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="stagnantWater" checked>
<label class="form-check-label" for="gWaterreenPool">Stagnant Water</label>
</div>
</div>
</div>
<!-- Back button -->
<div class="row mt-5">
<div class="col-12 text-center">
<a href="/" class="btn btn-outline-secondary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left me-2" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"/>
</svg>
Back to Home
</a>
</div>
</form>
</div>
</div>
<!-- Map Section -->
<div class="card mb-4">
<div class="card-header bg-info text-white">
<h5 class="mb-0"><i class="fas fa-map-marked-alt me-2"></i>Reports Map</h5>
</div>
<div class="card-body p-0">
<map-multipoint
api-key="{{ .MapboxToken }}"
latitude="36.3"
longitude="-119.2"
tegola="{{.URL.Tegola}}"
zoom="9"
/></map-multipoint>
</div>
</div>
<!-- Results Section -->
<div class="card">
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
<h5 class="mb-0"><i class="fas fa-list me-2"></i>Reports Near You</h5>
<span class="badge bg-light text-dark">15 Reports Found</span>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<report-table />
</div>
</div>
</section>
</main>
<!--
<div class="card-footer">
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center mb-0">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>
<li class="page-item active"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
</div>
-->
</div>
</div>
{{end}}