Initial commit

This commit is contained in:
Victor Lacasse-Beaudoin 2025-02-27 14:13:21 -05:00
commit 02947128bc
24 changed files with 1126 additions and 0 deletions

4
ui/decompte.html Normal file
View file

@ -0,0 +1,4 @@
{{ define "decompte-html" }}
Décompte: {{ .Decompte }}
{{if not .HideFermerButton}}<button hx-get="/nothing/" hx-on:click="document.getElementById('app-dialog').style.display = 'none';">fermer</button>{{else}}{{end}}
{{ end }}

13
ui/embed.go Normal file
View file

@ -0,0 +1,13 @@
package ui
import "embed"
//go:embed *.html
var htmlFS embed.FS
func HTMLFS() embed.FS { return htmlFS }
//go:embed js/*.js
var jsFS embed.FS
func JSFS() embed.FS { return jsFS }

31
ui/index.html Normal file
View file

@ -0,0 +1,31 @@
{{ define "index-html" }}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AGECEM | Assemblée Générale</title>
<script src="/public/js/htmx.min.js"></script>
<script src="/public/js/membreid-selected-and-cleared.js"></script>
</head>
<body>
<h2>Présences en Assemblée Générale</h2>
{{ if .Error }}<h3>Error: {{ .Error }}</h3>{{ end }}
<div hx-get="/decompte?hideFermerButton=true" hx-trigger="load, every 3s">
Obtention du décompte...
</div>
<form action="" hx-post="/scan/" hx-target="#app-content">
<label for="membre_id">Numéro étudiant:</label>
<input id="membre_id" name="membre_id" value="" required />
<button type="submit">enregistrer</button>
</form>
<div id="app-content">
</div>
</body>
</html>
{{ end }}

1
ui/js/htmx.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
function clearInput(inputId) {
document.getElementById(inputId).value = '';
};
function focusInput(inputId) {
document.getElementById(inputId).focus();
};
window.onload = function() {
inputId = "membre_id";
clearInput(inputId);
focusInput(inputId);
};

22
ui/render.go Normal file
View file

@ -0,0 +1,22 @@
package ui
import (
"io"
"text/template"
"github.com/labstack/echo/v4"
)
type Renderer struct {
templates *template.Template
}
func (t *Renderer) Render(w io.Writer, name string, data any, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}
func NewRenderer() *Renderer {
return &Renderer{
templates: template.Must(template.ParseFS(htmlFS, "*.html")),
}
}

4
ui/scan.html Normal file
View file

@ -0,0 +1,4 @@
{{ define "scan-html" }}
{{ if .Error }}<h3>Erreur: {{ .Error }}</h3>{{ end }}
{{ if .Result }}<h3>Résultat: {{ .Result }}</h3>{{ end }}
{{ end }}