diff --git a/pkg/agecemorg/handler.go b/pkg/agecemorg/handler.go index 5f8b886..69643ce 100644 --- a/pkg/agecemorg/handler.go +++ b/pkg/agecemorg/handler.go @@ -2,6 +2,7 @@ package agecemorg import ( "context" + "encoding/json" "fmt" "io" "log" @@ -11,6 +12,7 @@ import ( "codeberg.org/vlbeaudoin/pave/v2" "codeberg.org/vlbeaudoin/voki/v3" + "git.agecem.com/agecem/agecem-org/v3/ui" "github.com/labstack/echo/v4" "github.com/minio/minio-go/v7" ) @@ -590,7 +592,24 @@ func HandleActualiteArticle(c echo.Context) error { */ func HandleVieEtudiante(c echo.Context) error { - return c.Render(http.StatusOK, "vie-etudiante-html", nil) + var data struct { + Data struct { + Organismes map[string][]struct { + Nom string + Local string + Poste string + Statut string + } + } + Error string + } + + if err := json.Unmarshal([]byte(ui.OrganismesJSON()), &data.Data.Organismes); err != nil { + data.Error = err.Error() + log.Println("json error in vie-etudiante:", err) + } + + return c.Render(http.StatusOK, "vie-etudiante-html", data) } func HandleVieEtudianteOrganisme(c echo.Context) error { diff --git a/ui/ui.go b/ui/ui.go index c69ecf5..be54960 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -19,6 +19,11 @@ import ( //go:embed *.html var htmlFS embed.FS +//go:embed vie-etudiante-organismes.json +var organismesJSON string + +func OrganismesJSON() string { return organismesJSON } + type Renderer struct { templates *template.Template } diff --git a/ui/organismes.json b/ui/vie-etudiante-organismes.json similarity index 99% rename from ui/organismes.json rename to ui/vie-etudiante-organismes.json index 0e251a2..c635eff 100644 --- a/ui/organismes.json +++ b/ui/vie-etudiante-organismes.json @@ -1,16 +1,4 @@ { - "Organismes thématiques": [ - { "Nom": "AME", "Local": "C-060", "Poste": "7919", "Statut": "Actif" }, - { "Nom": "BEAM", "Local": "F-024a", "Poste": "5930", "Statut": "Actif" }, - { "Nom": "Club Aventurier", "Local": "F-011b", "Poste": "2418", "Statut": "Actif" }, - { "Nom": "MAEL", "Local": "F-027b", "Poste": "6438", "Statut": "Actif" }, - { "Nom": "Montpetit Donjon", "Local": "C-067", "Poste": "2299", "Statut": "Actif" }, - { "Nom": "MotDit", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, - { "Nom": "OGRE", "Local": "F-011c", "Poste": "2248", "Statut": "Actif" }, - { "Nom": "ORGASME", "Local": "F-049", "Poste": "N/A", "Statut": "Actif" }, - { "Nom": "RECEM", "Local": "A-125s", "Poste": "N/A", "Statut": "Actif" }, - { "Nom": "Équipe Santé", "Local": "F-011", "Poste": "2361", "Statut": "Actif" } - ], "Associations de programme": [ { "Nom": "ADEPT", "Local": "F-045", "Poste": "2286", "Statut": "Actif" }, { "Nom": "ASI", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, @@ -30,6 +18,17 @@ { "Nom": "ESPACE", "Local": "F-011d", "Poste": "2418", "Statut": "Actif" }, { "Nom": "EUMC-CEM", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, { "Nom": "Friperie", "Local": "F-027a", "Poste": "2248", "Statut": "Actif" } + ], + "Organismes thématiques": [ + { "Nom": "AME", "Local": "C-060", "Poste": "7919", "Statut": "Actif" }, + { "Nom": "BEAM", "Local": "F-024a", "Poste": "5930", "Statut": "Actif" }, + { "Nom": "Club Aventurier", "Local": "F-011b", "Poste": "2418", "Statut": "Actif" }, + { "Nom": "MAEL", "Local": "F-027b", "Poste": "6438", "Statut": "Actif" }, + { "Nom": "Montpetit Donjon", "Local": "C-067", "Poste": "2299", "Statut": "Actif" }, + { "Nom": "MotDit", "Local": "N/A", "Poste": "N/A", "Statut": "Inactif" }, + { "Nom": "OGRE", "Local": "F-011c", "Poste": "2248", "Statut": "Actif" }, + { "Nom": "ORGASME", "Local": "F-049", "Poste": "N/A", "Statut": "Actif" }, + { "Nom": "RECEM", "Local": "A-125s", "Poste": "N/A", "Statut": "Actif" }, + { "Nom": "Équipe Santé", "Local": "F-011", "Poste": "2361", "Statut": "Actif" } ] } - diff --git a/ui/vie-etudiante.html b/ui/vie-etudiante.html index 54046bd..d9f064b 100644 --- a/ui/vie-etudiante.html +++ b/ui/vie-etudiante.html @@ -13,7 +13,12 @@ {{ template "header-html" }} <div class="wrapper vieEtudianteWrapper"> <h1 class="heading1">Vie étudiante</h1> - <h2 class="heading2">Organismes thématiques</h2> + + {{if not .Data.Organismes}} + <h2>Liste des organismes étudiants non-disponible, merci de rééssayer plus tard.</h2> + {{else}} + {{range $categorie, $organismes := .Data.Organismes}} + <h2 class="heading2">{{$categorie}}</h2> <table class="table"> <tr class="tableRowHeading"> <td>Nom</td> @@ -21,193 +26,31 @@ <td>Poste</td> <td>Statut</td> </tr> - <tr class="tableRow"> - <td>AME</td> - <td>C-060</td> - <td>7919</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>BEAM</td> - <td>F-024a</td> - <td>5930</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>Club Aventurier</td> - <td>F-011b</td> - <td>2418</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>Équipe Santé</td> - <td>F-011</td> - <td>2361</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>Montpetit Donjon</td> - <td>C-067</td> - <td>2299</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>MAEL</td> - <td>F-027b</td> - <td>6438</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>OGRE</td> - <td>F-011c</td> - <td>2248</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>RECEM</td> - <td>A-125s</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>ORGASME</td> - <td>F-049</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> + {{range $organismes}} + {{if eq .Statut "Inactif"}} <tr class="tableRow inactive"> - <td>SOI</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - <tr class="tableRow inactive"> - <td>MotDit</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> + <td>{{.Nom}}</td> + <td>{{.Local}}</td> + <td>{{.Poste}}</td> + <td class="organismeInactif">{{.Statut}}</td> + {{else}} + <tr class="tableRow"> + <td>{{.Nom}}</td> + <td>{{.Local}}</td> + <td>{{.Poste}}</td> + <td class="organismeActif">{{.Statut}}</td> + {{end}} </tr> + {{end}} </table> <hr class="separator"> - <h2 class="heading2">Associations de programme</h2> - <table class="table"> - <tr class="tableRowHeading"> - <td>Nom</td> - <td>Local</td> - <td>Poste</td> - <td>Statut</td> - </tr> - <tr class="tableRow"> - <td>ADEPT</td> - <td>F-045</td> - <td>2286</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>ATIM</td> - <td>F-011b</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>LAC</td> - <td>A-125s</td> - <td>2873</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>PAPI</td> - <td>F-023</td> - <td>2795</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>TGE</td> - <td>C-063</td> - <td>2638</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow inactive"> - <td>ASI</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - <tr class="tableRow" inactive> - <td>ATEE</td> - <td>F-027d</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - </table> - <hr class="separator"> - <h2 class="heading2">Comités</h2> - <table class="table"> - <tr class="tableRowHeading"> - <td>Nom</td> - <td>Local</td> - <td>Poste</td> - <td>Statut</td> - </tr> - <tr class="tableRow"> - <td>ASEG</td> - <td>B-06</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>CIC</td> - <td>F-027c</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>Comité Mob</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>ESPACE</td> - <td>F-011d</td> - <td>2418</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow"> - <td>Friperie</td> - <td>F-027a</td> - <td>2248</td> - <td class="organismeActif">Actif</td> - </tr> - <tr class="tableRow inactive"> - <td>CAP</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - <tr class="tableRow inactive"> - <td>CÉSI</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - <tr class="tableRow inactive"> - <td>CFEM</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - <tr class="tableRow inactive"> - <td>EUMC-CEM</td> - <td>N/A</td> - <td>N/A</td> - <td class="organismeInactif">Inactif</td> - </tr> - </table> + {{end}} + {{end}} + </div> <!-- {{ template "snackbar-html" }} --> {{ template "footer-html" }} </body> </html> -{{ end }} \ No newline at end of file +{{ end }}