Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c291fc3bd4 | |||
| 81e81f8763 | |||
| 5f64b6c71a | |||
| 51dcaf01c8 | |||
| bd91ce1572 | |||
| edb03ae3b4 | |||
| 5ea89bf0b2 | |||
| 18e890ceed | |||
| b717be9b99 | |||
| ddb08cf671 | |||
| 4fe479c1fb | |||
| b0dd81bf67 | |||
|
|
3bfd2e1bfe | ||
|
|
b5154bf9be | ||
|
|
96823f3289 | ||
|
|
93cab33fb9 | ||
|
|
d5bc764ef3 | ||
|
|
1aeb6d50ef | ||
| f26d792b8b | |||
| bfd14d7f4c | |||
| 31e5eadc73 | |||
| 8f20a12bc5 |
4
Dockerfile
Executable file → Normal file
4
Dockerfile
Executable file → Normal 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 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
|
RUN git clone -b dev --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
Executable file → Normal file
20
go.mod
Executable file → Normal file
@@ -30,11 +30,11 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
|
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230222135722-e55cf41e203b
|
||||||
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-20230310144446-feb935f8bf4e
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230519092636-41bf03682ca9
|
||||||
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230117140716-312200e21063
|
||||||
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230329105908-a76c0412a386
|
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20221107003506-e2ff98094b81
|
||||||
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,6 +42,7 @@ 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
|
||||||
@@ -54,12 +55,16 @@ 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
|
||||||
@@ -68,6 +73,11 @@ 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
|
||||||
@@ -79,6 +89,7 @@ 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
|
||||||
@@ -101,6 +112,7 @@ 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
Executable file → Normal file
0
handlers/api/api.go
Executable file → Normal file
80
handlers/api/cache.go
Executable file → Normal file
80
handlers/api/cache.go
Executable file → Normal file
@@ -12,58 +12,40 @@ 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
|
|
||||||
ch := make(chan []byte)
|
d, err := h.cache.Get(cacheid)
|
||||||
// Fetch data from cache asynchronously
|
if err != nil {
|
||||||
go func() {
|
fmt.Println(err)
|
||||||
d, err := h.cache.Get(cacheid)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
if err != nil {
|
return
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
ch <- nil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
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
|
|
||||||
|
result := d
|
||||||
|
|
||||||
|
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:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
Executable file → Normal file
0
handlers/api/export.go
Executable file → Normal file
0
handlers/api/geo.go
Executable file → Normal file
0
handlers/api/geo.go
Executable file → Normal file
0
handlers/api/oidc.go
Executable file → Normal file
0
handlers/api/oidc.go
Executable file → Normal file
458
handlers/application/administration.go
Executable file → Normal file
458
handlers/application/administration.go
Executable file → Normal file
@@ -8,7 +8,6 @@ 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"
|
||||||
@@ -28,83 +27,79 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
|
||||||
wg sync.WaitGroup
|
accounts, err := h.services.GetAccounts()
|
||||||
accounts, beneficiaries []mobilityaccountsstorage.Account
|
if err != nil {
|
||||||
bookings []fleetsstorage.Booking
|
fmt.Println(err)
|
||||||
accountsErr, beneficiariesErr, bookingsErr, groupsResponseErr, eventsResponseErr, groupsBatchErr error
|
|
||||||
groups = []groupstorage.Group{}
|
|
||||||
responses = []agendastorage.Event{}
|
|
||||||
groupsResponse *groupsmanagement.GetGroupsResponse
|
|
||||||
eventsResponse *agenda.GetEventsResponse
|
|
||||||
groupids = []string{}
|
|
||||||
groupsBatchResponse *groupsmanagement.GetGroupsBatchResponse
|
|
||||||
)
|
|
||||||
// Retrieve accounts in a goroutine
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
accounts, accountsErr = h.services.GetAccounts()
|
|
||||||
}()
|
|
||||||
// Retrieve beneficiaries in a goroutine
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
beneficiaries, beneficiariesErr = h.services.GetBeneficiaries()
|
|
||||||
}()
|
|
||||||
// Retrieve bookings in a goroutine
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
bookings, bookingsErr = h.services.GetBookings()
|
|
||||||
}()
|
|
||||||
// Retrieve groupsRequest in a goroutine
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
request := &groupsmanagement.GetGroupsRequest{
|
|
||||||
Namespaces: []string{"parcoursmob_organizations"},
|
|
||||||
}
|
|
||||||
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)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beneficiaries, err := h.services.GetBeneficiaries()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bookings, err := h.services.GetBookings()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &groupsmanagement.GetGroupsRequest{
|
||||||
|
Namespaces: []string{"parcoursmob_organizations"},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var groups = []groupstorage.Group{}
|
||||||
|
|
||||||
|
for _, group := range resp.Groups {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,23 +155,22 @@ 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
|
||||||
go func() {
|
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
||||||
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
if err != nil {
|
||||||
if err != nil {
|
fmt.Println(err)
|
||||||
fmt.Println(err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
return
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -211,167 +205,165 @@ 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",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
fmt.Println(err)
|
Id: groupid,
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
Namespace: "parcoursmob_organizations",
|
||||||
return
|
})
|
||||||
}
|
|
||||||
}()
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
go func() {
|
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
||||||
accountresp, err = h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
Username: r.FormValue("username"),
|
||||||
Username: r.FormValue("username"),
|
Namespace: "parcoursmob",
|
||||||
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")
|
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
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")
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
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
|
||||||
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
|
onboarding := map[string]any{
|
||||||
vars := mux.Vars(r)
|
"username": r.FormValue("username"),
|
||||||
groupid := vars["groupid"]
|
"group": groupid,
|
||||||
var (
|
"admin": true,
|
||||||
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",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
b := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
group := groupresp.Group.ToStorageType()
|
key := base64.RawURLEncoding.EncodeToString(b)
|
||||||
groupCh <- group
|
|
||||||
}()
|
|
||||||
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)
|
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
data := map[string]any{
|
||||||
context.TODO(),
|
"group": groupresp.Group.ToStorageType().Data["name"],
|
||||||
&accounts.UpdateDataRequest{
|
"key": key,
|
||||||
Account: as,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
data := map[string]any{
|
|
||||||
"group": group.Data["name"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
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) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
groupid := vars["groupid"]
|
||||||
|
|
||||||
|
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
|
Id: groupid,
|
||||||
|
Namespace: "parcoursmob_organizations",
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
group := groupresp.Group.ToStorageType()
|
||||||
|
|
||||||
|
r.ParseForm()
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
|
|
||||||
|
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
||||||
|
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
|
||||||
|
}
|
||||||
|
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
Executable file → Normal file
0
handlers/application/agenda.go
Executable file → Normal file
0
handlers/application/application.go
Executable file → Normal file
0
handlers/application/application.go
Executable file → Normal file
0
handlers/application/beneficiaries.go
Executable file → Normal file
0
handlers/application/beneficiaries.go
Executable file → Normal file
0
handlers/application/dashboard.go
Executable file → Normal file
0
handlers/application/dashboard.go
Executable file → Normal file
0
handlers/application/directory.go
Executable file → Normal file
0
handlers/application/directory.go
Executable file → Normal file
0
handlers/application/group.go
Executable file → Normal file
0
handlers/application/group.go
Executable file → Normal file
0
handlers/application/group_module.go
Executable file → Normal file
0
handlers/application/group_module.go
Executable file → Normal file
159
handlers/application/journeys.go
Executable file → Normal file
159
handlers/application/journeys.go
Executable file → Normal file
@@ -27,14 +27,7 @@ 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 : ")
|
||||||
@@ -77,101 +70,91 @@ 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 := func() {
|
// carpoolrequest := fmt.Sprintf(
|
||||||
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
|
// "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",
|
||||||
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL.RawQuery = fmt.Sprintf(
|
if carpoolresults == nil {
|
||||||
"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{}
|
||||||
}
|
}
|
||||||
carpoolCh <- carpoolresults
|
} else {
|
||||||
|
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)
|
vehicleresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), vehiclerequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
for _, vehicle := range vehicleresp.Vehicles {
|
|
||||||
v := vehicle.ToStorageType()
|
for _, vehicle := range vehicleresp.Vehicles {
|
||||||
if v.Free(departuredatetime.Add(-24*time.Hour), departuredatetime.Add(168*time.Hour)) {
|
v := vehicle.ToStorageType()
|
||||||
vehicles = append(vehicles, v)
|
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, carpool_results, journeys_results, vehicle_results, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
h.Renderer.JourneysSearch(w, r, carpoolresults, journeys, vehicles, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupsModule []groupstorage.Group
|
type GroupsModule []groupstorage.Group
|
||||||
|
|||||||
0
handlers/application/members.go
Executable file → Normal file
0
handlers/application/members.go
Executable file → Normal file
0
handlers/application/support.go
Executable file → Normal file
0
handlers/application/support.go
Executable file → Normal file
263
handlers/application/vehicles-management.go
Executable file → Normal file
263
handlers/application/vehicles-management.go
Executable file → Normal file
@@ -45,7 +45,9 @@ 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 {
|
||||||
bookings = append(bookings, b)
|
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
|
||||||
|
bookings = append(bookings, b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if b.Unavailableto.After(time.Now()) {
|
if b.Unavailableto.After(time.Now()) {
|
||||||
vehicleBookings = append(vehicleBookings, b)
|
vehicleBookings = append(vehicleBookings, b)
|
||||||
@@ -188,36 +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())
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
@@ -467,27 +443,210 @@ 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
Executable file → Normal file
2
handlers/application/vehicles.go
Executable file → Normal 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
Executable file → Normal file
0
handlers/auth/auth.go
Executable file → Normal file
0
handlers/auth/disconnect.go
Executable file → Normal file
0
handlers/auth/disconnect.go
Executable file → Normal file
0
handlers/auth/groups.go
Executable file → Normal file
0
handlers/auth/groups.go
Executable file → Normal file
0
handlers/auth/lost_password.go
Executable file → Normal file
0
handlers/auth/lost_password.go
Executable file → Normal file
0
handlers/auth/onboarding.go
Executable file → Normal file
0
handlers/auth/onboarding.go
Executable file → Normal file
0
handlers/exports/agenda.go
Executable file → Normal file
0
handlers/exports/agenda.go
Executable file → Normal file
0
handlers/exports/exports.go
Executable file → Normal file
0
handlers/exports/exports.go
Executable file → Normal file
24
handlers/exports/fleets.go
Executable file → Normal file
24
handlers/exports/fleets.go
Executable file → Normal file
@@ -5,6 +5,7 @@ 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"
|
||||||
@@ -18,7 +19,6 @@ 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,6 +45,7 @@ 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{
|
||||||
@@ -106,14 +107,31 @@ 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["group"].(map[string]any); ok {
|
if v2, ok := v["user"].(map[string]any); ok {
|
||||||
if v3, ok := v2["name"].(string); ok {
|
if v3, ok := v2["display_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
Executable file → Normal file
11
main.go
Executable file → Normal file
@@ -19,7 +19,6 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := ReadConfig()
|
cfg, err := ReadConfig()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -30,15 +29,17 @@ 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)
|
||||||
@@ -107,6 +108,9 @@ 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)
|
||||||
@@ -162,11 +166,14 @@ 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
Executable file → Normal file
0
renderer/administration.go
Executable file → Normal file
0
renderer/agenda.go
Executable file → Normal file
0
renderer/agenda.go
Executable file → Normal file
0
renderer/auth.go
Executable file → Normal file
0
renderer/auth.go
Executable file → Normal file
0
renderer/beneficiaries.go
Executable file → Normal file
0
renderer/beneficiaries.go
Executable file → Normal file
0
renderer/dashboard.go
Executable file → Normal file
0
renderer/dashboard.go
Executable file → Normal file
0
renderer/directory.go
Executable file → Normal file
0
renderer/directory.go
Executable file → Normal file
0
renderer/func-maps.go
Executable file → Normal file
0
renderer/func-maps.go
Executable file → Normal file
0
renderer/group.go
Executable file → Normal file
0
renderer/group.go
Executable file → Normal file
0
renderer/group_module.go
Executable file → Normal file
0
renderer/group_module.go
Executable file → Normal file
0
renderer/journeys.go
Executable file → Normal file
0
renderer/journeys.go
Executable file → Normal file
0
renderer/layout.go
Executable file → Normal file
0
renderer/layout.go
Executable file → Normal file
0
renderer/mailer.go
Executable file → Normal file
0
renderer/mailer.go
Executable file → Normal file
0
renderer/members.go
Executable file → Normal file
0
renderer/members.go
Executable file → Normal file
0
renderer/renderer.go
Executable file → Normal file
0
renderer/renderer.go
Executable file → Normal file
0
renderer/support.go
Executable file → Normal file
0
renderer/support.go
Executable file → Normal file
16
renderer/vehicle-management.go
Executable file → Normal file
16
renderer/vehicle-management.go
Executable file → Normal file
@@ -53,11 +53,12 @@ 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) {
|
func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any, vehicle_types []string) {
|
||||||
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)
|
||||||
@@ -78,3 +79,14 @@ 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
Executable file → Normal file
0
renderer/vehicles.go
Executable file → Normal file
0
services/agenda.go
Executable file → Normal file
0
services/agenda.go
Executable file → Normal file
0
services/fleets.go
Executable file → Normal file
0
services/fleets.go
Executable file → Normal file
0
services/groupsmanagement.go
Executable file → Normal file
0
services/groupsmanagement.go
Executable file → Normal file
0
services/mobilityaccounts.go
Executable file → Normal file
0
services/mobilityaccounts.go
Executable file → Normal file
0
services/services.go
Executable file → Normal file
0
services/services.go
Executable file → Normal file
1
themes
1
themes
Submodule themes deleted from d6de19d8e2
0
utils/form-validators/form-validators.go
Executable file → Normal file
0
utils/form-validators/form-validators.go
Executable file → Normal file
0
utils/form-validators/phone-numbers.go
Executable file → Normal file
0
utils/form-validators/phone-numbers.go
Executable file → Normal file
0
utils/icons/svg-icons.go
Executable file → Normal file
0
utils/icons/svg-icons.go
Executable file → Normal file
0
utils/identification/groups.go
Executable file → Normal file
0
utils/identification/groups.go
Executable file → Normal file
0
utils/identification/oidc.go
Executable file → Normal file
0
utils/identification/oidc.go
Executable file → Normal file
0
utils/profile-pictures/profile-pictures.go
Executable file → Normal file
0
utils/profile-pictures/profile-pictures.go
Executable file → Normal file
0
utils/sorting/beneficiaries.go
Executable file → Normal file
0
utils/sorting/beneficiaries.go
Executable file → Normal file
0
utils/sorting/events.go
Executable file → Normal file
0
utils/sorting/events.go
Executable file → Normal file
0
utils/sorting/fleets.go
Executable file → Normal file
0
utils/sorting/fleets.go
Executable file → Normal file
0
utils/sorting/groups.go
Executable file → Normal file
0
utils/sorting/groups.go
Executable file → Normal file
0
utils/sorting/sorting.go
Executable file → Normal file
0
utils/sorting/sorting.go
Executable file → Normal file
@@ -1 +0,0 @@
|
|||||||
package storage
|
|
||||||
0
utils/storage/cache.go
Executable file → Normal file
0
utils/storage/cache.go
Executable file → Normal file
1
utils/storage/etcd.go
Executable file → Normal file
1
utils/storage/etcd.go
Executable file → Normal file
@@ -74,7 +74,6 @@ 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
Executable file → Normal file
0
utils/storage/files.go
Executable file → Normal file
@@ -1 +0,0 @@
|
|||||||
package storage
|
|
||||||
16
utils/storage/kv.go
Executable file → Normal file
16
utils/storage/kv.go
Executable file → Normal file
@@ -1,7 +1,6 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -15,18 +14,5 @@ type KVHandler interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
||||||
cacheType := cfg.GetString("storage.kv.dbType")
|
return NewEtcdHandler(cfg)
|
||||||
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
Executable file → Normal file
0
utils/storage/minio.go
Executable file → Normal file
0
utils/storage/sessions.go
Executable file → Normal file
0
utils/storage/sessions.go
Executable file → Normal file
Reference in New Issue
Block a user