Merge pull request 'Support module' (#1) from support into main

Reviewed-on: #1
This commit is contained in:
adelcasse 2022-11-01 10:56:32 +00:00
commit cb36a7c8dd
11 changed files with 191 additions and 11 deletions

1
go.mod
View File

@ -42,6 +42,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-mail/mail v2.3.1+incompatible // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect

2
go.sum
View File

@ -121,6 +121,8 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-mail/mail v2.3.1+incompatible h1:UzNOn0k5lpfVtO31cK3hn6I4VEVGhe3lX8AJBAxXExM=
github.com/go-mail/mail v2.3.1+incompatible/go.mod h1:VPWjmmNyRsWXQZHVHT3g0YbIINUkSmuKOiLIDkWbL6M=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=

View File

@ -0,0 +1,40 @@
package application
import (
"fmt"
"net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
)
type Message struct {
Content string
}
func (h *ApplicationHandler) SupportSend(w http.ResponseWriter, r *http.Request) {
c := r.Context().Value(identification.ClaimsKey)
if c == nil {
fmt.Println("no current user claims")
w.WriteHeader(http.StatusInternalServerError)
return
}
current_user_claims := c.(map[string]any)
comment := r.PostFormValue(("comment"))
if r.Method == "POST" {
data := map[string]any{
"key": comment,
"user": current_user_claims["email"],
}
if err := h.emailing.Send("support.request", "support@parcoursmob.fr", data); err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
}
http.Redirect(w, r, "/app/", http.StatusFound)
return
}
h.Renderer.SupportSend(w, r, comment, current_user_claims)
}

View File

@ -103,6 +103,11 @@ func main() {
application.HandleFunc("/group/settings", applicationHandler.GroupSettingsDisplay)
application.HandleFunc("/group/settings/invite-member", applicationHandler.GroupSettingsInviteMember)
/********************Code Supprt Emailing************************/
application.HandleFunc("/support/", applicationHandler.SupportSend)
/****************************************************************/
//TODO Subrouters with middlewares checking security for each module ?
application.Use(idp.Middleware)
application.Use(idp.GroupsMiddleware)

View File

@ -58,6 +58,7 @@ func (renderer *Renderer) Render(name string, w http.ResponseWriter, r *http.Req
},
)
t = template.Must(t.ParseFiles(prefixed_files...))
err := t.ExecuteTemplate(w, "main", state)
if err != nil {
fmt.Println(err)
@ -186,6 +187,18 @@ func NewState(r *http.Request, themeConfig *viper.Viper, menuState string) Rende
})
}
/*************************** my code ******************************/
if modules["support"] != nil && modules["support"].(bool) {
ls.MenuItems = append(ls.MenuItems, MenuItem{
Title: "Support",
Link: "/app/support/",
Active: menuState == commentMenu,
Icon: "hero:outline/support",
})
}
/*************************** my code ******************************/
if modules["directory"] != nil && modules["directory"].(bool) {
ls.MenuItems = append(ls.MenuItems, MenuItem{
Title: "Répertoire solutions",

20
renderer/support.go Normal file
View File

@ -0,0 +1,20 @@
package renderer
import (
"net/http"
)
const commentMenu = "comment"
//const commentsend = "sendComment"
func (renderer *Renderer) SupportSend(w http.ResponseWriter, r *http.Request, comment any, admins any) {
files := renderer.ThemeConfig.GetStringSlice("views.support.request.files")
state := NewState(r, renderer.ThemeConfig, commentMenu)
state.ViewState = map[string]any{
"comment": comment,
"admins": admins,
}
renderer.Render("comment", w, r, files, state)
}

View File

@ -32,6 +32,7 @@ views:
files:
- web/layouts/_partials/address_autocomplete.html
- web/layouts/beneficiaries/update.html
vehicles:
search:
files:
@ -96,6 +97,10 @@ views:
- web/layouts/journeys/_partials/journeys-carpool.html
- web/layouts/journeys/_partials/journeys-public-transit.html
- web/layouts/journeys/search.html
support:
request:
files:
- web/layouts/support/support.html
administration:
home:
files:
@ -141,6 +146,7 @@ icons:
svg:
coopgo:parcoursmob/monogram: <svg xmlns="http://www.w3.org/2000/svg" class="%s" viewBox="0 0 61.85 33.58"><defs><style>.cls-1{fill:#ff1300;}.cls-2{fill:#243887;}</style></defs><g id="Calque_2" data-name="Calque 2"><g id="Calque_1-2" data-name="Calque 1"><path class="cls-1" d="M44.978,0C31.337,0,28.1,6.824,27.875,15.505H39.536V9.434a.727.727,0,0,1,1.123-.607L52.6,16.453,40.659,24.08a.729.729,0,0,1-1.123-.608v-6.1H27.865c.075,8.427,1.527,16.213,17.113,16.213,14.867,0,16.872-7.764,16.872-17.032C61.85,7.91,59.894,0,44.978,0Z"/><polygon class="cls-1" points="41.412 21.385 49.133 16.453 41.412 11.521 41.412 21.385"/><path class="cls-2" d="M14.175,11.4l-.019,4.151H26.311a14.781,14.781,0,0,0,.819-5.141C27.046,3.767,22.545,0,14.764,0H1.052A1.147,1.147,0,0,0,0,1.24V31.87a1.149,1.149,0,0,0,1.094,1.239H11.525a1.145,1.145,0,0,0,1.051-1.239V10.41h.758C13.88,10.41,14.175,10.756,14.175,11.4Z"/><path class="cls-2" d="M14.148,17.3l-.015,3.514H18.97A7.521,7.521,0,0,0,25.458,17.3Z"/></g></g></svg>
hero:outline/briefcase: <svg xmlns="http://www.w3.org/2000/svg" class="%s" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" /></svg>
hero:outline/support: <svg xmlns="http://www.w3.org/2000/svg" class="%s" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" /></svg>
hero:outline/calendar: <svg xmlns="http://www.w3.org/2000/svg" class="%s" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
hero:outline/chevron-right: <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="%s"><path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" /></svg>
hero:outline/cog: <svg xmlns="http://www.w3.org/2000/svg" class="%s" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>
@ -192,4 +198,11 @@ emails:
subject: PAROURSMOB - Réinitialisez votre mot de passe
files:
- emails/layout.html
- emails/auth/retrieve-password.html
- emails/auth/retrieve-password.html
support:
request:
subject: PARCOURMOB - Demande de support
files:
- emails/layout.html
- emails/onboarding/support_emailing.html

View File

@ -0,0 +1,4 @@
{{define "content"}}
<p>Vous avez reçu un commentaire sur PARCOURSMOB de la part de <b>{{.user}}</b></p>
<p>{{.key}}</p>
{{end}}

View File

@ -0,0 +1,27 @@
{{define "content"}}
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 space-y-6">
<h1 class="text-2xl font-semibold text-gray-900">Demande de support</h1>
<div class="bg-white py-2 px-4 shadow sm:rounded-lg sm:px-10">
<p class="text-sm text-gray-600 p-4">
Le support PARCOURSMOB est ouvert les jours ouvrés de 9h à 18h. Vous pouvez également nous joindre par email à <b class="text-co-blue"><a href="mailto:support@parcoursmob.fr">support@parcoursmob.fr</a></b>, par exemple pour nous envoyez des copies d'écran du problème que vous rencontrez.
</p>
<form action="" method="POST">
<div class="mb-4 w-full bg-gray-50 rounded-3xl border border-gray-200 dark:bg-gray-700 dark:border-gray-600">
<div class="py-2 px-4 rounded-3xl bg-white dark:bg-gray-800">
<label class="sr-only">Votre message</label>
<textarea name="comment" rows="4" class="block w-full resize-none border-0 border-b border-transparent p-0 pb-2 focus:border-co-blue focus:ring-0 sm:text-sm" placeholder="Votre message..." required></textarea>
</div>
<div class="flex justify-center items-center py-2 px-3 border-t dark:border-gray-600">
<button type="submit" value="send message" class="px-2 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm text-white bg-co-blue hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">
Envoyer
</button>
</div>
</div>
</form>
</div>
</div>
{{end}}

View File

@ -1259,6 +1259,10 @@ html {
user-select: none;
}
.resize-none {
resize: none;
}
.appearance-none {
-webkit-appearance: none;
-moz-appearance: none;
@ -1527,6 +1531,11 @@ html {
border-bottom-left-radius: 1rem;
}
.rounded-t-lg {
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
}
.border {
border-width: 1px;
}
@ -1535,6 +1544,10 @@ html {
border-width: 2px;
}
.border-0 {
border-width: 0px;
}
.border-r {
border-right-width: 1px;
}
@ -1689,6 +1702,14 @@ html {
padding: 0.375rem;
}
.p-8 {
padding: 2rem;
}
.p-0 {
padding: 0px;
}
.px-4 {
padding-left: 1rem;
padding-right: 1rem;
@ -1820,10 +1841,6 @@ html {
padding-top: 2rem;
}
.pb-6 {
padding-bottom: 1.5rem;
}
.pt-4 {
padding-top: 1rem;
}
@ -1848,6 +1865,14 @@ html {
padding-left: 0.375rem;
}
.pb-6 {
padding-bottom: 1.5rem;
}
.pb-2 {
padding-bottom: 0.5rem;
}
.text-left {
text-align: left;
}
@ -2278,11 +2303,6 @@ html {
color: rgb(55 65 81 / var(--tw-text-opacity));
}
.hover\:text-indigo-500:hover {
--tw-text-opacity: 1;
color: rgb(99 102 241 / var(--tw-text-opacity));
}
.hover\:text-gray-900:hover {
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
@ -2297,6 +2317,11 @@ html {
color: inherit;
}
.hover\:text-indigo-500:hover {
--tw-text-opacity: 1;
color: rgb(99 102 241 / var(--tw-text-opacity));
}
.focus\:border-transparent:focus {
border-color: transparent;
}
@ -2316,6 +2341,11 @@ html {
border-color: rgb(59 130 246 / var(--tw-border-opacity));
}
.focus\:border-indigo-600:focus {
--tw-border-opacity: 1;
border-color: rgb(79 70 229 / var(--tw-border-opacity));
}
.focus\:placeholder-gray-400:focus::-moz-placeholder {
--tw-placeholder-opacity: 1;
color: rgb(156 163 175 / var(--tw-placeholder-opacity));
@ -2404,6 +2434,23 @@ html {
color: rgb(107 114 128 / var(--tw-text-opacity));
}
@media (prefers-color-scheme: dark) {
.dark\:border-gray-600 {
--tw-border-opacity: 1;
border-color: rgb(75 85 99 / var(--tw-border-opacity));
}
.dark\:bg-gray-700 {
--tw-bg-opacity: 1;
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
}
.dark\:bg-gray-800 {
--tw-bg-opacity: 1;
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
}
}
@media (min-width: 640px) {
.sm\:col-span-3 {
grid-column: span 3 / span 3;
@ -2629,6 +2676,14 @@ html {
grid-column: span 2 / span 2;
}
.md\:col-span-3 {
grid-column: span 3 / span 3;
}
.md\:col-span-6 {
grid-column: span 6 / span 6;
}
.md\:mx-0 {
margin-left: 0px;
margin-right: 0px;

View File

@ -52,7 +52,7 @@ func NewIdentificationProvider(cfg *viper.Viper, services *services.ServicesHand
Endpoint: provider.Endpoint(),
// "openid" is a required scope for OpenID Connect flows.
Scopes: []string{oidc.ScopeOpenID, "groups", "first_name", "last_name", "display_name"},
Scopes: []string{oidc.ScopeOpenID, "groups", "first_name", "last_name", "display_name", "email"},
}
store := storage.NewSessionStore(kv, []byte(sessionsSecret))