add page profile for the admins
This commit is contained in:
parent
707d9c63aa
commit
d9f5721a15
2
go.mod
2
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/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/
|
// replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
|
||||||
|
|
||||||
|
|
|
@ -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())
|
||||||
|
}
|
13
main.go
13
main.go
|
@ -97,7 +97,6 @@ func main() {
|
||||||
application.HandleFunc("/vehicles-management/fleet/{vehicleid}/update", applicationHandler.VehiclesFleetUpdate)
|
application.HandleFunc("/vehicles-management/fleet/{vehicleid}/update", applicationHandler.VehiclesFleetUpdate)
|
||||||
application.HandleFunc("/vehicles-management/bookings/", applicationHandler.VehiclesManagementBookingsList)
|
application.HandleFunc("/vehicles-management/bookings/", applicationHandler.VehiclesManagementBookingsList)
|
||||||
application.HandleFunc("/vehicles-management/bookings/{bookingid}", applicationHandler.VehicleManagementBookingDisplay)
|
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("/vehicles-management/bookings/{bookingid}/documents/{document}", applicationHandler.BookingDocumentDownload)
|
||||||
application.HandleFunc("/agenda/", applicationHandler.AgendaHome)
|
application.HandleFunc("/agenda/", applicationHandler.AgendaHome)
|
||||||
application.HandleFunc("/agenda/create-event", applicationHandler.AgendaCreateEvent)
|
application.HandleFunc("/agenda/create-event", applicationHandler.AgendaCreateEvent)
|
||||||
|
@ -108,14 +107,20 @@ func main() {
|
||||||
application.HandleFunc("/group/settings", applicationHandler.GroupSettingsDisplay)
|
application.HandleFunc("/group/settings", applicationHandler.GroupSettingsDisplay)
|
||||||
application.HandleFunc("/group/settings/invite-member", applicationHandler.GroupSettingsInviteMember)
|
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************************/
|
/********************Code Supprt Emailing************************/
|
||||||
application.HandleFunc("/support/", applicationHandler.SupportSend)
|
application.HandleFunc("/support/", applicationHandler.SupportSend)
|
||||||
/*********************** CODE GROUP **************************/
|
/*********************** CODE GROUP **************************/
|
||||||
|
|
||||||
appGroup := application.PathPrefix("/group_module").Subrouter()
|
appGroup := application.PathPrefix("/group_module").Subrouter()
|
||||||
appGroup.HandleFunc("/", applicationHandler.Groups)
|
appGroup.HandleFunc("/", applicationHandler.Groups)
|
||||||
appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule)
|
appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule)
|
||||||
appGroup.HandleFunc("/groups/{groupid}", applicationHandler.DisplayGroupModule)
|
appGroup.HandleFunc("/groups/{groupid}", applicationHandler.DisplayGroupModule)
|
||||||
/****************************************************************/
|
|
||||||
|
|
||||||
//TODO Subrouters with middlewares checking security for each module ?
|
//TODO Subrouters with middlewares checking security for each module ?
|
||||||
application.Use(idp.Middleware)
|
application.Use(idp.Middleware)
|
||||||
|
@ -127,6 +132,10 @@ func main() {
|
||||||
appAdmin.HandleFunc("/groups/{groupid}", applicationHandler.AdministrationGroupDisplay)
|
appAdmin.HandleFunc("/groups/{groupid}", applicationHandler.AdministrationGroupDisplay)
|
||||||
appAdmin.HandleFunc("/groups/{groupid}/invite-admin", applicationHandler.AdministrationGroupInviteAdmin)
|
appAdmin.HandleFunc("/groups/{groupid}/invite-admin", applicationHandler.AdministrationGroupInviteAdmin)
|
||||||
appAdmin.HandleFunc("/groups/{groupid}/invite-member", applicationHandler.AdministrationGroupInviteMember)
|
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
|
//TODO Secure with Middleware checking for modules
|
||||||
|
|
||||||
fmt.Println("-> HTTP server listening on", address)
|
fmt.Println("-> HTTP server listening on", address)
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
|
@ -240,7 +240,14 @@ func NewState(r *http.Request, themeConfig *viper.Viper, menuState string) Rende
|
||||||
Icon: "hero:outline/document-text",
|
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{
|
return RenderState{
|
||||||
IconSet: icons.NewIconSet(iconset),
|
IconSet: icons.NewIconSet(iconset),
|
||||||
Group: group,
|
Group: group,
|
||||||
|
|
Loading…
Reference in New Issue