diff --git a/go.mod b/go.mod index 9173408..66b43ee 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 // replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/ -// replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/ +replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/ // replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/ diff --git a/handlers/application/conseillers.go b/handlers/application/conseillers.go new file mode 100644 index 0000000..bb823a2 --- /dev/null +++ b/handlers/application/conseillers.go @@ -0,0 +1,29 @@ +package application + +import ( + "context" + "fmt" + "net/http" + "strings" + + mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi" +) + +func (h *ApplicationHandler) ConseillerDisplay(w http.ResponseWriter, r *http.Request) { + + adm := strings.Split(r.URL.Path, "/") + adminid := adm[3] + + request := &mobilityaccounts.GetAccountRequest{ + Id: adminid, + } + + resp, err := h.services.GRPC.MobilityAccounts.GetAccount(context.TODO(), request) + if err != nil { + fmt.Println(err) + w.WriteHeader(http.StatusInternalServerError) + return + } + + h.Renderer.ConseillerDisplay(w, r, resp.Account.ToStorageType()) +} diff --git a/main.go b/main.go index 0684d0d..3831d9e 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,6 @@ func main() { application.HandleFunc("/vehicles-management/fleet/{vehicleid}/update", applicationHandler.VehiclesFleetUpdate) application.HandleFunc("/vehicles-management/bookings/", applicationHandler.VehiclesManagementBookingsList) application.HandleFunc("/vehicles-management/bookings/{bookingid}", applicationHandler.VehicleManagementBookingDisplay) - application.HandleFunc("/vehicles-management/bookings/{bookingid}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle) application.HandleFunc("/vehicles-management/bookings/{bookingid}/documents/{document}", applicationHandler.BookingDocumentDownload) application.HandleFunc("/agenda/", applicationHandler.AgendaHome) application.HandleFunc("/agenda/create-event", applicationHandler.AgendaCreateEvent) @@ -108,14 +107,20 @@ func main() { application.HandleFunc("/group/settings", applicationHandler.GroupSettingsDisplay) application.HandleFunc("/group/settings/invite-member", applicationHandler.GroupSettingsInviteMember) + /****************************Groupe Déplacement ************************************/ + // application.HandleFunc("/journeys/groups_covoiturage", applicationHandler.GroupsGestion) + // application.HandleFunc("/journeys/groups_covoiturage/create", applicationHandler.CreateGroup) + // application.HandleFunc("/journeys/groups_covoiturage/create/{groupid}", applicationHandler.DisplayGroupCovoiturage) + /****************************************************************/ + /********************Code Supprt Emailing************************/ application.HandleFunc("/support/", applicationHandler.SupportSend) /*********************** CODE GROUP **************************/ + appGroup := application.PathPrefix("/group_module").Subrouter() appGroup.HandleFunc("/", applicationHandler.Groups) appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule) appGroup.HandleFunc("/groups/{groupid}", applicationHandler.DisplayGroupModule) - /****************************************************************/ //TODO Subrouters with middlewares checking security for each module ? application.Use(idp.Middleware) @@ -127,6 +132,10 @@ func main() { appAdmin.HandleFunc("/groups/{groupid}", applicationHandler.AdministrationGroupDisplay) appAdmin.HandleFunc("/groups/{groupid}/invite-admin", applicationHandler.AdministrationGroupInviteAdmin) appAdmin.HandleFunc("/groups/{groupid}/invite-member", applicationHandler.AdministrationGroupInviteMember) + + ///////////////////////////code page profile of admin /////////////////////////// + application.HandleFunc("/conseillers/{adminid}", applicationHandler.ConseillerDisplay) + //TODO Secure with Middleware checking for modules fmt.Println("-> HTTP server listening on", address) diff --git a/renderer/conseillers.go b/renderer/conseillers.go new file mode 100644 index 0000000..411c2b4 --- /dev/null +++ b/renderer/conseillers.go @@ -0,0 +1,17 @@ +package renderer + +import ( + "net/http" +) + +const conseillersMenu = "conseillers" + +func (renderer *Renderer) ConseillerDisplay(w http.ResponseWriter, r *http.Request, admins any) { + files := renderer.ThemeConfig.GetStringSlice("views.conseillers.display.files") + + state := NewState(r, renderer.ThemeConfig, conseillersMenu) + state.ViewState = map[string]any{ + "admins": admins, + } + renderer.Render("conseillers_list", w, r, files, state) +} diff --git a/renderer/renderer.go b/renderer/renderer.go index 9a2b34e..c3d8141 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -240,7 +240,14 @@ func NewState(r *http.Request, themeConfig *viper.Viper, menuState string) Rende Icon: "hero:outline/document-text", }) } - + if modules["conseillers"] != nil && modules["conseillers"].(bool) { + ls.MenuItems = append(ls.MenuItems, MenuItem{ + Title: "Conseillers", + Link: "/app/conseillers/", + Active: menuState == conseillersMenu, + Icon: "hero:outline/user-group", + }) + } return RenderState{ IconSet: icons.NewIconSet(iconset), Group: group,