diff --git a/go.mod b/go.mod index ddbcdb4..e37eb9e 100755 --- a/go.mod +++ b/go.mod @@ -2,13 +2,13 @@ module git.coopgo.io/coopgo-apps/parcoursmob 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/ -// replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/ +replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/ // replace git.coopgo.io/coopgo-platform/emailing => ../../coopgo-platform/emailing/ diff --git a/handlers/application/dashboard.go b/handlers/application/dashboard.go index d272a84..e7b651d 100755 --- a/handlers/application/dashboard.go +++ b/handlers/application/dashboard.go @@ -13,6 +13,8 @@ import ( "git.coopgo.io/coopgo-platform/groups-management/storage" mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi" "google.golang.org/protobuf/types/known/timestamppb" + fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi" + fleetstorage "git.coopgo.io/coopgo-platform/fleets/storage" ) func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) { @@ -76,6 +78,18 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) { sort.Sort(sorting.EventsByStartdate(events)) - h.Renderer.Dashboard(w, r, accounts, count, count_members, events) + bookings := []fleetstorage.Booking{} + + bookingsresp, err := h.services.GRPC.Fleets.GetBookings(context.TODO(), &fleets.GetBookingsRequest{ + Namespaces: []string{"parcoursmob_dispositifs"}, + }) + + if err == nil { + for _, b := range bookingsresp.Bookings { + bookings = append(bookings, b.ToStorageType()) + } + } + + h.Renderer.Dashboard(w, r, accounts, count, count_members, events, bookings) } diff --git a/handlers/application/vehicles-management.go b/handlers/application/vehicles-management.go index f56c833..78bd5f9 100755 --- a/handlers/application/vehicles-management.go +++ b/handlers/application/vehicles-management.go @@ -140,6 +140,9 @@ func (h *ApplicationHandler) VehiclesFleetAdd(w http.ResponseWriter, r *http.Req fmt.Println(v) dataMap["automatic"] = (v == "on") } + if v := r.FormValue("kilometers"); v != "" { + dataMap["kilometers"] = v + } data, err := structpb.NewValue(dataMap) if err != nil { @@ -614,6 +617,9 @@ func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http. if v := r.FormValue("licence_plate"); v != "" { dataMap["licence_plate"] = v } + if v := r.FormValue("kilometers"); v != "" { + dataMap["kilometers"] = v + } if v := r.FormValue("automatic"); v != "" { fmt.Println(v) dataMap["automatic"] = (v == "on") diff --git a/renderer/dashboard.go b/renderer/dashboard.go index cd88997..0caf84b 100755 --- a/renderer/dashboard.go +++ b/renderer/dashboard.go @@ -4,11 +4,12 @@ import ( "net/http" agendastorage "git.coopgo.io/coopgo-platform/agenda/storage" + fleetstorage "git.coopgo.io/coopgo-platform/fleets/storage" ) const dashboardMenu = "dashboard" -func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, accounts []any, nbaccounts int, count_members int, events []agendastorage.Event) { +func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, accounts []any, nbaccounts int, count_members int, events []agendastorage.Event, fleets []fleetstorage.Booking) { files := renderer.ThemeConfig.GetStringSlice("views.dashboard.files") state := NewState(r, renderer.ThemeConfig, dashboardMenu) state.ViewState = map[string]any{ @@ -18,6 +19,7 @@ func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, acco }, "count_members": count_members, "events": events, + "fleets": fleets, } renderer.Render("dashboard", w, r, files, state)