Add pages for showing the CSV upload UI
And sample CSV file download
This commit is contained in:
parent
59076e9eb0
commit
d437c68403
7 changed files with 63 additions and 26 deletions
4
html/static/file/sample-pool.csv
Normal file
4
html/static/file/sample-pool.csv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Street Address,City,Zip,Property Owner Name,Resident Owned,Resident Phone Number,Pool Condition,Notes,Recurrant,New,Hostile,Unresponsive
|
||||
123 Main Street,Visalia,93615,John Smith,Yes,1235556789,Empty,"Pool collects runoff, dry by summer",Yes,No,No,Yes
|
||||
456 Valley View Dr,Los Angeles,93618,Jane and Jim Blackner,No,2345550055,Green,Pool murky at beginning of season,No,Yes,No,No
|
||||
11235 Fibonacci Rd,San Francisco,93618,Warren Buffet,No,3455551212,,,,,,
|
||||
|
|
|
@ -1,31 +1,10 @@
|
|||
{{ template "sync/layout/base.html" . }}
|
||||
|
||||
{{ define "title" }}Data Entry{{ end }}
|
||||
{{ template "sync/layout/authenticated.html" . }}
|
||||
{{ define "title" }}Layout Test{{ end }}
|
||||
{{ define "extraheader" }}
|
||||
<style>
|
||||
.upload-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.schema-table {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.upload-area {
|
||||
border: 2px dashed #dee2e6;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
margin: 1.5rem 0;
|
||||
border-radius: 5px;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.required-field::after {
|
||||
content: "*";
|
||||
color: red;
|
||||
margin-left: 3px;
|
||||
}
|
||||
</style>
|
||||
<style></style>
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<!-- Main Content -->
|
||||
<div class="container mt-4 upload-container">
|
||||
<h2 class="mb-4">Upload Pool Data</h2>
|
||||
|
||||
|
|
@ -78,7 +57,12 @@
|
|||
|
||||
<div class="alert alert-info small">
|
||||
<i class="bi bi-info-circle"></i> Need a template?
|
||||
<a href="#" class="alert-link">Download sample CSV file</a>
|
||||
<a
|
||||
href="{{ .URL.SamplePoolCSV }}"
|
||||
class="alert-link"
|
||||
download="nidus-pool-sample.csv"
|
||||
>Download sample CSV file</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
9
html/template/sync/pool-list.html
Normal file
9
html/template/sync/pool-list.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{{ template "sync/layout/authenticated.html" . }}
|
||||
|
||||
{{ define "title" }}Pool List{{ end }}
|
||||
{{ define "extraheader" }}
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<h1>Pool list</h1>
|
||||
<a class="btn btn-primary" href="{{ .URL.PoolCSVUpload }}">Do an upload</a>
|
||||
{{ end }}
|
||||
20
scss/sync/pool-csv-upload.scss
Normal file
20
scss/sync/pool-csv-upload.scss
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
.upload-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.schema-table {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.upload-area {
|
||||
border: 2px dashed #dee2e6;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
margin: 1.5rem 0;
|
||||
border-radius: 5px;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.required-field::after {
|
||||
content: "*";
|
||||
color: red;
|
||||
margin-left: 3px;
|
||||
}
|
||||
17
sync/pool.go
17
sync/pool.go
|
|
@ -10,6 +10,10 @@ type ContentPoolList struct {
|
|||
URL ContentURL
|
||||
User User
|
||||
}
|
||||
type ContentPoolUpload struct {
|
||||
URL ContentURL
|
||||
User User
|
||||
}
|
||||
|
||||
func getPoolList(w http.ResponseWriter, r *http.Request, u *models.User) {
|
||||
userContent, err := contentForUser(r.Context(), u)
|
||||
|
|
@ -23,3 +27,16 @@ func getPoolList(w http.ResponseWriter, r *http.Request, u *models.User) {
|
|||
}
|
||||
html.RenderOrError(w, "sync/pool-list.html", data)
|
||||
}
|
||||
|
||||
func getPoolUpload(w http.ResponseWriter, r *http.Request, u *models.User) {
|
||||
userContent, err := contentForUser(r.Context(), u)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get user", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data := ContentPoolUpload{
|
||||
URL: newContentURL(),
|
||||
User: userContent,
|
||||
}
|
||||
html.RenderOrError(w, "sync/pool-csv-upload.html", data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func Router() chi.Router {
|
|||
r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails))
|
||||
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("GET", "/settings", auth.NewEnsureAuth(getSettings))
|
||||
r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout))
|
||||
r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource))
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ import (
|
|||
|
||||
type ContentURL struct {
|
||||
PoolCSVUpload string
|
||||
SamplePoolCSV string
|
||||
}
|
||||
|
||||
func newContentURL() ContentURL {
|
||||
return ContentURL{
|
||||
PoolCSVUpload: config.MakeURLNidus("/pool/upload"),
|
||||
SamplePoolCSV: config.MakeURLNidus("/static/file/sample-pool.csv"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue