Add all of Ben's mocks for the new root pages
This commit is contained in:
parent
5d8366015c
commit
9613cac11a
21 changed files with 1593 additions and 141 deletions
14
sync/communication.go
Normal file
14
sync/communication.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
)
|
||||
|
||||
type contentCommunicationRoot struct{}
|
||||
|
||||
func getCommunicationRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentCommunicationRoot], *errorWithStatus) {
|
||||
return newResponse("sync/communication-root.html", contentCommunicationRoot{}), nil
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
)
|
||||
|
||||
type contentConfig struct {
|
||||
IsProductionEnvironment bool
|
||||
}
|
||||
|
||||
func newContentConfig() contentConfig {
|
||||
return contentConfig{
|
||||
IsProductionEnvironment: config.IsProductionEnvironment(),
|
||||
}
|
||||
}
|
||||
117
sync/configuration.go
Normal file
117
sync/configuration.go
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/arcgis"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
//"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type contentConfig struct {
|
||||
IsProductionEnvironment bool
|
||||
}
|
||||
|
||||
func newContentConfig() contentConfig {
|
||||
return contentConfig{
|
||||
IsProductionEnvironment: config.IsProductionEnvironment(),
|
||||
}
|
||||
}
|
||||
|
||||
type contentConfigurationRoot struct{}
|
||||
|
||||
func getConfigurationRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentConfigurationRoot], *errorWithStatus) {
|
||||
return newResponse("sync/configuration/root.html", contentConfigurationRoot{}), nil
|
||||
}
|
||||
|
||||
type contentSettingOrganization struct {
|
||||
Organization *models.Organization
|
||||
}
|
||||
|
||||
type contentSettingIntegration struct {
|
||||
ArcGISOAuth *models.OauthToken
|
||||
}
|
||||
|
||||
func getConfigurationOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingOrganization], *errorWithStatus) {
|
||||
org, err := u.Organization().One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
return nil, newError("get organization: %w", err)
|
||||
}
|
||||
/*
|
||||
var district contentDistrict
|
||||
district, err = bob.One[contentDistrict](ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.From("import.district"),
|
||||
sm.Columns(
|
||||
"address",
|
||||
"agency",
|
||||
"area_4326_sqm",
|
||||
"city1",
|
||||
"city2",
|
||||
"contact",
|
||||
"fax1",
|
||||
"general_mg",
|
||||
"gid",
|
||||
"phone1",
|
||||
"phone2",
|
||||
"postal_c_1",
|
||||
"website",
|
||||
psql.F("ST_AsGeoJSON", "centroid_4326"),
|
||||
psql.F("ST_XMin", "extent_4326"),
|
||||
psql.F("ST_YMin", "extent_4326"),
|
||||
psql.F("ST_XMax", "extent_4326"),
|
||||
psql.F("ST_YMax", "extent_4326"),
|
||||
),
|
||||
sm.Where(psql.Quote("gid").EQ(psql.Arg(gid))),
|
||||
), scan.StructMapper[contentDistrict]())
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get extents", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
*/
|
||||
data := contentSettingOrganization{
|
||||
Organization: org,
|
||||
}
|
||||
return newResponse("sync/configuration/organization.html", data), nil
|
||||
}
|
||||
func getConfigurationIntegration(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingIntegration], *errorWithStatus) {
|
||||
oauth, err := arcgis.GetOAuthForUser(ctx, u)
|
||||
if err != nil {
|
||||
return nil, newError("Failed to get oauth: %w", err)
|
||||
}
|
||||
data := contentSettingIntegration{
|
||||
ArcGISOAuth: oauth,
|
||||
}
|
||||
return newResponse("sync/configuration/integration.html", data), nil
|
||||
}
|
||||
func getConfigurationIntegrationArcgis(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingIntegration], *errorWithStatus) {
|
||||
oauth, err := arcgis.GetOAuthForUser(ctx, u)
|
||||
if err != nil {
|
||||
return nil, newError("Failed to get oauth: %w", err)
|
||||
}
|
||||
data := contentSettingIntegration{
|
||||
ArcGISOAuth: oauth,
|
||||
}
|
||||
return newResponse("sync/configuration/integration-arcgis.html", data), nil
|
||||
}
|
||||
|
||||
type contentSettingPlaceholder struct{}
|
||||
|
||||
func getConfigurationPesticide(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/configuration/pesticide.html", content), nil
|
||||
}
|
||||
func getConfigurationPesticideAdd(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/configuration/pesticide-add.html", content), nil
|
||||
}
|
||||
func getConfigurationUserAdd(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/configuration/user-add.html", content), nil
|
||||
}
|
||||
func getConfigurationUserList(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/configuration/user-list.html", content), nil
|
||||
}
|
||||
14
sync/intelligence.go
Normal file
14
sync/intelligence.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
)
|
||||
|
||||
type contentIntelligenceRoot struct{}
|
||||
|
||||
func getIntelligenceRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentIntelligenceRoot], *errorWithStatus) {
|
||||
return newResponse("sync/intelligence-root.html", contentIntelligenceRoot{}), nil
|
||||
}
|
||||
14
sync/operations.go
Normal file
14
sync/operations.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
)
|
||||
|
||||
type contentOperationsRoot struct{}
|
||||
|
||||
func getOperationsRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentOperationsRoot], *errorWithStatus) {
|
||||
return newResponse("sync/operations-root.html", contentOperationsRoot{}), nil
|
||||
}
|
||||
14
sync/review.go
Normal file
14
sync/review.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
)
|
||||
|
||||
type contentReviewRoot struct{}
|
||||
|
||||
func getReviewRoot(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentReviewRoot], *errorWithStatus) {
|
||||
return newResponse("sync/review-root.html", contentReviewRoot{}), nil
|
||||
}
|
||||
|
|
@ -48,25 +48,34 @@ func Router() chi.Router {
|
|||
r.Route("/api", api.AddRoutes)
|
||||
r.Method("GET", "/admin", authenticatedHandler(getAdminDash))
|
||||
r.Method("GET", "/cell/{cell}", authenticatedHandler(getCellDetails))
|
||||
r.Method("GET", "/communication", authenticatedHandler(getCommunicationRoot))
|
||||
r.Method("GET", "/configuration", authenticatedHandler(getConfigurationRoot))
|
||||
r.Method("GET", "/configuration/upload", authenticatedHandler(getUploadList))
|
||||
r.Method("GET", "/configuration/upload/pool", authenticatedHandler(getUploadPoolCreate))
|
||||
r.Method("POST", "/configuration/upload/pool", authenticatedHandlerPostMultipart(postUploadPoolCreate))
|
||||
r.Method("GET", "/configuration/upload/{id}", authenticatedHandler(getUploadByID))
|
||||
r.Method("POST", "/configuration/upload/{id}/discard", authenticatedHandlerPost(postUploadDiscard))
|
||||
r.Method("GET", "/download", authenticatedHandler(getDownloadList))
|
||||
r.Method("GET", "/intelligence", authenticatedHandler(getIntelligenceRoot))
|
||||
r.Method("GET", "/layout-test", authenticatedHandler(getLayoutTest))
|
||||
r.Method("GET", "/message", authenticatedHandler(getMessageList))
|
||||
r.Method("GET", "/notification", authenticatedHandler(getNotificationList))
|
||||
r.Method("GET", "/operations", authenticatedHandler(getOperationsRoot))
|
||||
r.Method("GET", "/planning", authenticatedHandler(getPlanningRoot))
|
||||
r.Method("GET", "/pool", authenticatedHandler(getPoolList))
|
||||
r.Method("GET", "/pool/create", authenticatedHandler(getPoolCreate))
|
||||
r.Method("GET", "/pool/{id}", authenticatedHandler(getPoolByID))
|
||||
r.Method("GET", "/radar", authenticatedHandler(getRadar))
|
||||
r.Method("GET", "/review", authenticatedHandler(getReviewRoot))
|
||||
r.Method("GET", "/service-request", authenticatedHandler(getServiceRequestList))
|
||||
r.Method("GET", "/service-request/{id}", authenticatedHandler(getServiceRequestDetail))
|
||||
r.Method("GET", "/setting", authenticatedHandler(getSetting))
|
||||
r.Method("GET", "/setting/integration", authenticatedHandler(getSettingIntegration))
|
||||
r.Method("GET", "/setting/integration/arcgis", authenticatedHandler(getSettingIntegrationArcgis))
|
||||
r.Method("GET", "/setting/organization", authenticatedHandler(getSettingOrganization))
|
||||
r.Method("GET", "/setting/pesticide", authenticatedHandler(getSettingPesticide))
|
||||
r.Method("GET", "/setting/pesticide/add", authenticatedHandler(getSettingPesticideAdd))
|
||||
r.Method("GET", "/setting/user", authenticatedHandler(getSettingUserList))
|
||||
r.Method("GET", "/setting/user/add", authenticatedHandler(getSettingUserAdd))
|
||||
r.Method("GET", "/configuration/integration", authenticatedHandler(getConfigurationIntegration))
|
||||
r.Method("GET", "/configuration/integration/arcgis", authenticatedHandler(getConfigurationIntegrationArcgis))
|
||||
r.Method("GET", "/configuration/organization", authenticatedHandler(getConfigurationOrganization))
|
||||
r.Method("GET", "/configuration/pesticide", authenticatedHandler(getConfigurationPesticide))
|
||||
r.Method("GET", "/configuration/pesticide/add", authenticatedHandler(getConfigurationPesticideAdd))
|
||||
r.Method("GET", "/configuration/user", authenticatedHandler(getConfigurationUserList))
|
||||
r.Method("GET", "/configuration/user/add", authenticatedHandler(getConfigurationUserAdd))
|
||||
r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout))
|
||||
r.Method("GET", "/source/{globalid}", authenticatedHandler(getSource))
|
||||
r.Method("GET", "/stadia", authenticatedHandler(getStadia))
|
||||
|
|
@ -75,11 +84,6 @@ func Router() chi.Router {
|
|||
r.Method("POST", "/sudo/sms", authenticatedHandlerPost(postSudoSMS))
|
||||
r.Method("GET", "/trap/{globalid}", authenticatedHandler(getTrap))
|
||||
r.Method("GET", "/text/{destination}", authenticatedHandler(getTextMessages))
|
||||
r.Method("GET", "/upload", authenticatedHandler(getUploadList))
|
||||
r.Method("GET", "/upload/pool", authenticatedHandler(getUploadPoolCreate))
|
||||
r.Method("POST", "/upload/pool", authenticatedHandlerPostMultipart(postUploadPoolCreate))
|
||||
r.Method("GET", "/upload/{id}", authenticatedHandler(getUploadByID))
|
||||
r.Method("POST", "/upload/{id}/discard", authenticatedHandlerPost(postUploadDiscard))
|
||||
|
||||
html.AddStaticRoute(r, "/static")
|
||||
return r
|
||||
|
|
|
|||
106
sync/setting.go
106
sync/setting.go
|
|
@ -1,107 +1,3 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/arcgis"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
//"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type contentSettingOrganization struct {
|
||||
Organization *models.Organization
|
||||
}
|
||||
|
||||
type contentSettingIntegration struct {
|
||||
ArcGISOAuth *models.OauthToken
|
||||
}
|
||||
|
||||
type contentAuthenticatedPlaceholder struct {
|
||||
}
|
||||
|
||||
func getSetting(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentAuthenticatedPlaceholder], *errorWithStatus) {
|
||||
data := contentAuthenticatedPlaceholder{}
|
||||
return newResponse("sync/settings.html", data), nil
|
||||
}
|
||||
func getSettingOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingOrganization], *errorWithStatus) {
|
||||
org, err := u.Organization().One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
return nil, newError("get organization: %w", err)
|
||||
}
|
||||
/*
|
||||
var district contentDistrict
|
||||
district, err = bob.One[contentDistrict](ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.From("import.district"),
|
||||
sm.Columns(
|
||||
"address",
|
||||
"agency",
|
||||
"area_4326_sqm",
|
||||
"city1",
|
||||
"city2",
|
||||
"contact",
|
||||
"fax1",
|
||||
"general_mg",
|
||||
"gid",
|
||||
"phone1",
|
||||
"phone2",
|
||||
"postal_c_1",
|
||||
"website",
|
||||
psql.F("ST_AsGeoJSON", "centroid_4326"),
|
||||
psql.F("ST_XMin", "extent_4326"),
|
||||
psql.F("ST_YMin", "extent_4326"),
|
||||
psql.F("ST_XMax", "extent_4326"),
|
||||
psql.F("ST_YMax", "extent_4326"),
|
||||
),
|
||||
sm.Where(psql.Quote("gid").EQ(psql.Arg(gid))),
|
||||
), scan.StructMapper[contentDistrict]())
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get extents", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
*/
|
||||
data := contentSettingOrganization{
|
||||
Organization: org,
|
||||
}
|
||||
return newResponse("sync/setting-organization.html", data), nil
|
||||
}
|
||||
func getSettingIntegration(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingIntegration], *errorWithStatus) {
|
||||
oauth, err := arcgis.GetOAuthForUser(ctx, u)
|
||||
if err != nil {
|
||||
return nil, newError("Failed to get oauth: %w", err)
|
||||
}
|
||||
data := contentSettingIntegration{
|
||||
ArcGISOAuth: oauth,
|
||||
}
|
||||
return newResponse("sync/setting-integration.html", data), nil
|
||||
}
|
||||
func getSettingIntegrationArcgis(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingIntegration], *errorWithStatus) {
|
||||
oauth, err := arcgis.GetOAuthForUser(ctx, u)
|
||||
if err != nil {
|
||||
return nil, newError("Failed to get oauth: %w", err)
|
||||
}
|
||||
data := contentSettingIntegration{
|
||||
ArcGISOAuth: oauth,
|
||||
}
|
||||
return newResponse("sync/setting-integration-arcgis.html", data), nil
|
||||
}
|
||||
|
||||
type contentSettingPlaceholder struct{}
|
||||
|
||||
func getSettingPesticide(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/setting-pesticide.html", content), nil
|
||||
}
|
||||
func getSettingPesticideAdd(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/setting-pesticide-add.html", content), nil
|
||||
}
|
||||
func getSettingUserAdd(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/setting-user-add.html", content), nil
|
||||
}
|
||||
func getSettingUserList(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentSettingPlaceholder], *errorWithStatus) {
|
||||
content := contentSettingPlaceholder{}
|
||||
return newResponse("sync/setting-user-list.html", content), nil
|
||||
}
|
||||
import ()
|
||||
|
|
|
|||
12
sync/url.go
12
sync/url.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
)
|
||||
|
||||
type contentURL struct {
|
||||
Configuration contentURLConfiguration
|
||||
OAuthRefreshArcGIS string
|
||||
Root string
|
||||
Route string
|
||||
|
|
@ -17,6 +18,7 @@ type contentURL struct {
|
|||
|
||||
func newContentURL() contentURL {
|
||||
return contentURL{
|
||||
Configuration: newContentURLConfiguration(),
|
||||
OAuthRefreshArcGIS: config.MakeURLNidus("/arcgis/oauth/begin"),
|
||||
Root: config.MakeURLNidus("/"),
|
||||
Route: config.MakeURLNidus("/route"),
|
||||
|
|
@ -28,6 +30,16 @@ func newContentURL() contentURL {
|
|||
}
|
||||
}
|
||||
|
||||
type contentURLConfiguration struct {
|
||||
Upload string
|
||||
}
|
||||
|
||||
func newContentURLConfiguration() contentURLConfiguration {
|
||||
return contentURLConfiguration{
|
||||
Upload: config.MakeURLNidus("/configuration/upload"),
|
||||
}
|
||||
}
|
||||
|
||||
type contentURLSidebar struct {
|
||||
Communication string
|
||||
Configuration string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue