diff --git a/api/routes.go b/api/routes.go index c1e2335c..178424dc 100644 --- a/api/routes.go +++ b/api/routes.go @@ -7,7 +7,44 @@ import ( "github.com/gorilla/mux" ) -func AddRoutes(r *mux.Router) { +func AddRoutesRMO(r *mux.Router) { + router := resource.NewRouter(r) + + compliance_request := resource.ComplianceRequest(router) + district := resource.District(router) + geocode := resource.Geocode(router) + nuisance := resource.Nuisance(router) + pr_compliance := resource.PublicReportCompliance(router) + publicreport := resource.Publicreport(router) + publicreport_notification := resource.PublicreportNotification(router) + qrcode := resource.QRCode(router) + water := resource.Water(router) + + r.HandleFunc("/compliance-request/image/pool/{public_id}", compliance_request.ImagePoolGet).Methods("GET").Name("compliance-request.image.pool.ByIDGet") + r.Handle("/district", handlerJSONSlice(district.List)).Methods("GET") + r.Handle("/district/{id}", handlerJSON(district.GetByID)).Methods("GET").Name("district.ByIDGet") + r.HandleFunc("/district/{slug}/logo", apiGetDistrictLogo).Methods("GET").Name("district.logo.BySlug") + r.Handle("/geocode/by-gid/{id:.*}", handlerJSON(geocode.ByGID)).Methods("GET") + r.Handle("/geocode/reverse", handlerJSONPost(geocode.Reverse)).Methods("POST") + r.Handle("/geocode/reverse/closest", handlerJSONPost(geocode.ReverseClosest)).Methods("POST") + r.Handle("/geocode/suggestion", handlerJSONSlice(geocode.SuggestionList)).Methods("GET") + + r.Handle("/publicreport-notification", handlerJSONPost(publicreport_notification.Create)).Methods("POST") + r.Handle("/qr-code/mailer/{code}", handlerBasic(qrcode.Mailer)).Methods("GET") + r.Handle("/qr-code/marketing", handlerBasic(qrcode.Marketing)).Methods("GET") + r.Handle("/qr-code/report/{code}", handlerBasic(qrcode.Report)).Methods("GET") + r.HandleFunc("/rmo/compliance", handlerJSONPost(pr_compliance.Create)).Methods("POST") + r.HandleFunc("/rmo/nuisance", handlerFormPost(nuisance.Create)).Methods("POST") + r.Handle("/rmo/publicreport/{id}", handlerBasic(publicreport.ByIDPublic)).Methods("GET").Name("publicreport.ByIDGetPublic") + r.Handle("/rmo/publicreport/compliance/{id}/image", handlerFormPost(publicreport.ImageCreate)).Methods("POST") + r.Handle("/rmo/publicreport/compliance/{id}", handlerJSON(pr_compliance.ByIDPublic)).Methods("GET").Name("publicreport.compliance.ByIDGetPublic") + r.Handle("/rmo/publicreport/compliance/{id}", handlerJSONPut(pr_compliance.Update)).Methods("PUT") + r.Handle("/rmo/publicreport/nuisance/{id}", handlerJSON(nuisance.ByIDPublic)).Methods("GET").Name("publicreport.nuisance.ByIDGetPublic") + r.Handle("/rmo/publicreport/water/{id}", handlerJSON(water.ByIDPublic)).Methods("GET").Name("publicreport.water.ByIDGetPublic") + r.Handle("/rmo/publicreport/{id}", handlerBasic(publicreport.ByIDPublic)).Methods("GET").Name("publicreport.ByIDGetPublicPublic") + r.HandleFunc("/rmo/water", handlerFormPost(water.Create)).Methods("POST") +} +func AddRoutesSync(r *mux.Router) { router := resource.NewRouter(r) compliance_request := resource.ComplianceRequest(router) @@ -39,16 +76,6 @@ func AddRoutes(r *mux.Router) { r.Handle("/qr-code/mailer/{code}", handlerBasic(qrcode.Mailer)).Methods("GET") r.Handle("/qr-code/marketing", handlerBasic(qrcode.Marketing)).Methods("GET") r.Handle("/qr-code/report/{code}", handlerBasic(qrcode.Report)).Methods("GET") - r.HandleFunc("/rmo/compliance", handlerJSONPost(pr_compliance.Create)).Methods("POST") - r.HandleFunc("/rmo/nuisance", handlerFormPost(nuisance.Create)).Methods("POST") - r.Handle("/rmo/publicreport/{id}", handlerBasic(publicreport.ByIDPublic)).Methods("GET").Name("publicreport.ByIDGetPublic") - r.Handle("/rmo/publicreport/compliance/{id}/image", handlerFormPost(publicreport.ImageCreate)).Methods("POST") - r.Handle("/rmo/publicreport/compliance/{id}", handlerJSON(pr_compliance.ByIDPublic)).Methods("GET").Name("publicreport.compliance.ByIDGetPublic") - r.Handle("/rmo/publicreport/compliance/{id}", handlerJSONPut(pr_compliance.Update)).Methods("PUT") - r.Handle("/rmo/publicreport/nuisance/{id}", handlerJSON(nuisance.ByIDPublic)).Methods("GET").Name("publicreport.nuisance.ByIDGetPublic") - r.Handle("/rmo/publicreport/water/{id}", handlerJSON(water.ByIDPublic)).Methods("GET").Name("publicreport.water.ByIDGetPublic") - r.Handle("/rmo/publicreport/{id}", handlerBasic(publicreport.ByIDPublic)).Methods("GET").Name("publicreport.ByIDGetPublicPublic") - r.HandleFunc("/rmo/water", handlerFormPost(water.Create)).Methods("POST") r.HandleFunc("/signin", handlerJSONPost(postSignin)) r.Handle("/signout", authenticatedHandlerBasic(postSignout)) r.HandleFunc("/signup", handlerJSONPost(postSignup)) diff --git a/main.go b/main.go index be24d53d..5b290686 100644 --- a/main.go +++ b/main.go @@ -122,16 +122,15 @@ func main() { r.Use(sentryMiddleware.Handle) r.Use(auth.NewSessionManager().LoadAndSave) - sync_router := r.Host(config.DomainNidus).Subrouter() - rmo_router := r.Host(config.DomainRMO).Subrouter() - // Set up routing by hostname + sync_router := r.Host(config.DomainNidus).Subrouter() sync_api_router := sync_router.PathPrefix("/api").Subrouter() - api.AddRoutes(sync_api_router) + api.AddRoutesSync(sync_api_router) nidussync.Router(sync_router) + rmo_router := r.Host(config.DomainRMO).Subrouter() rmo_api_router := rmo_router.PathPrefix("/api").Subrouter() - api.AddRoutes(rmo_api_router) + api.AddRoutesRMO(rmo_api_router) rmo.Router(rmo_router) //hr.Map("", sr) // default diff --git a/resource/communication.go b/resource/communication.go index b013ef90..f7ded790 100644 --- a/resource/communication.go +++ b/resource/communication.go @@ -9,7 +9,6 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/config" nhttp "github.com/Gleipnir-Technology/nidus-sync/http" "github.com/Gleipnir-Technology/nidus-sync/platform" - "github.com/Gleipnir-Technology/nidus-sync/platform/types" "github.com/google/uuid" //"github.com/gorilla/mux" //"github.com/rs/zerolog/log" @@ -26,10 +25,10 @@ func Communication(r *router) *communicationR { } type communication struct { - Created time.Time `json:"created"` - ID string `json:"id"` - PublicReport types.PublicReport `json:"public_report"` - Type string `json:"type"` + Created time.Time `json:"created"` + ID string `json:"id"` + PublicReport string `json:"public_report"` + Type string `json:"type"` } type communicationList struct { Communications []communication `json:"communications"` @@ -58,7 +57,7 @@ func (res *communicationR) List(ctx context.Context, r *http.Request, user platf comms[i] = communication{ Created: report.Created, ID: report.PublicID, - PublicReport: *report, + PublicReport: report.URI, Type: "publicreport." + string(report.Type), } } diff --git a/ts/components/CommunicationColumnAction.vue b/ts/components/CommunicationColumnAction.vue index 5dd3f789..dafd057b 100644 --- a/ts/components/CommunicationColumnAction.vue +++ b/ts/components/CommunicationColumnAction.vue @@ -49,8 +49,8 @@
@@ -107,8 +107,7 @@
Activity Log
@@ -116,8 +115,7 @@
@@ -134,7 +132,7 @@ diff --git a/ts/components/ListCardPublicReport.vue b/ts/components/ListCardPublicReport.vue index eecea656..d1d173e2 100644 --- a/ts/components/ListCardPublicReport.vue +++ b/ts/components/ListCardPublicReport.vue @@ -1,33 +1,17 @@ @@ -57,6 +59,7 @@