diff --git a/public-report/endpoint.go b/public-report/endpoint.go index 0eb77bb7..35bff222 100644 --- a/public-report/endpoint.go +++ b/public-report/endpoint.go @@ -11,6 +11,16 @@ import ( "github.com/stephenafamo/bob/dialect/psql/um" ) +type ContextRegisterNotificationsComplete struct { + ReportID string +} +type ContextRoot struct{} + +var ( + RegisterNotificationsComplete = buildTemplate("register-notifications-complete", "base") + Root = buildTemplate("root", "base") +) + func getRoot(w http.ResponseWriter, r *http.Request) { htmlpage.RenderOrError( w, diff --git a/public-report/page.go b/public-report/page.go index 1f03ef15..84c18982 100644 --- a/public-report/page.go +++ b/public-report/page.go @@ -13,16 +13,6 @@ var embeddedFiles embed.FS //go:embed static/* var EmbeddedStaticFS embed.FS -type ContextRegisterNotificationsComplete struct { - ReportID string -} -type ContextRoot struct{} - -var ( - RegisterNotificationsComplete = buildTemplate("register-notifications-complete", "base") - Root = buildTemplate("root", "base") -) - var components = [...]string{"footer", "location-geocode", "location-geocode-header", "photo-upload", "photo-upload-header"} func buildTemplate(files ...string) *htmlpage.BuiltTemplate { diff --git a/sync/endpoint.go b/sync/endpoint.go index 6a55d94c..4e289f92 100644 --- a/sync/endpoint.go +++ b/sync/endpoint.go @@ -15,7 +15,6 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/config" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/htmlpage" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage/sync" "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/rs/zerolog/log" @@ -82,8 +81,8 @@ func Router() chi.Router { r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource)) //r.Method("GET", "/vector-tiles/{org_id}/{tileset_id}/{zoom}/{x}/{y}.{format}", auth.NewEnsureAuth(getVectorTiles)) - localFS := http.Dir("./static") - htmlpage.FileServer(r, "/static", localFS, sync.EmbeddedStaticFS, "static") + localFS := http.Dir("./sync/static") + htmlpage.FileServer(r, "/static", localFS, EmbeddedStaticFS, "static") return r } @@ -123,7 +122,7 @@ func getCellDetails(w http.ResponseWriter, r *http.Request, user *models.User) { respondError(w, "Cannot convert provided cell to uint64", err, http.StatusBadRequest) return } - sync.Cell(r.Context(), w, user, cell) + Cell(r.Context(), w, user, cell) } func getFavicon(w http.ResponseWriter, r *http.Request) { @@ -138,7 +137,7 @@ func getOAuthRefresh(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/?next=/oauth/refresh", http.StatusFound) return } - sync.OauthPrompt(w, user) + OauthPrompt(w, user) } func getQRCodeReport(w http.ResponseWriter, r *http.Request) { @@ -215,7 +214,7 @@ func getRoot(w http.ResponseWriter, r *http.Request) { } if user == nil { errorCode := r.URL.Query().Get("error") - sync.Signin(w, errorCode) + Signin(w, errorCode) return } else { has, err := background.HasFieldseekerConnection(r.Context(), user) @@ -224,10 +223,10 @@ func getRoot(w http.ResponseWriter, r *http.Request) { return } if has { - sync.Dashboard(r.Context(), w, user) + Dashboard(r.Context(), w, user) return } else { - sync.OauthPrompt(w, user) + OauthPrompt(w, user) return } } @@ -237,16 +236,16 @@ func getRoot(w http.ResponseWriter, r *http.Request) { } func getSettings(w http.ResponseWriter, r *http.Request, u *models.User) { - sync.Settings(w, r, u) + Settings(w, r, u) } func getSignin(w http.ResponseWriter, r *http.Request) { errorCode := r.URL.Query().Get("error") - sync.Signin(w, errorCode) + Signin(w, errorCode) } func getSignup(w http.ResponseWriter, r *http.Request) { - sync.Signup(w, r.URL.Path) + Signup(w, r.URL.Path) } func getSource(w http.ResponseWriter, r *http.Request, u *models.User) { @@ -260,7 +259,7 @@ func getSource(w http.ResponseWriter, r *http.Request, u *models.User) { respondError(w, "globalid is not a UUID", nil, http.StatusBadRequest) return } - sync.Source(w, r, u, globalid) + Source(w, r, u, globalid) } func postSMS(w http.ResponseWriter, r *http.Request) { @@ -324,12 +323,6 @@ func getVectorTiles(w http.ResponseWriter, r *http.Request, u *models.User) { } -// Respond with an error that is visible to the user -func respondError(w http.ResponseWriter, m string, e error, s int) { - log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error") - http.Error(w, m, s) -} - func postSignin(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { respondError(w, "Could not parse form", err, http.StatusBadRequest) @@ -394,6 +387,6 @@ func renderMock(templateName string) http.HandlerFunc { if code == "" { code = "abc-123" } - sync.Mock(templateName, w, code) + Mock(templateName, w, code) } } diff --git a/htmlpage/sync/model_conversion.go b/sync/model_conversion.go similarity index 100% rename from htmlpage/sync/model_conversion.go rename to sync/model_conversion.go diff --git a/htmlpage/sync/page.go b/sync/page.go similarity index 99% rename from htmlpage/sync/page.go rename to sync/page.go index 7866c9b6..0e35bd02 100644 --- a/htmlpage/sync/page.go +++ b/sync/page.go @@ -82,7 +82,7 @@ var ( var components = [...]string{"header", "map"} func buildTemplate(files ...string) *htmlpage.BuiltTemplate { - subdir := "htmlpage/sync" + subdir := "sync" full_files := make([]string, 0) for _, f := range files { full_files = append(full_files, fmt.Sprintf("%s/template/%s.html", subdir, f)) @@ -90,7 +90,7 @@ func buildTemplate(files ...string) *htmlpage.BuiltTemplate { for _, c := range components { full_files = append(full_files, fmt.Sprintf("%s/template/components/%s.html", subdir, c)) } - return htmlpage.NewBuiltTemplate(embeddedFiles, "htmlpage/sync/", full_files...) + return htmlpage.NewBuiltTemplate(embeddedFiles, "sync/", full_files...) } func Cell(ctx context.Context, w http.ResponseWriter, user *models.User, c int64) { diff --git a/htmlpage/sync/static/favicon.ico b/sync/static/favicon.ico similarity index 100% rename from htmlpage/sync/static/favicon.ico rename to sync/static/favicon.ico diff --git a/htmlpage/sync/static/img/nidus-logo-256-transparent.png b/sync/static/img/nidus-logo-256-transparent.png similarity index 100% rename from htmlpage/sync/static/img/nidus-logo-256-transparent.png rename to sync/static/img/nidus-logo-256-transparent.png diff --git a/htmlpage/sync/static/vendor/css/bootstrap.min.css b/sync/static/vendor/css/bootstrap.min.css similarity index 100% rename from htmlpage/sync/static/vendor/css/bootstrap.min.css rename to sync/static/vendor/css/bootstrap.min.css diff --git a/htmlpage/sync/static/vendor/js/bootstrap.bundle.min.js b/sync/static/vendor/js/bootstrap.bundle.min.js similarity index 100% rename from htmlpage/sync/static/vendor/js/bootstrap.bundle.min.js rename to sync/static/vendor/js/bootstrap.bundle.min.js diff --git a/htmlpage/sync/static/vendor/js/bootstrap.min.js b/sync/static/vendor/js/bootstrap.min.js similarity index 100% rename from htmlpage/sync/static/vendor/js/bootstrap.min.js rename to sync/static/vendor/js/bootstrap.min.js diff --git a/htmlpage/sync/template/admin.html b/sync/template/admin.html similarity index 100% rename from htmlpage/sync/template/admin.html rename to sync/template/admin.html diff --git a/htmlpage/sync/template/authenticated.html b/sync/template/authenticated.html similarity index 100% rename from htmlpage/sync/template/authenticated.html rename to sync/template/authenticated.html diff --git a/htmlpage/sync/template/base.html b/sync/template/base.html similarity index 100% rename from htmlpage/sync/template/base.html rename to sync/template/base.html diff --git a/htmlpage/sync/template/cell.html b/sync/template/cell.html similarity index 100% rename from htmlpage/sync/template/cell.html rename to sync/template/cell.html diff --git a/htmlpage/sync/template/components/header.html b/sync/template/components/header.html similarity index 100% rename from htmlpage/sync/template/components/header.html rename to sync/template/components/header.html diff --git a/htmlpage/sync/template/components/map.html b/sync/template/components/map.html similarity index 100% rename from htmlpage/sync/template/components/map.html rename to sync/template/components/map.html diff --git a/htmlpage/sync/template/dashboard.html b/sync/template/dashboard.html similarity index 100% rename from htmlpage/sync/template/dashboard.html rename to sync/template/dashboard.html diff --git a/htmlpage/sync/template/data-entry-bad.html b/sync/template/data-entry-bad.html similarity index 100% rename from htmlpage/sync/template/data-entry-bad.html rename to sync/template/data-entry-bad.html diff --git a/htmlpage/sync/template/data-entry-good.html b/sync/template/data-entry-good.html similarity index 100% rename from htmlpage/sync/template/data-entry-good.html rename to sync/template/data-entry-good.html diff --git a/htmlpage/sync/template/data-entry.html b/sync/template/data-entry.html similarity index 100% rename from htmlpage/sync/template/data-entry.html rename to sync/template/data-entry.html diff --git a/htmlpage/sync/template/dispatch-results.html b/sync/template/dispatch-results.html similarity index 100% rename from htmlpage/sync/template/dispatch-results.html rename to sync/template/dispatch-results.html diff --git a/htmlpage/sync/template/dispatch.html b/sync/template/dispatch.html similarity index 100% rename from htmlpage/sync/template/dispatch.html rename to sync/template/dispatch.html diff --git a/htmlpage/sync/template/empty-auth.html b/sync/template/empty-auth.html similarity index 100% rename from htmlpage/sync/template/empty-auth.html rename to sync/template/empty-auth.html diff --git a/htmlpage/sync/template/empty.html b/sync/template/empty.html similarity index 100% rename from htmlpage/sync/template/empty.html rename to sync/template/empty.html diff --git a/htmlpage/sync/template/mock-root.html b/sync/template/mock-root.html similarity index 100% rename from htmlpage/sync/template/mock-root.html rename to sync/template/mock-root.html diff --git a/htmlpage/sync/template/oauth-prompt.html b/sync/template/oauth-prompt.html similarity index 100% rename from htmlpage/sync/template/oauth-prompt.html rename to sync/template/oauth-prompt.html diff --git a/htmlpage/sync/template/report-confirmation.html b/sync/template/report-confirmation.html similarity index 100% rename from htmlpage/sync/template/report-confirmation.html rename to sync/template/report-confirmation.html diff --git a/htmlpage/sync/template/report-contribute.html b/sync/template/report-contribute.html similarity index 100% rename from htmlpage/sync/template/report-contribute.html rename to sync/template/report-contribute.html diff --git a/htmlpage/sync/template/report-detail.html b/sync/template/report-detail.html similarity index 100% rename from htmlpage/sync/template/report-detail.html rename to sync/template/report-detail.html diff --git a/htmlpage/sync/template/report-evidence.html b/sync/template/report-evidence.html similarity index 100% rename from htmlpage/sync/template/report-evidence.html rename to sync/template/report-evidence.html diff --git a/htmlpage/sync/template/report-schedule.html b/sync/template/report-schedule.html similarity index 100% rename from htmlpage/sync/template/report-schedule.html rename to sync/template/report-schedule.html diff --git a/htmlpage/sync/template/report-update.html b/sync/template/report-update.html similarity index 100% rename from htmlpage/sync/template/report-update.html rename to sync/template/report-update.html diff --git a/htmlpage/sync/template/report.html b/sync/template/report.html similarity index 100% rename from htmlpage/sync/template/report.html rename to sync/template/report.html diff --git a/htmlpage/sync/template/service-request-detail.html b/sync/template/service-request-detail.html similarity index 100% rename from htmlpage/sync/template/service-request-detail.html rename to sync/template/service-request-detail.html diff --git a/htmlpage/sync/template/service-request-location.html b/sync/template/service-request-location.html similarity index 100% rename from htmlpage/sync/template/service-request-location.html rename to sync/template/service-request-location.html diff --git a/htmlpage/sync/template/service-request-mosquito.html b/sync/template/service-request-mosquito.html similarity index 100% rename from htmlpage/sync/template/service-request-mosquito.html rename to sync/template/service-request-mosquito.html diff --git a/htmlpage/sync/template/service-request-pool.html b/sync/template/service-request-pool.html similarity index 100% rename from htmlpage/sync/template/service-request-pool.html rename to sync/template/service-request-pool.html diff --git a/htmlpage/sync/template/service-request-quick-confirmation.html b/sync/template/service-request-quick-confirmation.html similarity index 100% rename from htmlpage/sync/template/service-request-quick-confirmation.html rename to sync/template/service-request-quick-confirmation.html diff --git a/htmlpage/sync/template/service-request-quick.html b/sync/template/service-request-quick.html similarity index 100% rename from htmlpage/sync/template/service-request-quick.html rename to sync/template/service-request-quick.html diff --git a/htmlpage/sync/template/service-request-updates.html b/sync/template/service-request-updates.html similarity index 100% rename from htmlpage/sync/template/service-request-updates.html rename to sync/template/service-request-updates.html diff --git a/htmlpage/sync/template/service-request.html b/sync/template/service-request.html similarity index 100% rename from htmlpage/sync/template/service-request.html rename to sync/template/service-request.html diff --git a/htmlpage/sync/template/setting-integration.html b/sync/template/setting-integration.html similarity index 100% rename from htmlpage/sync/template/setting-integration.html rename to sync/template/setting-integration.html diff --git a/htmlpage/sync/template/setting-mock.html b/sync/template/setting-mock.html similarity index 100% rename from htmlpage/sync/template/setting-mock.html rename to sync/template/setting-mock.html diff --git a/htmlpage/sync/template/setting-pesticide-add.html b/sync/template/setting-pesticide-add.html similarity index 100% rename from htmlpage/sync/template/setting-pesticide-add.html rename to sync/template/setting-pesticide-add.html diff --git a/htmlpage/sync/template/setting-pesticide.html b/sync/template/setting-pesticide.html similarity index 100% rename from htmlpage/sync/template/setting-pesticide.html rename to sync/template/setting-pesticide.html diff --git a/htmlpage/sync/template/setting-user-add.html b/sync/template/setting-user-add.html similarity index 100% rename from htmlpage/sync/template/setting-user-add.html rename to sync/template/setting-user-add.html diff --git a/htmlpage/sync/template/setting-user.html b/sync/template/setting-user.html similarity index 100% rename from htmlpage/sync/template/setting-user.html rename to sync/template/setting-user.html diff --git a/htmlpage/sync/template/settings.html b/sync/template/settings.html similarity index 100% rename from htmlpage/sync/template/settings.html rename to sync/template/settings.html diff --git a/htmlpage/sync/template/signin.html b/sync/template/signin.html similarity index 100% rename from htmlpage/sync/template/signin.html rename to sync/template/signin.html diff --git a/htmlpage/sync/template/signup.html b/sync/template/signup.html similarity index 100% rename from htmlpage/sync/template/signup.html rename to sync/template/signup.html diff --git a/htmlpage/sync/template/source.html b/sync/template/source.html similarity index 100% rename from htmlpage/sync/template/source.html rename to sync/template/source.html diff --git a/htmlpage/sync/time.go b/sync/time.go similarity index 100% rename from htmlpage/sync/time.go rename to sync/time.go diff --git a/htmlpage/sync/types.go b/sync/types.go similarity index 100% rename from htmlpage/sync/types.go rename to sync/types.go diff --git a/htmlpage/sync/utils.go b/sync/utils.go similarity index 100% rename from htmlpage/sync/utils.go rename to sync/utils.go