Add beneficiaries informations to bookings list
Build and Push Docker Image / build_and_push (push) Failing after 1m25s Details

This commit is contained in:
Arnaud Delcasse 2024-11-19 15:53:40 +01:00
parent 2f760733af
commit 5f12bed2d4
3 changed files with 29 additions and 6 deletions

View File

@ -61,9 +61,11 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
}
}
driversMap, _ := h.services.GetBeneficiariesMap()
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
sort.Sort(sorting.BookingsByStartdate(bookings))
h.Renderer.VehiclesManagementOverview(w, r, vehicles, vehicles_map, bookings)
h.Renderer.VehiclesManagementOverview(w, r, vehicles, vehicles_map, driversMap, bookings)
}
func (h *ApplicationHandler) VehiclesManagementBookingsList(w http.ResponseWriter, r *http.Request) {
@ -98,7 +100,9 @@ func (h *ApplicationHandler) VehiclesManagementBookingsList(w http.ResponseWrite
cacheid := uuid.NewString()
h.cache.PutWithTTL(cacheid, bookings, 1*time.Hour)
h.Renderer.VehiclesManagementBookingsList(w, r, vehicles_map, bookings, cacheid)
driversMap, _ := h.services.GetBeneficiariesMap()
h.Renderer.VehiclesManagementBookingsList(w, r, vehicles_map, driversMap, bookings, cacheid)
}
func (h *ApplicationHandler) VehiclesFleetAdd(w http.ResponseWriter, r *http.Request) {

View File

@ -5,28 +5,31 @@ import (
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
)
const vehiclesmanagementMenu = "vehicles_management"
func (renderer *Renderer) VehiclesManagementOverview(w http.ResponseWriter, r *http.Request, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking) {
func (renderer *Renderer) VehiclesManagementOverview(w http.ResponseWriter, r *http.Request, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, driversMap map[string]mobilityaccountsstorage.Account, bookings []fleetsstorage.Booking) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.overview.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"vehicles": vehicles,
"bookings": bookings,
"vehicles_map": vehicles_map,
"drivers_map": driversMap,
}
renderer.Render("fleet overview", w, r, files, state)
}
func (renderer *Renderer) VehiclesManagementBookingsList(w http.ResponseWriter, r *http.Request, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking, cacheid string) {
func (renderer *Renderer) VehiclesManagementBookingsList(w http.ResponseWriter, r *http.Request, vehiclesMap map[string]fleetsstorage.Vehicle, driversMap map[string]mobilityaccountsstorage.Account, bookings []fleetsstorage.Booking, cacheid string) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.bookings_list.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"bookings": bookings,
"vehicles_map": vehicles_map,
"vehicles_map": vehiclesMap,
"drivers_map": driversMap,
"cacheid": cacheid,
}
@ -89,4 +92,4 @@ func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Reques
renderer.Render("vehicule unbooking", w, r, files, state)
}
}

View File

@ -42,6 +42,22 @@ func (s *ServicesHandler) GetBeneficiaries() (accounts []storage.Account, err er
return
}
func (s *ServicesHandler) GetBeneficiariesMap() (accounts map[string]storage.Account, err error) {
accounts = map[string]storage.Account{}
request := &mobilityaccounts.GetAccountsRequest{
Namespaces: []string{"parcoursmob_beneficiaries"},
}
resp, err := s.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
if err == nil {
for _, v := range resp.Accounts {
accounts[v.Id] = v.ToStorageType()
}
}
return
}
func (s *ServicesHandler) GetAccounts() (accounts []storage.Account, err error) {
accounts = []storage.Account{}
request := &mobilityaccounts.GetAccountsRequest{