Compare commits
37 Commits
eaf866154e
...
silvermobi
| Author | SHA1 | Date | |
|---|---|---|---|
| a04e53b47f | |||
| 726584b0fb | |||
| 50e939c455 | |||
| 3ad5711ae7 | |||
| 7a648ccd1b | |||
| a8ef3b758f | |||
| f43d02c762 | |||
| 163ffefbfb | |||
| 8f21248c29 | |||
| e811ea7a07 | |||
| 4f1cc21aeb | |||
| efaa4f9f0d | |||
| 0cfa78e938 | |||
| 5a89c8b24a | |||
| de060b2ecf | |||
| 13a34ad124 | |||
| 127a3c44bf | |||
| 66c2c31090 | |||
| c03fcb31d6 | |||
| 5593f8d563 | |||
| 4232bca50d | |||
| 0e3da8c8f6 | |||
| fa6faa51c3 | |||
| f4ce62543f | |||
| d8771c67d8 | |||
| 9f9ab9f1c0 | |||
| cf792f2e7c | |||
| 93a9d712c7 | |||
| 883453f4a4 | |||
| 982d07e8ad | |||
| b0129aae79 | |||
| ea400eefcd | |||
| ebad682a65 | |||
| 41d5f02879 | |||
| cc27f9ef1d | |||
| bfc39c22f7 | |||
| dc08de2419 |
@@ -1,81 +0,0 @@
|
|||||||
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}}
|
|
||||||
132
go.mod
132
go.mod
@@ -1,42 +1,53 @@
|
|||||||
module git.coopgo.io/coopgo-apps/parcoursmob
|
module git.coopgo.io/coopgo-apps/parcoursmob
|
||||||
|
|
||||||
go 1.18
|
go 1.22
|
||||||
|
|
||||||
// replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
|
toolchain go1.23.2
|
||||||
|
|
||||||
// replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/
|
replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
|
||||||
|
|
||||||
// replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
|
replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/
|
||||||
|
|
||||||
// replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
|
replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
|
||||||
|
|
||||||
|
replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
|
||||||
|
|
||||||
|
replace git.coopgo.io/sbouaram/solidarity-service => ../../coopgo-platform/solidarity-service/
|
||||||
|
|
||||||
|
replace git.coopgo.io/coopgo-apps/silvermobi => ../../coopgo-apps/silvermobi/
|
||||||
|
|
||||||
|
replace git.coopgo.io/coopgo-platform/routing-service => ../../coopgo-platform/routing-service/
|
||||||
|
|
||||||
// replace git.coopgo.io/coopgo-platform/emailing => ../../coopgo-platform/emailing/
|
// replace git.coopgo.io/coopgo-platform/emailing => ../../coopgo-platform/emailing/
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/coreos/go-oidc v2.2.1+incompatible
|
github.com/coreos/go-oidc v2.2.1+incompatible
|
||||||
github.com/fogleman/gg v1.3.0
|
github.com/fogleman/gg v1.3.0
|
||||||
github.com/go-playground/validator/v10 v10.11.0
|
github.com/go-playground/validator/v10 v10.12.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.1
|
||||||
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.15.0
|
github.com/spf13/viper v1.18.2
|
||||||
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.6
|
go.etcd.io/etcd/client/v3 v3.5.10
|
||||||
golang.org/x/image v0.5.0
|
golang.org/x/image v0.5.0
|
||||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
|
golang.org/x/oauth2 v0.23.0
|
||||||
google.golang.org/grpc v1.52.0
|
google.golang.org/grpc v1.68.1
|
||||||
google.golang.org/protobuf v1.31.0
|
google.golang.org/protobuf v1.34.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.coopgo.io/coopgo-platform/agenda v1.0.0
|
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 v1.0.0
|
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
|
||||||
git.coopgo.io/coopgo-platform/groups-management v1.0.0
|
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
|
||||||
git.coopgo.io/coopgo-platform/mobility-accounts v1.0.5
|
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230430115320-f5bb2e7c2c26
|
||||||
|
git.coopgo.io/coopgo-platform/routing-service v0.0.0-20230403183358-4d30329f06be
|
||||||
|
git.coopgo.io/sbouaram/solidarity-service v0.0.0-00010101000000-000000000000
|
||||||
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/rs/zerolog v1.33.0
|
||||||
github.com/xuri/excelize/v2 v2.7.1
|
github.com/xuri/excelize/v2 v2.7.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,33 +55,28 @@ require (
|
|||||||
ariga.io/atlas v0.13.1 // indirect
|
ariga.io/atlas v0.13.1 // indirect
|
||||||
github.com/agext/levenshtein v1.2.1 // indirect
|
github.com/agext/levenshtein v1.2.1 // indirect
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
|
|
||||||
github.com/cespare/xxhash v1.1.0 // indirect
|
|
||||||
github.com/coreos/go-semver v0.3.0 // indirect
|
github.com/coreos/go-semver v0.3.0 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
|
||||||
github.com/go-openapi/inflect v0.19.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.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // 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.3 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/golang/snappy v0.0.1 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/go-cmp v0.5.9 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/gorilla/csrf v1.7.1 // indirect
|
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/hashicorp/hcl/v2 v2.16.2 // indirect
|
github.com/hashicorp/hcl/v2 v2.16.2 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.15.9 // indirect
|
github.com/klauspost/compress v1.17.7 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.2 // indirect
|
||||||
github.com/lib/pq v1.10.9 // indirect
|
github.com/lib/pq v1.10.9 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mattn/goveralls v0.0.6 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // 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
|
||||||
@@ -80,55 +86,49 @@ require (
|
|||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||||
github.com/ory/fosite v0.42.2 // indirect
|
github.com/paulmach/orb v0.11.1 // indirect
|
||||||
github.com/ory/go-acc v0.2.6 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/ory/go-convenience v0.1.0 // indirect
|
|
||||||
github.com/ory/viper v1.7.5 // 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.6 // 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
|
||||||
github.com/richardlehane/msoleps v1.0.3 // indirect
|
github.com/richardlehane/msoleps v1.0.3 // indirect
|
||||||
github.com/rs/xid v1.4.0 // indirect
|
github.com/rs/xid v1.5.0 // indirect
|
||||||
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
|
github.com/sagikazarmark/slog-shim v0.1.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.9.3 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/cobra v1.0.0 // indirect
|
github.com/spf13/cast v1.6.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.2 // indirect
|
github.com/subosito/gotenv v1.6.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/twpayne/go-polyline v1.1.1 // indirect
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
github.com/xdg-go/scram v1.1.1 // indirect
|
github.com/xdg-go/scram v1.1.2 // indirect
|
||||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||||
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
|
||||||
github.com/zclconf/go-cty v1.12.1 // indirect
|
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.11.4 // indirect
|
go.mongodb.org/mongo-driver v1.15.0 // indirect
|
||||||
go.uber.org/atomic v1.9.0 // indirect
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.21.0 // indirect
|
go.uber.org/zap v1.21.0 // indirect
|
||||||
golang.org/x/crypto v0.8.0 // indirect
|
golang.org/x/crypto v0.27.0 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/net v0.29.0 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/sys v0.28.0 // indirect
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
golang.org/x/text v0.18.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // 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
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -14,13 +13,11 @@ import (
|
|||||||
formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators"
|
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/identification"
|
||||||
"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"
|
|
||||||
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
||||||
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
agendastorage "git.coopgo.io/coopgo-platform/agenda/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"
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"google.golang.org/protobuf/types/known/structpb"
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
@@ -150,52 +147,17 @@ func (h *ApplicationHandler) AgendaCreateEvent(w http.ResponseWriter, r *http.Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp, err := h.services.GRPC.Agenda.CreateEvent(context.TODO(), request)
|
resp, err := h.services.GRPC.Agenda.CreateEvent(context.TODO(), request)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
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)
|
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound)
|
||||||
return
|
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) {
|
func (h *ApplicationHandler) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -275,13 +237,7 @@ 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) {
|
func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -729,61 +685,3 @@ func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
h.Renderer.AgendaHistoryEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
|
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,9 @@ import (
|
|||||||
"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"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"google.golang.org/protobuf/types/known/structpb"
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
@@ -328,7 +331,84 @@ 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, events_list)
|
if r.Method == "POST" {
|
||||||
|
|
||||||
|
request := &mobilityaccounts.GetAccountRequest{
|
||||||
|
Id: beneficiaryID,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.MobilityAccounts.GetAccount(context.TODO(), request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fields := resp.Account.Data.Fields
|
||||||
|
|
||||||
|
firstName, ok := fields["first_name"]
|
||||||
|
if !ok {
|
||||||
|
fmt.Println("first_name not found in the data")
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
lastName, ok := fields["last_name"]
|
||||||
|
if !ok {
|
||||||
|
fmt.Println("last_name not found in the data")
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
passenger := solidarity_service.PassengerTripRequest {
|
||||||
|
Passenger : &solidarity_service.User {
|
||||||
|
Id: resp.Account.Id,
|
||||||
|
FirstName: firstName.Kind.(*structpb.Value_StringValue).StringValue,
|
||||||
|
LastName: lastName.Kind.(*structpb.Value_StringValue).StringValue,
|
||||||
|
Alias: " ",
|
||||||
|
Grade: 0,
|
||||||
|
Picture: " ",
|
||||||
|
Gender: " ",
|
||||||
|
VerifiedIdentity: true,
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
silvermobiPassenger, err := h.services.GRPC.SolidarityService.SetPassengerTrip(context.TODO(), &passenger)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t := silvermobiPassenger
|
||||||
|
t = t
|
||||||
|
}
|
||||||
|
|
||||||
|
solidarity_booking := &solidarity_service.GetBookingsByStatusRequest{
|
||||||
|
Status : 0, /// 0 : pending
|
||||||
|
UserId : beneficiaryID,
|
||||||
|
Type: 1, /// 1 : passenger
|
||||||
|
}
|
||||||
|
|
||||||
|
solidarity_bookings_object, err := h.services.GRPC.SolidarityService.GetBookingsByStatus(context.TODO(), solidarity_booking)
|
||||||
|
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var solidarity_bookings_list []any
|
||||||
|
|
||||||
|
for _, o := range solidarity_bookings_object.Booking {
|
||||||
|
if(o.PassengerPickupDate != nil){
|
||||||
|
solidarity_bookings_list = append(solidarity_bookings_list, o)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list, solidarity_bookings_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -446,8 +526,6 @@ func (h *ApplicationHandler) BeneficiaryDocuments(w http.ResponseWriter, r *http
|
|||||||
"name": document_name,
|
"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 {
|
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)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import (
|
|||||||
"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"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
|
||||||
fleetstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -78,18 +76,6 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
sort.Sort(sorting.EventsByStartdate(events))
|
sort.Sort(sorting.EventsByStartdate(events))
|
||||||
|
|
||||||
bookings := []fleetstorage.Booking{}
|
h.Renderer.Dashboard(w, r, accounts, count, count_members, events)
|
||||||
|
|
||||||
bookingsresp, err := h.services.GRPC.Fleets.GetBookings(context.TODO(), &fleets.GetBookingsRequest{
|
|
||||||
Namespaces: []string{"parcoursmob_dispositifs"},
|
|
||||||
})
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
for _, b := range bookingsresp.Bookings {
|
|
||||||
bookings = append(bookings, b.ToStorageType())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h.Renderer.Dashboard(w, r, accounts, count, count_members, events, bookings)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,27 +14,40 @@ import (
|
|||||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
groupstorage "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"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
models "git.coopgo.io/coopgo-apps/parcoursmob/utils/models"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
geojson "github.com/paulmach/go.geojson"
|
geojson "github.com/paulmach/go.geojson"
|
||||||
"gitlab.scity.coop/maas/navitia-golang"
|
|
||||||
"gitlab.scity.coop/maas/navitia-golang/types"
|
//"gitlab.scity.coop/maas/navitia-golang"
|
||||||
|
//"gitlab.scity.coop/maas/navitia-golang/types"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"google.golang.org/protobuf/types/known/structpb"
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Depart any
|
var Depart any
|
||||||
var Arrive any
|
var Arrive any
|
||||||
|
|
||||||
|
|
||||||
|
var SolidarityData models.SolidarityTransport
|
||||||
|
|
||||||
|
|
||||||
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 (
|
var (
|
||||||
journeys_results *navitia.JourneyResults
|
//journeys_results *navitia.JourneyResults
|
||||||
carpool_results any
|
carpool_results any
|
||||||
vehicle_results []any
|
vehicle_results []any
|
||||||
|
solidarity_results models.SolidarityTransport
|
||||||
)
|
)
|
||||||
vehiclech := make(chan []any, 1)
|
vehiclech := make(chan []any, 1)
|
||||||
navitiaCh := make(chan *navitia.JourneyResults, 1)
|
//navitiaCh := make(chan *navitia.JourneyResults, 1)
|
||||||
carpoolCh := make(chan any, 1)
|
carpoolCh := make(chan any, 1)
|
||||||
|
solidarityCh := make(chan models.SolidarityTransport, 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 : ")
|
||||||
@@ -54,9 +67,11 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
|
|||||||
var (
|
var (
|
||||||
departuregeo *geojson.Feature
|
departuregeo *geojson.Feature
|
||||||
destinationgeo *geojson.Feature
|
destinationgeo *geojson.Feature
|
||||||
journeys *navitia.JourneyResults
|
//journeys *navitia.JourneyResults
|
||||||
carpoolresults any
|
carpoolresults any
|
||||||
vehicles = []any{}
|
vehicles = []any{}
|
||||||
|
drivers []any
|
||||||
|
accounts []any
|
||||||
)
|
)
|
||||||
|
|
||||||
if departuredate != "" && departuretime != "" && departure != "" && destination != "" {
|
if departuredate != "" && departuretime != "" && departure != "" && destination != "" {
|
||||||
@@ -78,35 +93,35 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
journeysRequest := func() {
|
// journeysRequest := func() {
|
||||||
//TODO make it a library
|
// //TODO make it a library
|
||||||
session, _ := navitia.NewCustom(
|
// session, _ := navitia.NewCustom(
|
||||||
h.config.GetString("services.navitia.api_key"),
|
// h.config.GetString("services.navitia.api_key"),
|
||||||
"https://api.navitia.io/v1",
|
// "https://api.navitia.io/v1",
|
||||||
&http.Client{})
|
// &http.Client{})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fmt.Println(err)
|
// 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)
|
// w.WriteHeader(http.StatusBadRequest)
|
||||||
|
// navitiaCh <- nil
|
||||||
// return
|
// return
|
||||||
}
|
// }
|
||||||
navitiaCh <- journeys
|
|
||||||
|
|
||||||
}
|
// 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
|
||||||
|
|
||||||
|
// }
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//CARPOOL
|
//CARPOOL
|
||||||
carpoolRequest := func() {
|
carpoolRequest := func() {
|
||||||
@@ -163,15 +178,117 @@ func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
vehiclech <- vehicles
|
vehiclech <- vehicles
|
||||||
}
|
}
|
||||||
go journeysRequest()
|
|
||||||
go carpoolRequest()
|
///////////////////////////////////////////////////////////////////////////////////////////////////:::
|
||||||
go vehicleRequest()
|
//solidarity-service
|
||||||
carpool_results = <-carpoolCh
|
solidarityRequest := func() {
|
||||||
journeys_results = <-navitiaCh
|
timestamp := timestamppb.New(departuredatetime)
|
||||||
vehicle_results = <-vehiclech
|
PassengerId := r.FormValue("passenger_id")
|
||||||
|
driverId := r.FormValue("driver_id")
|
||||||
|
id := uuid.New().String()
|
||||||
|
|
||||||
|
type Booking struct {
|
||||||
|
bookingData solidarity_service.CreateBookingSolidarityRequest
|
||||||
|
}
|
||||||
|
var BookingData Booking
|
||||||
|
|
||||||
|
accountsRequest, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.JourneysSearch(w, r, carpool_results, journeys_results, vehicle_results, searched, departuregeo, destinationgeo, departuredate, departuretime)
|
for _, o := range accountsRequest.Passenger {
|
||||||
|
accounts = append(accounts, o)
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
|
||||||
|
|
||||||
|
request := solidarity_service.DriverJourneysRequest{
|
||||||
|
DepartureDate: timestamp,
|
||||||
|
Departure: &solidarity_service.Feature{
|
||||||
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
|
Long: departuregeo.Geometry.Point[1],
|
||||||
|
Address: departure,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
driversRequest, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), &request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, o := range driversRequest.DriverJourneys {
|
||||||
|
drivers = append(drivers, o)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Method == "POST" {
|
||||||
|
|
||||||
|
BookingData.bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||||
|
Booking : &solidarity_service.BookingSolidarityRequest {
|
||||||
|
Id: id,
|
||||||
|
DriverId: driverId,
|
||||||
|
PassengerId: PassengerId,
|
||||||
|
DepartureAddress: &solidarity_service.Feature{
|
||||||
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
|
Long: departuregeo.Geometry.Point[1],
|
||||||
|
Address: departure,
|
||||||
|
},
|
||||||
|
DestinationAddress: &solidarity_service.Feature{
|
||||||
|
Lat: destinationgeo.Geometry.Point[0],
|
||||||
|
Long: destinationgeo.Geometry.Point[1],
|
||||||
|
Address: departure,
|
||||||
|
},
|
||||||
|
PickupDate : timestamp,
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
BookingData.bookingData.Booking.DriverId = driverId
|
||||||
|
BookingData.bookingData.Booking.Id = id
|
||||||
|
|
||||||
|
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
booking = booking
|
||||||
|
|
||||||
|
SolidarityData = models.SolidarityTransport{
|
||||||
|
Drivers: drivers,
|
||||||
|
Beneficiaries: accounts,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
SolidarityData = models.SolidarityTransport{
|
||||||
|
Drivers: drivers,
|
||||||
|
Beneficiaries: accounts,
|
||||||
|
}
|
||||||
|
|
||||||
|
solidarityCh <- SolidarityData
|
||||||
|
|
||||||
|
}
|
||||||
|
//go journeysRequest()
|
||||||
|
go carpoolRequest()
|
||||||
|
go vehicleRequest()
|
||||||
|
go solidarityRequest()
|
||||||
|
carpool_results = <-carpoolCh
|
||||||
|
//journeys_results = <-navitiaCh
|
||||||
|
vehicle_results = <-vehiclech
|
||||||
|
solidarity_results = <-solidarityCh
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
h.Renderer.JourneysSearch(w, r, carpool_results, vehicle_results, searched, departuregeo, destinationgeo, departuredate, departuretime, solidarity_results) //journeys_results,
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupsModule []groupstorage.Group
|
type GroupsModule []groupstorage.Group
|
||||||
|
|||||||
260
handlers/application/solidarity_service.go
Normal file
260
handlers/application/solidarity_service.go
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
package application
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
geojson "github.com/paulmach/go.geojson"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
)
|
||||||
|
|
||||||
|
var BookingData Booking
|
||||||
|
|
||||||
|
type Booking struct {
|
||||||
|
bookingData solidarity_service.CreateBookingSolidarityRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
//List les conducteurs disponibles + Créer une réservation
|
||||||
|
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
if r.Method == "GET" && r.FormValue("date") != ""{
|
||||||
|
|
||||||
|
DepartureAddress := r.FormValue("departure");
|
||||||
|
DestinationAddress := r.FormValue("destination");
|
||||||
|
PickupDate := r.FormValue("date");
|
||||||
|
|
||||||
|
layout := "2006-01-02T15:04"
|
||||||
|
|
||||||
|
dateParsed, err := time.Parse(layout, PickupDate)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
departuregeo *geojson.Feature
|
||||||
|
destinationgeo *geojson.Feature
|
||||||
|
)
|
||||||
|
|
||||||
|
timestamp := timestamppb.New(dateParsed)
|
||||||
|
|
||||||
|
if PickupDate != "" && DepartureAddress != "" && DestinationAddress != "" {
|
||||||
|
// searched = true
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
departuregeo, err = geojson.UnmarshalFeature([]byte(DepartureAddress))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
destinationgeo, err = geojson.UnmarshalFeature([]byte(DestinationAddress))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request := solidarity_service.DriverJourneysRequest{
|
||||||
|
DepartureDate: timestamp,
|
||||||
|
Departure: &solidarity_service.Feature{
|
||||||
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
|
Long: departuregeo.Geometry.Point[1],
|
||||||
|
Address: DepartureAddress,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
drivers, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), &request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
BookingData.bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||||
|
Booking : &solidarity_service.BookingSolidarityRequest {
|
||||||
|
|
||||||
|
DepartureAddress: &solidarity_service.Feature{
|
||||||
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
|
Long: departuregeo.Geometry.Point[1],
|
||||||
|
Address: DepartureAddress,
|
||||||
|
},
|
||||||
|
DestinationAddress: &solidarity_service.Feature{
|
||||||
|
Lat: destinationgeo.Geometry.Point[0],
|
||||||
|
Long: destinationgeo.Geometry.Point[1],
|
||||||
|
Address: DepartureAddress,
|
||||||
|
},
|
||||||
|
PickupDate : timestamp,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &BookingData.bookingData)
|
||||||
|
|
||||||
|
} else if r.Method == "POST" {
|
||||||
|
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
beneficiaryID := vars["id"]
|
||||||
|
|
||||||
|
driverId := r.FormValue("driver_id")
|
||||||
|
id := uuid.New().String()
|
||||||
|
|
||||||
|
BookingData.bookingData.Booking.DriverId = driverId
|
||||||
|
BookingData.bookingData.Booking.PassengerId= beneficiaryID
|
||||||
|
BookingData.bookingData.Booking.Id = id
|
||||||
|
|
||||||
|
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.SolidarityServiceBooking(w, r, booking)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
|
||||||
|
h.Renderer.CreateBookingHome(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) SolidarityService(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
||||||
|
drivers, err := h.services.GRPC.SolidarityService.GetAllDrivers(context.TODO(), &emptypb.Empty{})
|
||||||
|
bookings, err := h.services.GRPC.SolidarityService.GetAllBookingsSolidarity(context.TODO(), &emptypb.Empty{})
|
||||||
|
|
||||||
|
parcourmobAccounts, err := h.beneficiaries(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
|
||||||
|
h.Renderer.SolidarityService(w, r, accounts, drivers, parcourmobAccounts, bookings ,cacheid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) CreateDriver(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
if r.Method== "POST" {
|
||||||
|
|
||||||
|
dataMap, err := parseBeneficiariesForm(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := structpb.NewValue(dataMap)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userRequest := &mobilityaccounts.RegisterRequest{
|
||||||
|
Account: &mobilityaccounts.Account{
|
||||||
|
Namespace: "silvermobi",
|
||||||
|
Data: data.GetStructValue(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := h.services.GRPC.MobilityAccounts.Register(context.TODO(), userRequest)
|
||||||
|
|
||||||
|
address := resp.Account.Data.GetFields()["address"].GetStructValue();
|
||||||
|
geometry := address.GetFields()["geometry"].GetStructValue();
|
||||||
|
coordinates:= geometry.GetFields()["coordinates"].GetListValue();
|
||||||
|
if len(coordinates.GetValues()) < 2{
|
||||||
|
fmt.Printf("Erreur lors de la récupération des coordonées : %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
radiusStr := r.PostFormValue("radius")
|
||||||
|
radius, err := strconv.Atoi(radiusStr)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Erreur lors de la conversion de radius : %v", err)
|
||||||
|
radius = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
availabilitiesJSON := r.PostFormValue("availabilities")
|
||||||
|
|
||||||
|
var availabilities []solidarity_service.RegularAvailabilitySlot
|
||||||
|
|
||||||
|
jsonerr:= json.Unmarshal([]byte(availabilitiesJSON), &availabilities)
|
||||||
|
if jsonerr != nil {
|
||||||
|
fmt.Printf("Erreur lors de la conversion de availabilitiesJSON : %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
driverRequest := solidarity_service.DriverRegularAvailabilities {
|
||||||
|
DriverRequest : &solidarity_service.DriverRequest {
|
||||||
|
DriverAddress: &solidarity_service.Feature{
|
||||||
|
Lat: coordinates.GetValues()[0].GetNumberValue(),
|
||||||
|
Long: coordinates.GetValues()[1].GetNumberValue(),
|
||||||
|
Address: "********",
|
||||||
|
},
|
||||||
|
DriverRadius: int32(radius),
|
||||||
|
Driver: &solidarity_service.User{
|
||||||
|
Id: resp.Account.Id,
|
||||||
|
Alias: r.PostFormValue("alias"),
|
||||||
|
FirstName: r.PostFormValue("first_name"),
|
||||||
|
LastName: r.PostFormValue("last_name"),
|
||||||
|
Grade: 1,
|
||||||
|
Picture: "h.png",
|
||||||
|
Gender: r.PostFormValue("gender"),
|
||||||
|
VerifiedIdentity: true, ///////// a Modifier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
},
|
||||||
|
Preferences: &solidarity_service.Preferences{
|
||||||
|
Smoking: false,
|
||||||
|
Animals: false,
|
||||||
|
Music: false,
|
||||||
|
IsTalker: false,
|
||||||
|
LuggageSize: 100,
|
||||||
|
},
|
||||||
|
Car: &solidarity_service.Car{
|
||||||
|
Model: r.PostFormValue("model"),
|
||||||
|
Brand: r.PostFormValue("brand"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DriverAvailabilities: []*solidarity_service.RegularAvailabilitySlot{},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, slot := range availabilities{
|
||||||
|
driverRequest.DriverAvailabilities = append( driverRequest.DriverAvailabilities, &solidarity_service.RegularAvailabilitySlot{
|
||||||
|
DayOfWeek: slot.DayOfWeek,
|
||||||
|
StartTime: slot.StartTime,
|
||||||
|
EndTime: slot.EndTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
driverResponse, err := h.services.GRPC.SolidarityService.SetDriverRegularAvailabilities(context.TODO(), &driverRequest)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("erreur lors de la création du conducteur: ", err)
|
||||||
|
radius = 0
|
||||||
|
}
|
||||||
|
fmt.Println("driver: ", driverResponse)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Renderer.CreateDriver(w, r)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -140,9 +140,6 @@ func (h *ApplicationHandler) VehiclesFleetAdd(w http.ResponseWriter, r *http.Req
|
|||||||
fmt.Println(v)
|
fmt.Println(v)
|
||||||
dataMap["automatic"] = (v == "on")
|
dataMap["automatic"] = (v == "on")
|
||||||
}
|
}
|
||||||
if v := r.FormValue("kilometers"); v != "" {
|
|
||||||
dataMap["kilometers"] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := structpb.NewValue(dataMap)
|
data, err := structpb.NewValue(dataMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -617,9 +614,6 @@ func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http.
|
|||||||
if v := r.FormValue("licence_plate"); v != "" {
|
if v := r.FormValue("licence_plate"); v != "" {
|
||||||
dataMap["licence_plate"] = v
|
dataMap["licence_plate"] = v
|
||||||
}
|
}
|
||||||
if v := r.FormValue("kilometers"); v != "" {
|
|
||||||
dataMap["kilometers"] = v
|
|
||||||
}
|
|
||||||
if v := r.FormValue("automatic"); v != "" {
|
if v := r.FormValue("automatic"); v != "" {
|
||||||
fmt.Println(v)
|
fmt.Println(v)
|
||||||
dataMap["automatic"] = (v == "on")
|
dataMap["automatic"] = (v == "on")
|
||||||
|
|||||||
9
main.go
9
main.go
@@ -137,6 +137,12 @@ func main() {
|
|||||||
application.HandleFunc("/support/", applicationHandler.SupportSend)
|
application.HandleFunc("/support/", applicationHandler.SupportSend)
|
||||||
/*********************** CODE GROUP **************************/
|
/*********************** CODE GROUP **************************/
|
||||||
|
|
||||||
|
//=================================silvermobi====================================
|
||||||
|
application.HandleFunc("/solidarity_service/", applicationHandler.SolidarityService)
|
||||||
|
application.HandleFunc("/solidarity_service/create/{id}", applicationHandler.DriversJourney)
|
||||||
|
application.HandleFunc("/solidarity_service/driver/create", applicationHandler.CreateDriver)
|
||||||
|
|
||||||
|
|
||||||
appGroup := application.PathPrefix("/group_module").Subrouter()
|
appGroup := application.PathPrefix("/group_module").Subrouter()
|
||||||
appGroup.HandleFunc("/", applicationHandler.Groups)
|
appGroup.HandleFunc("/", applicationHandler.Groups)
|
||||||
appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule)
|
appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule)
|
||||||
@@ -162,9 +168,6 @@ func main() {
|
|||||||
application.HandleFunc("/agenda/{eventid}/{subscribeid}/delete", applicationHandler.AgendaDeleteSubscribeEvent)
|
application.HandleFunc("/agenda/{eventid}/{subscribeid}/delete", applicationHandler.AgendaDeleteSubscribeEvent)
|
||||||
application.HandleFunc("/agenda/{eventid}/history", applicationHandler.AgendaHistoryEvent)
|
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 := r.PathPrefix("/exports").Subrouter()
|
||||||
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
|
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
|
||||||
|
|||||||
BIN
parcoursmob
Executable file
BIN
parcoursmob
Executable file
Binary file not shown.
@@ -30,29 +30,20 @@ func (renderer *Renderer) AgendaHistory(w http.ResponseWriter, r *http.Request,
|
|||||||
renderer.Render("agenda history", w, r, files, state)
|
renderer.Render("agenda history", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Request, events_file_types []string, file_types_map map[string]string, documents any) {
|
func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.agenda.create_event.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.agenda.create_event.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, agendaMenu)
|
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)
|
renderer.Render("agenda create event", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, subscribers map[string]any, beneficiaries any) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, agendaMenu)
|
state := NewState(r, renderer.ThemeConfig, agendaMenu)
|
||||||
|
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"event": event,
|
"event": event,
|
||||||
"group": group,
|
"group": group,
|
||||||
"events_file_types": events_file_types,
|
|
||||||
"file_types_map": file_types_map,
|
|
||||||
"documents": documents,
|
|
||||||
"subscribers": subscribers,
|
"subscribers": subscribers,
|
||||||
"beneficiaries": beneficiaries,
|
"beneficiaries": beneficiaries,
|
||||||
}
|
}
|
||||||
@@ -109,18 +100,3 @@ func (renderer *Renderer) AgendaDeleteEvent(w http.ResponseWriter, r *http.Reque
|
|||||||
|
|
||||||
renderer.Render("event_deleteEvent", w, r, files, state)
|
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)
|
|
||||||
// }
|
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
const beneficiariesMenu = "beneficiaries"
|
const beneficiariesMenu = "beneficiaries"
|
||||||
@@ -15,6 +16,16 @@ type BeneficiariesListState struct {
|
|||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
CacheId string `json:"cache_id"`
|
CacheId string `json:"cache_id"`
|
||||||
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BeneficiarySolidarityState struct {
|
||||||
|
Count int `json:"count"`
|
||||||
|
CacheId string `json:"cache_id"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
BeneficiarySolidarity *solidarity_service.GetPassengerResponse `json:"beneficiarysolidarity"`
|
||||||
|
BookingSolidarity *solidarity_service.GetBookingsByStatusResponse `json:"bookingsolidarity"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s BeneficiariesListState) JSON() template.JS {
|
func (s BeneficiariesListState) JSON() template.JS {
|
||||||
@@ -29,7 +40,19 @@ func (s BeneficiariesListState) JSONWithLimits(a int, b int) template.JS {
|
|||||||
return s.JSON()
|
return s.JSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, cacheid string) {
|
func (s BeneficiarySolidarityState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiarySolidarityState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account,cacheid string) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.list.files")
|
||||||
|
|
||||||
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||||
@@ -53,7 +76,7 @@ type BeneficiariesDisplayState struct {
|
|||||||
Beneficiary any
|
Beneficiary 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{}) {
|
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{}, solidarity_bookings_list []any) {
|
||||||
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{
|
||||||
@@ -64,6 +87,7 @@ func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Requ
|
|||||||
"documents": documents,
|
"documents": documents,
|
||||||
"organizations": organizations,
|
"organizations": organizations,
|
||||||
"event": event,
|
"event": event,
|
||||||
|
"bookingSolidarity" : solidarity_bookings_list,
|
||||||
}
|
}
|
||||||
renderer.Render("beneficiaries_display", w, r, files, state)
|
renderer.Render("beneficiaries_display", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
||||||
fleetstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const dashboardMenu = "dashboard"
|
const dashboardMenu = "dashboard"
|
||||||
|
|
||||||
func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, accounts []any, nbaccounts int, count_members int, events []agendastorage.Event, fleets []fleetstorage.Booking) {
|
func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, accounts []any, nbaccounts int, count_members int, events []agendastorage.Event) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.dashboard.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.dashboard.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, dashboardMenu)
|
state := NewState(r, renderer.ThemeConfig, dashboardMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
@@ -19,7 +18,6 @@ func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, acco
|
|||||||
},
|
},
|
||||||
"count_members": count_members,
|
"count_members": count_members,
|
||||||
"events": events,
|
"events": events,
|
||||||
"fleets": fleets,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("dashboard", w, r, files, state)
|
renderer.Render("dashboard", w, r, files, state)
|
||||||
|
|||||||
@@ -25,6 +25,20 @@ func TimeFrom(d any) *time.Time {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TimestampFrom(d any) *time.Time {
|
||||||
|
|
||||||
|
if date, ok := d.(time.Time); ok {
|
||||||
|
return &date
|
||||||
|
} else if date, ok := d.(string); ok {
|
||||||
|
datetime, err := time.Parse("2006-01-02T15:04:05Z", date)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return &datetime
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func TimeFormat(d any, f string) string {
|
func TimeFormat(d any, f string) string {
|
||||||
date := TimeFrom(d)
|
date := TimeFrom(d)
|
||||||
if date == nil {
|
if date == nil {
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
models "git.coopgo.io/coopgo-apps/parcoursmob/utils/models"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const journeysMenu = "journeys"
|
const journeysMenu = "journeys"
|
||||||
@@ -23,6 +24,7 @@ type BeneficiariesCovoiturageA struct {
|
|||||||
Beneficiaries []any `json:"beneficiaries"`
|
Beneficiaries []any `json:"beneficiaries"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s BeneficiariesCovoiturage) JSON() template.JS {
|
func (s BeneficiariesCovoiturage) JSON() template.JS {
|
||||||
result, _ := json.Marshal(s)
|
result, _ := json.Marshal(s)
|
||||||
return template.JS(result)
|
return template.JS(result)
|
||||||
@@ -35,7 +37,7 @@ func (s BeneficiariesCovoiturage) JSONWithLimits(a int, b int) template.JS {
|
|||||||
return s.JSON()
|
return s.JSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request, carpools any, transitjourneys any, vehicles []any, searched bool, departure any, destination any, departuredate string, departuretime string) {
|
func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request, carpools any, vehicles []any, searched bool, departure any, destination any, departuredate string, departuretime string, solidarity_results models.SolidarityTransport ) { //transitjourneys any,
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.journeys.search.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.journeys.search.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, journeysMenu)
|
state := NewState(r, renderer.ThemeConfig, journeysMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
@@ -44,11 +46,11 @@ func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request,
|
|||||||
"departuretime": departuretime,
|
"departuretime": departuretime,
|
||||||
"departure": departure,
|
"departure": departure,
|
||||||
"destination": destination,
|
"destination": destination,
|
||||||
"journeys": transitjourneys,
|
//"journeys": transitjourneys,
|
||||||
"carpools": carpools,
|
"carpools": carpools,
|
||||||
"vehicles": vehicles,
|
"vehicles": vehicles,
|
||||||
|
"solidarity_results": solidarity_results,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("journeys", w, r, files, state)
|
renderer.Render("journeys", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,14 @@ func NewState(r *http.Request, themeConfig *viper.Viper, menuState string) Rende
|
|||||||
Icon: "hero:outline/user-group",
|
Icon: "hero:outline/user-group",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if modules["solidarity_service"] != nil && modules["solidarity_service"].(bool) {
|
||||||
|
ls.MenuItems = append(ls.MenuItems, MenuItem{
|
||||||
|
Title: "Transport solidaire",
|
||||||
|
Link: "/app/solidarity_service/",
|
||||||
|
Active: menuState == solidarityserviceMenu,
|
||||||
|
Icon: "hero:outline/map",
|
||||||
|
})
|
||||||
|
}
|
||||||
return RenderState{
|
return RenderState{
|
||||||
IconSet: icons.NewIconSet(iconset),
|
IconSet: icons.NewIconSet(iconset),
|
||||||
Group: group,
|
Group: group,
|
||||||
|
|||||||
127
renderer/solidarity_service.go
Normal file
127
renderer/solidarity_service.go
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
package renderer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
const solidarityserviceMenu = "solidarity_service"
|
||||||
|
|
||||||
|
|
||||||
|
type SolidarityListState struct {
|
||||||
|
Count int `json:"count"`
|
||||||
|
CacheId string `json:"cache_id"`
|
||||||
|
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
|
||||||
|
Drivers *solidarity_service.DriverJourneysResponse `json:"drivers"`
|
||||||
|
Bookings *solidarity_service.GetAllBookingsSolidarityResponse `json:"bookings"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type BeneficiariesSolidarityListState struct {
|
||||||
|
Count int `json:"count"`
|
||||||
|
CacheId string `json:"cache_id"`
|
||||||
|
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
|
||||||
|
Drivers *solidarity_service.GetAllDriversResponse `json:"drivers"`
|
||||||
|
Bookings *solidarity_service.GetAllBookingsSolidarityResponse `json:"bookings"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type SolidarityBookingsState struct {
|
||||||
|
Bookings *solidarity_service.CreateBookingSolidarityResponse `json:"bookings"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiariesSolidarityListState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiariesSolidarityListState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SolidarityListState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SolidarityListState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SolidarityBookingsState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SolidarityBookingsState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, drivers *solidarity_service.GetAllDriversResponse, parcourmobAccounts []mobilityaccountsstorage.Account, bookings *solidarity_service.GetAllBookingsSolidarityResponse, cacheid string) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
state.ViewState = BeneficiariesSolidarityListState{
|
||||||
|
Count: len(parcourmobAccounts),
|
||||||
|
CacheId: cacheid,
|
||||||
|
Beneficiaries: parcourmobAccounts,
|
||||||
|
BeneficiariesSolidarity: accounts,
|
||||||
|
Drivers: drivers,
|
||||||
|
Bookings: bookings,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) CreateBookingHome(w http.ResponseWriter, r *http.Request ) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, bookings *solidarity_service.CreateBookingSolidarityResponse) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
state.ViewState = SolidarityBookingsState{
|
||||||
|
Bookings: bookings,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, booking *solidarity_service.CreateBookingSolidarityRequest) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
state.ViewState = SolidarityListState{
|
||||||
|
Drivers: drivers,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) CreateDriver(w http.ResponseWriter, r *http.Request) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create_driver.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
@@ -5,7 +5,11 @@ import (
|
|||||||
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
|
||||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||||
|
routing "git.coopgo.io/coopgo-platform/routing-service"
|
||||||
|
solidarityservice "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServicesHandler struct {
|
type ServicesHandler struct {
|
||||||
@@ -17,6 +21,9 @@ type GRPCServices struct {
|
|||||||
GroupsManagement groupsmanagement.GroupsManagementClient
|
GroupsManagement groupsmanagement.GroupsManagementClient
|
||||||
Fleets fleets.FleetsClient
|
Fleets fleets.FleetsClient
|
||||||
Agenda agenda.AgendaClient
|
Agenda agenda.AgendaClient
|
||||||
|
SolidarityService solidarityservice.SolidarityServiceClient
|
||||||
|
|
||||||
|
Routing routing.RoutingService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
||||||
@@ -25,6 +32,9 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
|||||||
groupsManagementDial = cfg.GetString("services.grpc.groupsmanagement.dial")
|
groupsManagementDial = cfg.GetString("services.grpc.groupsmanagement.dial")
|
||||||
fleetsDial = cfg.GetString("services.grpc.fleets.dial")
|
fleetsDial = cfg.GetString("services.grpc.fleets.dial")
|
||||||
agendaDial = cfg.GetString("services.grpc.agenda.dial")
|
agendaDial = cfg.GetString("services.grpc.agenda.dial")
|
||||||
|
solidarityDial = cfg.GetString("services.grpc.solidarityservice.dial")
|
||||||
|
routing_service_type = cfg.GetString("routing.type")
|
||||||
|
valhalla_base_url = cfg.GetString("routing.valhalla.base_url")
|
||||||
)
|
)
|
||||||
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
|
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -46,12 +56,27 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
solidarityService, err := NewSolidarityService(solidarityDial)
|
||||||
|
if err != nil {
|
||||||
|
return nil , err
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
routing, err := routing.NewRoutingService(routing_service_type, valhalla_base_url)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("Could not initiate the routing service")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &ServicesHandler{
|
return &ServicesHandler{
|
||||||
GRPC: GRPCServices{
|
GRPC: GRPCServices{
|
||||||
MobilityAccounts: mobilityAccounts,
|
MobilityAccounts: mobilityAccounts,
|
||||||
GroupsManagement: groupsManagement,
|
GroupsManagement: groupsManagement,
|
||||||
Fleets: fleetsSvc,
|
Fleets: fleetsSvc,
|
||||||
Agenda: agendaSvc,
|
Agenda: agendaSvc,
|
||||||
|
SolidarityService: solidarityService,
|
||||||
|
Routing: routing,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
23
services/solidarity_service.go
Normal file
23
services/solidarity_service.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
solidarityservice "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SolidarityService struct {
|
||||||
|
solidarityservice.SolidarityServiceClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSolidarityService(silvermobiDial string) (*SolidarityService, error) {
|
||||||
|
conn, err := grpc.Dial(silvermobiDial, grpc.WithInsecure())
|
||||||
|
|
||||||
|
client := solidarityservice.NewSolidarityServiceClient(conn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SolidarityService{
|
||||||
|
SolidarityServiceClient: client,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
7
utils/models/models.go
Normal file
7
utils/models/models.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
|
||||||
|
type SolidarityTransport struct {
|
||||||
|
Drivers []any
|
||||||
|
Beneficiaries []any
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
PREFIX_BENEFICIARIES = "beneficiaries"
|
PREFIX_BENEFICIARIES = "beneficiaries"
|
||||||
PREFIX_BOOKINGS = "fleets_bookings"
|
PREFIX_BOOKINGS = "fleets_bookings"
|
||||||
PREFIX_AGENDA = "event_files"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileInfo struct {
|
type FileInfo struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user