27 Commits

Author SHA1 Message Date
b4c59c7408 edit agenda handlers - delete logs
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m8s
2024-10-23 10:39:11 +02:00
334351a0cf renderer agenda.go & handler agendo.go 2024-10-22 12:09:46 +02:00
7184f4735c edit agenda handlers 2024-10-15 10:51:15 +02:00
434be30074 add logical to add docs in event 2024-10-09 18:21:45 +02:00
498b12de18 fix dependencies in go.mod
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 54s
2024-05-20 17:25:31 +02:00
b77403c674 test actions
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 53s
2024-04-10 09:18:24 +02:00
f7cb9f1116 test actions
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 26s
2024-04-05 12:22:22 +02:00
2aec61e520 Merge branch 'dev' of https://git.coopgo.io/coopgo-apps/parcoursmob into dev 2024-04-04 12:24:59 +02:00
73586aa61a add .gitea/worflows/build.yml 2024-04-04 12:24:21 +02:00
a636b54a94 [+] Correction for véhicule partages 2023-12-08 13:29:25 +01:00
7c73c1d233 Merge branch 'dev' of https://git.coopgo.io/coopgo-apps/parcoursmob into dev 2023-11-24 17:06:12 +01:00
7a31b0ceb2 [+] merge main.go 2023-11-24 17:04:10 +01:00
2274f8d6d0 [+] bug fix regarding booking-list 2023-11-24 16:27:34 +01:00
4229c13b6b Implemented functional "Actions réalisées"
- Added events and vehicles inside it
- Included dates, characteristics, and names of events/vehicles
- Introduced color-coded badges to indicate the status of events/vehicles (ongoing or not)
2023-10-23 09:45:57 +02:00
100ffbe05a delete themes.zip 2023-09-06 13:32:49 +02:00
0f50b5e678 [+] adding in beneficiary-events the agenda-widget 2023-09-06 13:28:02 +02:00
275c8b1999 comments replace in go.mod 2023-08-07 10:52:29 +02:00
0e00a839a3 agenda dispositifs exports 2023-05-30 09:06:48 +02:00
c354bece5f refactoring groupcache 2023-05-19 10:58:37 +02:00
6299a6c7be cache refactoring 2023-05-19 10:06:30 +02:00
718c39de00 refactoring 2023-05-16 08:40:05 +02:00
9f66851529 adding groupcache 2023-05-15 14:49:00 +02:00
aa13d60ca6 AdministrationGroupInviteMember 2023-04-25 04:37:20 -04:00
d169566cd1 administration create group 2023-04-24 05:36:57 -04:00
root
b54961b619 handlers/administration goroutines 2023-04-20 19:14:00 +03:00
root
c34d08ff70 go routines /handlers/application/journeys 2023-04-20 15:28:27 +03:00
root
46a72e1aef api/cache 2023-04-20 13:14:25 +03:00
78 changed files with 917 additions and 1396 deletions

View File

@@ -0,0 +1,81 @@
name: Build and Push Docker Image
on:
push:
tags:
- '*'
branches:
- main
- dev
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Install Docker
run: |
apt-get update
apt-get install -y docker.io
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Kubernetes Context
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{secrets.buildx_kubeconfig}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: kubernetes
driver-opts: |
namespace=gitea
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.coopgo.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract metadata (tags, labels) for Docker image
id: metadata
uses: docker/metadata-action@v3
with:
images: git.coopgo.io/${{gitea.repository}}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
flavor: |
latest=auto
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ steps.metadata.outputs.tags }}
build-args: |
ACCESS_TOKEN_USR=${{gitea.actor}}
ACCESS_TOKEN_PWD=${{gitea.token}}
# BUILD WITH KANIKO
# - name: Kaniko build and push
# uses: aevea/action-kaniko@master
# with:
# build_file: Dockerfile
# registry: git.coopgo.io
# username: ${{secrets.registry_user}}
# password: ${{secrets.registry_token}}
# image: ${{gitea.repository}}
# tag: ${{gitea.ref_name}}
# cache: true
# cache_registry: git.coopgo.io/${{gitea.repository}}/cache
# extra-args: |
# ACCESS_TOKEN_USR=${{gitea.actor}}
# ACCESS_TOKEN_PWD=${{gitea.token}}

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/parcoursmob.iml" filepath="$PROJECT_DIR$/.idea/parcoursmob.iml" />
</modules>
</component>
</project>

