Compare commits
20 Commits
f09d9d0a16
...
850633eac7
Author | SHA1 | Date |
---|---|---|
soukainna | 850633eac7 | |
soukainna | 7847b4c31f | |
soukainna | a63a4ad1c2 | |
soukainna | 232764e7d7 | |
soukainna | e4418f26e0 | |
soukainna | a05942b7ed | |
soukainna | 1b2902c632 | |
soukainna | c9b326c49a | |
soukainna | c3e67cb9dd | |
soukainna | 795066b6e5 | |
soukainna | bdcb386dff | |
soukainna | 64521c01c1 | |
soukainna | 3b9ac66965 | |
soukainna | 167e8cfe2e | |
soukainna | f023a7bbff | |
soukainna | d1818b6251 | |
soukainna | fa065f2a43 | |
soukainna | e559359ff0 | |
soukainna | 9965271788 | |
soukainna | 97ebcf480e |
|
@ -10,10 +10,14 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
||||||
|
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
||||||
|
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
||||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||||
"git.coopgo.io/coopgo-platform/fleets/storage"
|
fleetsstorage "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"
|
||||||
|
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||||
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"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
@ -64,8 +68,39 @@ func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(sorting.GroupsByName(groups))
|
sort.Sort(sorting.GroupsByName(groups))
|
||||||
|
////////////////////////////////////add event////////////////////////////////////////////
|
||||||
|
rresp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
||||||
|
Namespaces: []string{"parcoursmob_dispositifs"},
|
||||||
|
})
|
||||||
|
|
||||||
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings)
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses := []agendastorage.Event{}
|
||||||
|
|
||||||
|
groupids := []string{}
|
||||||
|
for _, e := range rresp.Events {
|
||||||
|
groupids = append(groupids, e.Owners...)
|
||||||
|
responses = append(responses, e.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sorting.EventsByStartdate(responses))
|
||||||
|
|
||||||
|
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: groupids,
|
||||||
|
})
|
||||||
|
groupps := map[string]any{}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
for _, g := range groupsresp.Groups {
|
||||||
|
groupps[g.Id] = g.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -333,29 +368,74 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func filteVehicle(r *http.Request, v *fleets.Vehicle) bool {
|
||||||
|
g := r.Context().Value(identification.GroupKey)
|
||||||
|
if g == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
group := g.(storage.Group)
|
||||||
|
|
||||||
|
for _, n := range v.Administrators {
|
||||||
|
if n == group.ID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (h ApplicationHandler) AdminStatVehicles(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) AdminStatVehicles(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
request := &fleets.GetBookingsRequest{}
|
bookings := []fleetsstorage.Booking{}
|
||||||
resp, err := h.services.GRPC.Fleets.GetBookings(context.TODO(), request)
|
administrators := []string{}
|
||||||
|
reequest := &fleets.GetVehiclesRequest{
|
||||||
|
Namespaces: []string{"parcoursmob"},
|
||||||
|
}
|
||||||
|
reesp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), reequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bookings := []storage.Booking{}
|
vehicles := []fleetsstorage.Vehicle{}
|
||||||
|
for _, vehiicle := range reesp.Vehicles {
|
||||||
|
|
||||||
|
v := vehiicle.ToStorageType()
|
||||||
|
adminfound := false
|
||||||
|
for _, a := range administrators {
|
||||||
|
if a == v.Administrators[0] {
|
||||||
|
adminfound = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !adminfound {
|
||||||
|
administrators = append(administrators, v.Administrators[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicles = append(vehicles, v)
|
||||||
|
|
||||||
for _, b := range resp.Bookings {
|
|
||||||
booking := b.ToStorageType()
|
|
||||||
bookings = append(bookings, booking)
|
|
||||||
}
|
}
|
||||||
|
groups := map[string]any{}
|
||||||
|
|
||||||
|
if len(administrators) > 0 {
|
||||||
|
admingroups, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: administrators,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, g := range admingroups.Groups {
|
||||||
|
groups[g.Id] = g.ToStorageType()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
h.Renderer.AdminStatVehicles(w, r, vehicles, bookings, groups)
|
||||||
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) {
|
||||||
|
@ -395,3 +475,49 @@ func (h *ApplicationHandler) groupmembers(groupid string) (groupmembers []mobili
|
||||||
|
|
||||||
return groupmembers, admins, err
|
return groupmembers, admins, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h ApplicationHandler) AdminStatBeneficaires(w http.ResponseWriter, r *http.Request) {
|
||||||
|
beneficiaries, err := h.services.GetBeneficiaries()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, beneficiaries, 1*time.Hour)
|
||||||
|
h.Renderer.AdminStatBeneficaires(w, r, beneficiaries, cacheid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h ApplicationHandler) AdminStatEvents(w http.ResponseWriter, r *http.Request) {
|
||||||
|
resp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
||||||
|
Namespaces: []string{"parcoursmob_dispositifs"},
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses := []agendastorage.Event{}
|
||||||
|
|
||||||
|
groupids := []string{}
|
||||||
|
for _, e := range resp.Events {
|
||||||
|
groupids = append(groupids, e.Owners...)
|
||||||
|
responses = append(responses, e.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sorting.EventsByStartdate(responses))
|
||||||
|
|
||||||
|
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: groupids,
|
||||||
|
})
|
||||||
|
groups := map[string]any{}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
for _, g := range groupsresp.Groups {
|
||||||
|
groups[g.Id] = g.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h.Renderer.AdminStatEvents(w, r, responses, groups)
|
||||||
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ func (h *ApplicationHandler) AgendaHome(w http.ResponseWriter, r *http.Request)
|
||||||
groups[g.Id] = g.ToStorageType()
|
groups[g.Id] = g.ToStorageType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.AgendaHome(w, r, responses, groups)
|
h.Renderer.AgendaHome(w, r, responses, groups)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Re
|
||||||
|
|
||||||
cacheid := uuid.NewString()
|
cacheid := uuid.NewString()
|
||||||
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
|
||||||
h.Renderer.BeneficiariesList(w, r, accounts, cacheid)
|
h.Renderer.BeneficiariesList(w, r, accounts, cacheid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators"
|
formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators"
|
||||||
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
|
"github.com/google/uuid"
|
||||||
"google.golang.org/protobuf/types/known/structpb"
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,8 +39,34 @@ func (h *ApplicationHandler) MemberDisplay(w http.ResponseWriter, r *http.Reques
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//////////////////////////////////add organisations/////////////////////////////////////////////////
|
||||||
|
|
||||||
h.Renderer.MemberDisplay(w, r, resp.Account.ToStorageType())
|
var allIds []string
|
||||||
|
for _, v := range resp.Account.ToStorageType().Data["groups"].([]any) {
|
||||||
|
s := fmt.Sprintf("%v", v)
|
||||||
|
if !(strings.Contains(s, "admin")) {
|
||||||
|
allIds = append(allIds, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reques := &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: allIds,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), reques)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var groupsName []string
|
||||||
|
|
||||||
|
for _, group := range res.Groups {
|
||||||
|
g := fmt.Sprintf("%v", group.ToStorageType().Data["name"])
|
||||||
|
groupsName = append(groupsName, g)
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.MemberDisplay(w, r, resp.Account.ToStorageType(), groupsName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) MemberUpdate(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) MemberUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -126,3 +155,59 @@ func parseUserForm(r *http.Request) (map[string]any, error) {
|
||||||
|
|
||||||
return dataMap, nil
|
return dataMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) MembersList(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
accounts, err := h.services.GetAccounts()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var groupsName []string
|
||||||
|
|
||||||
|
for _, v := range accounts {
|
||||||
|
adminid := v.ID
|
||||||
|
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
|
||||||
|
}
|
||||||
|
//////////////////////////////////add organisations/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
var allIds []string
|
||||||
|
for _, v := range resp.Account.ToStorageType().Data["groups"].([]any) {
|
||||||
|
s := fmt.Sprintf("%v", v)
|
||||||
|
if !(strings.Contains(s, "admin")) {
|
||||||
|
allIds = append(allIds, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
reques := &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: allIds,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), reques)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
g := ""
|
||||||
|
for _, group := range res.Groups {
|
||||||
|
g += fmt.Sprintf("%v", group.ToStorageType().Data["name"]) + " "
|
||||||
|
}
|
||||||
|
groupsName = append(groupsName, g)
|
||||||
|
|
||||||
|
}
|
||||||
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
|
||||||
|
h.Renderer.MembersList(w, r, accounts, cacheid, groupsName)
|
||||||
|
}
|
||||||
|
|
|
@ -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.VehiclesByLicencePlate(vehicles))
|
||||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
|
||||||
h.Renderer.VehiclesManagementOverview(w, r, vehicles, vehicles_map, 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)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
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())
|
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)
|
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)
|
||||||
|
// }
|
||||||
|
|
4
main.go
4
main.go
|
@ -87,6 +87,7 @@ func main() {
|
||||||
application.HandleFunc("/members/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
application.HandleFunc("/members/{beneficiaryid}/picture", applicationHandler.BeneficiaryPicture)
|
||||||
application.HandleFunc("/members/{adminid}", applicationHandler.MemberDisplay)
|
application.HandleFunc("/members/{adminid}", applicationHandler.MemberDisplay)
|
||||||
application.HandleFunc("/members/{adminid}/update", applicationHandler.MemberUpdate)
|
application.HandleFunc("/members/{adminid}/update", applicationHandler.MemberUpdate)
|
||||||
|
application.HandleFunc("/members/", applicationHandler.MembersList)
|
||||||
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)
|
||||||
|
@ -141,7 +142,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)
|
||||||
|
//add statistiques
|
||||||
appAdmin.HandleFunc("/stats/vehicles", applicationHandler.AdminStatVehicles)
|
appAdmin.HandleFunc("/stats/vehicles", applicationHandler.AdminStatVehicles)
|
||||||
|
appAdmin.HandleFunc("/stats/beneficaires", applicationHandler.AdminStatBeneficaires)
|
||||||
|
appAdmin.HandleFunc("/stats/events", applicationHandler.AdminStatEvents)
|
||||||
|
|
||||||
/////////////////////////////////////Delete subscriber///////////////////////////////////////////////
|
/////////////////////////////////////Delete subscriber///////////////////////////////////////////////
|
||||||
application.HandleFunc("/agenda/{eventid}/{subscribeid}/delete", applicationHandler.AgendaDeleteSubscribeEvent)
|
application.HandleFunc("/agenda/{eventid}/{subscribeid}/delete", applicationHandler.AgendaDeleteSubscribeEvent)
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package renderer
|
package renderer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
||||||
|
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const administrationMenu = "administration"
|
const administrationMenu = "administration"
|
||||||
|
|
||||||
func (renderer *Renderer) Administration(w http.ResponseWriter, r *http.Request, accounts any, beneficiaries any, groups any, bookings any) {
|
func (renderer *Renderer) Administration(w http.ResponseWriter, r *http.Request, accounts any, beneficiaries any, groups any, bookings any, events []agendastorage.Event) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.administration.home.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.administration.home.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, administrationMenu)
|
state := NewState(r, renderer.ThemeConfig, administrationMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
|
@ -16,6 +20,7 @@ func (renderer *Renderer) Administration(w http.ResponseWriter, r *http.Request,
|
||||||
"beneficiaries": beneficiaries,
|
"beneficiaries": beneficiaries,
|
||||||
"bookings": bookings,
|
"bookings": bookings,
|
||||||
"groups": groups,
|
"groups": groups,
|
||||||
|
"events": events,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("administration", w, r, files, state)
|
renderer.Render("administration", w, r, files, state)
|
||||||
|
@ -39,3 +44,58 @@ func (renderer *Renderer) AdministrationGroupDisplay(w http.ResponseWriter, r *h
|
||||||
|
|
||||||
renderer.Render("administration", w, r, files, state)
|
renderer.Render("administration", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BeneficiariesState struct {
|
||||||
|
Count int `json:"count"`
|
||||||
|
CacheId string `json:"cache_id"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiariesState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiariesState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < len(s.Beneficiaries) {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) AdminStatBeneficaires(w http.ResponseWriter, r *http.Request, Beneficiaries []mobilityaccountsstorage.Account, cacheid string) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.administration.beneficaires_list.files")
|
||||||
|
|
||||||
|
state := NewState(r, renderer.ThemeConfig, administrationMenu)
|
||||||
|
state.ViewState = BeneficiariesState{
|
||||||
|
Count: len(Beneficiaries),
|
||||||
|
CacheId: cacheid,
|
||||||
|
Beneficiaries: Beneficiaries,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("beneficiaries_State", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) AdminStatEvents(w http.ResponseWriter, r *http.Request, events []agendastorage.Event, groups map[string]any) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.administration.events_list.files")
|
||||||
|
|
||||||
|
state := NewState(r, renderer.ThemeConfig, administrationMenu)
|
||||||
|
state.ViewState = map[string]any{
|
||||||
|
"events": events,
|
||||||
|
"groups": groups,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("beneficiaries_State", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) AdminStatVehicles(w http.ResponseWriter, r *http.Request, vehicles []fleetsstorage.Vehicle, bookings []fleetsstorage.Booking, admingroups map[string]any) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.administration.vehicles_list.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, administrationMenu)
|
||||||
|
state.ViewState = map[string]any{
|
||||||
|
"vehicles": vehicles,
|
||||||
|
"bookings": bookings,
|
||||||
|
"admingroups": admingroups,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("vehicles_state", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
package renderer
|
package renderer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const membersMenu = "members"
|
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")
|
files := renderer.ThemeConfig.GetStringSlice("views.members.display.files")
|
||||||
|
|
||||||
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
state := NewState(r, renderer.ThemeConfig, membersMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"admins": admins,
|
"admins": admins,
|
||||||
|
"groups": groups,
|
||||||
}
|
}
|
||||||
renderer.Render("members_list", w, r, files, state)
|
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
|
state.ViewState = user
|
||||||
renderer.Render("members_update", w, r, files, state)
|
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,15 @@ func (renderer *Renderer) VehicleBookingsList(w http.ResponseWriter, r *http.Req
|
||||||
|
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
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