Add dashboard for time between getting oath and creating org
I hit this on my new dev setup and we want to show something nice to our users.
This commit is contained in:
parent
1fdc59d7c7
commit
7779feac4b
2 changed files with 55 additions and 6 deletions
25
html.go
25
html.go
|
|
@ -18,8 +18,8 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
||||
"github.com/google/uuid"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/stephenafamo/bob"
|
||||
"github.com/stephenafamo/bob/dialect/psql"
|
||||
|
|
@ -34,6 +34,7 @@ var embeddedFiles embed.FS
|
|||
var (
|
||||
cell = newBuiltTemplate("cell", "authenticated")
|
||||
dashboard = newBuiltTemplate("dashboard", "authenticated")
|
||||
dashboardLoading = newBuiltTemplate("dashboard-loading", "authenticated")
|
||||
oauthPrompt = newBuiltTemplate("oauth-prompt", "authenticated")
|
||||
settings = newBuiltTemplate("settings", "authenticated")
|
||||
source = newBuiltTemplate("source", "authenticated")
|
||||
|
|
@ -147,6 +148,11 @@ type ContentDashboard struct {
|
|||
RecentRequests []ServiceRequestSummary
|
||||
User User
|
||||
}
|
||||
|
||||
type ContentDashboardLoading struct {
|
||||
User User
|
||||
}
|
||||
|
||||
type ContentPlaceholder struct {
|
||||
}
|
||||
type ContentSignin struct {
|
||||
|
|
@ -309,6 +315,10 @@ func htmlCell(ctx context.Context, w http.ResponseWriter, user *models.User, c i
|
|||
func htmlDashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
|
||||
org, err := user.Organization().One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
if err.Error() == "sql: no rows in result set" {
|
||||
htmlDashboardLoading(ctx, w, user)
|
||||
return
|
||||
}
|
||||
respondError(w, "Failed to get org", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
|
@ -367,6 +377,19 @@ func htmlDashboard(ctx context.Context, w http.ResponseWriter, user *models.User
|
|||
renderOrError(w, dashboard, data)
|
||||
}
|
||||
|
||||
// A dashboard to show while we are still downloading information about their organization
|
||||
func htmlDashboardLoading(ctx context.Context, w http.ResponseWriter, user *models.User) {
|
||||
userContent, err := contentForUser(ctx, user)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get user context", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data := ContentDashboardLoading{
|
||||
User: userContent,
|
||||
}
|
||||
renderOrError(w, dashboardLoading, data)
|
||||
}
|
||||
|
||||
func htmlMock(t string, w http.ResponseWriter, code string) {
|
||||
data := ContentMock{
|
||||
DistrictName: "Delta MVCD",
|
||||
|
|
|
|||
26
templates/dashboard-loading.html
Normal file
26
templates/dashboard-loading.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{{template "authenticated.html" .}}
|
||||
|
||||
{{define "title"}}Dash{{end}}
|
||||
{{define "extraheader"}}
|
||||
<script src='https://api.mapbox.com/mapbox-gl-js/v3.17.0-beta.1/mapbox-gl.js'></script>
|
||||
<link href='https://api.mapbox.com/mapbox-gl-js/v3.17.0-beta.1/mapbox-gl.css' rel='stylesheet' />
|
||||
<script>
|
||||
function onLoad() {
|
||||
console.log("Map init done.");
|
||||
}
|
||||
window.addEventListener("load", onLoad);
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.dashboard-container {
|
||||
padding: 20px 0;
|
||||
}
|
||||
</style>
|
||||
{{end}}
|
||||
{{define "content"}}
|
||||
<div class="container dashboard-container">
|
||||
<p>We're downloading the data we need, hold on. This page will refresh every 10 seconds automatically until we've got it.</p>
|
||||
</div>
|
||||
{{end}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue