Add basic pipe to provide status to the pool id page
This commit is contained in:
parent
d06b8f7949
commit
515dbb54fa
5 changed files with 53 additions and 37 deletions
|
|
@ -2,28 +2,28 @@
|
|||
{{ define "title" }}Pool Upload{{ end }}
|
||||
|
||||
{{ define "extraheader" }}
|
||||
<style>
|
||||
.summary-card {
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.summary-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
.warning-row {
|
||||
background-color: rgba(255, 193, 7, 0.15) !important;
|
||||
}
|
||||
.status-badge {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
</style>
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<div class="container mt-4 results-container">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Upload Results: pools-data-2023.csv</h2>
|
||||
<span class="badge bg-success rounded-pill">
|
||||
<i class="bi bi-check-circle me-1"></i> File Parsed Successfully
|
||||
</span>
|
||||
<h2>Upload Results: {{ .Upload.Name }}</h2>
|
||||
{{ if eq .Upload.Status "parsed" }}
|
||||
<span class="badge bg-success rounded-pill">
|
||||
<i class="bi bi-check-circle me-1"></i> File Parsed Successfully
|
||||
</span>
|
||||
{{ else if eq .Upload.Status "error" }}
|
||||
<span class="badge bg-danger rounded-pill">
|
||||
<i class="bi bi-exclamation me-1"></i> File Has Problems
|
||||
</span>
|
||||
{{ else if eq .Upload.Status "uploaded" }}
|
||||
<span class="badge bg-info rounded-pill">
|
||||
<i class="bi bi-arrow-clockwise me-1"></i> File Is Processing
|
||||
</span>
|
||||
{{ else }}
|
||||
<span class="badge bg-warning rounded-pill">
|
||||
<i class="bi bi-question me-1"></i> Unknown status
|
||||
</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ import (
|
|||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
type PoolDetail struct {
|
||||
Created time.Time `db:"created"`
|
||||
ID int32 `db:"id"`
|
||||
Pools []PoolRow
|
||||
Status string `db:"status"`
|
||||
type UploadPoolDetail struct {
|
||||
Created time.Time
|
||||
ID int32
|
||||
Name string
|
||||
Pools []UploadPoolRow
|
||||
Status string
|
||||
}
|
||||
type PoolRow struct {
|
||||
type UploadPoolRow struct {
|
||||
Street string
|
||||
City string
|
||||
}
|
||||
|
|
@ -72,10 +73,10 @@ func NewPoolUpload(ctx context.Context, u *models.User, upload userfile.FileUplo
|
|||
ID: file.ID,
|
||||
}, nil
|
||||
}
|
||||
func GetPoolDetail(ctx context.Context, organization_id int32, file_id int32) (PoolDetail, error) {
|
||||
func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int32) (UploadPoolDetail, error) {
|
||||
file, err := models.FindFileuploadFile(ctx, db.PGInstance.BobDB, file_id)
|
||||
if err != nil {
|
||||
return PoolDetail{}, fmt.Errorf("Failed to lookup file %d: %w", file_id, err)
|
||||
return UploadPoolDetail{}, fmt.Errorf("Failed to lookup file %d: %w", file_id, err)
|
||||
}
|
||||
/*
|
||||
csv, err := models.FindFileuploadCSV(ctx, db.PGInstance.BobDB, file_id)
|
||||
|
|
@ -87,16 +88,17 @@ func GetPoolDetail(ctx context.Context, organization_id int32, file_id int32) (P
|
|||
models.SelectWhere.FileuploadPools.CSVFile.EQ(file_id),
|
||||
).All(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
return PoolDetail{}, fmt.Errorf("Failed to query pools for %d: %w", file_id, err)
|
||||
return UploadPoolDetail{}, fmt.Errorf("Failed to query pools for %d: %w", file_id, err)
|
||||
}
|
||||
pools := make([]PoolRow, 0)
|
||||
pools := make([]UploadPoolRow, 0)
|
||||
for _, r := range rows {
|
||||
pools = append(pools, PoolRow{
|
||||
pools = append(pools, UploadPoolRow{
|
||||
Street: r.AddressStreet,
|
||||
City: r.AddressCity,
|
||||
})
|
||||
}
|
||||
return PoolDetail{
|
||||
return UploadPoolDetail{
|
||||
Name: file.Name,
|
||||
Pools: pools,
|
||||
Status: file.Status.String(),
|
||||
}, nil
|
||||
|
|
|
|||
|
|
@ -52,3 +52,4 @@ $theme-colors: map-merge(
|
|||
@import "./rmo/status.scss";
|
||||
@import "./sync/dashboard.scss";
|
||||
@import "./sync/pool-csv-upload.scss";
|
||||
@import "./sync/pool-by-id.scss";
|
||||
|
|
|
|||
13
scss/sync/pool-by-id.scss
Normal file
13
scss/sync/pool-by-id.scss
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
.summary-card {
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.summary-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
.warning-row {
|
||||
background-color: rgba(255, 193, 7, 0.15) !important;
|
||||
}
|
||||
.status-badge {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
14
sync/pool.go
14
sync/pool.go
|
|
@ -13,9 +13,9 @@ import (
|
|||
)
|
||||
|
||||
type ContentPoolDetail struct {
|
||||
Pool platform.PoolDetail
|
||||
URL ContentURL
|
||||
User User
|
||||
Upload platform.UploadPoolDetail
|
||||
URL ContentURL
|
||||
User User
|
||||
}
|
||||
type ContentPoolList struct {
|
||||
Uploads []platform.PoolUpload
|
||||
|
|
@ -72,15 +72,15 @@ func getPoolUploadByID(w http.ResponseWriter, r *http.Request, u *models.User) {
|
|||
respondError(w, "Failed to parse file_id", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
detail, err := platform.GetPoolDetail(ctx, u.OrganizationID, int32(file_id))
|
||||
detail, err := platform.GetUploadPoolDetail(ctx, u.OrganizationID, int32(file_id))
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get pool", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data := ContentPoolDetail{
|
||||
Pool: detail,
|
||||
URL: newContentURL(),
|
||||
User: userContent,
|
||||
Upload: detail,
|
||||
URL: newContentURL(),
|
||||
User: userContent,
|
||||
}
|
||||
html.RenderOrError(w, "sync/pool-by-id.html", data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue