Compare commits
4 Commits
707d9c63aa
...
0c0a9d0496
Author | SHA1 | Date |
---|---|---|
Arnaud Delcasse | 0c0a9d0496 | |
soukainna | d531fe63ff | |
soukainna | 47a2b1a3cb | |
soukainna | 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/
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
||||||
|
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||||
|
"git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||||
accounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
accounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
|
@ -86,6 +88,8 @@ func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r
|
||||||
"agenda": r.FormValue("modules.agenda") == "on",
|
"agenda": r.FormValue("modules.agenda") == "on",
|
||||||
"groups": r.FormValue("modules.groups") == "on",
|
"groups": r.FormValue("modules.groups") == "on",
|
||||||
"administration": r.FormValue("modules.administration") == "on",
|
"administration": r.FormValue("modules.administration") == "on",
|
||||||
|
"support": r.FormValue("modules.support") == "on",
|
||||||
|
"group_module": r.FormValue("modules.group_module") == "on",
|
||||||
}
|
}
|
||||||
|
|
||||||
groupid := uuid.NewString()
|
groupid := uuid.NewString()
|
||||||
|
@ -329,6 +333,31 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h ApplicationHandler) AdminStatVehicles(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
request := &fleets.GetBookingsRequest{}
|
||||||
|
resp, err := h.services.GRPC.Fleets.GetBookings(context.TODO(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bookings := []storage.Booking{}
|
||||||
|
|
||||||
|
for _, b := range resp.Bookings {
|
||||||
|
booking := b.ToStorageType()
|
||||||
|
bookings = append(bookings, booking)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
|
||||||
|
vehicles, _ := h.services.GetVehiclesMap()
|
||||||
|
groups, _ := h.services.GetGroupsMap()
|
||||||
|
|
||||||
|
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) members() ([]*accounts.Account, error) {
|
func (h *ApplicationHandler) members() ([]*accounts.Account, error) {
|
||||||
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(context.TODO(), &accounts.GetAccountsRequest{
|
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(context.TODO(), &accounts.GetAccountsRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
|
|
|
@ -61,6 +61,7 @@ func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Re
|
||||||
func (h *ApplicationHandler) BeneficiaryCreate(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) BeneficiaryCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
g := r.Context().Value(identification.GroupKey)
|
g := r.Context().Value(identification.GroupKey)
|
||||||
if g == nil {
|
if g == nil {
|
||||||
|
fmt.Println("Create beneficiary : could not find group")
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
package application
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators"
|
||||||
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserForm struct {
|
||||||
|
FirstName string `json:"first_name" validate:"required"`
|
||||||
|
LastName string `json:"last_name" validate:"required"`
|
||||||
|
Email string `json:"email" validate:"required,email"`
|
||||||
|
PhoneNumber string `json:"phone_number" validate:"required,phoneNumber"`
|
||||||
|
Address any `json:"address,omitempty"`
|
||||||
|
Gender string `json:"gender"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) MemberDisplay(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.MemberDisplay(w, r, resp.Account.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) MemberUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
adm := strings.Split(r.URL.Path, "/")
|
||||||
|
userID := adm[3]
|
||||||
|
|
||||||
|
if r.Method == "POST" {
|
||||||
|
|
||||||
|
dataMap, err := parseUserForm(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := structpb.NewValue(dataMap)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &mobilityaccounts.UpdateDataRequest{
|
||||||
|
Account: &mobilityaccounts.Account{
|
||||||
|
Id: userID,
|
||||||
|
Namespace: "parcoursmob",
|
||||||
|
Data: data.GetStructValue(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.MobilityAccounts.UpdateData(context.TODO(), request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("/app/profile/%s", resp.Account.Id), http.StatusFound)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &mobilityaccounts.GetAccountRequest{
|
||||||
|
Id: userID,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.MobilityAccounts.GetAccount(context.TODO(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.MemberUpdate(w, r, resp.Account.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseUserForm(r *http.Request) (map[string]any, error) {
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
formData := UserForm{
|
||||||
|
FirstName: r.PostFormValue("first_name"),
|
||||||
|
LastName: r.PostFormValue("last_name"),
|
||||||
|
Email: r.PostFormValue("email"),
|
||||||
|
PhoneNumber: r.PostFormValue("phone_number"),
|
||||||
|
Gender: r.PostFormValue("gender"),
|
||||||
|
}
|
||||||
|
|
||||||
|
validate := formvalidators.New()
|
||||||
|
if err := validate.Struct(formData); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
d, err := json.Marshal(formData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataMap map[string]any
|
||||||
|
err = json.Unmarshal(d, &dataMap)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataMap, nil
|
||||||
|
}
|
|
@ -136,14 +136,7 @@ func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Reques
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
// Get Group
|
fmt.Println("Book")
|
||||||
// g := r.Context().Value(identification.GroupKey)
|
|
||||||
// if g == nil {
|
|
||||||
// fmt.Println("no current group")
|
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// current_group := g.(storage.Group)
|
|
||||||
current_group, err := h.currentGroup(r)
|
current_group, err := h.currentGroup(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -151,24 +144,6 @@ func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current user ID
|
|
||||||
// u := r.Context().Value(identification.IdtokenKey)
|
|
||||||
// if u == nil {
|
|
||||||
// fmt.Println("no current user")
|
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// current_user_token := u.(*oidc.IDToken)
|
|
||||||
|
|
||||||
// // Get current user claims
|
|
||||||
// c := r.Context().Value(identification.ClaimsKey)
|
|
||||||
// if c == nil {
|
|
||||||
// fmt.Println("no current user claims")
|
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// current_user_claims := c.(map[string]any)
|
|
||||||
|
|
||||||
current_user_token, current_user_claims, err := h.currentUser(r)
|
current_user_token, current_user_claims, err := h.currentUser(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -191,7 +166,7 @@ func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.ParseMultipartForm(10 * 1024 * 1024)
|
r.ParseMultipartForm(100 * 1024 * 1024)
|
||||||
|
|
||||||
start := r.FormValue("startdate")
|
start := r.FormValue("startdate")
|
||||||
end := r.FormValue("enddate")
|
end := r.FormValue("enddate")
|
||||||
|
@ -203,7 +178,7 @@ func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
"booked_by": map[string]any{
|
"booked_by": map[string]any{
|
||||||
"user": map[string]any{
|
"user": map[string]any{
|
||||||
"id": current_user_token.Subject,
|
"id": current_user_token.Subject,
|
||||||
"display_name": current_user_claims["display_name"],
|
"display_name": fmt.Sprintf("%s %s", current_user_claims["first_name"], current_user_claims["last_name"]),
|
||||||
},
|
},
|
||||||
"group": map[string]any{
|
"group": map[string]any{
|
||||||
"id": current_group.ID,
|
"id": current_group.ID,
|
||||||
|
@ -233,7 +208,6 @@ func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
Booking: booking,
|
Booking: booking,
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(r.FormFile("doc-identity_proof"))
|
|
||||||
for _, v := range h.config.GetStringSlice("modules.fleets.booking_documents.mandatory") {
|
for _, v := range h.config.GetStringSlice("modules.fleets.booking_documents.mandatory") {
|
||||||
existing_file := r.FormValue("type-" + v)
|
existing_file := r.FormValue("type-" + v)
|
||||||
if existing_file == "" {
|
if existing_file == "" {
|
||||||
|
@ -282,11 +256,13 @@ func (h ApplicationHandler) Book(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
for _, m := range members {
|
for _, m := range members {
|
||||||
h.emailing.Send("fleets.bookings.creation_admin_alert", m.Data["email"].(string), map[string]string{
|
if email, ok := m.Data["email"].(string); ok {
|
||||||
|
h.emailing.Send("fleets.bookings.creation_admin_alert", email, map[string]string{
|
||||||
"bookingid": booking.Id,
|
"bookingid": booking.Id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/vehicles/bookings/%s", booking.Id), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("/app/vehicles/bookings/%s", booking.Id), http.StatusFound)
|
||||||
|
|
||||||
|
@ -314,9 +290,9 @@ func (h ApplicationHandler) VehicleBookingDisplay(w http.ResponseWriter, r *http
|
||||||
|
|
||||||
beneficiaryresp, err := h.services.GRPC.MobilityAccounts.GetAccount(context.TODO(), beneficiaryrequest)
|
beneficiaryresp, err := h.services.GRPC.MobilityAccounts.GetAccount(context.TODO(), beneficiaryrequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
beneficiaryresp = &mobilityaccounts.GetAccountResponse{
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
Account: &mobilityaccounts.Account{},
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grouprequest := &groupsmanagement.GetGroupRequest{
|
grouprequest := &groupsmanagement.GetGroupRequest{
|
||||||
|
@ -370,7 +346,10 @@ func (h ApplicationHandler) VehiclesBookingsList(w http.ResponseWriter, r *http.
|
||||||
|
|
||||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
|
||||||
h.Renderer.VehicleBookingsList(w, r, bookings)
|
vehicles, _ := h.services.GetVehiclesMap()
|
||||||
|
groups, _ := h.services.GetGroupsMap()
|
||||||
|
|
||||||
|
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) BookingDocumentDownload(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) BookingDocumentDownload(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package auth
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
func (h *AuthHandler) Disconnect(w http.ResponseWriter, r *http.Request) {
|
||||||
|
session, err := h.idp.SessionsStore.Get(r, "parcoursmob_session")
|
||||||
|
if err == nil {
|
||||||
|
session.Options.MaxAge = -1
|
||||||
|
session.Save(r, w)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Redirect(w, r, "/", http.StatusOK)
|
||||||
|
}
|
14
main.go
14
main.go
|
@ -61,6 +61,7 @@ func main() {
|
||||||
r.PathPrefix("/public/").Handler(http.StripPrefix("/public/", http.FileServer(http.Dir(templates_public_dir))))
|
r.PathPrefix("/public/").Handler(http.StripPrefix("/public/", http.FileServer(http.Dir(templates_public_dir))))
|
||||||
|
|
||||||
r.HandleFunc("/auth/onboarding", authHandler.Onboarding)
|
r.HandleFunc("/auth/onboarding", authHandler.Onboarding)
|
||||||
|
r.HandleFunc("/auth/disconnect", authHandler.Disconnect)
|
||||||
r.HandleFunc("/auth/lost-password", authHandler.LostPasswordInit)
|
r.HandleFunc("/auth/lost-password", authHandler.LostPasswordInit)
|
||||||
r.HandleFunc("/auth/lost-password/recover", authHandler.LostPasswordRecover)
|
r.HandleFunc("/auth/lost-password/recover", authHandler.LostPasswordRecover)
|
||||||
r.HandleFunc("/auth/groups/", authHandler.Groups)
|
r.HandleFunc("/auth/groups/", authHandler.Groups)
|
||||||
|
@ -84,6 +85,8 @@ func main() {
|
||||||
application.HandleFunc("/beneficiaries/{beneficiaryid}/documents/{document}", applicationHandler.BeneficiaryDocumentDownload)
|
application.HandleFunc("/beneficiaries/{beneficiaryid}/documents/{document}", applicationHandler.BeneficiaryDocumentDownload)
|
||||||
application.HandleFunc("/beneficiaries/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
application.HandleFunc("/beneficiaries/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
||||||
application.HandleFunc("/members/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
application.HandleFunc("/members/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
||||||
|
application.HandleFunc("/members/{adminid}", applicationHandler.MemberDisplay)
|
||||||
|
application.HandleFunc("/members/{adminid}/update", applicationHandler.MemberUpdate)
|
||||||
application.HandleFunc("/journeys/", applicationHandler.JourneysSearch)
|
application.HandleFunc("/journeys/", applicationHandler.JourneysSearch)
|
||||||
application.HandleFunc("/vehicles/", applicationHandler.VehiclesSearch)
|
application.HandleFunc("/vehicles/", applicationHandler.VehiclesSearch)
|
||||||
application.HandleFunc("/vehicles/bookings/", applicationHandler.VehiclesBookingsList)
|
application.HandleFunc("/vehicles/bookings/", applicationHandler.VehiclesBookingsList)
|
||||||
|
@ -97,7 +100,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 +110,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,7 +135,7 @@ 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)
|
||||||
//TODO Secure with Middleware checking for modules
|
appAdmin.HandleFunc("/stats/vehicles", applicationHandler.AdminStatVehicles)
|
||||||
|
|
||||||
fmt.Println("-> HTTP server listening on", address)
|
fmt.Println("-> HTTP server listening on", address)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package renderer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
const membersMenu = "members"
|
||||||
|
|
||||||
|
func (renderer *Renderer) MemberDisplay(w http.ResponseWriter, r *http.Request, admins any) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.members.display.files")
|
||||||
|
|
||||||
|
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
||||||
|
state.ViewState = map[string]any{
|
||||||
|
"admins": admins,
|
||||||
|
}
|
||||||
|
renderer.Render("members_list", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) MemberUpdate(w http.ResponseWriter, r *http.Request, user any) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.members.update.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
||||||
|
state.ViewState = user
|
||||||
|
renderer.Render("members_update", 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 == membersMenu,
|
||||||
|
Icon: "hero:outline/user-group",
|
||||||
|
})
|
||||||
|
}
|
||||||
return RenderState{
|
return RenderState{
|
||||||
IconSet: icons.NewIconSet(iconset),
|
IconSet: icons.NewIconSet(iconset),
|
||||||
Group: group,
|
Group: group,
|
||||||
|
|
|
@ -67,11 +67,13 @@ func (renderer *Renderer) VehicleBookingDisplay(w http.ResponseWriter, r *http.R
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
renderer.Render("vehicles search", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) VehicleBookingsList(w http.ResponseWriter, r *http.Request, bookings []storage.Booking) {
|
func (renderer *Renderer) VehicleBookingsList(w http.ResponseWriter, r *http.Request, bookings []storage.Booking, vehiclesMap any, groupsMap any) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles.bookings_list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles.bookings_list.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"bookings": bookings,
|
"bookings": bookings,
|
||||||
|
"vehicles_map": vehiclesMap,
|
||||||
|
"groups_map": groupsMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
renderer.Render("vehicles search", w, r, files, state)
|
||||||
|
|
|
@ -52,3 +52,17 @@ func (s *ServicesHandler) GetBookings() (bookings []storage.Booking, err error)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) GetVehiclesMap() (vehicles map[string]storage.Vehicle, err error) {
|
||||||
|
vehicles = map[string]storage.Vehicle{}
|
||||||
|
|
||||||
|
request := &fleets.GetVehiclesRequest{}
|
||||||
|
resp, err := s.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
||||||
|
if err == nil {
|
||||||
|
for _, vehicle := range resp.Vehicles {
|
||||||
|
vehicles[vehicle.Id] = vehicle.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
|
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,3 +24,17 @@ func NewGroupsManagementService(groupsManagementDial string) (*GroupsManagementS
|
||||||
GroupsManagementClient: client,
|
GroupsManagementClient: client,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) GetGroupsMap() (groups map[string]storage.Group, err error) {
|
||||||
|
groups = map[string]storage.Group{}
|
||||||
|
|
||||||
|
request := &groupsmanagement.GetGroupsRequest{}
|
||||||
|
resp, err := s.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
||||||
|
if err == nil {
|
||||||
|
for _, group := range resp.Groups {
|
||||||
|
groups[group.Id] = group.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue