Add check in Diags home if its the same groupID
Build and Push Docker Image / build_and_push (push) Failing after 1m49s
Details
Build and Push Docker Image / build_and_push (push) Failing after 1m49s
Details
This commit is contained in:
parent
d0fc96f8bb
commit
0a690cadf1
2
go.mod
2
go.mod
|
@ -51,7 +51,7 @@ require (
|
|||
|
||||
require (
|
||||
ariga.io/atlas v0.12.0 // indirect
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250210110754-726bb4643c63
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250212093351-64da61495c9d
|
||||
github.com/agext/levenshtein v1.2.1 // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
|
|
6
go.sum
6
go.sum
|
@ -2,10 +2,12 @@ ariga.io/atlas v0.12.0 h1:jDfjxT3ppKhzqLS26lZv9ni7p9TVNrhy7SQquaF7bPs=
|
|||
ariga.io/atlas v0.12.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk=
|
||||
git.coopgo.io/coopgo-platform/agenda v1.0.0 h1:rTHgva1JKKO0wAPlINegifMkHm+xOg3IWW4yQRy334w=
|
||||
git.coopgo.io/coopgo-platform/agenda v1.0.0/go.mod h1:/hToSla0p6SeWn1zo1MDrfxdmo7RBdZDkbLqCVituIM=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20241120133550-917ed8705c73 h1:Xyc2Xuf7VnaOVD7sro2GPD1gzwo+R9lyfkWjyrTYlqY=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20241120133550-917ed8705c73/go.mod h1:diyq11WNkgJ0kYHdT7SphXPMQUyoq4lRk7T6IgM5yPA=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250210110754-726bb4643c63 h1:BvNTshj4TToGptaheeAzEmaNeuqPCR/NIH6TGePd54A=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250210110754-726bb4643c63/go.mod h1:diyq11WNkgJ0kYHdT7SphXPMQUyoq4lRk7T6IgM5yPA=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250211082457-291671c295e6 h1:McRGfPLueD+wcx8yf19a31uei4Ha0ugiDtnYtHYErrg=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250211082457-291671c295e6/go.mod h1:diyq11WNkgJ0kYHdT7SphXPMQUyoq4lRk7T6IgM5yPA=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250212093351-64da61495c9d h1:fBxVvik4Cb/6d4+HAXZi9e8x8P9UBCJt8JcWgqnNjsE=
|
||||
git.coopgo.io/coopgo-platform/diags v0.0.0-20250212093351-64da61495c9d/go.mod h1:diyq11WNkgJ0kYHdT7SphXPMQUyoq4lRk7T6IgM5yPA=
|
||||
git.coopgo.io/coopgo-platform/emailing v0.0.0-20241119141913-9836b30191c1 h1:gAhJ9wwlitMiETmnD4U2L6xLnVd5xE4hPX72IJ5s7+I=
|
||||
git.coopgo.io/coopgo-platform/emailing v0.0.0-20241119141913-9836b30191c1/go.mod h1:EXy6NRvFfpW6yIHoZUixldkXrj1qzjCbTHpumDvzaKI=
|
||||
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e h1:eHahRTKlC8aBWYCd6LbXNcX8HoQhuZj31OFWrw0EL0U=
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
|
||||
diagsstorage "git.coopgo.io/coopgo-platform/diags/storage"
|
||||
|
||||
// groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||
// "git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
|
||||
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||
// mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||
// "github.com/google/uuid"
|
||||
"github.com/google/uuid"
|
||||
|
@ -40,9 +40,12 @@ type DiagsForm struct {
|
|||
Data map[string]any `json:"data"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Diagdate *time.Time `json:"diagdate"`
|
||||
Owners []string `json:"owners"`
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) DiagsHome(w http.ResponseWriter, r *http.Request) {
|
||||
groupID := r.Context().Value(identification.GroupKey).(storage.Group).ID
|
||||
|
||||
resp, err := h.services.GRPC.Diags.GetDiags(context.TODO(), &diags.GetDiagsRequest{
|
||||
Namespaces: []string{"parcoursmob_beneficiaries", "parcoursmob_diagnostiques", "parcoursmob_vehicles", "parcoursmob_bookings"},
|
||||
})
|
||||
|
@ -55,11 +58,35 @@ func (h *ApplicationHandler) DiagsHome(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
responses := []diagsstorage.Diag{}
|
||||
|
||||
groupids := []string{}
|
||||
for _, e := range resp.Diags {
|
||||
groupids = append(groupids, e.Owners...)
|
||||
responses = append(responses, e.ToStorageType())
|
||||
}
|
||||
|
||||
h.Renderer.DiagsHome(w, r, responses)
|
||||
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
|
||||
Groupids: groupids,
|
||||
})
|
||||
groups := map[string]any{}
|
||||
|
||||
if err == nil {
|
||||
for _, g := range groupsresp.Groups {
|
||||
groups[g.Id] = g.ToStorageType()
|
||||
}
|
||||
}
|
||||
|
||||
filteredDiags := []diagsstorage.Diag{}
|
||||
for _, diag := range responses {
|
||||
for _, owner := range diag.Owners {
|
||||
if string(owner) == groupID {
|
||||
filteredDiags = append(filteredDiags, diag)
|
||||
log.Debug().Msgf("Diag %s added to filtered list", diag.ID)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
h.Renderer.DiagsHome(w, r, filteredDiags, groups)
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) DiagsHistory(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -102,6 +129,8 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h
|
|||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
diagForm, err := parseDiagsForm(r)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Invalid form data")
|
||||
|
@ -109,8 +138,6 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h
|
|||
return
|
||||
}
|
||||
|
||||
log.Debug().Interface("diagForm", diagForm).Msg("Form data parsed")
|
||||
|
||||
data, err := structpb.NewStruct(map[string]any{
|
||||
"beneficiary": beneficiaryID,
|
||||
})
|
||||
|
@ -129,6 +156,7 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h
|
|||
Data: data,
|
||||
Deleted: diagForm.Deleted,
|
||||
Diagdate: timestamppb.New(time.Now()),
|
||||
Owners: []string{group.ID},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -173,7 +201,7 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/diags/%s", resp.Diag.Id), http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
@ -217,6 +245,8 @@ func (h *ApplicationHandler) VehiclesCreateDiag(w http.ResponseWriter, r *http.R
|
|||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
request := &diags.CreateDiagRequest{
|
||||
Diag: &diags.Diag{
|
||||
Name: diagForm.Name,
|
||||
|
@ -226,6 +256,7 @@ func (h *ApplicationHandler) VehiclesCreateDiag(w http.ResponseWriter, r *http.R
|
|||
Data: data,
|
||||
Deleted: diagForm.Deleted,
|
||||
Diagdate: timestamppb.New(time.Now()),
|
||||
Owners: []string{group.ID},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -279,6 +310,8 @@ func (h *ApplicationHandler) BookingsCreateDiag(w http.ResponseWriter, r *http.R
|
|||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
request := &diags.CreateDiagRequest{
|
||||
Diag: &diags.Diag{
|
||||
Name: diagForm.Name,
|
||||
|
@ -288,6 +321,7 @@ func (h *ApplicationHandler) BookingsCreateDiag(w http.ResponseWriter, r *http.R
|
|||
Data: data,
|
||||
Deleted: diagForm.Deleted,
|
||||
Diagdate: timestamppb.New(time.Now()),
|
||||
Owners: []string{group.ID},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -341,6 +375,8 @@ func (h *ApplicationHandler) VehicleBookingsCreateDiag(w http.ResponseWriter, r
|
|||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
request := &diags.CreateDiagRequest{
|
||||
Diag: &diags.Diag{
|
||||
Name: diagForm.Name,
|
||||
|
@ -350,6 +386,7 @@ func (h *ApplicationHandler) VehicleBookingsCreateDiag(w http.ResponseWriter, r
|
|||
Data: data,
|
||||
Deleted: diagForm.Deleted,
|
||||
Diagdate: timestamppb.New(time.Now()),
|
||||
Owners: []string{group.ID},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -447,6 +484,8 @@ func (h *ApplicationHandler) DiagUpdate(w http.ResponseWriter, r *http.Request)
|
|||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
diagForm, err := parseDiagsForm(r)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("")
|
||||
|
@ -465,6 +504,7 @@ func (h *ApplicationHandler) DiagUpdate(w http.ResponseWriter, r *http.Request)
|
|||
UiSchema: diagForm.UiSchema,
|
||||
Data: data,
|
||||
Diagdate: timestamppb.New(time.Now()),
|
||||
Owners: []string{group.ID},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -599,4 +639,4 @@ func (h *ApplicationHandler) DiagsDocumentDownload(w http.ResponseWriter, r *htt
|
|||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/diags/%s", diagID), http.StatusFound)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@ import (
|
|||
|
||||
const diagsMenu = "diags"
|
||||
|
||||
func (renderer *Renderer) DiagsHome(w http.ResponseWriter, r *http.Request, diags []diagsstorage.Diag) {
|
||||
func (renderer *Renderer) DiagsHome(w http.ResponseWriter, r *http.Request, diags []diagsstorage.Diag, groups map[string]any) {
|
||||
files := renderer.ThemeConfig.GetStringSlice("views.diags.list.files")
|
||||
state := NewState(r, renderer.ThemeConfig, diagsMenu)
|
||||
state.ViewState = map[string]any{
|
||||
"diags": diags,
|
||||
"groups": groups,
|
||||
}
|
||||
|
||||
renderer.Render("diags home", w, r, files, state)
|
||||
|
|
Loading…
Reference in New Issue