Show pool uploads in the upload page
And remove a bunch of things, like employee information and field notebooks
This commit is contained in:
parent
e93e4cc115
commit
b741c3e14d
3 changed files with 76 additions and 60 deletions
59
html/func.go
59
html/func.go
|
|
@ -15,25 +15,30 @@ import (
|
|||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func addFuncMap(t *template.Template) {
|
||||
funcMap := template.FuncMap{
|
||||
"bigNumber": bigNumber,
|
||||
"duration": duration,
|
||||
"hasPassed": hasPassed,
|
||||
"html": unescapeHTML,
|
||||
"json": unescapeJS,
|
||||
"GISStatement": gisStatement,
|
||||
"latLngDisplay": latLngDisplay,
|
||||
"publicReportID": publicReportID,
|
||||
"timeAsRelativeDate": timeAsRelativeDate,
|
||||
"timeDelta": timeDelta,
|
||||
"timeElapsed": timeElapsed,
|
||||
"timeInterval": timeInterval,
|
||||
"timeRelative": timeRelative,
|
||||
"timeRelativePtr": timeRelativePtr,
|
||||
"uuidShort": uuidShort,
|
||||
"bigNumber": bigNumber,
|
||||
"displayUploadStatus": displayUploadStatus,
|
||||
"displayUploadType": displayUploadType,
|
||||
"duration": duration,
|
||||
"hasPassed": hasPassed,
|
||||
"html": unescapeHTML,
|
||||
"json": unescapeJS,
|
||||
"GISStatement": gisStatement,
|
||||
"latLngDisplay": latLngDisplay,
|
||||
"publicReportID": publicReportID,
|
||||
"timeAsRelativeDate": timeAsRelativeDate,
|
||||
"timeDelta": timeDelta,
|
||||
"timeElapsed": timeElapsed,
|
||||
"timeInterval": timeInterval,
|
||||
"timeRelative": timeRelative,
|
||||
"timeRelativePtr": timeRelativePtr,
|
||||
"title": title,
|
||||
"uuidShort": uuidShort,
|
||||
}
|
||||
t.Funcs(funcMap)
|
||||
}
|
||||
|
|
@ -53,7 +58,26 @@ func bigNumber(n int) string {
|
|||
|
||||
return result.String()
|
||||
}
|
||||
|
||||
func displayUploadStatus(s string) string {
|
||||
switch s {
|
||||
case "error":
|
||||
return "Bad upload"
|
||||
case "parsed":
|
||||
return "Waiting for review"
|
||||
case "uploaded":
|
||||
return "Processing"
|
||||
default:
|
||||
return "Unknown status type"
|
||||
}
|
||||
}
|
||||
func displayUploadType(s string) string {
|
||||
switch s {
|
||||
case "PoolList":
|
||||
return "Green Pool List"
|
||||
default:
|
||||
return "Unknown upload type"
|
||||
}
|
||||
}
|
||||
func duration(d time.Duration) string {
|
||||
seconds := int(d.Seconds())
|
||||
|
||||
|
|
@ -265,6 +289,9 @@ func timeRelativePtr(t *time.Time) string {
|
|||
}
|
||||
return timeRelative(*t)
|
||||
}
|
||||
func title(s string) string {
|
||||
return cases.Title(language.AmericanEnglish).String(s)
|
||||
}
|
||||
func unescapeHTML(s string) template.HTML {
|
||||
return template.HTML(s)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,6 @@
|
|||
|
||||
{{ define "content" }}
|
||||
<div class="container mb-5">
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle-fill me-2"></i>
|
||||
Select a data type below to import information into the system.
|
||||
Supported file formats include CSV, Excel, and PDF documents.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Green Pool Management -->
|
||||
<div class="col-md-4">
|
||||
|
|
@ -73,6 +63,7 @@
|
|||
Import employee data including names, contact information, and
|
||||
responsibilities for system user creation.
|
||||
</p>
|
||||
<!--
|
||||
<p class="text-muted small">Supported formats: .xlsx, .csv</p>
|
||||
<div class="mb-3">
|
||||
<label for="employeeFile" class="form-label"
|
||||
|
|
@ -80,9 +71,10 @@
|
|||
>
|
||||
<input class="form-control" type="file" id="employeeFile" />
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary">
|
||||
<button type="button" class="btn btn-primary disabled" disabled>
|
||||
<i class="bi bi-upload me-2"></i>Upload Employee Data
|
||||
</button>
|
||||
-->
|
||||
</div>
|
||||
<div class="card-footer bg-white text-muted">
|
||||
<small><i class="bi bi-clock"></i> Last import: 03/01/2023</small>
|
||||
|
|
@ -100,6 +92,7 @@
|
|||
Upload scanned technician field notebooks to digitize information
|
||||
about breeding sources they've identified.
|
||||
</p>
|
||||
<!--
|
||||
<p class="text-muted small">Supported formats: .pdf, .jpg, .png</p>
|
||||
<div class="mb-3">
|
||||
<label for="notebookFile" class="form-label"
|
||||
|
|
@ -110,6 +103,7 @@
|
|||
<button type="button" class="btn btn-warning text-white">
|
||||
<i class="bi bi-upload me-2"></i>Upload Notebook Data
|
||||
</button>
|
||||
-->
|
||||
</div>
|
||||
<div class="card-footer bg-white text-muted">
|
||||
<small><i class="bi bi-clock"></i> Last import: 03/15/2023</small>
|
||||
|
|
@ -134,36 +128,26 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>03/15/2023 09:32 AM</td>
|
||||
<td>Field Notebooks</td>
|
||||
<td>march-field-notes.pdf</td>
|
||||
<td><span class="badge bg-success">Complete</span></td>
|
||||
<td>42 entries</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-primary">View</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>03/01/2023 02:15 PM</td>
|
||||
<td>Employee Information</td>
|
||||
<td>staff-2023-update.xlsx</td>
|
||||
<td><span class="badge bg-success">Complete</span></td>
|
||||
<td>18 employees</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-primary">View</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>02/15/2023 10:45 AM</td>
|
||||
<td>Green Pool Management</td>
|
||||
<td>feb-pools.csv</td>
|
||||
<td><span class="badge bg-success">Complete</span></td>
|
||||
<td>157 properties</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-primary">View</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{ range .C.RecentUploads }}
|
||||
<tr>
|
||||
<td>{{ .Created|timeRelative }}</td>
|
||||
<td>{{ .Type|displayUploadType }}</td>
|
||||
<td>{{ .Filename }}</td>
|
||||
<td>
|
||||
<span class="badge bg-success {{ .Status }}"
|
||||
>{{ .Status|displayUploadStatus }}</span
|
||||
>
|
||||
</td>
|
||||
<td>{{ .RecordCount }} entries</td>
|
||||
<td>
|
||||
<a
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
href="/upload/{{ .ID }}"
|
||||
>View</a
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,11 +13,16 @@ import (
|
|||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
type contentUploadList struct {
|
||||
RecentUploads []platform.UploadSummary
|
||||
}
|
||||
type contentUploadPlaceholder struct{}
|
||||
|
||||
func getUploadList(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentUploadPlaceholder], *errorWithStatus) {
|
||||
content := contentUploadPlaceholder{}
|
||||
return newResponse("sync/upload-list.html", content), nil
|
||||
func getUploadList(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentUploadList], *errorWithStatus) {
|
||||
rows, err := platform.UploadSummaryList(ctx, org)
|
||||
return newResponse("sync/upload-list.html", contentUploadList{
|
||||
RecentUploads: rows,
|
||||
}), newErrorMaybe("get upload list: %w", err)
|
||||
}
|
||||
|
||||
type contentPoolDetail struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue