3 Commits

3 changed files with 13 additions and 7 deletions

View File

@ -20,10 +20,10 @@ func main() {
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/")))) mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
mux.HandleFunc("/", server.DisplayTable(db)) mux.HandleFunc("/", server.DisplayTable(db))
mux.HandleFunc("/submit/", server.SubmitForm(db, &i, &j))
mux.HandleFunc("/search/", server.DisplayResults(db)) mux.HandleFunc("/search/", server.DisplayResults(db))
mux.HandleFunc("/new-briefing/", server.DisplayForm(&i)) mux.HandleFunc("/new-briefing/", server.DisplayForm(&i))
mux.HandleFunc("/add-participant/", server.AddParticipant(&i)) mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
mux.HandleFunc("/submit/", server.SubmitForm(db, &i, &j))
log.Fatalln(http.ListenAndServe(":8080", mux)) log.Fatalln(http.ListenAndServe(":8080", mux))
} }

View File

@ -37,6 +37,12 @@ func getCredentials() (string, string, error) {
return strings.TrimSpace(user), strings.TrimSpace(pass), nil return strings.TrimSpace(user), strings.TrimSpace(pass), nil
} }
func reverseOrder(bs *[]types.Briefing) {
for i, j := 0, len(*bs)-1; i < j; i, j = i+1, j-1 {
(*bs)[i], (*bs)[j] = (*bs)[j], (*bs)[i]
}
}
func Open(dbName string) (*DB, error) { func Open(dbName string) (*DB, error) {
var err error var err error
db := new(DB) db := new(DB)
@ -108,6 +114,7 @@ func (db *DB) ReadAll() (*[]types.Briefing, error) {
bs = append(bs, *b) bs = append(bs, *b)
} }
reverseOrder(&bs)
return &bs, nil return &bs, nil
} }
@ -145,5 +152,6 @@ func (db *DB) ReadByName(name string) (*[]types.Briefing, error) {
bs = append(bs, *b) bs = append(bs, *b)
} }
reverseOrder(&bs)
return &bs, nil return &bs, nil
} }

View File

@ -19,10 +19,8 @@
{{ define "content" }} {{ define "content" }}
<form> <form>
<label for="search-input">Suche</label> <label for="search-input">Suche</label>
<input type="text" name="search" id="search-input" /> <input type="text" name="search" id="search-input" hx-post="/search/" hx-target="#results" hx-swap="innerHTML"
<button type="submit" hx-post="/search/" hx-target="#results" hx-swap="innerHTML"> hx-trigger="keyup changed delay:200ms" />
Suchen
</button>
</form> </form>
<form> <form>
@ -34,12 +32,12 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th colspan="2">Name Unterweiser</th> <th colspan="2">Unterweiser</th>
<th>Datum</th> <th>Datum</th>
<th>Uhrzeit</th> <th>Uhrzeit</th>
<th>Stand</th> <th>Stand</th>
<th>Ort</th> <th>Ort</th>
<th colspan="2">Name Teilnehmer</th> <th colspan="2">Teilnehmer</th>
<th>Firma</th> <th>Firma</th>
</tr> </tr>
</thead> </thead>