diff --git a/main.go b/main.go index a36e40b..95a3736 100644 --- a/main.go +++ b/main.go @@ -27,8 +27,14 @@ func main() { log.Fatalln(err) } + bs, err := db.ReadAll() + if err != nil { + log.Fatalln(err) + } + mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/")))) - mux.HandleFunc("/", server.DisplayForm(&i)) + // mux.HandleFunc("/", server.DisplayForm(&i)) + mux.HandleFunc("/", server.DisplayTable(bs)) mux.HandleFunc("/add-participant/", server.AddParticipant(&i)) mux.HandleFunc("/submit/", server.SubmitForm(cb, &i, &j)) diff --git a/packages/server/server.go b/packages/server/server.go index 28ae6b1..0059a0a 100644 --- a/packages/server/server.go +++ b/packages/server/server.go @@ -8,16 +8,22 @@ import ( "streifling.com/jason/sicherheitsunterweisung/packages/types" ) +func DisplayTable(bs *[]types.Briefing) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + template.Must(template.ParseFiles("templates/index.html", "templates/table.html")).Execute(w, bs) + } +} + func DisplayForm(i *int64) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - template.Must(template.ParseFiles("templates/form.html")).Execute(w, i) + template.Must(template.ParseFiles("templates/index.html", "templates/form.html")).Execute(w, i) } } func AddParticipant(i *int64) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { *i++ - template.Must(template.ParseFiles("templates/form.html", "templates/participant.html")).ExecuteTemplate(w, "participant", i) + template.Must(template.ParseFiles("templates/form.html")).ExecuteTemplate(w, "participant", i) } } diff --git a/templates/form.html b/templates/form.html index 452bf83..2ef2f40 100644 --- a/templates/form.html +++ b/templates/form.html @@ -1,69 +1,54 @@ - - +{{ define "participant" }} +
Name Unterweiser | +Datum | +Uhrzeit | +Stand | +Ort | +Name Teilnehmer | +Firma | +
---|