Compare commits
10 Commits
soukaina
...
eaf866154e
| Author | SHA1 | Date | |
|---|---|---|---|
| eaf866154e | |||
| 06f42947b9 | |||
| acb5232b94 | |||
| 8de170a009 | |||
| a0557b0971 | |||
| b4c59c7408 | |||
| 334351a0cf | |||
| 7184f4735c | |||
| 434be30074 | |||
| 498b12de18 |
33
go.mod
33
go.mod
@@ -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/
|
||||||
|
|
||||||
@@ -30,11 +30,11 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
|
git.coopgo.io/coopgo-platform/agenda v1.0.0
|
||||||
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15
|
||||||
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
|
git.coopgo.io/coopgo-platform/fleets v1.0.0
|
||||||
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
|
git.coopgo.io/coopgo-platform/groups-management v1.0.0
|
||||||
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230329105908-a76c0412a386
|
git.coopgo.io/coopgo-platform/mobility-accounts v1.0.5
|
||||||
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/xuri/excelize/v2 v2.7.1
|
github.com/xuri/excelize/v2 v2.7.1
|
||||||
@@ -44,8 +44,11 @@ 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.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.6.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
|
||||||
@@ -56,14 +59,18 @@ require (
|
|||||||
github.com/golang/protobuf v1.5.3 // 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/google/go-cmp v0.5.9 // indirect
|
github.com/google/go-cmp v0.5.9 // 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.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/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/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
|
github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
|
||||||
github.com/minio/md5-simd v1.1.2 // indirect
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||||
@@ -73,6 +80,13 @@ require (
|
|||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||||
|
github.com/ory/fosite v0.42.2 // indirect
|
||||||
|
github.com/ory/go-acc v0.2.6 // indirect
|
||||||
|
github.com/ory/go-convenience v0.1.0 // indirect
|
||||||
|
github.com/ory/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/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
|
||||||
@@ -83,6 +97,7 @@ require (
|
|||||||
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/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.2 // indirect
|
github.com/subosito/gotenv v1.4.2 // indirect
|
||||||
@@ -106,6 +121,7 @@ require (
|
|||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
golang.org/x/sys v0.7.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
|
golang.org/x/tools v0.6.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // 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
|
||||||
@@ -113,5 +129,6 @@ require (
|
|||||||
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,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -13,11 +14,13 @@ 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"
|
||||||
@@ -147,17 +150,52 @@ 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) {
|
||||||
@@ -237,7 +275,13 @@ func (h *ApplicationHandler) AgendaDisplayEvent(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.AgendaDisplayEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
|
|
||||||
|
documents := h.filestorage.List(filestorage.PREFIX_AGENDA + "/" + eventid)
|
||||||
|
|
||||||
|
events_file_types := h.config.GetStringSlice("modules.agenda.documents_types")
|
||||||
|
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||||
|
|
||||||
|
h.Renderer.AgendaDisplayEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), events_file_types, file_types_map, documents, subscribers, accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -255,7 +299,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)
|
||||||
@@ -685,3 +729,61 @@ func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
h.Renderer.AgendaHistoryEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -205,7 +205,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("icii")
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -213,15 +212,13 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
events := []agendastorage.Event{}
|
events := []agendastorage.Event{}
|
||||||
currentTime := time.Now().Truncate(24 * time.Hour)
|
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||||
fmt.Println(subcriptionresp)
|
|
||||||
for _, e := range subcriptionresp.Subscription {
|
for _, e := range subcriptionresp.Subscription {
|
||||||
eventresquest := &agenda.GetEventRequest{
|
eventresquest := &agenda.GetEventRequest{
|
||||||
Id: e.Eventid,
|
Id: e.Eventid,
|
||||||
}
|
}
|
||||||
fmt.Println(eventresquest)
|
|
||||||
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("iciiiiii")
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -272,7 +269,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
events_list = append(events_list, event)
|
events_list = append(events_list, event)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var status_booking int
|
var status_booking int
|
||||||
@@ -310,7 +306,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
events_list = append(events_list, event)
|
events_list = append(events_list, event)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sortByDate(events_list)
|
sortByDate(events_list)
|
||||||
@@ -451,6 +446,8 @@ 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,6 +13,8 @@ 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) {
|
||||||
@@ -76,6 +78,18 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
sort.Sort(sorting.EventsByStartdate(events))
|
sort.Sort(sorting.EventsByStartdate(events))
|
||||||
|
|
||||||
h.Renderer.Dashboard(w, r, accounts, count, count_members, events)
|
bookings := []fleetstorage.Booking{}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,9 @@ 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 {
|
||||||
@@ -305,12 +308,9 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
|||||||
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.Startdate.Add(After(time.Now()))),
|
AvailabilityTo: timestamppb.New(booking.Enddate.Add(24 * time.Hour)),
|
||||||
}
|
}
|
||||||
// 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 {
|
||||||
@@ -322,48 +322,11 @@ 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, vehicles, vehicles_map, bookings)
|
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -593,17 +556,8 @@ 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)
|
|
||||||
|
|
||||||
if errr != nil {
|
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
||||||
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)
|
||||||
@@ -663,6 +617,9 @@ 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")
|
||||||
|
|||||||
@@ -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"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
3
main.go
3
main.go
@@ -162,6 +162,9 @@ 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)
|
||||||
|
|||||||
@@ -30,20 +30,29 @@ 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) {
|
func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Request, events_file_types []string, file_types_map map[string]string, documents any) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.agenda.create_event.files")
|
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, subscribers map[string]any, beneficiaries any) {
|
func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, events_file_types []string, file_types_map map[string]string, documents any, subscribers map[string]any, beneficiaries any) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files")
|
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,
|
||||||
}
|
}
|
||||||
@@ -100,3 +109,18 @@ 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)
|
||||||
|
// }
|
||||||
@@ -4,11 +4,12 @@ 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) {
|
func (renderer *Renderer) Dashboard(w http.ResponseWriter, r *http.Request, accounts []any, nbaccounts int, count_members int, events []agendastorage.Event, fleets []fleetstorage.Booking) {
|
||||||
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{
|
||||||
@@ -18,6 +19,7 @@ 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)
|
||||||
|
|||||||
@@ -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, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking) {
|
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) {
|
||||||
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,9 +75,6 @@ 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)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ 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