9
.idea/parcoursmob.iml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

7
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/themes" vcs="Git" />
</component>
</project>

4
Dockerfile Normal file → Executable file
View File

@@ -19,8 +19,8 @@ COPY . .
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
# RUN rm -r themes/*
RUN git clone -b dev --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
RUN rm -r themes/*
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
FROM scratch

0
README.md Normal file → Executable file
View File

0
config.go Normal file → Executable file
View File

78
go.mod Normal file → Executable file
View File

@@ -2,13 +2,13 @@ module git.coopgo.io/coopgo-apps/parcoursmob
go 1.18
// replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
// replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/
replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/
// replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
// replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
// replace git.coopgo.io/coopgo-platform/emailing => ../../coopgo-platform/emailing/
@@ -20,66 +20,60 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1
github.com/paulmach/go.geojson v1.4.0
github.com/spf13/viper v1.13.0
github.com/spf13/viper v1.15.0
gitlab.scity.coop/maas/navitia-golang v0.0.0-20220429110621-5c22d6efdd0c
go.etcd.io/etcd/client/v3 v3.5.4
go.etcd.io/etcd/client/v3 v3.5.6
golang.org/x/image v0.5.0
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.1
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
google.golang.org/grpc v1.52.0
google.golang.org/protobuf v1.31.0
)
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/fleets v0.0.0-20230519092636-41bf03682ca9
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230117140716-312200e21063
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20221107003506-e2ff98094b81
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230329105908-a76c0412a386
github.com/gorilla/securecookie v1.1.1
github.com/minio/minio-go/v7 v7.0.43
github.com/ory/viper v1.7.5
github.com/xuri/excelize/v2 v2.7.1
)
require (
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
ariga.io/atlas v0.13.1 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/gogo/protobuf v1.3.2 // 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.3 // 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/google/go-cmp v0.5.9 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.16.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/goveralls v0.0.6 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // 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/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
@@ -87,12 +81,11 @@ require (
github.com/rs/xid v1.4.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.3 // 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/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tidwall/pretty v1.1.0 // indirect
github.com/twpayne/go-geom v1.3.6 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
@@ -101,25 +94,24 @@ require (
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
go.mongodb.org/mongo-driver v1.11.4 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.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/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/square/go-jose.v2 v2.5.2-0.20210529014059-a5c7eec3c614 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

1073
go.sum Normal file → Executable file

File diff suppressed because it is too large Load Diff

0
handlers/api/api.go Normal file → Executable file
View File

42
handlers/api/cache.go Normal file → Executable file
View File

@@ -12,17 +12,41 @@ import (
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
cacheid := vars["cacheid"]
// Use a channel to synchronize the goroutines
ch := make(chan []byte)
// Fetch data from cache asynchronously
go func() {
d, err := h.cache.Get(cacheid)
if err != nil {
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
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
w.Write(j)
result := d
if data, ok := d.([]any); ok {
<-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 {
@@ -36,16 +60,10 @@ func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
result = data[min:]
}
}
}
j, err := json.Marshal(result)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
return nil
}
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
w.Write(j)
return j
}

0
handlers/api/export.go Normal file → Executable file
View File

0
handlers/api/geo.go Normal file → Executable file
View File

0
handlers/api/oidc.go Normal file → Executable file
View File

160
handlers/application/administration.go Normal file → Executable file
View File

@@ -8,6 +8,7 @@ import (
"io"
"net/http"
"sort"
"sync"
"time"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
@@ -27,79 +28,83 @@ import (
)
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
accounts, err := h.services.GetAccounts()
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
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
}
var (
wg sync.WaitGroup
accounts, beneficiaries []mobilityaccountsstorage.Account
bookings []fleetsstorage.Booking
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"},
}
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 {
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))
////////////////////////////////////add event////////////////////////////////////////////
rresp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
}()
// 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"},
})
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
responses := []agendastorage.Event{}
groupids := []string{}
for _, e := range rresp.Events {
for _, e := range eventsResponse.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{
}()
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 err == nil {
for _, g := range groupsresp.Groups {
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)
}
@@ -155,22 +160,23 @@ func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r
Namespace: "parcoursmob_roles",
},
}
go func() {
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_organization)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
}()
// Create the admin role for the organization
go func() {
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
}()
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
return
}
@@ -205,8 +211,13 @@ func (h *ApplicationHandler) AdministrationGroupDisplay(w http.ResponseWriter, r
func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
groupid := vars["groupid"]
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
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",
})
@@ -216,14 +227,14 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
w.WriteHeader(http.StatusInternalServerError)
return
}
}()
r.ParseForm()
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
go func() {
accountresp, err = h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
Username: r.FormValue("username"),
Namespace: "parcoursmob",
})
if err == nil {
// Account already exists : adding the existing account to admin list
account := accountresp.Account.ToStorageType()
@@ -283,12 +294,16 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
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"]
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",
@@ -299,16 +314,16 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
w.WriteHeader(http.StatusInternalServerError)
return
}
group := groupresp.Group.ToStorageType()
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)
@@ -321,15 +336,11 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
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)
@@ -344,26 +355,23 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
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)
return
}

108
handlers/application/agenda.go Normal file → Executable file
View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"sort"
"strconv"
@@ -13,11 +14,13 @@ import (
formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
"git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
"github.com/google/uuid"
"github.com/gorilla/mux"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
@@ -147,17 +150,52 @@ func (h *ApplicationHandler) AgendaCreateEvent(w http.ResponseWriter, r *http.Re
}
resp, err := h.services.GRPC.Agenda.CreateEvent(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
contentType := r.Header.Get("Content-Type")
if strings.HasPrefix(contentType, "multipart/form-data") {
err = r.ParseMultipartForm(100 * 1024 * 1024) // 100 MB limit
if err != nil {
fmt.Println("Error parsing multipart form:", err)
w.WriteHeader(http.StatusBadRequest)
return
}
file, header, err := r.FormFile("file-upload")
if err == nil {
defer file.Close()
document_type := r.FormValue("file_type")
document_name := r.FormValue("file_name")
fileid := uuid.NewString()
metadata := map[string]string{
"file_type": document_type,
"file_name": document_name,
}
if err := h.filestorage.Put(file, filestorage.PREFIX_AGENDA, fmt.Sprintf("%s/%s_%s", resp.Event.Id, fileid, header.Filename), header.Size, metadata); err != nil {
fmt.Println("Error uploading file:", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
} else if err != http.ErrMissingFile {
fmt.Println("Error retrieving file:", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
}
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound)
return
}
h.Renderer.AgendaCreateEvent(w, r)
h.Renderer.AgendaCreateEvent(w, r, h.config.GetStringSlice("modules.agenda.documents_types"), h.config.GetStringMapString("storage.files.file_types"), nil)
}
func (h *ApplicationHandler) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request) {
@@ -237,7 +275,13 @@ func (h *ApplicationHandler) AgendaDisplayEvent(w http.ResponseWriter, r *http.R
}
}
h.Renderer.AgendaDisplayEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
documents := h.filestorage.List(filestorage.PREFIX_AGENDA + "/" + eventid)
events_file_types := h.config.GetStringSlice("modules.agenda.documents_types")
file_types_map := h.config.GetStringMapString("storage.files.file_types")
h.Renderer.AgendaDisplayEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), events_file_types, file_types_map, documents, subscribers, accounts)
}
func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http.Request) {
@@ -685,3 +729,61 @@ func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.R
h.Renderer.AgendaHistoryEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
}
////// ADD DOCUMENTS //////
func (h *ApplicationHandler) EventDocuments(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
eventID := vars["eventid"]
//r.ParseForm()
r.ParseMultipartForm(100 * 1024 * 1024)
document_type := r.FormValue("type")
document_name := r.FormValue("name")
file, header, err := r.FormFile("file-upload")
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
fileid := uuid.NewString()
metadata := map[string]string{
"type": document_type,
"name": document_name,
}
if err := h.filestorage.Put(file, filestorage.PREFIX_AGENDA, fmt.Sprintf("%s/%s_%s", eventID, fileid, header.Filename), header.Size, metadata); err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", eventID), http.StatusFound)
}
func (h *ApplicationHandler) EventDocumentDownload(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
eventID := vars["eventid"]
document := vars["document"]
file, info, err := h.filestorage.Get(filestorage.PREFIX_AGENDA, fmt.Sprintf("%s/%s", eventID, document))
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", info.ContentType)
if _, err = io.Copy(w, file); err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", eventID), http.StatusFound)
}

0
handlers/application/application.go Normal file → Executable file
View File

167
handlers/application/beneficiaries.go Normal file → Executable file
View File

@@ -20,7 +20,10 @@ import (
profilepictures "git.coopgo.io/coopgo-apps/parcoursmob/utils/profile-pictures"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
"git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
@@ -41,6 +44,67 @@ type BeneficiariesForm struct {
Gender string `json:"gender"`
}
type Event_Beneficiary interface {
Name() string
Date() time.Time
DateEnd() time.Time
Type() string
Db() string
ID() string
Icons() string
Status() int
}
type Event struct {
IDVal string
NameVal string
DateVal time.Time
DateEndVal time.Time
TypeVal string
DbVal string
Deleted bool
IconSet string
StatusVal int
}
func (e Event) Name() string {
return e.NameVal
}
func (e Event) Date() time.Time {
return e.DateVal
}
func (e Event) DateEnd() time.Time {
return e.DateEndVal
}
func (e Event) Type() string {
return e.TypeVal
}
func (e Event) ID() string {
return e.IDVal
}
func (e Event) Db() string {
return e.DbVal
}
func (e Event) Icons() string {
return e.IconSet
}
func (e Event) Status() int {
return e.StatusVal
}
func sortByDate(events []Event_Beneficiary) {
sort.Slice(events, func(i, j int) bool {
return events[i].Date().After(events[j].Date())
})
}
func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Request) {
accounts, err := h.beneficiaries(r)
@@ -135,6 +199,35 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
return
}
subscriptionrequest := &agenda.GetSubscriptionByUserRequest{
Subscriber: beneficiaryID,
}
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
events := []agendastorage.Event{}
currentTime := time.Now().Truncate(24 * time.Hour)
for _, e := range subcriptionresp.Subscription {
eventresquest := &agenda.GetEventRequest{
Id: e.Eventid,
}
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
events = append(events, eventresp.Event.ToStorageType())
}
sort.Sort(sorting.EventsByStartdate(events))
bookingsrequest := &fleets.GetDriverBookingsRequest{
Driver: beneficiaryID,
}
@@ -145,12 +238,78 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
return
}
bookings := []any{}
bookings := []fleetsstorage.Booking{}
for _, b := range bookingsresp.Bookings {
bookings = append(bookings, b.ToStorageType())
}
var events_list []Event_Beneficiary
var status_event int
for _, e := range events {
if e.Startdate.After(currentTime) {
status_event = 1
} else if e.Startdate.Before(currentTime) && e.Enddate.After(currentTime) || e.Enddate.Equal(currentTime) {
status_event = 2
} else {
status_event = 3
}
event := Event{
NameVal: e.Name,
DateVal: e.Startdate,
DateEndVal: e.Enddate,
TypeVal: e.Type,
IDVal: e.ID,
DbVal: "/app/agenda/",
IconSet: "calendar",
StatusVal: status_event,
}
events_list = append(events_list, event)
}
var status_booking int
for _, b := range bookings {
if b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) {
GetVehiculeRequest := &fleets.GetVehicleRequest{
Vehicleid: b.Vehicleid,
}
GetVehiculeResp, err := h.services.GRPC.Fleets.GetVehicle(context.Background(), GetVehiculeRequest)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if b.Startdate.After(currentTime) {
status_booking = 1
} else if b.Startdate.Before(currentTime) && b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) {
status_booking = 2
} else {
status_booking = 3
}
event := Event{
NameVal: GetVehiculeResp.Vehicle.ToStorageType().Data["name"].(string),
DateVal: b.Startdate,
DateEndVal: b.Enddate,
TypeVal: "Réservation de véhicule",
IDVal: b.ID,
DbVal: "/app/vehicles-management/bookings/",
IconSet: "vehicle",
StatusVal: status_booking,
}
events_list = append(events_list, event)
}
}
sortByDate(events_list)
groupsrequest := &groupsmanagement.GetGroupsRequest{
Namespaces: []string{"parcoursmob_organizations"},
Member: beneficiaryID,
@@ -169,7 +328,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
file_types_map := h.config.GetStringMapString("storage.files.file_types")
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents)
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list)
}
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
@@ -287,6 +446,8 @@ func (h *ApplicationHandler) BeneficiaryDocuments(w http.ResponseWriter, r *http
"name": document_name,
}
fmt.Println("metadata", metadata)
if err := h.filestorage.Put(file, filestorage.PREFIX_BENEFICIARIES, fmt.Sprintf("%s/%s_%s", beneficiaryID, fileid, header.Filename), header.Size, metadata); err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
@@ -333,6 +494,8 @@ func filterAccount(r *http.Request, a *mobilityaccounts.Account) bool {
return true
}
// func BeneficiariesEventList()
func (h *ApplicationHandler) beneficiaries(r *http.Request) ([]mobilityaccountsstorage.Account, error) {
var accounts = []mobilityaccountsstorage.Account{}
g := r.Context().Value(identification.GroupKey)

2
handlers/application/dashboard.go Normal file → Executable file
View File

@@ -68,9 +68,11 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
Mindate: timestamppb.Now(),
})
if err == nil {
for _, e := range eventsresp.Events {
events = append(events, e.ToStorageType())
}
}
sort.Sort(sorting.EventsByStartdate(events))

0
handlers/application/directory.go Normal file → Executable file
View File

0
handlers/application/group.go Normal file → Executable file
View File

0
handlers/application/group_module.go Normal file → Executable file
View File

39
handlers/application/journeys.go Normal file → Executable file
View File

@@ -27,7 +27,14 @@ var Arrive any
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
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")
if errTime != nil {
fmt.Println("Loading timezone location Europe/Paris error : ")
@@ -70,7 +77,8 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
w.WriteHeader(http.StatusBadRequest)
return
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
journeysRequest := func() {
//TODO make it a library
session, _ := navitia.NewCustom(
h.config.GetString("services.navitia.api_key"),
@@ -79,6 +87,7 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
navitiaCh <- nil
return
}
@@ -95,13 +104,12 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
// w.WriteHeader(http.StatusBadRequest)
// return
}
navitiaCh <- journeys
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CARPOOL
// carpoolrequest := fmt.Sprintf(
// "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 := func() {
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
client := &http.Client{}
@@ -134,9 +142,11 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
} else {
carpoolresults = []any{}
}
carpoolCh <- carpoolresults
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Vehicles
vehicleRequest := func() {
vehiclerequest := &fleets.GetVehiclesRequest{
Namespaces: []string{"parcoursmob"},
}
@@ -145,16 +155,23 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
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

0
handlers/application/members.go Normal file → Executable file
View File

0
handlers/application/support.go Normal file → Executable file
View File

0
handlers/application/vehicles-management.go Normal file → Executable file
View File

5
handlers/application/vehicles.go Normal file → Executable file
View File

@@ -26,7 +26,7 @@ import (
func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
fmt.Println("invoked")
var beneficiary mobilityaccountsstorage.Account
beneficiarydocuments := []filestorage.FileInfo{}
@@ -349,6 +349,9 @@ func (h ApplicationHandler) VehiclesBookingsList(w http.ResponseWriter, r *http.
vehicles, _ := h.services.GetVehiclesMap()
groups, _ := h.services.GetGroupsMap()
// fmt.Println("bookings : ", bookings)
// fmt.Println("vehicles : ", vehicles)
// fmt.Println("groups : ", groups)
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
}

0
handlers/auth/auth.go Normal file → Executable file
View File

0
handlers/auth/disconnect.go Normal file → Executable file
View File

0
handlers/auth/groups.go Normal file → Executable file
View File

0
handlers/auth/lost_password.go Normal file → Executable file
View File

0
handlers/auth/onboarding.go Normal file → Executable file
View File

0
handlers/exports/agenda.go Normal file → Executable file
View File

0
handlers/exports/exports.go Normal file → Executable file
View File

0
handlers/exports/fleets.go Normal file → Executable file
View File

14
main.go Normal file → Executable file
View File

@@ -19,27 +19,26 @@ import (
func main() {
cfg, err := ReadConfig()
if err != nil {
panic(err)
}
var (
address = cfg.GetString("server.listen")
//address = cfg.GetString("server.listen")
service_name = cfg.GetString("service_name")
templates_public_dir = cfg.GetString("templates.public_dir")
dev_env = cfg.GetBool("dev_env")
)
svc, err := services.NewServicesHandler(cfg)
if err != nil {
panic(err)
}
fmt.Println(cfg)
kv, err := cache.NewKVHandler(cfg)
if err != nil {
panic(err)
}
filestorage, err := cache.NewFileStorage(cfg)
idp, err := identification.NewIdentificationProvider(cfg, svc, kv)
@@ -163,6 +162,9 @@ func main() {
application.HandleFunc("/agenda/{eventid}/{subscribeid}/delete", applicationHandler.AgendaDeleteSubscribeEvent)
application.HandleFunc("/agenda/{eventid}/history", applicationHandler.AgendaHistoryEvent)
/////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////Add documents in event////////////////////////
application.HandleFunc("/agenda/{eventid}/documents", applicationHandler.EventDocuments)
application.HandleFunc("/agenda/{eventid}/documents/{document}", applicationHandler.EventDocumentDownload)
export := r.PathPrefix("/exports").Subrouter()
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
@@ -172,11 +174,9 @@ func main() {
export.Use(idp.Middleware)
export.Use(idp.GroupsMiddleware)
fmt.Println("-> HTTP server listening on", address)
srv := &http.Server{
Handler: r,
Addr: address,
Addr: "0.0.0.0:9000",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}

0
renderer/administration.go Normal file → Executable file
View File

28
renderer/agenda.go Normal file → Executable file
View File

@@ -30,20 +30,29 @@ func (renderer *Renderer) AgendaHistory(w http.ResponseWriter, r *http.Request,
renderer.Render("agenda history", w, r, files, state)
}
func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Request) {
func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Request, events_file_types []string, file_types_map map[string]string, documents any) {
files := renderer.ThemeConfig.GetStringSlice("views.agenda.create_event.files")
state := NewState(r, renderer.ThemeConfig, agendaMenu)
state.ViewState = map[string]any{
"events_file_types": events_file_types,
"file_types_map": file_types_map,
"documents": documents,
}
renderer.Render("agenda create event", w, r, files, state)
}
func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, subscribers map[string]any, beneficiaries any) {
func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, events_file_types []string, file_types_map map[string]string, documents any, subscribers map[string]any, beneficiaries any) {
files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files")
state := NewState(r, renderer.ThemeConfig, agendaMenu)
state.ViewState = map[string]any{
"event": event,
"group": group,
"events_file_types": events_file_types,
"file_types_map": file_types_map,
"documents": documents,
"subscribers": subscribers,
"beneficiaries": beneficiaries,
}
@@ -100,3 +109,18 @@ func (renderer *Renderer) AgendaDeleteEvent(w http.ResponseWriter, r *http.Reque
renderer.Render("event_deleteEvent", w, r, files, state)
}
////////Event documents////////////////////////
// func (renderer *Renderer) EventDocuments(w http.ResponseWriter, r *http.Request, event any, documents []any) {
// files := renderer.ThemeConfig.GetStringSlice("views.agenda.event_files.files")
// state := NewState(r, renderer.ThemeConfig, agendaMenu)
// state.ViewState = map[string]any{
// "event": event,
// "documents": documents,
// "eventid": event.(map[string]any)["id"],
// "eventtitle": event.(map[string]any)["title"],
// }
// renderer.Render("event_files", w, r, files, state)
// }

0
renderer/auth.go Normal file → Executable file
View File

5
renderer/beneficiaries.go Normal file → Executable file
View File

@@ -5,6 +5,7 @@ import (
"html/template"
"net/http"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
)
@@ -52,7 +53,7 @@ type BeneficiariesDisplayState struct {
Beneficiary any
}
func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Request, beneficiary any, bookings []any, organizations []any, beneficiaries_file_types []string, file_types_map map[string]string, documents any) {
func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Request, beneficiary any, bookings []fleetsstorage.Booking, organizations []any, beneficiaries_file_types []string, file_types_map map[string]string, documents any, event interface{}) {
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
state.ViewState = map[string]any{
@@ -62,8 +63,8 @@ func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Requ
"file_types_map": file_types_map,
"documents": documents,
"organizations": organizations,
"event": event,
}
renderer.Render("beneficiaries_display", w, r, files, state)
}

0
renderer/dashboard.go Normal file → Executable file
View File

0
renderer/directory.go Normal file → Executable file
View File

0
renderer/func-maps.go Normal file → Executable file
View File

0
renderer/group.go Normal file → Executable file
View File

0
renderer/group_module.go Normal file → Executable file
View File

0
renderer/journeys.go Normal file → Executable file
View File

0
renderer/layout.go Normal file → Executable file
View File

0
renderer/mailer.go Normal file → Executable file
View File

0
renderer/members.go Normal file → Executable file
View File

0
renderer/renderer.go Normal file → Executable file
View File

0
renderer/support.go Normal file → Executable file
View File

0
renderer/vehicle-management.go Normal file → Executable file
View File

0
renderer/vehicles.go Normal file → Executable file
View File

0
services/agenda.go Normal file → Executable file
View File

11
services/fleets.go Normal file → Executable file
View File

@@ -2,6 +2,7 @@ package services
import (
"context"
"fmt"
"sort"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
@@ -56,13 +57,17 @@ func (s *ServicesHandler) GetBookings() (bookings []storage.Booking, err error)
func (s *ServicesHandler) GetVehiclesMap() (vehicles map[string]storage.Vehicle, err error) {
vehicles = map[string]storage.Vehicle{}
request := &fleets.GetVehiclesRequest{}
request := &fleets.GetVehiclesRequest{
Namespaces: []string{"parcoursmob"},
}
resp, err := s.GRPC.Fleets.GetVehicles(context.TODO(), request)
if err == nil {
if err != nil {
fmt.Println(err)
} else {
for _, vehicle := range resp.Vehicles {
vehicles[vehicle.Id] = vehicle.ToStorageType()
}
}
return
return vehicles, err
}

0
services/groupsmanagement.go Normal file → Executable file
View File

0
services/mobilityaccounts.go Normal file → Executable file
View File

0
services/services.go Normal file → Executable file
View File

1
themes Submodule

Submodule themes added at db4c22699e

0
utils/form-validators/form-validators.go Normal file → Executable file
View File

0
utils/form-validators/phone-numbers.go Normal file → Executable file
View File

0
utils/icons/svg-icons.go Normal file → Executable file
View File

0
utils/identification/groups.go Normal file → Executable file
View File

0
utils/identification/oidc.go Normal file → Executable file
View File

0
utils/profile-pictures/profile-pictures.go Normal file → Executable file
View File

0
utils/sorting/beneficiaries.go Normal file → Executable file
View File

0
utils/sorting/events.go Normal file → Executable file
View File

0
utils/sorting/fleets.go Normal file → Executable file
View File

0
utils/sorting/groups.go Normal file → Executable file
View File

0
utils/sorting/sorting.go Normal file → Executable file
View File

1
utils/storage/badger.go Normal file
View File

@@ -0,0 +1 @@
package storage

0
utils/storage/cache.go Normal file → Executable file
View File

1
utils/storage/etcd.go Normal file → Executable file
View File

@@ -74,6 +74,7 @@ func NewEtcdHandler(cfg *viper.Viper) (*EtcdHandler, error) {
Password: password,
DialTimeout: 5 * time.Second,
})
fmt.Println(endpoints,prefix,username,password)
if err != nil {
fmt.Println(err)
return nil, err

1
utils/storage/files.go Normal file → Executable file
View File

@@ -10,6 +10,7 @@ import (
const (
PREFIX_BENEFICIARIES = "beneficiaries"
PREFIX_BOOKINGS = "fleets_bookings"
PREFIX_AGENDA = "event_files"
)
type FileInfo struct {

2
utils/storage/kv.go Normal file → Executable file
View File

@@ -15,4 +15,6 @@ type KVHandler interface {
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
return NewEtcdHandler(cfg)
return nil, nil
}

0
utils/storage/minio.go Normal file → Executable file
View File

0
utils/storage/sessions.go Normal file → Executable file
View File