diff --git a/html/template/sync/pool-csv-upload.html b/html/template/sync/pool-csv-upload.html index 33644319..5061ba59 100644 --- a/html/template/sync/pool-csv-upload.html +++ b/html/template/sync/pool-csv-upload.html @@ -24,34 +24,94 @@ Field Description Format - Required + Example - Latitude - GPS latitude coordinate - Decimal (e.g., 37.7749) - Yes + Street Address + Street number and name of the address of the pool + Text + 123 Main St. - Longitude - GPS longitude coordinate - Decimal (e.g., -122.4194) - Yes + City + The city portion of the pool's address + Text + Visalia - Plat ID - Unique identifier for the property - Alphanumeric (e.g., P12345) - Yes + Notes + + Any notes from the district to include with the pool record + + Text + "Collects rain water when empty" - Street Address - Nearest street address to the pool - Text (e.g., 123 Main St) + Postal Code + Postal (Zip) Code of the pool's address + numbers and optional hypen + 81234 or 91234-5678 + + + Pool Condition + The condition of the pool when it was last inspected + Text + "blue", "dry", "green", or "murky" + + + Property Owner Name + Name of the person or entity that owns the property + Text No + + Property Owner Phone + + Phone number of the person or entity that owns the property + + + E164 format, or enough digits to be a valid phone number + + + "+14155552671" or "1-(901)-555-1234" or "9015551234" or + "1901-555-12-34" + + + + Resident Owned + + Whether or not the current resident of the property is also the + owner + + Yes, No, or empty + "Yes" or "No" or "" + + + Resident Phone + Phone number of the resident + + E164 format, or enough digits to be a valid phone number + + + "+14155552671" or "1-(901)-555-1234" or "9015551234" or + "1901-555-12-34" + + + + Tags> + + Any additional columns in the file will be treated as tags and + attached to the record + + Text + "Hostile" or "Unresponsive" or "Dog" + @@ -72,36 +132,47 @@
Upload Data
-
- - +
+ + + + +
Select your CSV file
+

+ Drag and drop a file here or click to browse +

+ - - -
Select your CSV file
-

Drag and drop a file here or click to browse

- -
+
-
- - - - See what happens on a bad upload -
+
+ diff --git a/scss/sync/pool-csv-upload.scss b/scss/sync/pool-csv-upload.scss index 496f0c59..2fb33e28 100644 --- a/scss/sync/pool-csv-upload.scss +++ b/scss/sync/pool-csv-upload.scss @@ -1,7 +1,3 @@ -.upload-container { - max-width: 800px; - margin: 0 auto; -} .schema-table { font-size: 0.9rem; } diff --git a/sync/pool.go b/sync/pool.go index 6a9d2a76..b1968a68 100644 --- a/sync/pool.go +++ b/sync/pool.go @@ -41,3 +41,16 @@ func getPoolUpload(w http.ResponseWriter, r *http.Request, u *models.User) { } html.RenderOrError(w, "sync/pool-csv-upload.html", data) } +func postPoolUpload(w http.ResponseWriter, r *http.Request, u *models.User) { + err := r.ParseMultipartForm(32 << 10) // 32 MB buffer + if err != nil { + respondError(w, "Failed to parse form", err, http.StatusBadRequest) + return + } + uploads, err := userfile.SaveFileUpload(r, "csvfile", "pool", "csv") + if err != nil { + respondError(w, "Failed to extract image uploads", err, http.StatusInternalServerError) + return + } + images, err := saveImageUploads(r.Context(), tx, uploads) +} diff --git a/sync/routes.go b/sync/routes.go index 340c0149..e5f069cc 100644 --- a/sync/routes.go +++ b/sync/routes.go @@ -64,6 +64,7 @@ func Router() chi.Router { r.Method("GET", "/layout-test", auth.NewEnsureAuth(getLayoutTest)) r.Method("GET", "/pool", auth.NewEnsureAuth(getPoolList)) r.Method("GET", "/pool/upload", auth.NewEnsureAuth(getPoolUpload)) + r.Method("POST", "/pool/upload", auth.NewEnsureAuth(postPoolUpload)) r.Method("GET", "/settings", auth.NewEnsureAuth(getSettings)) r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout)) r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource))