Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e00a839a3 | |||
| c354bece5f | |||
| 6299a6c7be | |||
| 718c39de00 | |||
| 9f66851529 | |||
| aa13d60ca6 | |||
| d169566cd1 | |||
|
|
b54961b619 | ||
|
|
c34d08ff70 | ||
|
|
46a72e1aef |
4
Dockerfile
Normal file → Executable file
4
Dockerfile
Normal file → Executable file
@@ -19,8 +19,8 @@ COPY . .
|
|||||||
|
|
||||||
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
|
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
|
||||||
|
|
||||||
# RUN rm -r themes/*
|
RUN rm -r themes/*
|
||||||
RUN git clone -b dev --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
|
RUN git clone --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
|
||||||
RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06
|
RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|||||||
20
go.mod
Normal file → Executable file
20
go.mod
Normal file → Executable file
@@ -30,11 +30,11 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230222135722-e55cf41e203b
|
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
|
||||||
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
||||||
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230519092636-41bf03682ca9
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
|
||||||
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230117140716-312200e21063
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
|
||||||
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20221107003506-e2ff98094b81
|
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230329105908-a76c0412a386
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
github.com/minio/minio-go/v7 v7.0.43
|
github.com/minio/minio-go/v7 v7.0.43
|
||||||
github.com/ory/viper v1.7.5
|
github.com/ory/viper v1.7.5
|
||||||
@@ -42,7 +42,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
|
|
||||||
github.com/cespare/xxhash v1.1.0 // indirect
|
github.com/cespare/xxhash v1.1.0 // indirect
|
||||||
github.com/coreos/go-semver v0.3.0 // indirect
|
github.com/coreos/go-semver v0.3.0 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||||
@@ -55,16 +54,12 @@ require (
|
|||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/golang/snappy v0.0.1 // indirect
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
github.com/gorilla/csrf v1.7.1 // indirect
|
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.15.9 // indirect
|
github.com/klauspost/compress v1.15.9 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.1 // indirect
|
||||||
github.com/magiconair/properties v1.8.6 // indirect
|
github.com/magiconair/properties v1.8.6 // indirect
|
||||||
github.com/mattn/goveralls v0.0.6 // indirect
|
|
||||||
github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
|
github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
|
||||||
github.com/minio/md5-simd v1.1.2 // indirect
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||||
@@ -73,11 +68,6 @@ require (
|
|||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||||
github.com/ory/fosite v0.42.2 // indirect
|
|
||||||
github.com/ory/go-acc v0.2.6 // indirect
|
|
||||||
github.com/ory/go-convenience v0.1.0 // indirect
|
|
||||||
github.com/ory/x v0.0.214 // indirect
|
|
||||||
github.com/pborman/uuid v1.2.0 // indirect
|
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
@@ -89,7 +79,6 @@ require (
|
|||||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||||
github.com/spf13/afero v1.8.2 // indirect
|
github.com/spf13/afero v1.8.2 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
github.com/spf13/cobra v1.0.0 // indirect
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/subosito/gotenv v1.4.1 // indirect
|
github.com/subosito/gotenv v1.4.1 // indirect
|
||||||
@@ -112,7 +101,6 @@ require (
|
|||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
golang.org/x/sys v0.7.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
|
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
|
|||||||
0
handlers/api/api.go
Normal file → Executable file
0
handlers/api/api.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
@@ -12,40 +12,58 @@ import (
|
|||||||
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
cacheid := vars["cacheid"]
|
cacheid := vars["cacheid"]
|
||||||
|
// Use a channel to synchronize the goroutines
|
||||||
d, err := h.cache.Get(cacheid)
|
ch := make(chan []byte)
|
||||||
if err != nil {
|
// Fetch data from cache asynchronously
|
||||||
fmt.Println(err)
|
go func() {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
d, err := h.cache.Get(cacheid)
|
||||||
return
|
if err != nil {
|
||||||
}
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
result := d
|
ch <- nil
|
||||||
|
return
|
||||||
if data, ok := d.([]any); ok {
|
|
||||||
if limitsmin, ok := r.URL.Query()["limits.min"]; ok {
|
|
||||||
min, _ := strconv.Atoi(limitsmin[0])
|
|
||||||
if limitsmax, ok := r.URL.Query()["limits.max"]; ok {
|
|
||||||
max, _ := strconv.Atoi(limitsmax[0])
|
|
||||||
if max > len(data) {
|
|
||||||
result = data[min:]
|
|
||||||
} else {
|
|
||||||
result = data[min:max]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = data[min:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var data []any
|
||||||
|
if val, ok := d.([]any); ok {
|
||||||
|
data = val
|
||||||
|
} else {
|
||||||
|
data = []any{d}
|
||||||
|
}
|
||||||
|
j := toJSON(data, w, r)
|
||||||
|
ch <- j // Signal that the data has been fetched successfully
|
||||||
|
close(ch)
|
||||||
|
}()
|
||||||
|
// wait for the JSON marshaling goroutine to finish
|
||||||
|
j := <-ch
|
||||||
|
if j == nil {
|
||||||
|
return // Stop processing if an error occurred
|
||||||
}
|
}
|
||||||
|
// Send the JSON response to the client
|
||||||
j, err := json.Marshal(result)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
|
|
||||||
|
<-ch
|
||||||
|
}
|
||||||
|
func toJSON(data []any, w http.ResponseWriter, r *http.Request) []byte {
|
||||||
|
result := data
|
||||||
|
if limitsmin, ok := r.URL.Query()["limits.min"]; ok {
|
||||||
|
min, _ := strconv.Atoi(limitsmin[0])
|
||||||
|
if limitsmax, ok := r.URL.Query()["limits.max"]; ok {
|
||||||
|
max, _ := strconv.Atoi(limitsmax[0])
|
||||||
|
if max > len(data) {
|
||||||
|
result = data[min:]
|
||||||
|
} else {
|
||||||
|
result = data[min:max]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = data[min:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j, err := json.Marshal(result)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return j
|
||||||
}
|
}
|
||||||
|
|||||||
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
452
handlers/application/administration.go
Normal file → Executable file
452
handlers/application/administration.go
Normal file → Executable file
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
||||||
@@ -27,79 +28,83 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var (
|
||||||
accounts, err := h.services.GetAccounts()
|
wg sync.WaitGroup
|
||||||
if err != nil {
|
accounts, beneficiaries []mobilityaccountsstorage.Account
|
||||||
fmt.Println(err)
|
bookings []fleetsstorage.Booking
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
accountsErr, beneficiariesErr, bookingsErr, groupsResponseErr, eventsResponseErr, groupsBatchErr error
|
||||||
return
|
groups = []groupstorage.Group{}
|
||||||
}
|
responses = []agendastorage.Event{}
|
||||||
|
groupsResponse *groupsmanagement.GetGroupsResponse
|
||||||
beneficiaries, err := h.services.GetBeneficiaries()
|
eventsResponse *agenda.GetEventsResponse
|
||||||
if err != nil {
|
groupids = []string{}
|
||||||
fmt.Println(err)
|
groupsBatchResponse *groupsmanagement.GetGroupsBatchResponse
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
)
|
||||||
return
|
// Retrieve accounts in a goroutine
|
||||||
}
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
bookings, err := h.services.GetBookings()
|
defer wg.Done()
|
||||||
if err != nil {
|
accounts, accountsErr = h.services.GetAccounts()
|
||||||
fmt.Println(err)
|
}()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
// Retrieve beneficiaries in a goroutine
|
||||||
return
|
wg.Add(1)
|
||||||
}
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
request := &groupsmanagement.GetGroupsRequest{
|
beneficiaries, beneficiariesErr = h.services.GetBeneficiaries()
|
||||||
Namespaces: []string{"parcoursmob_organizations"},
|
}()
|
||||||
}
|
// Retrieve bookings in a goroutine
|
||||||
|
wg.Add(1)
|
||||||
resp, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
go func() {
|
||||||
if err != nil {
|
defer wg.Done()
|
||||||
fmt.Println(err)
|
bookings, bookingsErr = h.services.GetBookings()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
}()
|
||||||
return
|
// Retrieve groupsRequest in a goroutine
|
||||||
}
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
var groups = []groupstorage.Group{}
|
defer wg.Done()
|
||||||
|
request := &groupsmanagement.GetGroupsRequest{
|
||||||
for _, group := range resp.Groups {
|
Namespaces: []string{"parcoursmob_organizations"},
|
||||||
g := group.ToStorageType()
|
|
||||||
groups = append(groups, g)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(sorting.GroupsByName(groups))
|
|
||||||
////////////////////////////////////add event////////////////////////////////////////////
|
|
||||||
rresp, 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 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()
|
|
||||||
}
|
}
|
||||||
|
groupsResponse, groupsResponseErr = h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
||||||
|
for _, group := range groupsResponse.Groups {
|
||||||
|
g := group.ToStorageType()
|
||||||
|
groups = append(groups, g)
|
||||||
|
}
|
||||||
|
sort.Sort(sorting.GroupsByName(groups))
|
||||||
|
}()
|
||||||
|
// Retrieve Events in a goroutine
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
eventsResponse, eventsResponseErr = h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
||||||
|
Namespaces: []string{"parcoursmob_dispositifs"},
|
||||||
|
})
|
||||||
|
for _, e := range eventsResponse.Events {
|
||||||
|
groupids = append(groupids, e.Owners...)
|
||||||
|
responses = append(responses, e.ToStorageType())
|
||||||
|
}
|
||||||
|
sort.Sort(sorting.EventsByStartdate(responses))
|
||||||
|
}()
|
||||||
|
wg.Add(1)
|
||||||
|
// Retrieve groupsBatch in a goroutine
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
groupsBatchResponse, groupsBatchErr = h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: groupids,
|
||||||
|
})
|
||||||
|
groupps := map[string]any{}
|
||||||
|
if groupsBatchErr == nil {
|
||||||
|
for _, g := range groupsBatchResponse.Groups {
|
||||||
|
groupps[g.Id] = g.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
if accountsErr != nil || beneficiariesErr != nil || bookingsErr != nil || groupsResponseErr != nil || eventsResponseErr != nil {
|
||||||
|
fmt.Println(accountsErr, beneficiariesErr, bookingsErr, groupsResponseErr, eventsResponseErr, groupsBatchErr)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,22 +160,23 @@ func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r
|
|||||||
Namespace: "parcoursmob_roles",
|
Namespace: "parcoursmob_roles",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
go func() {
|
||||||
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_organization)
|
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_organization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
// Create the admin role for the organization
|
// Create the admin role for the organization
|
||||||
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
go func() {
|
||||||
if err != nil {
|
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
fmt.Println(err)
|
||||||
return
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -205,165 +211,167 @@ func (h *ApplicationHandler) AdministrationGroupDisplay(w http.ResponseWriter, r
|
|||||||
func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
groupid := vars["groupid"]
|
groupid := vars["groupid"]
|
||||||
|
var (
|
||||||
|
groupresp *groupsmanagement.GetGroupResponse
|
||||||
|
accountresp *accounts.GetAccountUsernameResponse
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
groupresp, err = h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
|
Id: groupid,
|
||||||
|
Namespace: "parcoursmob_organizations",
|
||||||
|
})
|
||||||
|
|
||||||
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
if err != nil {
|
||||||
Id: groupid,
|
fmt.Println(err)
|
||||||
Namespace: "parcoursmob_organizations",
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
}()
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
go func() {
|
||||||
Username: r.FormValue("username"),
|
accountresp, err = h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
||||||
Namespace: "parcoursmob",
|
Username: r.FormValue("username"),
|
||||||
})
|
Namespace: "parcoursmob",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
// Account already exists : adding the existing account to admin list
|
||||||
|
account := accountresp.Account.ToStorageType()
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid)
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid+":admin")
|
||||||
|
|
||||||
if err == nil {
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
// Account already exists : adding the existing account to admin list
|
|
||||||
account := accountresp.Account.ToStorageType()
|
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid)
|
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid+":admin")
|
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
||||||
|
context.TODO(),
|
||||||
|
&accounts.UpdateDataRequest{
|
||||||
|
Account: as,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
|
||||||
context.TODO(),
|
|
||||||
&accounts.UpdateDataRequest{
|
|
||||||
Account: as,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": groupresp.Group.ToStorageType().Data["name"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
||||||
|
data := map[string]any{
|
||||||
|
"group": groupresp.Group.ToStorageType().Data["name"],
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// Onboard now administrator
|
||||||
|
onboarding := map[string]any{
|
||||||
|
"username": r.FormValue("username"),
|
||||||
|
"group": groupid,
|
||||||
|
"admin": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
b := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key := base64.RawURLEncoding.EncodeToString(b)
|
||||||
|
|
||||||
|
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
||||||
|
|
||||||
|
data := map[string]any{
|
||||||
|
"group": groupresp.Group.ToStorageType().Data["name"],
|
||||||
|
"key": key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
return
|
return
|
||||||
} else {
|
}()
|
||||||
// Onboard now administrator
|
|
||||||
onboarding := map[string]any{
|
|
||||||
"username": r.FormValue("username"),
|
|
||||||
"group": groupid,
|
|
||||||
"admin": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
b := make([]byte, 16)
|
|
||||||
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
key := base64.RawURLEncoding.EncodeToString(b)
|
|
||||||
|
|
||||||
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": groupresp.Group.ToStorageType().Data["name"],
|
|
||||||
"key": key,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
groupid := vars["groupid"]
|
groupid := vars["groupid"]
|
||||||
|
var (
|
||||||
|
group storage.Group
|
||||||
|
)
|
||||||
|
groupCh := make(chan storage.Group)
|
||||||
|
go func() {
|
||||||
|
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
|
Id: groupid,
|
||||||
|
Namespace: "parcoursmob_organizations",
|
||||||
|
})
|
||||||
|
|
||||||
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
if err != nil {
|
||||||
Id: groupid,
|
fmt.Println(err)
|
||||||
Namespace: "parcoursmob_organizations",
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
group := groupresp.Group.ToStorageType()
|
||||||
fmt.Println(err)
|
groupCh <- group
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
}()
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
group := groupresp.Group.ToStorageType()
|
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
go func() {
|
||||||
|
group = <-groupCh
|
||||||
|
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
||||||
|
Username: r.FormValue("username"),
|
||||||
|
Namespace: "parcoursmob",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
account := accountresp.Account.ToStorageType()
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), group.ID)
|
||||||
|
|
||||||
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
Username: r.FormValue("username"),
|
|
||||||
Namespace: "parcoursmob",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err == nil {
|
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
||||||
account := accountresp.Account.ToStorageType()
|
context.TODO(),
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), group.ID)
|
&accounts.UpdateDataRequest{
|
||||||
|
Account: as,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
data := map[string]any{
|
||||||
|
"group": group.Data["name"],
|
||||||
|
}
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
|
||||||
|
}
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
http.Redirect(w, r, "/app/group/settings", http.StatusFound)
|
||||||
context.TODO(),
|
|
||||||
&accounts.UpdateDataRequest{
|
|
||||||
Account: as,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": group.Data["name"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/app/group/settings", http.StatusFound)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
// Onboard now administrator
|
|
||||||
onboarding := map[string]any{
|
|
||||||
"username": r.FormValue("username"),
|
|
||||||
"group": group.ID,
|
|
||||||
"admin": false,
|
|
||||||
}
|
|
||||||
|
|
||||||
b := make([]byte, 16)
|
|
||||||
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
// Onboard now administrator
|
||||||
|
onboarding := map[string]any{
|
||||||
|
"username": r.FormValue("username"),
|
||||||
|
"group": group.ID,
|
||||||
|
"admin": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
b := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key := base64.RawURLEncoding.EncodeToString(b)
|
||||||
|
|
||||||
|
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
||||||
|
data := map[string]any{
|
||||||
|
"group": group.Data["name"],
|
||||||
|
"key": key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
key := base64.RawURLEncoding.EncodeToString(b)
|
}()
|
||||||
|
|
||||||
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": group.Data["name"],
|
|
||||||
"key": key,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/app/administration/groups/"+group.ID, http.StatusFound)
|
http.Redirect(w, r, "/app/administration/groups/"+group.ID, http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
0
handlers/application/agenda.go
Normal file → Executable file
0
handlers/application/agenda.go
Normal file → Executable file
0
handlers/application/application.go
Normal file → Executable file
0
handlers/application/application.go
Normal file → Executable file
0
handlers/application/beneficiaries.go
Normal file → Executable file
0
handlers/application/beneficiaries.go
Normal file → Executable file
0
handlers/application/dashboard.go
Normal file → Executable file
0
handlers/application/dashboard.go
Normal file → Executable file
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
157
handlers/application/journeys.go
Normal file → Executable file
157
handlers/application/journeys.go
Normal file → Executable file
@@ -27,7 +27,14 @@ var Arrive any
|
|||||||
|
|
||||||
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
var (
|
||||||
|
journeys_results *navitia.JourneyResults
|
||||||
|
carpool_results any
|
||||||
|
vehicle_results []any
|
||||||
|
)
|
||||||
|
vehiclech := make(chan []any, 1)
|
||||||
|
navitiaCh := make(chan *navitia.JourneyResults, 1)
|
||||||
|
carpoolCh := make(chan any, 1)
|
||||||
locTime, errTime := time.LoadLocation("Europe/Paris")
|
locTime, errTime := time.LoadLocation("Europe/Paris")
|
||||||
if errTime != nil {
|
if errTime != nil {
|
||||||
fmt.Println("Loading timezone location Europe/Paris error : ")
|
fmt.Println("Loading timezone location Europe/Paris error : ")
|
||||||
@@ -70,91 +77,101 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
|
|||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
journeysRequest := func() {
|
||||||
|
//TODO make it a library
|
||||||
|
session, _ := navitia.NewCustom(
|
||||||
|
h.config.GetString("services.navitia.api_key"),
|
||||||
|
"https://api.navitia.io/v1",
|
||||||
|
&http.Client{})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
navitiaCh <- nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := navitia.JourneyRequest{
|
||||||
|
From: types.ID(fmt.Sprintf("%f", departuregeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", departuregeo.Geometry.Point[1])),
|
||||||
|
To: types.ID(fmt.Sprintf("%f", destinationgeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", destinationgeo.Geometry.Point[1])),
|
||||||
|
Date: departuredatetime.Add(-2 * time.Hour),
|
||||||
|
DateIsArrival: false, //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
journeys, err = session.Journeys(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
// w.WriteHeader(http.StatusBadRequest)
|
||||||
|
// return
|
||||||
|
}
|
||||||
|
navitiaCh <- journeys
|
||||||
|
|
||||||
//TODO make it a library
|
|
||||||
session, _ := navitia.NewCustom(
|
|
||||||
h.config.GetString("services.navitia.api_key"),
|
|
||||||
"https://api.navitia.io/v1",
|
|
||||||
&http.Client{})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
request := navitia.JourneyRequest{
|
|
||||||
From: types.ID(fmt.Sprintf("%f", departuregeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", departuregeo.Geometry.Point[1])),
|
|
||||||
To: types.ID(fmt.Sprintf("%f", destinationgeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", destinationgeo.Geometry.Point[1])),
|
|
||||||
Date: departuredatetime.Add(-2 * time.Hour),
|
|
||||||
DateIsArrival: false, //TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
journeys, err = session.Journeys(context.Background(), request)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
// w.WriteHeader(http.StatusBadRequest)
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
|
|
||||||
//CARPOOL
|
//CARPOOL
|
||||||
// carpoolrequest := fmt.Sprintf(
|
carpoolRequest := func() {
|
||||||
// "https://api.rdex.ridygo.fr/journeys.json?p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
|
||||||
// departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
|
||||||
// destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
|
||||||
// departuredatetime.Format("2006-01-02"), departuredatetime.Add(24*time.Hour).Format("2006-01-02"))
|
|
||||||
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
|
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", carpoolrequest, nil)
|
req, err := http.NewRequest("GET", carpoolrequest, nil)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req.URL.RawQuery = fmt.Sprintf(
|
|
||||||
"p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
|
||||||
departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
|
||||||
destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
|
||||||
departuredatetime.Format("2006-01-02"), departuredatetime.Format("2006-01-02"))
|
|
||||||
|
|
||||||
req.Header.Set("X-API-KEY", "123456")
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil && resp.StatusCode == http.StatusOK {
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(&carpoolresults)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if carpoolresults == nil {
|
req.URL.RawQuery = fmt.Sprintf(
|
||||||
|
"p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
||||||
|
departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
||||||
|
destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
||||||
|
departuredatetime.Format("2006-01-02"), departuredatetime.Format("2006-01-02"))
|
||||||
|
|
||||||
|
req.Header.Set("X-API-KEY", "123456")
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&carpoolresults)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if carpoolresults == nil {
|
||||||
|
carpoolresults = []any{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
carpoolresults = []any{}
|
carpoolresults = []any{}
|
||||||
}
|
}
|
||||||
} else {
|
carpoolCh <- carpoolresults
|
||||||
carpoolresults = []any{}
|
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Vehicles
|
// Vehicles
|
||||||
|
vehicleRequest := func() {
|
||||||
vehiclerequest := &fleets.GetVehiclesRequest{
|
vehiclerequest := &fleets.GetVehiclesRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
}
|
|
||||||
vehicleresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), vehiclerequest)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, vehicle := range vehicleresp.Vehicles {
|
|
||||||
v := vehicle.ToStorageType()
|
|
||||||
if v.Free(departuredatetime.Add(-24*time.Hour), departuredatetime.Add(168*time.Hour)) {
|
|
||||||
vehicles = append(vehicles, v)
|
|
||||||
}
|
}
|
||||||
|
vehicleresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), vehiclerequest)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
for _, vehicle := range vehicleresp.Vehicles {
|
||||||
|
v := vehicle.ToStorageType()
|
||||||
|
if v.Free(departuredatetime.Add(-24*time.Hour), departuredatetime.Add(168*time.Hour)) {
|
||||||
|
vehicles = append(vehicles, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vehiclech <- vehicles
|
||||||
}
|
}
|
||||||
|
go journeysRequest()
|
||||||
|
go carpoolRequest()
|
||||||
|
go vehicleRequest()
|
||||||
|
carpool_results = <-carpoolCh
|
||||||
|
journeys_results = <-navitiaCh
|
||||||
|
vehicle_results = <-vehiclech
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.JourneysSearch(w, r, carpoolresults, journeys, vehicles, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
h.Renderer.JourneysSearch(w, r, carpool_results, journeys_results, vehicle_results, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupsModule []groupstorage.Group
|
type GroupsModule []groupstorage.Group
|
||||||
|
|||||||
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
263
handlers/application/vehicles-management.go
Normal file → Executable file
263
handlers/application/vehicles-management.go
Normal file → Executable file
@@ -45,9 +45,7 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
|
|||||||
vehicleBookings := []fleetsstorage.Booking{}
|
vehicleBookings := []fleetsstorage.Booking{}
|
||||||
for _, b := range v.Bookings {
|
for _, b := range v.Bookings {
|
||||||
if b.Status() != fleetsstorage.StatusOld {
|
if b.Status() != fleetsstorage.StatusOld {
|
||||||
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
|
bookings = append(bookings, b)
|
||||||
bookings = append(bookings, b)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if b.Unavailableto.After(time.Now()) {
|
if b.Unavailableto.After(time.Now()) {
|
||||||
vehicleBookings = append(vehicleBookings, b)
|
vehicleBookings = append(vehicleBookings, b)
|
||||||
@@ -190,10 +188,36 @@ 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
vehicleid := vars["vehicleid"]
|
||||||
|
|
||||||
|
if r.Method == "POST" {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &fleets.GetVehicleRequest{
|
||||||
|
Vehicleid: vehicleid,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.Fleets.GetVehicle(context.TODO(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.VehiclesFleetUpdate(w, r, resp.Vehicle.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
func filterVehicle(r *http.Request, v *fleets.Vehicle) bool {
|
func filterVehicle(r *http.Request, v *fleets.Vehicle) bool {
|
||||||
g := r.Context().Value(identification.GroupKey)
|
g := r.Context().Value(identification.GroupKey)
|
||||||
if g == nil {
|
if g == nil {
|
||||||
@@ -443,210 +467,27 @@ 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) {
|
// func (h *ApplicationHandler) UnbookingVehicles(w http.ResponseWriter, r *http.Request) {
|
||||||
// request := &fleets.GetVehiclesRequest{
|
// request := &fleets.GetVehiclesRequest{
|
||||||
// Namespaces: []string{"parcoursmob"},
|
// Namespaces: []string{"parcoursmob"},
|
||||||
// }
|
// }
|
||||||
// resp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
// resp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Println(err)
|
// fmt.Println(err)
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
// w.WriteHeader(http.StatusInternalServerError)
|
||||||
// }
|
// }
|
||||||
// vehicles := []fleetsstorage.Vehicle{}
|
// vehicles := []fleetsstorage.Vehicle{}
|
||||||
// fmt.Println(resp.Vehicles[0].Bookings)
|
// fmt.Println(resp.Vehicles[0].Bookings)
|
||||||
// for i, vehicle := range resp.Vehicles {
|
// for i, vehicle := range resp.Vehicles {
|
||||||
// if len(resp.Vehicles[i].Bookings) == 0 {
|
// if len(resp.Vehicles[i].Bookings) == 0 {
|
||||||
// v := vehicle.ToStorageType()
|
// v := vehicle.ToStorageType()
|
||||||
// vehicles = append(vehicles, v)
|
// vehicles = append(vehicles, v)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// // if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
|
// // if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
|
||||||
// // h.Renderer.UnbookingVehicles(w, r, resp.Vehicle.ToStorageType())
|
// // h.Renderer.UnbookingVehicles(w, r, resp.Vehicle.ToStorageType())
|
||||||
// // }
|
// // }
|
||||||
// // fmt.Println(resp.Vehicle.ToStorageType().Bookings)
|
// // fmt.Println(resp.Vehicle.ToStorageType().Bookings)
|
||||||
// fmt.Println(vehicles)
|
// fmt.Println(vehicles)
|
||||||
// h.Renderer.UnbookingVehicles(w, r, vehicles)
|
// h.Renderer.UnbookingVehicles(w, r, vehicles)
|
||||||
// }
|
// }
|
||||||
func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Request) {
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
bookingid := vars["bookingid"]
|
|
||||||
|
|
||||||
request := &fleets.GetBookingRequest{
|
|
||||||
Bookingid: bookingid,
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := h.services.GRPC.Fleets.GetBooking(context.TODO(), request)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
now := time.Now()
|
|
||||||
date := now.Format("2006-01-02")
|
|
||||||
unavailableto, _ := time.Parse("2006-01-02", date)
|
|
||||||
|
|
||||||
current_group, err := h.currentGroup(r)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
current_user_token, current_user_claims, err := h.currentUser(r)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
booked_by_id := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["id"].GetStringValue()
|
|
||||||
booked_by_name := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["display_name"].GetStringValue()
|
|
||||||
booked_by_email := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["email"].GetStringValue()
|
|
||||||
booked_by_group_id := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["group"].GetStructValue().Fields["id"].GetStringValue()
|
|
||||||
booked_by_group_name := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["group"].GetStructValue().Fields["name"].GetStringValue()
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"booked_by": map[string]any{
|
|
||||||
"user": map[string]any{
|
|
||||||
"id": booked_by_id,
|
|
||||||
"display_name": booked_by_name,
|
|
||||||
"email": booked_by_email,
|
|
||||||
},
|
|
||||||
"group": map[string]any{
|
|
||||||
"id": booked_by_group_id,
|
|
||||||
"name": booked_by_group_name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"unbooked_by": map[string]any{
|
|
||||||
"user": map[string]any{
|
|
||||||
"id": current_user_token.Subject,
|
|
||||||
"display_name": current_user_claims["first_name"].(string) + " " + current_user_claims["last_name"].(string),
|
|
||||||
"email": current_user_claims["email"],
|
|
||||||
},
|
|
||||||
"group": map[string]any{
|
|
||||||
"id": current_group.ID,
|
|
||||||
"name": current_group.Data["name"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"Deleted": true,
|
|
||||||
"motif": r.FormValue("motif"),
|
|
||||||
}
|
|
||||||
|
|
||||||
datapb, err := structpb.NewStruct(data)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.Method == "POST" {
|
|
||||||
|
|
||||||
request := &fleets.UpdateBookingRequest{
|
|
||||||
Booking: &fleets.Booking{
|
|
||||||
Id: resp.Booking.Id,
|
|
||||||
Vehicleid: resp.Booking.Vehicleid,
|
|
||||||
Driver: resp.Booking.Driver,
|
|
||||||
Startdate: resp.Booking.Startdate,
|
|
||||||
Enddate: resp.Booking.Enddate,
|
|
||||||
Unavailablefrom: resp.Booking.Unavailablefrom,
|
|
||||||
Unavailableto: timestamppb.New(unavailableto),
|
|
||||||
Data: datapb,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/app/vehicles-management/", http.StatusFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
h.Renderer.UnbookingVehicle(w, r, resp.Booking.ToStorageType())
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////UpdateVehicle///////////////////////
|
|
||||||
|
|
||||||
func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request) {
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
vehicleID := vars["vehicleid"]
|
|
||||||
request := &fleets.GetVehicleRequest{
|
|
||||||
Vehicleid: vehicleID,
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := h.services.GRPC.Fleets.GetVehicle(context.TODO(), request)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
namespaceV := resp.Vehicle.Namespace
|
|
||||||
//typeV := resp.Vehicle.Type
|
|
||||||
administratorsV := resp.Vehicle.Administrators
|
|
||||||
|
|
||||||
if r.Method == "POST" {
|
|
||||||
fmt.Print(r.FormValue("vehicle_type"))
|
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dataMap := map[string]any{}
|
|
||||||
if v := r.FormValue("name"); v != "" {
|
|
||||||
dataMap["name"] = v
|
|
||||||
}
|
|
||||||
if v := r.FormValue("address"); v != "" {
|
|
||||||
var address map[string]any
|
|
||||||
err := json.Unmarshal([]byte(v), &address)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dataMap["address"] = address
|
|
||||||
}
|
|
||||||
if v := r.FormValue("informations"); v != "" {
|
|
||||||
dataMap["informations"] = v
|
|
||||||
}
|
|
||||||
if v := r.FormValue("licence_plate"); v != "" {
|
|
||||||
dataMap["licence_plate"] = v
|
|
||||||
}
|
|
||||||
if v := r.FormValue("automatic"); v != "" {
|
|
||||||
fmt.Println(v)
|
|
||||||
dataMap["automatic"] = (v == "on")
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := structpb.NewValue(dataMap)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
request := &fleets.UpdateVehicleRequest{
|
|
||||||
Vehicle: &fleets.Vehicle{
|
|
||||||
Id: vehicleID,
|
|
||||||
Namespace: namespaceV,
|
|
||||||
Type: r.FormValue("type"),
|
|
||||||
Administrators: administratorsV,
|
|
||||||
Data: data.GetStructValue(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := h.services.GRPC.Fleets.UpdateVehicle(context.TODO(), request)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/vehicles-management/fleet/%s", resp.Vehicle.Id), http.StatusFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
vehicles_types := h.config.GetStringSlice("modules.fleets.vehicle_types")
|
|
||||||
h.Renderer.VehiclesFleetUpdate(w, r, resp.Vehicle.ToStorageType(), vehicles_types)
|
|
||||||
}
|
|
||||||
|
|||||||
2
handlers/application/vehicles.go
Normal file → Executable file
2
handlers/application/vehicles.go
Normal file → Executable file
@@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
fmt.Println("invoked")
|
||||||
var beneficiary mobilityaccountsstorage.Account
|
var beneficiary mobilityaccountsstorage.Account
|
||||||
|
|
||||||
beneficiarydocuments := []filestorage.FileInfo{}
|
beneficiarydocuments := []filestorage.FileInfo{}
|
||||||
|
|||||||
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
0
handlers/auth/onboarding.go
Normal file → Executable file
0
handlers/auth/onboarding.go
Normal file → Executable file
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
24
handlers/exports/fleets.go
Normal file → Executable file
24
handlers/exports/fleets.go
Normal file → Executable file
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
|
||||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||||
fleetsstorage "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"
|
||||||
@@ -19,6 +18,7 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
vehicles := map[string]fleetsstorage.Vehicle{}
|
vehicles := map[string]fleetsstorage.Vehicle{}
|
||||||
bookings := []fleetsstorage.Booking{}
|
bookings := []fleetsstorage.Booking{}
|
||||||
|
|
||||||
reequest := &fleets.GetVehiclesRequest{
|
reequest := &fleets.GetVehiclesRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,6 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
groups := map[string]groupsstorage.Group{}
|
groups := map[string]groupsstorage.Group{}
|
||||||
|
|
||||||
admingroups, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), &groupsmanagement.GetGroupsRequest{
|
admingroups, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), &groupsmanagement.GetGroupsRequest{
|
||||||
@@ -107,31 +106,14 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
bookedby := ""
|
bookedby := ""
|
||||||
if v, ok := b.Data["booked_by"].(map[string]any); ok {
|
if v, ok := b.Data["booked_by"].(map[string]any); ok {
|
||||||
if v2, ok := v["user"].(map[string]any); ok {
|
if v2, ok := v["group"].(map[string]any); ok {
|
||||||
if v3, ok := v2["display_name"].(string); ok {
|
if v3, ok := v2["name"].(string); ok {
|
||||||
bookedby = v3
|
bookedby = v3
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bookedbygroup := ""
|
|
||||||
if v4, ok := b.Data["booked_by"].(map[string]any); ok {
|
|
||||||
if v5, ok := v4["group"].(map[string]any); ok {
|
|
||||||
if v6, ok := v5["id"].(string); ok {
|
|
||||||
bookedbygroup = v6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// filter by group
|
|
||||||
g := r.Context().Value(identification.GroupKey)
|
|
||||||
group := g.(groupsstorage.Group)
|
|
||||||
|
|
||||||
if bookedbygroup != group.ID {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
beneficiary := beneficiaries_map[b.Driver]
|
beneficiary := beneficiaries_map[b.Driver]
|
||||||
adminunavailability := false
|
adminunavailability := false
|
||||||
|
|
||||||
|
|||||||
11
main.go
Normal file → Executable file
11
main.go
Normal file → Executable file
@@ -19,6 +19,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := ReadConfig()
|
cfg, err := ReadConfig()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -29,17 +30,15 @@ func main() {
|
|||||||
templates_public_dir = cfg.GetString("templates.public_dir")
|
templates_public_dir = cfg.GetString("templates.public_dir")
|
||||||
dev_env = cfg.GetBool("dev_env")
|
dev_env = cfg.GetBool("dev_env")
|
||||||
)
|
)
|
||||||
|
|
||||||
svc, err := services.NewServicesHandler(cfg)
|
svc, err := services.NewServicesHandler(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
fmt.Println(cfg)
|
||||||
kv, err := cache.NewKVHandler(cfg)
|
kv, err := cache.NewKVHandler(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
filestorage, err := cache.NewFileStorage(cfg)
|
filestorage, err := cache.NewFileStorage(cfg)
|
||||||
|
|
||||||
idp, err := identification.NewIdentificationProvider(cfg, svc, kv)
|
idp, err := identification.NewIdentificationProvider(cfg, svc, kv)
|
||||||
@@ -108,9 +107,6 @@ func main() {
|
|||||||
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}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle)
|
||||||
/////////////////////////////////////Remove booking vehicle/////////////////////////////////////////
|
|
||||||
application.HandleFunc("/vehicles-management/bookings/{bookingid}/delete", applicationHandler.UnbookingVehicle)
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
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/history", applicationHandler.AgendaHistory)
|
application.HandleFunc("/agenda/history", applicationHandler.AgendaHistory)
|
||||||
@@ -166,14 +162,11 @@ func main() {
|
|||||||
|
|
||||||
export := r.PathPrefix("/exports").Subrouter()
|
export := r.PathPrefix("/exports").Subrouter()
|
||||||
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
|
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
|
||||||
export.HandleFunc("/fleets/bookings/{groupid}", exportsHandler.Bookings)
|
|
||||||
export.HandleFunc("/agenda/subscriptions", exportsHandler.Agenda("allEvents"))
|
export.HandleFunc("/agenda/subscriptions", exportsHandler.Agenda("allEvents"))
|
||||||
export.HandleFunc("/agenda/{eventid}", exportsHandler.Agenda("oneEvent"))
|
export.HandleFunc("/agenda/{eventid}", exportsHandler.Agenda("oneEvent"))
|
||||||
export.Use(idp.Middleware)
|
export.Use(idp.Middleware)
|
||||||
export.Use(idp.GroupsMiddleware)
|
export.Use(idp.GroupsMiddleware)
|
||||||
|
|
||||||
fmt.Println("-> HTTP server listening on", address)
|
|
||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Handler: r,
|
Handler: r,
|
||||||
Addr: address,
|
Addr: address,
|
||||||
|
|||||||
0
renderer/administration.go
Normal file → Executable file
0
renderer/administration.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
0
renderer/beneficiaries.go
Normal file → Executable file
0
renderer/beneficiaries.go
Normal file → Executable file
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
16
renderer/vehicle-management.go
Normal file → Executable file
16
renderer/vehicle-management.go
Normal file → Executable file
@@ -53,12 +53,11 @@ func (renderer *Renderer) VehiclesFleetDisplay(w http.ResponseWriter, r *http.Re
|
|||||||
renderer.Render("fleet display vehicle", w, r, files, state)
|
renderer.Render("fleet display vehicle", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any, vehicle_types []string) {
|
func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_update.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_update.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"vehicle": vehicle,
|
"vehicle": vehicle,
|
||||||
"vehicle_types": vehicle_types,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("fleet display vehicle", w, r, files, state)
|
renderer.Render("fleet display vehicle", w, r, files, state)
|
||||||
@@ -79,14 +78,3 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter,
|
|||||||
|
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
renderer.Render("vehicles search", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Request, booking any) {
|
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
|
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
|
||||||
state.ViewState = map[string]any{
|
|
||||||
"booking": booking,
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer.Render("vehicule unbooking", w, r, files, state)
|
|
||||||
|
|
||||||
}
|
|
||||||
0
renderer/vehicles.go
Normal file → Executable file
0
renderer/vehicles.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
0
services/fleets.go
Normal file → Executable file
0
services/fleets.go
Normal file → Executable file
0
services/groupsmanagement.go
Normal file → Executable file
0
services/groupsmanagement.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
1
themes
Submodule
1
themes
Submodule
Submodule themes added at d6de19d8e2
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
1
utils/storage/badger.go
Normal file
1
utils/storage/badger.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package storage
|
||||||
0
utils/storage/cache.go
Normal file → Executable file
0
utils/storage/cache.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
@@ -74,6 +74,7 @@ func NewEtcdHandler(cfg *viper.Viper) (*EtcdHandler, error) {
|
|||||||
Password: password,
|
Password: password,
|
||||||
DialTimeout: 5 * time.Second,
|
DialTimeout: 5 * time.Second,
|
||||||
})
|
})
|
||||||
|
fmt.Println(endpoints,prefix,username,password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
0
utils/storage/files.go
Normal file → Executable file
0
utils/storage/files.go
Normal file → Executable file
1
utils/storage/groupcache.go
Normal file
1
utils/storage/groupcache.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package storage
|
||||||
16
utils/storage/kv.go
Normal file → Executable file
16
utils/storage/kv.go
Normal file → Executable file
@@ -1,6 +1,7 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -14,5 +15,18 @@ type KVHandler interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
||||||
return NewEtcdHandler(cfg)
|
cacheType := cfg.GetString("storage.kv.dbType")
|
||||||
|
switch cacheType {
|
||||||
|
case "etcd":
|
||||||
|
return NewEtcdHandler(cfg)
|
||||||
|
case "badger":
|
||||||
|
return NewBadgerHandler(cfg)
|
||||||
|
case "etcdGroupcache":
|
||||||
|
return NewGroupCacheHandler(cfg)
|
||||||
|
fmt.Println("here")
|
||||||
|
case "badgerGroupcache":
|
||||||
|
return NewGroupCacheHandler(cfg)
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
Reference in New Issue
Block a user