diff --git a/sync/dash.go b/sync/dash.go index 54ab9abd..e0b58016 100644 --- a/sync/dash.go +++ b/sync/dash.go @@ -22,12 +22,13 @@ import ( // Authenticated pages var ( - cellT = buildTemplate("cell", "authenticated") - dashboardT = buildTemplate("dashboard", "authenticated") - districtT = buildTemplate("district", "base") - settingsT = buildTemplate("settings", "authenticated") - sourceT = buildTemplate("source", "authenticated") - trapT = buildTemplate("trap", "authenticated") + cellT = buildTemplate("cell", "authenticated") + dashboardT = buildTemplate("dashboard", "authenticated") + districtT = buildTemplate("district", "base") + layoutTestT = buildTemplate("layout-test", "authenticated") + settingsT = buildTemplate("settings", "authenticated") + sourceT = buildTemplate("source", "authenticated") + trapT = buildTemplate("trap", "authenticated") ) type Config struct { @@ -71,6 +72,9 @@ type ContextDashboard struct { User User } +type ContentLayoutTest struct { + User User +} type ContextDistrict struct { MapboxToken string } @@ -96,6 +100,15 @@ func getDistrict(w http.ResponseWriter, r *http.Request) { htmlpage.RenderOrError(w, districtT, &context) } +func getLayoutTest(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 + } + htmlpage.RenderOrError(w, layoutTestT, &ContentLayoutTest{User: userContent}) +} + func getRoot(w http.ResponseWriter, r *http.Request) { user, err := auth.GetAuthenticatedUser(r) if err != nil { diff --git a/sync/page.go b/sync/page.go index 1738e5b7..291c5e05 100644 --- a/sync/page.go +++ b/sync/page.go @@ -12,7 +12,7 @@ import ( //go:embed template/* var embeddedFiles embed.FS -var components = [...]string{"header", "map"} +var components = [...]string{"header", "icons", "map", "sidebar"} func buildTemplate(files ...string) *htmlpage.BuiltTemplate { subdir := "sync" diff --git a/sync/routes.go b/sync/routes.go index feba55ce..abb2be6b 100644 --- a/sync/routes.go +++ b/sync/routes.go @@ -60,6 +60,7 @@ func Router() chi.Router { // Authenticated endpoints r.Route("/api", api.AddRoutes) r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails)) + r.Method("GET", "/layout-test", auth.NewEnsureAuth(getLayoutTest)) r.Method("GET", "/settings", auth.NewEnsureAuth(getSettings)) r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout)) r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource)) diff --git a/sync/template/authenticated.html b/sync/template/authenticated.html index 0ffb64e6..4fc97cc4 100644 --- a/sync/template/authenticated.html +++ b/sync/template/authenticated.html @@ -8,15 +8,123 @@ + + + {{block "extraheader" .}} {{end}} -{{if .User}} - {{template "header" .User}} -{{end}} +{{template "icons"}} +
+ {{if .User}} + {{template "sidebar" .User}} + {{end}} +
+ {{template "content" .}} + diff --git a/sync/template/components/icons.html b/sync/template/components/icons.html new file mode 100644 index 00000000..424e1ccc --- /dev/null +++ b/sync/template/components/icons.html @@ -0,0 +1,60 @@ +{{define "icons"}} + + + Bootstrap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{{end}} diff --git a/sync/template/components/sidebar.html b/sync/template/components/sidebar.html new file mode 100644 index 00000000..2786092a --- /dev/null +++ b/sync/template/components/sidebar.html @@ -0,0 +1,52 @@ +{{define "sidebar"}} + +{{end}} diff --git a/sync/template/layout-test.html b/sync/template/layout-test.html new file mode 100644 index 00000000..9abc1750 --- /dev/null +++ b/sync/template/layout-test.html @@ -0,0 +1,50 @@ +{{template "authenticated.html" . }} +{{define "title"}}Layout Test{{end}} +{{define "extraheader"}} +{{end}} +{{define "content"}} + +
+ + +
+
+
+
+
+
Welcome to the Dashboard
+

This is an example of a Bootstrap layout with a collapsible sidebar.

+

The sidebar can be toggled using the button in the navigation bar. When the sidebar collapses, only the icons remain visible.

+
+
+
+
+ +
+
+
+
+
Card 1
+

Some example content for the first card.

+
+
+
+
+
+
+
Card 2
+

Some example content for the second card.

+
+
+
+
+
+
+{{end}}