Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ecefbc8e1 | ||
| b77403c674 | |||
| f7cb9f1116 | |||
| 2aec61e520 | |||
| 73586aa61a | |||
| a636b54a94 | |||
| 7c73c1d233 | |||
| 7a31b0ceb2 | |||
| 2274f8d6d0 | |||
| 4229c13b6b | |||
| 100ffbe05a | |||
| 0f50b5e678 | |||
| 275c8b1999 | |||
| 0e00a839a3 | |||
| c354bece5f | |||
| 6299a6c7be | |||
| 718c39de00 | |||
| 9f66851529 | |||
| aa13d60ca6 | |||
| d169566cd1 | |||
|
|
b54961b619 | ||
|
|
c34d08ff70 | ||
|
|
46a72e1aef |
81
.gitea/workflows/build.yml
Normal file
81
.gitea/workflows/build.yml
Normal 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
8
.idea/.gitignore
generated
vendored
Normal 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
8
.idea/modules.xml
generated
Normal 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
9
.idea/parcoursmob.iml
generated
Normal 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
7
.idea/vcs.xml
generated
Normal 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
4
Dockerfile
Normal file → Executable file
@@ -19,8 +19,8 @@ COPY . .
|
|||||||
|
|
||||||
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
|
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
|
||||||
|
|
||||||
# RUN rm -r themes/*
|
RUN rm -r themes/*
|
||||||
RUN git clone -b dev --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
|
RUN git clone --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
|
||||||
RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06
|
RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|||||||
78
go.mod
Normal file → Executable file
78
go.mod
Normal file → Executable file
@@ -2,13 +2,13 @@ module git.coopgo.io/coopgo-apps/parcoursmob
|
|||||||
|
|
||||||
go 1.18
|
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/
|
// 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/mux v1.8.0
|
||||||
github.com/gorilla/sessions v1.2.1
|
github.com/gorilla/sessions v1.2.1
|
||||||
github.com/paulmach/go.geojson v1.4.0
|
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
|
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/image v0.5.0
|
||||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
|
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
|
||||||
google.golang.org/grpc v1.48.0
|
google.golang.org/grpc v1.52.0
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.31.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230222135722-e55cf41e203b
|
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
|
||||||
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
||||||
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230519092636-41bf03682ca9
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
|
||||||
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230117140716-312200e21063
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
|
||||||
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20221107003506-e2ff98094b81
|
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230329105908-a76c0412a386
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
github.com/minio/minio-go/v7 v7.0.43
|
github.com/minio/minio-go/v7 v7.0.43
|
||||||
github.com/ory/viper v1.7.5
|
|
||||||
github.com/xuri/excelize/v2 v2.7.1
|
github.com/xuri/excelize/v2 v2.7.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
|
ariga.io/atlas v0.13.1 // indirect
|
||||||
github.com/cespare/xxhash v1.1.0 // 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-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
|
||||||
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
|
||||||
github.com/dustin/go-humanize v1.0.0 // 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/locales v0.14.0 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
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.3 // 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/google/go-cmp v0.5.9 // 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/hashicorp/hcl/v2 v2.16.2 // 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/lib/pq v1.10.9 // indirect
|
||||||
github.com/mattn/goveralls v0.0.6 // indirect
|
github.com/magiconair/properties v1.8.7 // 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
|
||||||
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
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/pelletier/go-toml/v2 v2.0.6 // 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/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pquerna/cachecontrol v0.1.0 // indirect
|
github.com/pquerna/cachecontrol v0.1.0 // indirect
|
||||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||||
@@ -87,12 +81,11 @@ require (
|
|||||||
github.com/rs/xid v1.4.0 // indirect
|
github.com/rs/xid v1.4.0 // indirect
|
||||||
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
|
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
|
||||||
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.9.3 // 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.2 // indirect
|
||||||
github.com/tidwall/pretty v1.1.0 // indirect
|
github.com/tidwall/pretty v1.1.0 // indirect
|
||||||
github.com/twpayne/go-geom v1.3.6 // indirect
|
github.com/twpayne/go-geom v1.3.6 // indirect
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // 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/efp v0.0.0-20220603152613-6918739fd470 // indirect
|
||||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
|
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
|
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.10.1 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.mongodb.org/mongo-driver v1.11.4 // indirect
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/atomic v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.17.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/crypto v0.8.0 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/net v0.9.0 // indirect
|
||||||
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-20221227171554-f9683d7f8bef // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/mail.v2 v2.3.1 // indirect
|
gopkg.in/mail.v2 v2.3.1 // indirect
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // 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/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
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
0
handlers/api/api.go
Normal file → Executable file
0
handlers/api/api.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
@@ -12,40 +12,58 @@ import (
|
|||||||
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
cacheid := vars["cacheid"]
|
cacheid := vars["cacheid"]
|
||||||
|
// Use a channel to synchronize the goroutines
|
||||||
d, err := h.cache.Get(cacheid)
|
ch := make(chan []byte)
|
||||||
if err != nil {
|
// Fetch data from cache asynchronously
|
||||||
fmt.Println(err)
|
go func() {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
d, err := h.cache.Get(cacheid)
|
||||||
return
|
if err != nil {
|
||||||
}
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
result := d
|
ch <- nil
|
||||||
|
return
|
||||||
if data, ok := d.([]any); ok {
|
|
||||||
if limitsmin, ok := r.URL.Query()["limits.min"]; ok {
|
|
||||||
min, _ := strconv.Atoi(limitsmin[0])
|
|
||||||
if limitsmax, ok := r.URL.Query()["limits.max"]; ok {
|
|
||||||
max, _ := strconv.Atoi(limitsmax[0])
|
|
||||||
if max > len(data) {
|
|
||||||
result = data[min:]
|
|
||||||
} else {
|
|
||||||
result = data[min:max]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = data[min:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var data []any
|
||||||
|
if val, ok := d.([]any); ok {
|
||||||
|
data = val
|
||||||
|
} else {
|
||||||
|
data = []any{d}
|
||||||
|
}
|
||||||
|
j := toJSON(data, w, r)
|
||||||
|
ch <- j // Signal that the data has been fetched successfully
|
||||||
|
close(ch)
|
||||||
|
}()
|
||||||
|
// wait for the JSON marshaling goroutine to finish
|
||||||
|
j := <-ch
|
||||||
|
if j == nil {
|
||||||
|
return // Stop processing if an error occurred
|
||||||
}
|
}
|
||||||
|
// Send the JSON response to the client
|
||||||
j, err := json.Marshal(result)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
|
|
||||||
|
<-ch
|
||||||
|
}
|
||||||
|
func toJSON(data []any, w http.ResponseWriter, r *http.Request) []byte {
|
||||||
|
result := data
|
||||||
|
if limitsmin, ok := r.URL.Query()["limits.min"]; ok {
|
||||||
|
min, _ := strconv.Atoi(limitsmin[0])
|
||||||
|
if limitsmax, ok := r.URL.Query()["limits.max"]; ok {
|
||||||
|
max, _ := strconv.Atoi(limitsmax[0])
|
||||||
|
if max > len(data) {
|
||||||
|
result = data[min:]
|
||||||
|
} else {
|
||||||
|
result = data[min:max]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = data[min:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j, err := json.Marshal(result)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return j
|
||||||
}
|
}
|
||||||
|
|||||||
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
452
handlers/application/administration.go
Normal file → Executable file
452
handlers/application/administration.go
Normal file → Executable file
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
|
||||||
@@ -27,79 +28,83 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var (
|
||||||
accounts, err := h.services.GetAccounts()
|
wg sync.WaitGroup
|
||||||
if err != nil {
|
accounts, beneficiaries []mobilityaccountsstorage.Account
|
||||||
fmt.Println(err)
|
bookings []fleetsstorage.Booking
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
accountsErr, beneficiariesErr, bookingsErr, groupsResponseErr, eventsResponseErr, groupsBatchErr error
|
||||||
return
|
groups = []groupstorage.Group{}
|
||||||
}
|
responses = []agendastorage.Event{}
|
||||||
|
groupsResponse *groupsmanagement.GetGroupsResponse
|
||||||
beneficiaries, err := h.services.GetBeneficiaries()
|
eventsResponse *agenda.GetEventsResponse
|
||||||
if err != nil {
|
groupids = []string{}
|
||||||
fmt.Println(err)
|
groupsBatchResponse *groupsmanagement.GetGroupsBatchResponse
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
)
|
||||||
return
|
// Retrieve accounts in a goroutine
|
||||||
}
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
bookings, err := h.services.GetBookings()
|
defer wg.Done()
|
||||||
if err != nil {
|
accounts, accountsErr = h.services.GetAccounts()
|
||||||
fmt.Println(err)
|
}()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
// Retrieve beneficiaries in a goroutine
|
||||||
return
|
wg.Add(1)
|
||||||
}
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
request := &groupsmanagement.GetGroupsRequest{
|
beneficiaries, beneficiariesErr = h.services.GetBeneficiaries()
|
||||||
Namespaces: []string{"parcoursmob_organizations"},
|
}()
|
||||||
}
|
// Retrieve bookings in a goroutine
|
||||||
|
wg.Add(1)
|
||||||
resp, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
go func() {
|
||||||
if err != nil {
|
defer wg.Done()
|
||||||
fmt.Println(err)
|
bookings, bookingsErr = h.services.GetBookings()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
}()
|
||||||
return
|
// Retrieve groupsRequest in a goroutine
|
||||||
}
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
var groups = []groupstorage.Group{}
|
defer wg.Done()
|
||||||
|
request := &groupsmanagement.GetGroupsRequest{
|
||||||
for _, group := range resp.Groups {
|
Namespaces: []string{"parcoursmob_organizations"},
|
||||||
g := group.ToStorageType()
|
|
||||||
groups = append(groups, g)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(sorting.GroupsByName(groups))
|
|
||||||
////////////////////////////////////add event////////////////////////////////////////////
|
|
||||||
rresp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
|
||||||
Namespaces: []string{"parcoursmob_dispositifs"},
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
responses := []agendastorage.Event{}
|
|
||||||
|
|
||||||
groupids := []string{}
|
|
||||||
for _, e := range rresp.Events {
|
|
||||||
groupids = append(groupids, e.Owners...)
|
|
||||||
responses = append(responses, e.ToStorageType())
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(sorting.EventsByStartdate(responses))
|
|
||||||
|
|
||||||
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
|
||||||
Groupids: groupids,
|
|
||||||
})
|
|
||||||
groupps := map[string]any{}
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
for _, g := range groupsresp.Groups {
|
|
||||||
groupps[g.Id] = g.ToStorageType()
|
|
||||||
}
|
}
|
||||||
|
groupsResponse, groupsResponseErr = h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), request)
|
||||||
|
for _, group := range groupsResponse.Groups {
|
||||||
|
g := group.ToStorageType()
|
||||||
|
groups = append(groups, g)
|
||||||
|
}
|
||||||
|
sort.Sort(sorting.GroupsByName(groups))
|
||||||
|
}()
|
||||||
|
// Retrieve Events in a goroutine
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
eventsResponse, eventsResponseErr = h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
|
||||||
|
Namespaces: []string{"parcoursmob_dispositifs"},
|
||||||
|
})
|
||||||
|
for _, e := range eventsResponse.Events {
|
||||||
|
groupids = append(groupids, e.Owners...)
|
||||||
|
responses = append(responses, e.ToStorageType())
|
||||||
|
}
|
||||||
|
sort.Sort(sorting.EventsByStartdate(responses))
|
||||||
|
}()
|
||||||
|
wg.Add(1)
|
||||||
|
// Retrieve groupsBatch in a goroutine
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
groupsBatchResponse, groupsBatchErr = h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||||
|
Groupids: groupids,
|
||||||
|
})
|
||||||
|
groupps := map[string]any{}
|
||||||
|
if groupsBatchErr == nil {
|
||||||
|
for _, g := range groupsBatchResponse.Groups {
|
||||||
|
groupps[g.Id] = g.ToStorageType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
if accountsErr != nil || beneficiariesErr != nil || bookingsErr != nil || groupsResponseErr != nil || eventsResponseErr != nil {
|
||||||
|
fmt.Println(accountsErr, beneficiariesErr, bookingsErr, groupsResponseErr, eventsResponseErr, groupsBatchErr)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,22 +160,23 @@ func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r
|
|||||||
Namespace: "parcoursmob_roles",
|
Namespace: "parcoursmob_roles",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
go func() {
|
||||||
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_organization)
|
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_organization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
// Create the admin role for the organization
|
// Create the admin role for the organization
|
||||||
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
go func() {
|
||||||
if err != nil {
|
_, err = h.services.GRPC.GroupsManagement.AddGroup(context.TODO(), request_role)
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
fmt.Println(err)
|
||||||
return
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -205,165 +211,167 @@ func (h *ApplicationHandler) AdministrationGroupDisplay(w http.ResponseWriter, r
|
|||||||
func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
groupid := vars["groupid"]
|
groupid := vars["groupid"]
|
||||||
|
var (
|
||||||
|
groupresp *groupsmanagement.GetGroupResponse
|
||||||
|
accountresp *accounts.GetAccountUsernameResponse
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
groupresp, err = h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
|
Id: groupid,
|
||||||
|
Namespace: "parcoursmob_organizations",
|
||||||
|
})
|
||||||
|
|
||||||
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
if err != nil {
|
||||||
Id: groupid,
|
fmt.Println(err)
|
||||||
Namespace: "parcoursmob_organizations",
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
}()
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
go func() {
|
||||||
Username: r.FormValue("username"),
|
accountresp, err = h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
||||||
Namespace: "parcoursmob",
|
Username: r.FormValue("username"),
|
||||||
})
|
Namespace: "parcoursmob",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
// Account already exists : adding the existing account to admin list
|
||||||
|
account := accountresp.Account.ToStorageType()
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid)
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid+":admin")
|
||||||
|
|
||||||
if err == nil {
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
// Account already exists : adding the existing account to admin list
|
|
||||||
account := accountresp.Account.ToStorageType()
|
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid)
|
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), groupid, groupid+":admin")
|
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
||||||
|
context.TODO(),
|
||||||
|
&accounts.UpdateDataRequest{
|
||||||
|
Account: as,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
|
||||||
context.TODO(),
|
|
||||||
&accounts.UpdateDataRequest{
|
|
||||||
Account: as,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": groupresp.Group.ToStorageType().Data["name"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
||||||
|
data := map[string]any{
|
||||||
|
"group": groupresp.Group.ToStorageType().Data["name"],
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// Onboard now administrator
|
||||||
|
onboarding := map[string]any{
|
||||||
|
"username": r.FormValue("username"),
|
||||||
|
"group": groupid,
|
||||||
|
"admin": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
b := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key := base64.RawURLEncoding.EncodeToString(b)
|
||||||
|
|
||||||
|
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
||||||
|
|
||||||
|
data := map[string]any{
|
||||||
|
"group": groupresp.Group.ToStorageType().Data["name"],
|
||||||
|
"key": key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
||||||
return
|
return
|
||||||
} else {
|
}()
|
||||||
// Onboard now administrator
|
|
||||||
onboarding := map[string]any{
|
|
||||||
"username": r.FormValue("username"),
|
|
||||||
"group": groupid,
|
|
||||||
"admin": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
b := make([]byte, 16)
|
|
||||||
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
key := base64.RawURLEncoding.EncodeToString(b)
|
|
||||||
|
|
||||||
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": groupresp.Group.ToStorageType().Data["name"],
|
|
||||||
"key": key,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
groupid := vars["groupid"]
|
groupid := vars["groupid"]
|
||||||
|
var (
|
||||||
|
group storage.Group
|
||||||
|
)
|
||||||
|
groupCh := make(chan storage.Group)
|
||||||
|
go func() {
|
||||||
|
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
||||||
|
Id: groupid,
|
||||||
|
Namespace: "parcoursmob_organizations",
|
||||||
|
})
|
||||||
|
|
||||||
groupresp, err := h.services.GRPC.GroupsManagement.GetGroup(context.TODO(), &groupsmanagement.GetGroupRequest{
|
if err != nil {
|
||||||
Id: groupid,
|
fmt.Println(err)
|
||||||
Namespace: "parcoursmob_organizations",
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
group := groupresp.Group.ToStorageType()
|
||||||
fmt.Println(err)
|
groupCh <- group
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
}()
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
group := groupresp.Group.ToStorageType()
|
|
||||||
|
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
go func() {
|
||||||
|
group = <-groupCh
|
||||||
|
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
||||||
|
Username: r.FormValue("username"),
|
||||||
|
Namespace: "parcoursmob",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
account := accountresp.Account.ToStorageType()
|
||||||
|
account.Data["groups"] = append(account.Data["groups"].([]any), group.ID)
|
||||||
|
|
||||||
accountresp, err := h.services.GRPC.MobilityAccounts.GetAccountUsername(context.TODO(), &accounts.GetAccountUsernameRequest{
|
as, _ := accounts.AccountFromStorageType(&account)
|
||||||
Username: r.FormValue("username"),
|
|
||||||
Namespace: "parcoursmob",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err == nil {
|
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
||||||
account := accountresp.Account.ToStorageType()
|
context.TODO(),
|
||||||
account.Data["groups"] = append(account.Data["groups"].([]any), group.ID)
|
&accounts.UpdateDataRequest{
|
||||||
|
Account: as,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
data := map[string]any{
|
||||||
|
"group": group.Data["name"],
|
||||||
|
}
|
||||||
|
|
||||||
as, _ := accounts.AccountFromStorageType(&account)
|
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
|
||||||
|
}
|
||||||
|
|
||||||
_, err = h.services.GRPC.MobilityAccounts.UpdateData(
|
http.Redirect(w, r, "/app/group/settings", http.StatusFound)
|
||||||
context.TODO(),
|
|
||||||
&accounts.UpdateDataRequest{
|
|
||||||
Account: as,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
fmt.Println(err)
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": group.Data["name"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/app/group/settings", http.StatusFound)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
// Onboard now administrator
|
|
||||||
onboarding := map[string]any{
|
|
||||||
"username": r.FormValue("username"),
|
|
||||||
"group": group.ID,
|
|
||||||
"admin": false,
|
|
||||||
}
|
|
||||||
|
|
||||||
b := make([]byte, 16)
|
|
||||||
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
// Onboard now administrator
|
||||||
|
onboarding := map[string]any{
|
||||||
|
"username": r.FormValue("username"),
|
||||||
|
"group": group.ID,
|
||||||
|
"admin": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
b := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, b); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key := base64.RawURLEncoding.EncodeToString(b)
|
||||||
|
|
||||||
|
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
||||||
|
data := map[string]any{
|
||||||
|
"group": group.Data["name"],
|
||||||
|
"key": key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
key := base64.RawURLEncoding.EncodeToString(b)
|
}()
|
||||||
|
|
||||||
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
|
|
||||||
|
|
||||||
data := map[string]any{
|
|
||||||
"group": group.Data["name"],
|
|
||||||
"key": key,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/app/administration/groups/"+group.ID, http.StatusFound)
|
http.Redirect(w, r, "/app/administration/groups/"+group.ID, http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
2
handlers/application/agenda.go
Normal file → Executable file
2
handlers/application/agenda.go
Normal file → Executable file
@@ -255,7 +255,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
eventid := vars["eventid"]
|
eventid := vars["eventid"]
|
||||||
|
fmt.Println(eventid)
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := r.ParseForm(); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
|||||||
0
handlers/application/application.go
Normal file → Executable file
0
handlers/application/application.go
Normal file → Executable file
170
handlers/application/beneficiaries.go
Normal file → Executable file
170
handlers/application/beneficiaries.go
Normal file → Executable file
@@ -20,7 +20,10 @@ import (
|
|||||||
profilepictures "git.coopgo.io/coopgo-apps/parcoursmob/utils/profile-pictures"
|
profilepictures "git.coopgo.io/coopgo-apps/parcoursmob/utils/profile-pictures"
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
||||||
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
|
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"
|
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"
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
@@ -41,6 +44,67 @@ type BeneficiariesForm struct {
|
|||||||
Gender string `json:"gender"`
|
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) {
|
func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
accounts, err := h.beneficiaries(r)
|
accounts, err := h.beneficiaries(r)
|
||||||
@@ -135,6 +199,38 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subscriptionrequest := &agenda.GetSubscriptionByUserRequest{
|
||||||
|
Subscriber: beneficiaryID,
|
||||||
|
}
|
||||||
|
|
||||||
|
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("icii")
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
events := []agendastorage.Event{}
|
||||||
|
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||||
|
fmt.Println(subcriptionresp)
|
||||||
|
for _, e := range subcriptionresp.Subscription {
|
||||||
|
eventresquest := &agenda.GetEventRequest{
|
||||||
|
Id: e.Eventid,
|
||||||
|
}
|
||||||
|
fmt.Println(eventresquest)
|
||||||
|
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("iciiiiii")
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
events = append(events, eventresp.Event.ToStorageType())
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sorting.EventsByStartdate(events))
|
||||||
|
|
||||||
bookingsrequest := &fleets.GetDriverBookingsRequest{
|
bookingsrequest := &fleets.GetDriverBookingsRequest{
|
||||||
Driver: beneficiaryID,
|
Driver: beneficiaryID,
|
||||||
}
|
}
|
||||||
@@ -145,12 +241,80 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
bookings := []any{}
|
bookings := []fleetsstorage.Booking{}
|
||||||
|
|
||||||
for _, b := range bookingsresp.Bookings {
|
for _, b := range bookingsresp.Bookings {
|
||||||
bookings = append(bookings, b.ToStorageType())
|
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{
|
groupsrequest := &groupsmanagement.GetGroupsRequest{
|
||||||
Namespaces: []string{"parcoursmob_organizations"},
|
Namespaces: []string{"parcoursmob_organizations"},
|
||||||
Member: beneficiaryID,
|
Member: beneficiaryID,
|
||||||
@@ -169,7 +333,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
|
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
|
||||||
file_types_map := h.config.GetStringMapString("storage.files.file_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) {
|
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -333,6 +497,8 @@ func filterAccount(r *http.Request, a *mobilityaccounts.Account) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func BeneficiariesEventList()
|
||||||
|
|
||||||
func (h *ApplicationHandler) beneficiaries(r *http.Request) ([]mobilityaccountsstorage.Account, error) {
|
func (h *ApplicationHandler) beneficiaries(r *http.Request) ([]mobilityaccountsstorage.Account, error) {
|
||||||
var accounts = []mobilityaccountsstorage.Account{}
|
var accounts = []mobilityaccountsstorage.Account{}
|
||||||
g := r.Context().Value(identification.GroupKey)
|
g := r.Context().Value(identification.GroupKey)
|
||||||
|
|||||||
6
handlers/application/dashboard.go
Normal file → Executable file
6
handlers/application/dashboard.go
Normal file → Executable file
@@ -68,8 +68,10 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
|||||||
Mindate: timestamppb.Now(),
|
Mindate: timestamppb.Now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, e := range eventsresp.Events {
|
if err == nil {
|
||||||
events = append(events, e.ToStorageType())
|
for _, e := range eventsresp.Events {
|
||||||
|
events = append(events, e.ToStorageType())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(sorting.EventsByStartdate(events))
|
sort.Sort(sorting.EventsByStartdate(events))
|
||||||
|
|||||||
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
157
handlers/application/journeys.go
Normal file → Executable file
157
handlers/application/journeys.go
Normal file → Executable file
@@ -27,7 +27,14 @@ var Arrive any
|
|||||||
|
|
||||||
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
var (
|
||||||
|
journeys_results *navitia.JourneyResults
|
||||||
|
carpool_results any
|
||||||
|
vehicle_results []any
|
||||||
|
)
|
||||||
|
vehiclech := make(chan []any, 1)
|
||||||
|
navitiaCh := make(chan *navitia.JourneyResults, 1)
|
||||||
|
carpoolCh := make(chan any, 1)
|
||||||
locTime, errTime := time.LoadLocation("Europe/Paris")
|
locTime, errTime := time.LoadLocation("Europe/Paris")
|
||||||
if errTime != nil {
|
if errTime != nil {
|
||||||
fmt.Println("Loading timezone location Europe/Paris error : ")
|
fmt.Println("Loading timezone location Europe/Paris error : ")
|
||||||
@@ -70,91 +77,101 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
|
|||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
journeysRequest := func() {
|
||||||
|
//TODO make it a library
|
||||||
|
session, _ := navitia.NewCustom(
|
||||||
|
h.config.GetString("services.navitia.api_key"),
|
||||||
|
"https://api.navitia.io/v1",
|
||||||
|
&http.Client{})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
navitiaCh <- nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request := navitia.JourneyRequest{
|
||||||
|
From: types.ID(fmt.Sprintf("%f", departuregeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", departuregeo.Geometry.Point[1])),
|
||||||
|
To: types.ID(fmt.Sprintf("%f", destinationgeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", destinationgeo.Geometry.Point[1])),
|
||||||
|
Date: departuredatetime.Add(-2 * time.Hour),
|
||||||
|
DateIsArrival: false, //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
journeys, err = session.Journeys(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
// w.WriteHeader(http.StatusBadRequest)
|
||||||
|
// return
|
||||||
|
}
|
||||||
|
navitiaCh <- journeys
|
||||||
|
|
||||||
//TODO make it a library
|
|
||||||
session, _ := navitia.NewCustom(
|
|
||||||
h.config.GetString("services.navitia.api_key"),
|
|
||||||
"https://api.navitia.io/v1",
|
|
||||||
&http.Client{})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
request := navitia.JourneyRequest{
|
|
||||||
From: types.ID(fmt.Sprintf("%f", departuregeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", departuregeo.Geometry.Point[1])),
|
|
||||||
To: types.ID(fmt.Sprintf("%f", destinationgeo.Geometry.Point[0]) + ";" + fmt.Sprintf("%f", destinationgeo.Geometry.Point[1])),
|
|
||||||
Date: departuredatetime.Add(-2 * time.Hour),
|
|
||||||
DateIsArrival: false, //TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
journeys, err = session.Journeys(context.Background(), request)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
// w.WriteHeader(http.StatusBadRequest)
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
|
|
||||||
//CARPOOL
|
//CARPOOL
|
||||||
// carpoolrequest := fmt.Sprintf(
|
carpoolRequest := func() {
|
||||||
// "https://api.rdex.ridygo.fr/journeys.json?p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
|
||||||
// departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
|
||||||
// destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
|
||||||
// departuredatetime.Format("2006-01-02"), departuredatetime.Add(24*time.Hour).Format("2006-01-02"))
|
|
||||||
carpoolrequest := "https://api.rdex.ridygo.fr/journeys.json"
|
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", carpoolrequest, nil)
|
req, err := http.NewRequest("GET", carpoolrequest, nil)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req.URL.RawQuery = fmt.Sprintf(
|
|
||||||
"p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
|
||||||
departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
|
||||||
destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
|
||||||
departuredatetime.Format("2006-01-02"), departuredatetime.Format("2006-01-02"))
|
|
||||||
|
|
||||||
req.Header.Set("X-API-KEY", "123456")
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil && resp.StatusCode == http.StatusOK {
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(&carpoolresults)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if carpoolresults == nil {
|
req.URL.RawQuery = fmt.Sprintf(
|
||||||
|
"p[driver][state]=1&frequency=punctual&p[passenger][state]=0&p[from][latitude]=%f&p[from][longitude]=%f&p[to][latitude]=%f&p[to][longitude]=%f&p[outward][mindate]=%s&p[outward][maxdate]=%s",
|
||||||
|
departuregeo.Geometry.Point[1], departuregeo.Geometry.Point[0],
|
||||||
|
destinationgeo.Geometry.Point[1], destinationgeo.Geometry.Point[0],
|
||||||
|
departuredatetime.Format("2006-01-02"), departuredatetime.Format("2006-01-02"))
|
||||||
|
|
||||||
|
req.Header.Set("X-API-KEY", "123456")
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&carpoolresults)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if carpoolresults == nil {
|
||||||
|
carpoolresults = []any{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
carpoolresults = []any{}
|
carpoolresults = []any{}
|
||||||
}
|
}
|
||||||
} else {
|
carpoolCh <- carpoolresults
|
||||||
carpoolresults = []any{}
|
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Vehicles
|
// Vehicles
|
||||||
|
vehicleRequest := func() {
|
||||||
vehiclerequest := &fleets.GetVehiclesRequest{
|
vehiclerequest := &fleets.GetVehiclesRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
}
|
|
||||||
vehicleresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), vehiclerequest)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, vehicle := range vehicleresp.Vehicles {
|
|
||||||
v := vehicle.ToStorageType()
|
|
||||||
if v.Free(departuredatetime.Add(-24*time.Hour), departuredatetime.Add(168*time.Hour)) {
|
|
||||||
vehicles = append(vehicles, v)
|
|
||||||
}
|
}
|
||||||
|
vehicleresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), vehiclerequest)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
for _, vehicle := range vehicleresp.Vehicles {
|
||||||
|
v := vehicle.ToStorageType()
|
||||||
|
if v.Free(departuredatetime.Add(-24*time.Hour), departuredatetime.Add(168*time.Hour)) {
|
||||||
|
vehicles = append(vehicles, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vehiclech <- vehicles
|
||||||
}
|
}
|
||||||
|
go journeysRequest()
|
||||||
|
go carpoolRequest()
|
||||||
|
go vehicleRequest()
|
||||||
|
carpool_results = <-carpoolCh
|
||||||
|
journeys_results = <-navitiaCh
|
||||||
|
vehicle_results = <-vehiclech
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.JourneysSearch(w, r, carpoolresults, journeys, vehicles, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
h.Renderer.JourneysSearch(w, r, carpool_results, journeys_results, vehicle_results, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupsModule []groupstorage.Group
|
type GroupsModule []groupstorage.Group
|
||||||
|
|||||||
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
63
handlers/application/vehicles-management.go
Normal file → Executable file
63
handlers/application/vehicles-management.go
Normal file → Executable file
@@ -302,12 +302,15 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
|||||||
}
|
}
|
||||||
|
|
||||||
alternativerequest := &fleets.GetVehiclesRequest{
|
alternativerequest := &fleets.GetVehiclesRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
Types: []string{booking.Vehicle.Type},
|
Types: []string{booking.Vehicle.Type},
|
||||||
Administrators: booking.Vehicle.Administrators,
|
Administrators: booking.Vehicle.Administrators,
|
||||||
AvailabilityFrom: timestamppb.New(booking.Startdate),
|
//AvailabilityFrom: timestamppb.New(booking.Startdate),
|
||||||
AvailabilityTo: timestamppb.New(booking.Enddate.Add(24 * time.Hour)),
|
//AvailabilityTo: timestamppb.New(booking.Startdate.Add(After(time.Now()))),
|
||||||
}
|
}
|
||||||
|
// if alternativerequest.AvailabilityFrom.After(time.Now()) {
|
||||||
|
// fmt.Println("loooool")
|
||||||
|
// }
|
||||||
|
|
||||||
alternativeresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), alternativerequest)
|
alternativeresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), alternativerequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -319,11 +322,48 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
|||||||
for _, a := range alternativeresp.Vehicles {
|
for _, a := range alternativeresp.Vehicles {
|
||||||
alternatives = append(alternatives, a.ToStorageType())
|
alternatives = append(alternatives, a.ToStorageType())
|
||||||
}
|
}
|
||||||
|
/***************************************add list of vehicules ******************************************/
|
||||||
|
requesst := &fleets.GetVehiclesRequest{
|
||||||
|
Namespaces: []string{"parcoursmob"},
|
||||||
|
}
|
||||||
|
ressp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), requesst)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicles := []fleetsstorage.Vehicle{}
|
||||||
|
bookings := []fleetsstorage.Booking{}
|
||||||
|
vehicles_map := map[string]fleetsstorage.Vehicle{}
|
||||||
|
|
||||||
|
for _, vehicle := range ressp.Vehicles {
|
||||||
|
if filterVehicle(r, vehicle) {
|
||||||
|
v := vehicle.ToStorageType()
|
||||||
|
vehicleBookings := []fleetsstorage.Booking{}
|
||||||
|
for _, b := range v.Bookings {
|
||||||
|
if b.Status() != fleetsstorage.StatusOld {
|
||||||
|
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
|
||||||
|
bookings = append(bookings, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if b.Unavailableto.After(time.Now()) {
|
||||||
|
vehicleBookings = append(vehicleBookings, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v.Bookings = vehicleBookings
|
||||||
|
vehicles = append(vehicles, v)
|
||||||
|
vehicles_map[v.ID] = v
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||||
|
//sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
/*********************************************************************************/
|
||||||
documents := h.filestorage.List(filestorage.PREFIX_BOOKINGS + "/" + bookingid)
|
documents := h.filestorage.List(filestorage.PREFIX_BOOKINGS + "/" + bookingid)
|
||||||
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||||
|
|
||||||
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives)
|
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives, vehicles, vehicles_map, bookings)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -553,8 +593,17 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
|
|||||||
Data: datapb,
|
Data: datapb,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
requestt := &fleets.DeleteBookingRequest{
|
||||||
|
Id: bookingid,
|
||||||
|
}
|
||||||
|
_, errr := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
||||||
|
|
||||||
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
if errr != nil {
|
||||||
|
fmt.Println(errr)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err := h.services.GRPC.Fleets.DeleteBooking(context.TODO(), requestt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|||||||
5
handlers/application/vehicles.go
Normal file → Executable file
5
handlers/application/vehicles.go
Normal file → Executable file
@@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) VehiclesSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
fmt.Println("invoked")
|
||||||
var beneficiary mobilityaccountsstorage.Account
|
var beneficiary mobilityaccountsstorage.Account
|
||||||
|
|
||||||
beneficiarydocuments := []filestorage.FileInfo{}
|
beneficiarydocuments := []filestorage.FileInfo{}
|
||||||
@@ -349,6 +349,9 @@ func (h ApplicationHandler) VehiclesBookingsList(w http.ResponseWriter, r *http.
|
|||||||
vehicles, _ := h.services.GetVehiclesMap()
|
vehicles, _ := h.services.GetVehiclesMap()
|
||||||
groups, _ := h.services.GetGroupsMap()
|
groups, _ := h.services.GetGroupsMap()
|
||||||
|
|
||||||
|
// fmt.Println("bookings : ", bookings)
|
||||||
|
// fmt.Println("vehicles : ", vehicles)
|
||||||
|
// fmt.Println("groups : ", groups)
|
||||||
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
|
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
4
handlers/auth/onboarding.go
Normal file → Executable file
4
handlers/auth/onboarding.go
Normal file → Executable file
@@ -40,8 +40,8 @@ func (h *AuthHandler) Onboarding(w http.ResponseWriter, r *http.Request) {
|
|||||||
display_name := fmt.Sprint(r.FormValue("first_name")) + " " + fmt.Sprint(r.FormValue("last_name"))
|
display_name := fmt.Sprint(r.FormValue("first_name")) + " " + fmt.Sprint(r.FormValue("last_name"))
|
||||||
account := &ma.Account{
|
account := &ma.Account{
|
||||||
Authentication: ma.AccountAuth{
|
Authentication: ma.AccountAuth{
|
||||||
Local: ma.LocalAuth{
|
Local: &ma.LocalAuth{
|
||||||
Username: onboardingmap["username"].(string),
|
Username: onboardingmap["username"].(*string),
|
||||||
Password: r.FormValue("password"),
|
Password: r.FormValue("password"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
0
handlers/exports/fleets.go
Normal file → Executable file
0
handlers/exports/fleets.go
Normal file → Executable file
11
main.go
Normal file → Executable file
11
main.go
Normal file → Executable file
@@ -19,27 +19,26 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := ReadConfig()
|
cfg, err := ReadConfig()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
address = cfg.GetString("server.listen")
|
//address = cfg.GetString("server.listen")
|
||||||
service_name = cfg.GetString("service_name")
|
service_name = cfg.GetString("service_name")
|
||||||
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)
|
||||||
@@ -172,11 +171,9 @@ func main() {
|
|||||||
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: "0.0.0.0:9000",
|
||||||
WriteTimeout: 15 * time.Second,
|
WriteTimeout: 15 * time.Second,
|
||||||
ReadTimeout: 15 * time.Second,
|
ReadTimeout: 15 * time.Second,
|
||||||
}
|
}
|
||||||
|
|||||||
0
renderer/administration.go
Normal file → Executable file
0
renderer/administration.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
5
renderer/beneficiaries.go
Normal file → Executable file
5
renderer/beneficiaries.go
Normal file → Executable file
@@ -5,6 +5,7 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ type BeneficiariesDisplayState struct {
|
|||||||
Beneficiary any
|
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")
|
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||||
state.ViewState = map[string]any{
|
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,
|
"file_types_map": file_types_map,
|
||||||
"documents": documents,
|
"documents": documents,
|
||||||
"organizations": organizations,
|
"organizations": organizations,
|
||||||
|
"event": event,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("beneficiaries_display", w, r, files, state)
|
renderer.Render("beneficiaries_display", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
9
renderer/vehicle-management.go
Normal file → Executable file
9
renderer/vehicle-management.go
Normal file → Executable file
@@ -64,7 +64,7 @@ func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Req
|
|||||||
renderer.Render("fleet display vehicle", w, r, files, state)
|
renderer.Render("fleet display vehicle", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, r *http.Request, booking any, vehicle any, beneficiary any, group any, documents []filestorage.FileInfo, file_types_map map[string]string, alternative_vehicles []any) {
|
func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, r *http.Request, booking any, vehicle any, beneficiary any, group any, documents []filestorage.FileInfo, file_types_map map[string]string, alternative_vehicles []any, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.booking_display.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.booking_display.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
@@ -75,6 +75,9 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter,
|
|||||||
"documents": documents,
|
"documents": documents,
|
||||||
"file_types_map": file_types_map,
|
"file_types_map": file_types_map,
|
||||||
"alternative_vehicles": alternative_vehicles,
|
"alternative_vehicles": alternative_vehicles,
|
||||||
|
"vehicles": vehicles,
|
||||||
|
"bookings": bookings,
|
||||||
|
"vehicles_map": vehicles_map,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
renderer.Render("vehicles search", w, r, files, state)
|
||||||
@@ -84,9 +87,9 @@ func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Reques
|
|||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"booking": booking,
|
"booking": booking,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("vehicule unbooking", w, r, files, state)
|
renderer.Render("vehicule unbooking", w, r, files, state)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
0
renderer/vehicles.go
Normal file → Executable file
0
renderer/vehicles.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
11
services/fleets.go
Normal file → Executable file
11
services/fleets.go
Normal file → Executable file
@@ -2,6 +2,7 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
|
"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) {
|
func (s *ServicesHandler) GetVehiclesMap() (vehicles map[string]storage.Vehicle, err error) {
|
||||||
vehicles = map[string]storage.Vehicle{}
|
vehicles = map[string]storage.Vehicle{}
|
||||||
|
|
||||||
request := &fleets.GetVehiclesRequest{}
|
request := &fleets.GetVehiclesRequest{
|
||||||
|
Namespaces: []string{"parcoursmob"},
|
||||||
|
}
|
||||||
resp, err := s.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
resp, err := s.GRPC.Fleets.GetVehicles(context.TODO(), request)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
} else {
|
||||||
for _, vehicle := range resp.Vehicles {
|
for _, vehicle := range resp.Vehicles {
|
||||||
vehicles[vehicle.Id] = vehicle.ToStorageType()
|
vehicles[vehicle.Id] = vehicle.ToStorageType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return vehicles, err
|
||||||
}
|
}
|
||||||
|
|||||||
0
services/groupsmanagement.go
Normal file → Executable file
0
services/groupsmanagement.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
1
themes
Submodule
1
themes
Submodule
Submodule themes added at db4c22699e
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
1
utils/storage/badger.go
Normal file
1
utils/storage/badger.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package storage
|
||||||
0
utils/storage/cache.go
Normal file → Executable file
0
utils/storage/cache.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
@@ -74,6 +74,7 @@ func NewEtcdHandler(cfg *viper.Viper) (*EtcdHandler, error) {
|
|||||||
Password: password,
|
Password: password,
|
||||||
DialTimeout: 5 * time.Second,
|
DialTimeout: 5 * time.Second,
|
||||||
})
|
})
|
||||||
|
fmt.Println(endpoints,prefix,username,password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
0
utils/storage/files.go
Normal file → Executable file
0
utils/storage/files.go
Normal file → Executable file
2
utils/storage/kv.go
Normal file → Executable file
2
utils/storage/kv.go
Normal file → Executable file
@@ -15,4 +15,6 @@ type KVHandler interface {
|
|||||||
|
|
||||||
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
func NewKVHandler(cfg *viper.Viper) (KVHandler, error) {
|
||||||
return NewEtcdHandler(cfg)
|
return NewEtcdHandler(cfg)
|
||||||
|
return nil, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
Reference in New Issue
Block a user