add members data
This commit is contained in:
parent
d1818b6251
commit
f023a7bbff
|
@ -52,10 +52,16 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
vehiicles := []fleetsstorage.Vehicle{}
|
||||
for i, vehiicle := range resp.Vehicles {
|
||||
if len(resp.Vehicles[i].Bookings) == 0 {
|
||||
v := vehiicle.ToStorageType()
|
||||
vehiicles = append(vehiicles, v)
|
||||
}
|
||||
}
|
||||
fmt.Println(vehiicles)
|
||||
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||
|
||||
h.Renderer.VehiclesManagementOverview(w, r, vehicles, vehicles_map, bookings)
|
||||
}
|
||||
|
||||
|
@ -184,7 +190,10 @@ func (h *ApplicationHandler) VehiclesFleetDisplay(w http.ResponseWriter, r *http
|
|||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
|
||||
fmt.Println("lol")
|
||||
}
|
||||
fmt.Println(resp.Vehicle.ToStorageType().Bookings)
|
||||
h.Renderer.VehiclesFleetDisplay(w, r, resp.Vehicle.ToStorageType())
|
||||
}
|
||||
|
||||
|
@ -457,3 +466,28 @@ func (h ApplicationHandler) VehiclesFleetMakeUnavailable(w http.ResponseWriter,
|
|||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/vehicles-management/fleet/%s", vehicleid), http.StatusFound)
|
||||
}
|
||||
|
||||
// func (h *ApplicationHandler) UnbookingVehicles(w http.ResponseWriter, r *http.Request) {
|
||||
// request := &fleets.GetVehiclesRequest{
|
||||
// Namespaces: []string{"parcoursmob"},
|
||||
// }
|
||||
// resp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// w.WriteHeader(http.StatusInternalServerError)
|
||||
// }
|
||||
// vehicles := []fleetsstorage.Vehicle{}
|
||||
// fmt.Println(resp.Vehicles[0].Bookings)
|
||||
// for i, vehicle := range resp.Vehicles {
|
||||
// if len(resp.Vehicles[i].Bookings) == 0 {
|
||||
// v := vehicle.ToStorageType()
|
||||
// vehicles = append(vehicles, v)
|
||||
// }
|
||||
// }
|
||||
// // if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
|
||||
// // h.Renderer.UnbookingVehicles(w, r, resp.Vehicle.ToStorageType())
|
||||
// // }
|
||||
// // fmt.Println(resp.Vehicle.ToStorageType().Bookings)
|
||||
// fmt.Println(vehicles)
|
||||
// h.Renderer.UnbookingVehicles(w, r, vehicles)
|
||||
// }
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package renderer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
)
|
||||
|
||||
const membersMenu = "members"
|
||||
|
||||
func (renderer *Renderer) MemberDisplay(w http.ResponseWriter, r *http.Request, admins any) {
|
||||
func (renderer *Renderer) MemberDisplay(w http.ResponseWriter, r *http.Request, admins any, groups []string) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.members.display.files")
|
||||
|
||||
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
||||
state.ViewState = map[string]any{
|
||||
"admins": admins,
|
||||
"groups": groups,
|
||||
}
|
||||
renderer.Render("members_list", w, r, files, state)
|
||||
}
|
||||
|
@ -22,3 +27,41 @@ func (renderer *Renderer) MemberUpdate(w http.ResponseWriter, r *http.Request, u
|
|||
state.ViewState = user
|
||||
renderer.Render("members_update", w, r, files, state)
|
||||
}
|
||||
|
||||
type MembersListState struct {
|
||||
Count int `json:"count"`
|
||||
CacheId string `json:"cache_id"`
|
||||
Members []mobilityaccountsstorage.Account `json:"members"`
|
||||
Groups []string `json:"groups"`
|
||||
}
|
||||
|
||||
func (s MembersListState) JSON() template.JS {
|
||||
result, _ := json.Marshal(s)
|
||||
return template.JS(result)
|
||||
}
|
||||
|
||||
func (s MembersListState) JSONWithLimits(a int, b int) template.JS {
|
||||
if b < len(s.Members) {
|
||||
s.Members = s.Members[a:b]
|
||||
}
|
||||
return s.JSON()
|
||||
}
|
||||
|
||||
func (renderer *Renderer) MembersList(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, cacheid string, groups []string) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.members.list.files")
|
||||
|
||||
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
||||
|
||||
state.ViewState = map[string]any{
|
||||
|
||||
"list": MembersListState{
|
||||
Count: len(accounts),
|
||||
CacheId: cacheid,
|
||||
Members: accounts,
|
||||
Groups: groups,
|
||||
},
|
||||
"groups": groups,
|
||||
}
|
||||
|
||||
renderer.Render("members_list", w, r, files, state)
|
||||
}
|
||||
|
|
|
@ -78,3 +78,13 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter,
|
|||
|
||||
renderer.Render("vehicles search", w, r, files, state)
|
||||
}
|
||||
|
||||
// func (renderer *Renderer) UnbookingVehicles(w http.ResponseWriter, r *http.Request, vehicles []fleetsstorage.Vehicle) {
|
||||
// files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.unbooking_display.files")
|
||||
// state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||
// state.ViewState = map[string]any{
|
||||
// "vehicles": vehicles,
|
||||
// }
|
||||
|
||||
// renderer.Render("fleet display Unbooking vehicle", w, r, files, state)
|
||||
// }
|
||||
|
|
|
@ -78,3 +78,15 @@ func (renderer *Renderer) VehicleBookingsList(w http.ResponseWriter, r *http.Req
|
|||
|
||||
renderer.Render("vehicles search", w, r, files, state)
|
||||
}
|
||||
|
||||
// func (renderer *Renderer) VehicleUnbookingsList(w http.ResponseWriter, r *http.Request, bookings []storage.Booking, vehiclesMap any, groupsMap any) {
|
||||
// files := renderer.ThemeConfig.GetStringSlice("views.vehicles.bookings_list.files")
|
||||
// state := NewState(r, renderer.ThemeConfig, vehiclesMenu)
|
||||
// state.ViewState = map[string]any{
|
||||
// "bookings": bookings,
|
||||
// "vehicles_map": vehiclesMap,
|
||||
// "groups_map": groupsMap,
|
||||
// }
|
||||
|
||||
// renderer.Render("vehicles search", w, r, files, state)
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue