Templates verbessert

This commit is contained in:
Gonne 2022-09-07 21:48:40 +02:00
parent 56b4a3ab34
commit e9e0cbf382
11 changed files with 53 additions and 42 deletions

View file

@ -16,10 +16,7 @@ type maskData struct {
MinuteGranularity int
SelectedCourse int
SelectedRoom int
Week int
Day int
Hour int
Minute int
Date models.Date
Duration int
Roomname string
Name string
@ -115,7 +112,6 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
info := req.FormValue("info")
allowed, err := b.officeHourRepo.AllowedAt(date, duration, room, true)
fmt.Println(allowed)
if err != nil {
errors = append(errors, fmt.Sprintf("Fehler beim Abfragen der Raumkapazität: %s", err.Error()))
} else if !allowed {
@ -128,10 +124,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
models.MinuteGranularity,
courseid,
roomid,
week,
day,
hour,
minute,
date,
duration,
roomname,
name,

View file

@ -18,7 +18,14 @@ func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Req
err = b.requestRepo.Execute(request)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
tmpl, err := template.ParseFiles("templates/executeFailure.html")
tmpl.Execute(w, err)
tmpl, _ := template.ParseFiles("templates/executeFailure.html")
tmpl.Execute(w, err.Error())
return
}
tmpl, err := template.ParseFiles("templates/executeSuccess.html")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
tmpl.Execute(w, struct{}{})
}

View file

@ -50,10 +50,7 @@ func GetTimetable(officeHours []models.OfficeHour) (timetable map[models.Date]ma
func printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots []int, deleteIcons bool) template.HTML {
var tableBody string
tableCell, _ := template.New("td.html").
Funcs(template.FuncMap{"mod": func(i int, j int) int { return i % j },
"add": func(i int, j int) int { return i + j },
"divide": func(i int, j int) int { return i / j }}).ParseFiles("templates/td.html")
tableCell, _ := template.New("td.html").Funcs(template.FuncMap{"divide": func(i int, j int) int { return i / j }}).ParseFiles("templates/td.html")
for hour := 8; hour < 19; hour += 1 {
for minute := 0; minute < 60; minute += models.MinuteGranularity {
tableBody += "<tr>"