Create secondary upload for pool data

This commit is contained in:
Eli Ribble 2026-03-01 22:21:20 +00:00
parent 8bfad892bc
commit 9939434cb3
No known key found for this signature in database
7 changed files with 472 additions and 175 deletions

View file

@ -0,0 +1,110 @@
{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Pool Upload{{ end }}
{{ define "extraheader" }}
<style></style>
{{ end }}
{{ define "content" }}
<!-- Main Content -->
<div class="container mt-4 upload-container">
<h2 class="mb-4">Upload Pool Data</h2>
<div class="card mb-4">
<div class="card-header bg-light">
<h5 class="mb-0">CSV Upload Requirements</h5>
</div>
<div class="card-body">
<p>
Your CSV file must contain the following columns in any order. Please
ensure your data matches the required format.
</p>
<table class="table table-bordered schema-table">
<thead class="table-light">
<tr>
<th>Field</th>
<th>Description</th>
<th>Format</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="required-field">TargetLat</td>
<td>The latitude of the target location</td>
<td>Decimal Number</td>
<td>36.56245379</td>
</tr>
<tr>
<td class="required-field">TargetLon</td>
<td>The longitude of the target location</td>
<td>Decimal Number</td>
<td>-119.3948222</td>
</tr>
<tr>
<td class="required-field">Comment</td>
<td>The condition of the pool</td>
<td>Text</td>
<td>"blue", "dry", "false pool", "green", or "murky"</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0">Upload Data</h5>
</div>
<div class="card-body">
<form
action="{{ .URL.Upload.PoolBob }}"
method="POST"
enctype="multipart/form-data"
>
<div class="upload-area">
<svg
xmlns="http://www.w3.org/2000/svg"
width="48"
height="48"
fill="currentColor"
class="bi bi-cloud-arrow-up text-primary mb-3"
viewBox="0 0 16 16"
>
<path
fill-rule="evenodd"
d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708l2-2z"
/>
<path
d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383zm.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"
/>
</svg>
<h5>Select your CSV file</h5>
<p class="text-muted">
Drag and drop a file here or click to browse
</p>
<input
type="file"
class="form-control"
id="csvFile"
name="csvfile"
accept=".csv"
/>
</div>
<div class="d-grid gap-2 text-center">
<button class="btn btn-primary" type="submit">
Upload and Continue
</button>
</div>
</form>
</div>
</div>
<div class="text-muted text-center mt-4">
<small
>Need assistance? Contact
<a href="mailto:support@example.com">support@example.com</a></small
>
</div>
</div>
{{ end }}

View file

@ -0,0 +1,186 @@
{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Pool Upload{{ end }}
{{ define "extraheader" }}
<style></style>
{{ end }}
{{ define "content" }}
<!-- Main Content -->
<div class="container mt-4 upload-container">
<h2 class="mb-4">Upload Pool Data</h2>
<div class="card mb-4">
<div class="card-header bg-light">
<h5 class="mb-0">CSV Upload Requirements</h5>
</div>
<div class="card-body">
<p>
Your CSV file must contain the following columns in any order. Please
ensure your data matches the required format.
</p>
<table class="table table-bordered schema-table">
<thead class="table-light">
<tr>
<th>Field</th>
<th>Description</th>
<th>Format</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="required-field">Street Address</td>
<td>Street number and name of the address of the pool</td>
<td>Text</td>
<td>123 Main St.</td>
</tr>
<tr>
<td class="required-field">City</td>
<td>The city portion of the pool's address</td>
<td>Text</td>
<td>Visalia</td>
</tr>
<tr>
<td>Notes</td>
<td>
Any notes from the district to include with the pool record
</td>
<td>Text</td>
<td>"Collects rain water when empty"</td>
</tr>
<tr>
<td class="required-field">Postal Code</td>
<td>Postal (Zip) Code of the pool's address</td>
<td>numbers and optional hypen</td>
<td>81234 or 91234-5678</td>
</tr>
<tr>
<td>Pool Condition</td>
<td>The condition of the pool when it was last inspected</td>
<td>Text</td>
<td>"blue", "dry", "false pool", "green", or "murky"</td>
</tr>
<tr>
<td>Property Owner Name</td>
<td>Name of the person or entity that owns the property</td>
<td>Text</td>
<td>No</td>
</tr>
<tr>
<td>Property Owner Phone</td>
<td>
Phone number of the person or entity that owns the property
</td>
<td>
<a href="https://www.twilio.com/docs/glossary/what-e164"
>E164 format</a
>, or enough digits to be a valid phone number
</td>
<td>
"+14155552671" or "1-(901)-555-1234" or "9015551234" or
"1901-555-12-34"
</td>
</tr>
<tr>
<td>Resident Owned</td>
<td>
Whether or not the current resident of the property is also the
owner
</td>
<td>Yes, No, or empty</td>
<td>"Yes" or "No" or ""</td>
</tr>
<tr>
<td>Resident Phone</td>
<td>Phone number of the resident</td>
<td>
<a href="https://www.twilio.com/docs/glossary/what-e164"
>E164 format</a
>, or enough digits to be a valid phone number
</td>
<td>
"+14155552671" or "1-(901)-555-1234" or "9015551234" or
"1901-555-12-34"
</td>
</tr>
<tr>
<td>Tags</td>
<td>
Any additional columns in the file will be treated as tags and
attached to the record
</td>
<td>Text</td>
<td>"Hostile" or "Unresponsive" or "Dog"</td>
</tr>
</tbody>
</table>
<div class="alert alert-info small">
<i class="bi bi-info-circle"></i> Need a template?
<a
href="{{ .URL.SamplePoolCSV }}"
class="alert-link"
download="nidus-pool-sample.csv"
>Download sample CSV file</a
>
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0">Upload Data</h5>
</div>
<div class="card-body">
<form
action="{{ .URL.Upload.CSVPoolCustom }}"
method="POST"
enctype="multipart/form-data"
>
<div class="upload-area">
<svg
xmlns="http://www.w3.org/2000/svg"
width="48"
height="48"
fill="currentColor"
class="bi bi-cloud-arrow-up text-primary mb-3"
viewBox="0 0 16 16"
>
<path
fill-rule="evenodd"
d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708l2-2z"
/>
<path
d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383zm.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"
/>
</svg>
<h5>Select your CSV file</h5>
<p class="text-muted">
Drag and drop a file here or click to browse
</p>
<input
type="file"
class="form-control"
id="csvFile"
name="csvfile"
accept=".csv"
/>
</div>
<div class="d-grid gap-2 text-center">
<button class="btn btn-primary" type="submit">
Upload and Continue
</button>
</div>
</form>
</div>
</div>
<div class="text-muted text-center mt-4">
<small
>Need assistance? Contact
<a href="mailto:support@example.com">support@example.com</a></small
>
</div>
</div>
{{ end }}

View file

@ -1,186 +1,153 @@
{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Pool Upload{{ end }}
{{ define "title" }}Choose Pool Upload Type{{ end }}
{{ define "extraheader" }}
<style></style>
<style>
.upload-card {
transition:
transform 0.2s,
box-shadow 0.2s;
cursor: pointer;
height: 100%;
}
.upload-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}
.card-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
</style>
{{ end }}
{{ define "content" }}
<!-- Main Content -->
<div class="container mt-4 upload-container">
<h2 class="mb-4">Upload Pool Data</h2>
<div class="card mb-4">
<div class="card-header bg-light">
<h5 class="mb-0">CSV Upload Requirements</h5>
</div>
<div class="card-body">
<p>
Your CSV file must contain the following columns in any order. Please
ensure your data matches the required format.
<div class="container py-5">
<div class="row mb-4">
<div class="col-12 text-center">
<h1 class="display-5 fw-bold mb-2">Green Pool CSV Data</h1>
<p class="lead text-muted">
Select the type of data you want to upload
</p>
</div>
</div>
<table class="table table-bordered schema-table">
<thead class="table-light">
<tr>
<th>Field</th>
<th>Description</th>
<th>Format</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="required-field">Street Address</td>
<td>Street number and name of the address of the pool</td>
<td>Text</td>
<td>123 Main St.</td>
</tr>
<tr>
<td class="required-field">City</td>
<td>The city portion of the pool's address</td>
<td>Text</td>
<td>Visalia</td>
</tr>
<tr>
<td>Notes</td>
<td>
Any notes from the district to include with the pool record
</td>
<td>Text</td>
<td>"Collects rain water when empty"</td>
</tr>
<tr>
<td class="required-field">Postal Code</td>
<td>Postal (Zip) Code of the pool's address</td>
<td>numbers and optional hypen</td>
<td>81234 or 91234-5678</td>
</tr>
<tr>
<td>Pool Condition</td>
<td>The condition of the pool when it was last inspected</td>
<td>Text</td>
<td>"blue", "dry", "false pool", "green", or "murky"</td>
</tr>
<tr>
<td>Property Owner Name</td>
<td>Name of the person or entity that owns the property</td>
<td>Text</td>
<td>No</td>
</tr>
<tr>
<td>Property Owner Phone</td>
<td>
Phone number of the person or entity that owns the property
</td>
<td>
<a href="https://www.twilio.com/docs/glossary/what-e164"
>E164 format</a
>, or enough digits to be a valid phone number
</td>
<td>
"+14155552671" or "1-(901)-555-1234" or "9015551234" or
"1901-555-12-34"
</td>
</tr>
<tr>
<td>Resident Owned</td>
<td>
Whether or not the current resident of the property is also the
owner
</td>
<td>Yes, No, or empty</td>
<td>"Yes" or "No" or ""</td>
</tr>
<tr>
<td>Resident Phone</td>
<td>Phone number of the resident</td>
<td>
<a href="https://www.twilio.com/docs/glossary/what-e164"
>E164 format</a
>, or enough digits to be a valid phone number
</td>
<td>
"+14155552671" or "1-(901)-555-1234" or "9015551234" or
"1901-555-12-34"
</td>
</tr>
<tr>
<td>Tags</td>
<td>
Any additional columns in the file will be treated as tags and
attached to the record
</td>
<td>Text</td>
<td>"Hostile" or "Unresponsive" or "Dog"</td>
</tr>
</tbody>
</table>
<div class="row g-4">
<!-- Option 1: Green Pool Flyover Data -->
<div class="col-md-6">
<div class="card upload-card border-0 shadow-sm">
<div class="card-body text-center p-5">
<div class="card-icon text-primary">
<i class="bi bi-cloud-upload"></i>
</div>
<h3 class="card-title h4 mb-3">Green Pool Flyover Data</h3>
<p class="card-text text-muted mb-4">
Upload aerial survey data from ABC Data Analytics. This includes
GPS coordinates, timestamp information, and pool identification
data.
</p>
<div class="mb-3">
<span
class="badge bg-primary-subtle text-primary border border-primary me-2"
>
<i class="bi bi-building me-1"></i> ABC Data Analytics
</span>
<span class="badge bg-info-subtle text-info border border-info">
<i class="bi bi-filetype-csv me-1"></i> CSV Format
</span>
</div>
<a
class="btn btn-primary btn-lg w-100"
href="{{ .URL.Upload.PoolBob }}"
>
<i class="bi bi-upload me-2"></i>Let's do this
</a>
</div>
</div>
</div>
<div class="alert alert-info small">
<i class="bi bi-info-circle"></i> Need a template?
<a
href="{{ .URL.SamplePoolCSV }}"
class="alert-link"
download="nidus-pool-sample.csv"
>Download sample CSV file</a
>
<!-- Option 2: Custom Green Pool Operations Data -->
<div class="col-md-6">
<div class="card upload-card border-0 shadow-sm">
<div class="card-body text-center p-5">
<div class="card-icon text-success">
<i class="bi bi-file-earmark-spreadsheet"></i>
</div>
<h3 class="card-title h4 mb-3">Custom Operations Data</h3>
<p class="card-text text-muted mb-4">
Upload custom green pool operations data. This includes treatment
records, inspection logs, and maintenance activities in your own
CSV format.
</p>
<div class="mb-3">
<span
class="badge bg-success-subtle text-success border border-success me-2"
>
<i class="bi bi-gear me-1"></i> Custom Format
</span>
<span class="badge bg-info-subtle text-info border border-info">
<i class="bi bi-filetype-csv me-1"></i> CSV Format
</span>
</div>
<a
class="btn btn-success btn-lg w-100"
href="{{ .URL.Upload.PoolCustom }}"
>
<i class="bi bi-upload me-2"></i>Pick me
</a>
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0">Upload Data</h5>
</div>
<div class="card-body">
<form
action="{{ .URL.UploadCSVPool }}"
method="POST"
enctype="multipart/form-data"
>
<div class="upload-area">
<svg
xmlns="http://www.w3.org/2000/svg"
width="48"
height="48"
fill="currentColor"
class="bi bi-cloud-arrow-up text-primary mb-3"
viewBox="0 0 16 16"
>
<path
fill-rule="evenodd"
d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708l2-2z"
/>
<path
d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383zm.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"
/>
</svg>
<h5>Select your CSV file</h5>
<p class="text-muted">
Drag and drop a file here or click to browse
</p>
<!-- Upload Modal -->
<div
class="modal fade"
id="uploadModal"
tabindex="-1"
aria-labelledby="uploadModalLabel"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="uploadModalLabel">Upload CSV File</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="fileInput" class="form-label">Select CSV file:</label>
<input
type="file"
class="form-control"
id="csvFile"
name="csvfile"
id="fileInput"
accept=".csv"
/>
</div>
<div class="d-grid gap-2 text-center">
<button class="btn btn-primary" type="submit">
Upload and Continue
</button>
<div class="alert alert-secondary mb-0" role="alert">
<small
><strong>Upload Type:</strong>
<span id="uploadType">Not selected</span></small
>
</div>
</form>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Cancel
</button>
<button type="button" class="btn btn-primary">
<i class="bi bi-upload me-2"></i>Upload
</button>
</div>
</div>
</div>
<div class="text-muted text-center mt-4">
<small
>Need assistance? Contact
<a href="mailto:support@example.com">support@example.com</a></small
>
</div>
</div>
{{ end }}

View file

@ -17,7 +17,7 @@
Upload spreadsheets with addresses and contact information of
unmaintained pools that may breed mosquitoes.
</p>
<a class="btn btn-primary" href="{{ .URL.UploadCSVPool }}">
<a class="btn btn-primary" href="{{ .URL.Upload.Pool }}">
<i class="bi bi-upload me-2"></i>Upload Green Pool Data</a
>
</div>

View file

@ -59,8 +59,11 @@ func Router() chi.Router {
r.Method("GET", "/configuration/pesticide", authenticatedHandler(getConfigurationPesticide))
r.Method("GET", "/configuration/pesticide/add", authenticatedHandler(getConfigurationPesticideAdd))
r.Method("GET", "/configuration/upload", authenticatedHandler(getUploadList))
r.Method("GET", "/configuration/upload/pool", authenticatedHandler(getUploadPoolCreate))
r.Method("POST", "/configuration/upload/pool", authenticatedHandlerPostMultipart(postUploadPoolCreate))
r.Method("GET", "/configuration/upload/pool", authenticatedHandler(getUploadPool))
r.Method("GET", "/configuration/upload/pool/bob", authenticatedHandler(getUploadPoolBobCreate))
r.Method("POST", "/configuration/upload/pool/bob", authenticatedHandlerPostMultipart(postUploadPoolBobCreate))
r.Method("GET", "/configuration/upload/pool/custom", authenticatedHandler(getUploadPoolCustomCreate))
r.Method("POST", "/configuration/upload/pool/custom", authenticatedHandlerPostMultipart(postUploadPoolCustomCreate))
r.Method("GET", "/configuration/upload/{id}", authenticatedHandler(getUploadByID))
r.Method("POST", "/configuration/upload/{id}/discard", authenticatedHandlerPost(postUploadDiscard))
r.Method("GET", "/configuration/user", authenticatedHandler(getConfigurationUserList))

View file

@ -45,12 +45,26 @@ type contentUploadDetail struct {
type contentUploadPoolList struct {
Uploads []platform.PoolUpload
}
type contentUploadPoolCreate struct{}
type contentUploadPool struct{}
func getUploadPoolCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentUploadPoolCreate], *errorWithStatus) {
data := contentUploadPoolCreate{}
func getUploadPool(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentUploadPool], *errorWithStatus) {
data := contentUploadPool{}
return newResponse("sync/upload-csv-pool.html", data), nil
}
type contentUploadPoolBobCreate struct{}
func getUploadPoolBobCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentUploadPoolBobCreate], *errorWithStatus) {
data := contentUploadPoolBobCreate{}
return newResponse("sync/upload-csv-pool-bob.html", data), nil
}
type contentUploadPoolCustomCreate struct{}
func getUploadPoolCustomCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentUploadPoolCustomCreate], *errorWithStatus) {
data := contentUploadPoolCustomCreate{}
return newResponse("sync/upload-csv-pool-custom.html", data), nil
}
func getUploadByID(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentUploadDetail], *errorWithStatus) {
file_id_str := chi.URLParam(r, "id")
file_id_, err := strconv.ParseInt(file_id_str, 10, 32)
@ -88,7 +102,10 @@ func postUploadDiscard(ctx context.Context, r *http.Request, org *models.Organiz
type FormUploadPool struct{}
func postUploadPoolCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User, f FormUploadPool) (string, *errorWithStatus) {
func postUploadPoolBobCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User, f FormUploadPool) (string, *errorWithStatus) {
return "", nil
}
func postUploadPoolCustomCreate(ctx context.Context, r *http.Request, org *models.Organization, u *models.User, f FormUploadPool) (string, *errorWithStatus) {
uploads, err := userfile.SaveFileUpload(r, "csvfile", userfile.CollectionCSV)
if err != nil {
return "", newError("Failed to extract image uploads: %s", err)

View file

@ -9,10 +9,9 @@ type contentURL struct {
OAuthRefreshArcGIS string
Root string
Route string
SamplePoolCSV string
Sidebar contentURLSidebar
Tegola string
UploadCSVPool string
Upload contentURLUpload
}
func newContentURL() contentURL {
@ -21,10 +20,9 @@ func newContentURL() contentURL {
OAuthRefreshArcGIS: config.MakeURLNidus("/arcgis/oauth/begin"),
Root: config.MakeURLNidus("/"),
Route: config.MakeURLNidus("/route"),
SamplePoolCSV: config.MakeURLNidus("/static/file/sample-pool.csv"),
Sidebar: newContentURLSidebar(),
Tegola: config.MakeURLTegola("/"),
UploadCSVPool: config.MakeURLNidus("/configuration/upload/pool"),
Upload: newContentURLUpload(),
}
}
@ -75,3 +73,19 @@ func newContentURLSidebar() contentURLSidebar {
Review: config.MakeURLNidus("/review"),
}
}
type contentURLUpload struct {
Pool string
PoolBob string
PoolCustom string
SamplePoolCSV string
}
func newContentURLUpload() contentURLUpload {
return contentURLUpload{
Pool: config.MakeURLNidus("/configuration/upload/pool"),
PoolBob: config.MakeURLNidus("/configuration/upload/pool/bob"),
PoolCustom: config.MakeURLNidus("/configuration/upload/pool/custom"),
SamplePoolCSV: config.MakeURLNidus("/static/file/sample-pool.csv"),
}
}