From a634b7a69ee21036f61a27dbecc65cf436fbfe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Tr=C3=B6ger?= Date: Mon, 27 Oct 2025 22:53:07 +0100 Subject: [PATCH] separaded endpoints + cleaned page templates + added constants to time formatting --- Backend/endpoints/pdf-create.go | 161 ++++++++ Backend/endpoints/pdf.go | 156 -------- Backend/endpoints/team.go | 2 +- Backend/endpoints/time.go | 10 +- Backend/endpoints/user-settings.go | 2 +- Backend/helper/logs/main.go | 2 +- Backend/helper/paramParser/main.go | 31 ++ Backend/helper/time_test.go | 4 +- Backend/main.go | 2 +- Backend/models/workDay.go | 8 +- Backend/models/workDay_test.go | 2 +- Backend/models/workWeek_test.go | 4 +- Backend/static/css/styles.css | 107 +----- Backend/static/script.js | 6 + Backend/templates/headerComponent.templ | 3 +- Backend/templates/headerComponent_templ.go | 4 +- Backend/templates/pages.templ | 40 +- Backend/templates/pages_templ.go | 119 +----- Backend/templates/pdf.templ | 30 +- Backend/templates/pdf_templ.go | 415 +++++++++++---------- Backend/templates/presencePage.templ | 29 ++ Backend/templates/presencePage_templ.go | 110 ++++++ Backend/templates/timeComponents.templ | 8 +- Backend/templates/timeComponents_templ.go | 16 +- Backend/templates/timePage.templ | 8 +- Backend/templates/timePage_templ.go | 14 +- 26 files changed, 654 insertions(+), 639 deletions(-) create mode 100644 Backend/endpoints/pdf-create.go create mode 100644 Backend/helper/paramParser/main.go create mode 100644 Backend/templates/presencePage.templ create mode 100644 Backend/templates/presencePage_templ.go diff --git a/Backend/endpoints/pdf-create.go b/Backend/endpoints/pdf-create.go new file mode 100644 index 0000000..5184c70 --- /dev/null +++ b/Backend/endpoints/pdf-create.go @@ -0,0 +1,161 @@ +package endpoints + +import ( + "arbeitszeitmessung/helper" + "arbeitszeitmessung/helper/paramParser" + "arbeitszeitmessung/models" + "bytes" + "fmt" + "log" + "log/slog" + "net/http" + "time" + + "github.com/Dadido3/go-typst" +) + +func convertDaysToTypst(days []models.IWorkDay, u models.User) ([]typstDay, error) { + var typstDays []typstDay + for _, day := range days { + var thisTypstDay typstDay + work, pause, overtime := day.GetAllWorkTimesVirtual(u) + thisTypstDay.Date = day.Date().Format("02.01.2006") + thisTypstDay.Worktime = helper.FormatDurationFill(work, true) + thisTypstDay.Pausetime = helper.FormatDurationFill(pause, true) + thisTypstDay.Overtime = helper.FormatDurationFill(overtime, true) + thisTypstDay.IsFriday = day.Date().Weekday() == time.Friday + + thisTypstDay.DayParts = convertDayToTypstDayParts(day, u) + typstDays = append(typstDays, thisTypstDay) + } + return typstDays, nil +} + +func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDayPart { + var typstDayParts []typstDayPart + if day.IsWorkDay() { + workDay, _ := day.(*models.WorkDay) + for i := 0; i < len(workDay.Bookings); i += 2 { + var typstDayPart typstDayPart + typstDayPart.BookingFrom = workDay.Bookings[i].Timestamp.Format("15:04") + typstDayPart.BookingTo = workDay.Bookings[i+1].Timestamp.Format("15:04") + typstDayPart.WorkType = workDay.Bookings[i].BookingType.Name + typstDayPart.IsWorkDay = true + typstDayParts = append(typstDayParts, typstDayPart) + } + if day.IsKurzArbeit() { + tsFrom, tsTo := workDay.GenerateKurzArbeitBookings(user) + typstDayParts = append(typstDayParts, typstDayPart{ + BookingFrom: tsFrom.Format("15:04"), + BookingTo: tsTo.Format("15:04"), + WorkType: "Kurzarbeit", + IsWorkDay: true, + }) + } + } else { + absentDay, _ := day.(*models.Absence) + typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: absentDay.AbwesenheitTyp.Name}) + } + return typstDayParts +} + +func renderPDF(days []typstDay, metadata typstMetadata) (bytes.Buffer, error) { + var markup bytes.Buffer + var output bytes.Buffer + + if err := typst.InjectValues(&markup, map[string]any{"meta": metadata, "days": days}); err != nil { + return output, err + } + + // Import the template and invoke the template function with the custom data. + // Show is used to replace the current document with whatever content the template function in `template.typ` returns. + markup.WriteString(` + #import "template.typ": abrechnung + #show: doc => abrechnung(meta, days) + `) + + // Compile the prepared markup with Typst and write the result it into `output.pdf`. + // f, err := os.Create("output.pdf") + // if err != nil { + // log.Panicf("Failed to create output file: %v.", err) + // } + // defer f.Close() + // + + typstCLI := typst.CLI{} + if err := typstCLI.Compile(&markup, &output, nil); err != nil { + return output, err + } + return output, nil +} + +func PDFHandler(w http.ResponseWriter, r *http.Request) { + helper.RequiresLogin(Session, w, r) + pp := paramParser.New(r.URL.Query()) + startDate := pp.ParseTimestamp("start_date", time.DateOnly, time.Now()) + if startDate.Day() > 1 { + startDate = startDate.AddDate(0, 0, -(startDate.Day() - 1)) + } + endDate := startDate.AddDate(0, 1, -1) + + user, err := models.GetUserFromSession(Session, r.Context()) + if err != nil { + log.Println("Error getting user!") + } + + //TODO: only accepted weeks + + weeks := models.GetDays(user, startDate, endDate, false) + var aggregatedOvertime, aggregatedWorkTime time.Duration + for _, day := range weeks { + aggregatedOvertime += day.TimeOvertimeReal(user) + aggregatedWorkTime += day.TimeWorkVirtual(user) + } + + typstDays, err := convertDaysToTypst(weeks, user) + if err != nil { + log.Panicf("Failed to convert days!") + } + metadata := typstMetadata{ + EmployeeName: fmt.Sprintf("%s %s", user.Vorname, user.Name), + TimeRange: fmt.Sprintf("%s - %s", startDate.Format("02.01.2006"), endDate.Format("02.01.2006")), + Overtime: helper.FormatDurationFill(aggregatedOvertime, true), + WorkTime: helper.FormatDurationFill(aggregatedWorkTime, true), + OvertimeTotal: "", + CurrentTimestamp: time.Now().Format("02.01.2006 - 15:04 Uhr"), + } + + output, err := renderPDF(typstDays, metadata) + if err != nil { + slog.Warn("Could not create pdf report", slog.Any("Error", err)) + } + + w.Header().Set("Content-type", "application/pdf") + output.WriteTo(w) + w.WriteHeader(200) +} + +type typstMetadata struct { + TimeRange string `json:"time-range"` + EmployeeName string `json:"employee-name"` + WorkTime string `json:"worktime"` + Overtime string `json:"overtime"` + OvertimeTotal string `json:"overtime-total"` + CurrentTimestamp string `json:"current-timestamp"` +} + +type typstDayPart struct { + BookingFrom string `json:"booking-from"` + BookingTo string `json:"booking-to"` + WorkType string `json:"worktype"` + IsWorkDay bool `json:"is-workday"` +} + +type typstDay struct { + Date string `json:"date"` + DayParts []typstDayPart `json:"day-parts"` + Worktime string `json:"worktime"` + Pausetime string `json:"pausetime"` + Overtime string `json:"overtime"` + IsFriday bool `json:"is-weekend"` +} diff --git a/Backend/endpoints/pdf.go b/Backend/endpoints/pdf.go index eb36e9f..e08ef6d 100644 --- a/Backend/endpoints/pdf.go +++ b/Backend/endpoints/pdf.go @@ -4,116 +4,10 @@ import ( "arbeitszeitmessung/helper" "arbeitszeitmessung/models" "arbeitszeitmessung/templates" - "bytes" - "fmt" - "log" "log/slog" "net/http" - "time" - - "github.com/Dadido3/go-typst" ) -type typstMetadata struct { - TimeRange string `json:"time-range"` - EmployeeName string `json:"employee-name"` - WorkTime string `json:"worktime"` - Overtime string `json:"overtime"` - OvertimeTotal string `json:"overtime-total"` - CurrentTimestamp string `json:"current-timestamp"` -} - -type typstDayPart struct { - BookingFrom string `json:"booking-from"` - BookingTo string `json:"booking-to"` - WorkType string `json:"worktype"` - IsWorkDay bool `json:"is-workday"` -} - -type typstDay struct { - Date string `json:"date"` - DayParts []typstDayPart `json:"day-parts"` - Worktime string `json:"worktime"` - Pausetime string `json:"pausetime"` - Overtime string `json:"overtime"` - IsFriday bool `json:"is-weekend"` -} - -func convertDaysToTypst(days []models.IWorkDay, u models.User) ([]typstDay, error) { - var typstDays []typstDay - for _, day := range days { - var thisTypstDay typstDay - work, pause, overtime := day.GetAllWorkTimesVirtual(u) - thisTypstDay.Date = day.Date().Format("02.01.2006") - thisTypstDay.Worktime = helper.FormatDurationFill(work, true) - thisTypstDay.Pausetime = helper.FormatDurationFill(pause, true) - thisTypstDay.Overtime = helper.FormatDurationFill(overtime, true) - thisTypstDay.IsFriday = day.Date().Weekday() == time.Friday - - thisTypstDay.DayParts = convertDayToTypstDayParts(day, u) - typstDays = append(typstDays, thisTypstDay) - } - return typstDays, nil -} - -func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDayPart { - var typstDayParts []typstDayPart - if day.IsWorkDay() { - workDay, _ := day.(*models.WorkDay) - for i := 0; i < len(workDay.Bookings); i += 2 { - var typstDayPart typstDayPart - typstDayPart.BookingFrom = workDay.Bookings[i].Timestamp.Format("15:04") - typstDayPart.BookingTo = workDay.Bookings[i+1].Timestamp.Format("15:04") - typstDayPart.WorkType = workDay.Bookings[i].BookingType.Name - typstDayPart.IsWorkDay = true - typstDayParts = append(typstDayParts, typstDayPart) - } - if day.IsKurzArbeit() { - tsFrom, tsTo := workDay.GenerateKurzArbeitBookings(user) - typstDayParts = append(typstDayParts, typstDayPart{ - BookingFrom: tsFrom.Format("15:04"), - BookingTo: tsTo.Format("15:04"), - WorkType: "Kurzarbeit", - IsWorkDay: true, - }) - } - } else { - absentDay, _ := day.(*models.Absence) - typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: absentDay.AbwesenheitTyp.Name}) - } - return typstDayParts -} - -func renderPDF(days []typstDay, metadata typstMetadata) (bytes.Buffer, error) { - var markup bytes.Buffer - var output bytes.Buffer - - if err := typst.InjectValues(&markup, map[string]any{"meta": metadata, "days": days}); err != nil { - return output, err - } - - // Import the template and invoke the template function with the custom data. - // Show is used to replace the current document with whatever content the template function in `template.typ` returns. - markup.WriteString(` - #import "template.typ": abrechnung - #show: doc => abrechnung(meta, days) - `) - - // Compile the prepared markup with Typst and write the result it into `output.pdf`. - // f, err := os.Create("output.pdf") - // if err != nil { - // log.Panicf("Failed to create output file: %v.", err) - // } - // defer f.Close() - // - - typstCLI := typst.CLI{} - if err := typstCLI.Compile(&markup, &output, nil); err != nil { - return output, err - } - return output, nil -} - func PDFFormHandler(w http.ResponseWriter, r *http.Request) { helper.RequiresLogin(Session, w, r) @@ -129,53 +23,3 @@ func PDFFormHandler(w http.ResponseWriter, r *http.Request) { } templates.PDFForm(teamMembers).Render(r.Context(), w) } - -func PDFHandler(w http.ResponseWriter, r *http.Request) { - helper.RequiresLogin(Session, w, r) - startDate, err := parseTimestamp(r, "start_date", time.Now().Format("2006-01-02")) - if err != nil { - log.Println("Error parsing 'start_date' time", err) - http.Error(w, "Timestamp 'start_date' cannot be parsed!", http.StatusBadRequest) - return - } - if startDate.Day() > 1 { - startDate = startDate.AddDate(0, 0, -(startDate.Day() - 1)) - } - endDate := startDate.AddDate(0, 1, -1) - - user, err := models.GetUserFromSession(Session, r.Context()) - if err != nil { - log.Println("Error getting user!") - } - - //TODO: only accepted weeks - - weeks := models.GetDays(user, startDate, endDate, false) - var aggregatedOvertime, aggregatedWorkTime time.Duration - for _, day := range weeks { - aggregatedOvertime += day.TimeOvertimeReal(user) - aggregatedWorkTime += day.TimeWorkVirtual(user) - } - - typstDays, err := convertDaysToTypst(weeks, user) - if err != nil { - log.Panicf("Failed to convert days!") - } - metadata := typstMetadata{ - EmployeeName: fmt.Sprintf("%s %s", user.Vorname, user.Name), - TimeRange: fmt.Sprintf("%s - %s", startDate.Format("02.01.2006"), endDate.Format("02.01.2006")), - Overtime: helper.FormatDurationFill(aggregatedOvertime, true), - WorkTime: helper.FormatDurationFill(aggregatedWorkTime, true), - OvertimeTotal: "", - CurrentTimestamp: time.Now().Format("02.01.2006 - 15:04 Uhr"), - } - - output, err := renderPDF(typstDays, metadata) - if err != nil { - slog.Warn("Could not create pdf report", slog.Any("Error", err)) - } - - w.Header().Set("Content-type", "application/pdf") - output.WriteTo(w) - w.WriteHeader(200) -} diff --git a/Backend/endpoints/team.go b/Backend/endpoints/team.go index 397d45a..467b4bf 100644 --- a/Backend/endpoints/team.go +++ b/Backend/endpoints/team.go @@ -65,7 +65,7 @@ func showWeeks(w http.ResponseWriter, r *http.Request) { submissionDate := r.URL.Query().Get("submission_date") lastSub := user.GetLastWorkWeekSubmission() if submissionDate != "" { - submissionDate, err := time.Parse("2006-01-02", submissionDate) + submissionDate, err := time.Parse(time.DateOnly, submissionDate) if err == nil { lastSub = helper.GetMonday(submissionDate) } diff --git a/Backend/endpoints/time.go b/Backend/endpoints/time.go index 0ed80a8..5e0f6f7 100644 --- a/Backend/endpoints/time.go +++ b/Backend/endpoints/time.go @@ -52,7 +52,7 @@ func parseTimestamp(r *http.Request, getKey string, fallback string) (time.Time, if getTimestamp == "" { getTimestamp = fallback } - Timestamp, err := time.Parse("2006-01-02", getTimestamp) + Timestamp, err := time.Parse(time.DateOnly, getTimestamp) if err != nil { return time.Now(), err } @@ -69,13 +69,13 @@ func getBookings(w http.ResponseWriter, r *http.Request) { } // TODO add config for timeoffset - tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format("2006-01-02")) + tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format(time.DateOnly)) if err != nil { log.Println("Error parsing 'from' time", err) http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest) return } - tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02")) + tsTo, err := parseTimestamp(r, "time_to", time.Now().Format(time.DateOnly)) if err != nil { log.Println("Error parsing 'to' time", err) http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest) @@ -193,13 +193,13 @@ func updateAbsence(r *http.Request) error { loc = time.Local } - dateFrom, err := time.ParseInLocation("2006-01-02", r.FormValue("date_from"), loc) + dateFrom, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_from"), loc) if err != nil { log.Println("Error parsing date_from input for absence", err) return err } - dateTo, err := time.ParseInLocation("2006-01-02", r.FormValue("date_to"), loc) + dateTo, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_to"), loc) if err != nil { log.Println("Error parsing date_to input for absence", err) return err diff --git a/Backend/endpoints/user-settings.go b/Backend/endpoints/user-settings.go index 66f7d1b..65b7ebd 100644 --- a/Backend/endpoints/user-settings.go +++ b/Backend/endpoints/user-settings.go @@ -43,5 +43,5 @@ func showUserPage(w http.ResponseWriter, r *http.Request, status int) { if user, err := models.GetUserFromSession(Session, r.Context()); err == nil { ctx = context.WithValue(r.Context(), "user", user) } - templates.UserPage(status).Render(ctx, w) + templates.SettingsPage(status).Render(ctx, w) } diff --git a/Backend/helper/logs/main.go b/Backend/helper/logs/main.go index 764a51c..9cad2bb 100644 --- a/Backend/helper/logs/main.go +++ b/Backend/helper/logs/main.go @@ -14,7 +14,7 @@ type FileLog struct { var Logs map[string]FileLog = make(map[string]FileLog) func NewAudit() (i *log.Logger, close func() error) { - LOG_FILE := "logs/" + time.Now().Format("2006-01-02") + ".log" + LOG_FILE := "logs/" + time.Now().Format(time.DateOnly) + ".log" logFile, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { log.Panic(err) diff --git a/Backend/helper/paramParser/main.go b/Backend/helper/paramParser/main.go new file mode 100644 index 0000000..0b08c2d --- /dev/null +++ b/Backend/helper/paramParser/main.go @@ -0,0 +1,31 @@ +package paramParser + +import ( + "log/slog" + "net/url" + "time" +) + +type ParamsParser struct { + urlParams url.Values +} + +func New(_urlParams url.Values) ParamsParser { + return ParamsParser{ + urlParams: _urlParams, + } +} + +func (p *ParamsParser) ParseTimestamp(key string, format string, fallback time.Time) time.Time { + paramTimestamp := p.urlParams.Get(key) + if paramTimestamp == "" { + return fallback + } + if timestamp, err := time.Parse(format, paramTimestamp); err == nil { + return timestamp + } else { + slog.Warn("Error parsing HTTP Params to timestamp", slog.Any("key", key), slog.Any("error", err)) + return fallback + } + +} diff --git a/Backend/helper/time_test.go b/Backend/helper/time_test.go index 454d4e3..e09cbd3 100644 --- a/Backend/helper/time_test.go +++ b/Backend/helper/time_test.go @@ -6,8 +6,8 @@ import ( ) func TestGetMonday(t *testing.T) { - isMonday, err := time.Parse("2006-01-02", "2025-07-14") - notMonday, err := time.Parse("2006-01-02", "2025-07-16") + isMonday, err := time.Parse(time.DateOnly, "2025-07-14") + notMonday, err := time.Parse(time.DateOnly, "2025-07-16") if err != nil || isMonday.Equal(notMonday) { t.Errorf("U stupid? %e", err) } diff --git a/Backend/main.go b/Backend/main.go index abccfd0..98fde52 100644 --- a/Backend/main.go +++ b/Backend/main.go @@ -51,7 +51,7 @@ func main() { // server.HandleFunc("/user/login", endpoints.LoginHandler) // server.HandleFunc("/user/settings", endpoints.UserSettingsHandler) server.HandleFunc("/team", endpoints.TeamHandler) - server.HandleFunc("/team/presence", endpoints.TeamPresenceHandler) + server.HandleFunc("/presence", endpoints.TeamPresenceHandler) server.Handle("/pdf", ParamsMiddleware(endpoints.PDFFormHandler)) server.HandleFunc("/pdf/generate", endpoints.PDFHandler) server.Handle("/", http.RedirectHandler("/time", http.StatusPermanentRedirect)) diff --git a/Backend/models/workDay.go b/Backend/models/workDay.go index de5cf14..be74595 100644 --- a/Backend/models/workDay.go +++ b/Backend/models/workDay.go @@ -41,7 +41,7 @@ func GetDays(user User, tsFrom, tsTo time.Time, orderedForward bool) []IWorkDay var allDays map[string]IWorkDay = make(map[string]IWorkDay) for _, day := range GetWorkDays(user, tsFrom, tsTo) { - allDays[day.Date().Format("2006-01-02")] = &day + allDays[day.Date().Format(time.DateOnly)] = &day } absences, err := GetAbsencesByCardUID(user.CardUID, tsFrom, tsTo) if err != nil { @@ -53,12 +53,12 @@ func GetDays(user User, tsFrom, tsTo time.Time, orderedForward bool) []IWorkDay continue } if day.AbwesenheitTyp.WorkTime == 1 { - if workDay, ok := allDays[day.Date().Format("2006-01-02")].(*WorkDay); ok && len(workDay.Bookings) > 0 { + if workDay, ok := allDays[day.Date().Format(time.DateOnly)].(*WorkDay); ok && len(workDay.Bookings) > 0 { workDay.kurzArbeit = true workDay.kurzArbeitAbsence = day } } else { - allDays[day.Date().Format("2006-01-02")] = &day + allDays[day.Date().Format(time.DateOnly)] = &day } } @@ -165,7 +165,7 @@ func (d *WorkDay) TimePauseReal(u User) (work, pause time.Duration) { } func (d *WorkDay) ToString() string { - return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s", d.Date().Format("2006-01-02"), len(d.Bookings), helper.FormatDuration(d.workTime)) + return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s", d.Date().Format(time.DateOnly), len(d.Bookings), helper.FormatDuration(d.workTime)) } func (d *WorkDay) IsWorkDay() bool { diff --git a/Backend/models/workDay_test.go b/Backend/models/workDay_test.go index abc3d89..5b1aef7 100644 --- a/Backend/models/workDay_test.go +++ b/Backend/models/workDay_test.go @@ -16,7 +16,7 @@ func CatchError[T any](val T, err error) T { } var testWorkDay = models.WorkDay{ - Day: CatchError(time.Parse("2006-01-02", "2025-01-01")), + Day: CatchError(time.Parse(time.DateOnly, "2025-01-01")), Bookings: testBookings8hrs, TimeFrom: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), TimeTo: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:30")), diff --git a/Backend/models/workWeek_test.go b/Backend/models/workWeek_test.go index cd78cef..ef989e4 100644 --- a/Backend/models/workWeek_test.go +++ b/Backend/models/workWeek_test.go @@ -8,7 +8,7 @@ import ( func SetupWorkWeekFixture(t *testing.T) models.WorkWeek { t.Helper() - monday, err := time.Parse("2006-01-02", "2025-01-10") + monday, err := time.Parse(time.DateOnly, "2025-01-10") if err != nil { t.Fatal(err) } @@ -16,7 +16,7 @@ func SetupWorkWeekFixture(t *testing.T) models.WorkWeek { } func TestNewWorkWeekNoPopulate(t *testing.T) { - monday, err := time.Parse("2006-01-02", "2025-01-10") + monday, err := time.Parse(time.DateOnly, "2025-01-10") if err != nil { t.Fatal(err) } diff --git a/Backend/static/css/styles.css b/Backend/static/css/styles.css index 9098dd5..ee0ad93 100644 --- a/Backend/static/css/styles.css +++ b/Backend/static/css/styles.css @@ -620,6 +620,12 @@ .border-slate-300 { border-color: var(--color-slate-300); } + .border-slate-700 { + border-color: var(--color-slate-700); + } + .border-slate-800 { + border-color: var(--color-slate-800); + } .bg-accent { background-color: var(--color-accent); } @@ -726,10 +732,6 @@ .opacity-0 { opacity: 0%; } - .shadow { - --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)); - box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); - } .outline { outline-style: var(--tw-outline-style); outline-width: 1px; @@ -871,14 +873,6 @@ } } } - .hover\:shadow-md { - &:hover { - @media (hover: hover) { - --tw-shadow: 0 4px 6px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 2px 4px -2px var(--tw-shadow-color, rgb(0 0 0 / 0.1)); - box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); - } - } - } .focus\:bg-neutral-700 { &:focus { background-color: var(--color-neutral-700); @@ -941,11 +935,6 @@ grid-column: span 3 / span 3; } } - .md\:col-span-4 { - @media (width >= 48rem) { - grid-column: span 4 / span 4; - } - } .md\:mx-\[10\%\] { @media (width >= 48rem) { margin-inline: 10%; @@ -971,6 +960,11 @@ width: calc(1/2 * 100%); } } + .md\:flex-row { + @media (width >= 48rem) { + flex-direction: row; + } + } .md\:px-4 { @media (width >= 48rem) { padding-inline: calc(var(--spacing) * 4); @@ -1187,71 +1181,6 @@ syntax: "*"; inherits: false; } -@property --tw-shadow { - syntax: "*"; - inherits: false; - initial-value: 0 0 #0000; -} -@property --tw-shadow-color { - syntax: "*"; - inherits: false; -} -@property --tw-shadow-alpha { - syntax: ""; - inherits: false; - initial-value: 100%; -} -@property --tw-inset-shadow { - syntax: "*"; - inherits: false; - initial-value: 0 0 #0000; -} -@property --tw-inset-shadow-color { - syntax: "*"; - inherits: false; -} -@property --tw-inset-shadow-alpha { - syntax: ""; - inherits: false; - initial-value: 100%; -} -@property --tw-ring-color { - syntax: "*"; - inherits: false; -} -@property --tw-ring-shadow { - syntax: "*"; - inherits: false; - initial-value: 0 0 #0000; -} -@property --tw-inset-ring-color { - syntax: "*"; - inherits: false; -} -@property --tw-inset-ring-shadow { - syntax: "*"; - inherits: false; - initial-value: 0 0 #0000; -} -@property --tw-ring-inset { - syntax: "*"; - inherits: false; -} -@property --tw-ring-offset-width { - syntax: ""; - inherits: false; - initial-value: 0px; -} -@property --tw-ring-offset-color { - syntax: "*"; - inherits: false; - initial-value: #fff; -} -@property --tw-ring-offset-shadow { - syntax: "*"; - inherits: false; - initial-value: 0 0 #0000; -} @property --tw-outline-style { syntax: "*"; inherits: false; @@ -1329,20 +1258,6 @@ --tw-border-style: solid; --tw-divide-y-reverse: 0; --tw-font-weight: initial; - --tw-shadow: 0 0 #0000; - --tw-shadow-color: initial; - --tw-shadow-alpha: 100%; - --tw-inset-shadow: 0 0 #0000; - --tw-inset-shadow-color: initial; - --tw-inset-shadow-alpha: 100%; - --tw-ring-color: initial; - --tw-ring-shadow: 0 0 #0000; - --tw-inset-ring-color: initial; - --tw-inset-ring-shadow: 0 0 #0000; - --tw-ring-inset: initial; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-offset-shadow: 0 0 #0000; --tw-outline-style: solid; --tw-blur: initial; --tw-brightness: initial; diff --git a/Backend/static/script.js b/Backend/static/script.js index 2f3b643..a47b0ce 100644 --- a/Backend/static/script.js +++ b/Backend/static/script.js @@ -79,3 +79,9 @@ function navigateWeek(element, event, direction) { function logoutUser() { fetch("/user/logout", {}).then(() => globalThis.location.reload()); } + +function checkAll(pattern, state) { + for (let input of document.querySelectorAll(`input[id^=${pattern}]`)) { + input.checked = state; + } +} diff --git a/Backend/templates/headerComponent.templ b/Backend/templates/headerComponent.templ index ec2d673..53d044a 100644 --- a/Backend/templates/headerComponent.templ +++ b/Backend/templates/headerComponent.templ @@ -4,8 +4,9 @@ templ headerComponent() {
Zeitverwaltung Abrechnung + PDF if true { - Anwesenheit + Anwesenheit } Einstellungen @LogoutButton() diff --git a/Backend/templates/headerComponent_templ.go b/Backend/templates/headerComponent_templ.go index aeef6ec..b13c034 100644 --- a/Backend/templates/headerComponent_templ.go +++ b/Backend/templates/headerComponent_templ.go @@ -29,12 +29,12 @@ func headerComponent() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
Zeitverwaltung Abrechnung ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
Zeitverwaltung Abrechnung PDF ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if true { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Anwesenheit ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Anwesenheit ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/Backend/templates/pages.templ b/Backend/templates/pages.templ index b2a3475..01b142f 100644 --- a/Backend/templates/pages.templ +++ b/Backend/templates/pages.templ @@ -1,7 +1,6 @@ package templates import "arbeitszeitmessung/models" -import "arbeitszeitmessung/helper" templ Base() { @@ -29,7 +28,7 @@ templ LoginPage(success bool, errorMsg string) {
} -templ UserPage(status int) { +templ SettingsPage(status int) { {{ user := ctx.Value("user").(models.User) }} @@ -89,13 +88,13 @@ templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
-

Eigene Abrechnung

+

Eigene Abrechnung

@workWeekComponent(userWeek, false) if len(weeks) > 0 {
-

Abrechnung Mitarbeiter

+

Abrechnung Mitarbeiter

} for _, week := range weeks { @@ -104,39 +103,6 @@ templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
} -templ TeamPresencePage(teamPresence map[models.User]bool) { - @Base() - @headerComponent() -
-
-

Mitarbeiter

-
- for user, present := range teamPresence { -
-
- @timeGaugeComponent(helper.BoolToInt8(present)*100-1, false) -

{ user.Vorname } { user.Name }

-
-
- if present { - Anwesend - } else { - Abwesend - } -
-
- } - //
- //

Nicht Anwesend

- //
- // for _, user := range teamPresence[false] { - // @userPresenceComponent(user, false) - // } - //
- //
-
-} - templ LogoutButton() { } diff --git a/Backend/templates/pages_templ.go b/Backend/templates/pages_templ.go index 491784c..7753eaa 100644 --- a/Backend/templates/pages_templ.go +++ b/Backend/templates/pages_templ.go @@ -9,7 +9,6 @@ import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import "arbeitszeitmessung/models" -import "arbeitszeitmessung/helper" func Base() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { @@ -77,7 +76,7 @@ func LoginPage(success bool, errorMsg string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(errorMsg) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 25, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 24, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -96,7 +95,7 @@ func LoginPage(success bool, errorMsg string) templ.Component { }) } -func UserPage(status int) templ.Component { +func SettingsPage(status int) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -155,7 +154,7 @@ func UserPage(status int) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 64} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 60, Col: 64} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -168,7 +167,7 @@ func UserPage(status int) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 78} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 60, Col: 78} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -181,7 +180,7 @@ func UserPage(status int) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.PersonalNummer) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 62, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -260,7 +259,7 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

Eigene Abrechnung

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

Eigene Abrechnung

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -269,7 +268,7 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component return templ_7745c5c3_Err } if len(weeks) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "

Abrechnung Mitarbeiter

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "

Abrechnung Mitarbeiter

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -288,102 +287,6 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component }) } -func TeamPresencePage(teamPresence map[models.User]bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var10 := templ.GetChildren(ctx) - if templ_7745c5c3_Var10 == nil { - templ_7745c5c3_Var10 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = headerComponent().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

Mitarbeiter

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - for user, present := range teamPresence { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = timeGaugeComponent(helper.BoolToInt8(present)*100-1, false).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var11 string - templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 118, Col: 22} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 118, Col: 36} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if present { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "Anwesend") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "Abwesend") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - func LogoutButton() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context @@ -400,12 +303,12 @@ func LogoutButton() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var13 := templ.GetChildren(ctx) - if templ_7745c5c3_Var13 == nil { - templ_7745c5c3_Var13 = templ.NopComponent + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/Backend/templates/pdf.templ b/Backend/templates/pdf.templ index c21a232..3b4220a 100644 --- a/Backend/templates/pdf.templ +++ b/Backend/templates/pdf.templ @@ -3,6 +3,7 @@ package templates import ( "arbeitszeitmessung/helper" "arbeitszeitmessung/models" + "fmt" "time" ) @@ -10,33 +11,44 @@ templ PDFForm(teamMembers []models.User) { @Base() @headerComponent()
-
-
Zeitraum wählen
+
+

PDF Abrechnung erstellen

+
+
+
Zeitraum wählen
-
-
Mitarbeiter wählen
+
+
Mitarbeiter wählen
- - + +
- @CheckboxComponent("pdf-123", "Kim Mustermensch") + for _, member := range teamMembers { + @CheckboxComponent(fmt.Sprintf("pdf-%d", member.PersonalNummer), fmt.Sprintf("%s %s", member.Vorname, member.Name)) + }
-
Direktvorschau oder Download
+
+
Direktvorschau oder Download
+
+ + +
+
} templ CheckboxComponent(id, label string) {
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -156,9 +193,9 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var7 := templ.GetChildren(ctx) - if templ_7745c5c3_Var7 == nil { - templ_7745c5c3_Var7 = templ.NopComponent + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) @@ -168,98 +205,98 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var8 string - templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(e.Vorname) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 57, Col: 45} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 57, Col: 56} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "

Zeitraum: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var10 string - templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006")) + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(e.Vorname) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 58, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 69, Col: 45} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " - ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var11 string - templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006")) + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 58, Col: 98} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 69, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "

Arbeitszeit: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "

Zeitraum: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(worktime)) + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 59, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 70, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "

Überstunden: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " - ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime)) + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 60, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 70, Col: 98} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

Arbeitszeit: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(kw) + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(worktime)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 63, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 71, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "

Kommen

Gehen

Arbeitsart

Stunden

Pause

Überstunden

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "

Überstunden: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 72, Col: 59} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var16 string + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(kw) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 75, Col: 52} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

Kommen

Gehen

Arbeitsart

Stunden

Pause

Überstunden

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -268,60 +305,60 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays if index == len(workDays)-1 { noBorder = "border-b-0" } - var templ_7745c5c3_Var15 = []any{noBorder} - templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var15...) + var templ_7745c5c3_Var17 = []any{noBorder} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var17...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 76, Col: 59} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var18 = []any{"grid grid-cols-subgrid col-span-3 " + noBorder} - templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var18...) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var19 string - templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var18).String()) + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 1, Col: 0} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 88, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var20 = []any{"grid grid-cols-subgrid col-span-3 " + noBorder} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var20...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -329,65 +366,27 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays workDay, _ := day.(*models.WorkDay) for bookingI := 0; bookingI < len(workDay.Bookings); bookingI += 2 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].Timestamp.Format("15:04")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 83, Col: 64} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var21 string - templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI+1].Timestamp.Format("15:04")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 84, Col: 66} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var22 string - templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].BookingType.Name) + templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].Timestamp.Format("15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 85, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 95, Col: 64} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if workDay.IsKurzArbeit() { - - timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var23 string - templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(timeFrom.Format("15:04")) + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI+1].Timestamp.Format("15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 91, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 96, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -398,15 +397,53 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays return templ_7745c5c3_Err } var templ_7745c5c3_Var24 string - templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(timeTo.Format("15:04")) + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].BookingType.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 92, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 97, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "

Kurzarbeit

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if workDay.IsKurzArbeit() { + + timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(timeFrom.Format("15:04")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 103, Col: 36} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var26 string + templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(timeTo.Format("15:04")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 104, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "

Kurzarbeit

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -414,25 +451,25 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays } else { absentDay, _ := day.(*models.Absence) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var25 string - templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(absentDay.AbwesenheitTyp.Name) + var templ_7745c5c3_Var27 string + templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(absentDay.AbwesenheitTyp.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 99, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 111, Col: 62} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -441,7 +478,7 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -449,7 +486,7 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -457,18 +494,18 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if day.Date().Weekday() == time.Friday { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

Wochenende

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

Wochenende

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -492,9 +529,9 @@ func ColorDuration(d time.Duration, classes string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var26 := templ.GetChildren(ctx) - if templ_7745c5c3_Var26 == nil { - templ_7745c5c3_Var26 = templ.NopComponent + templ_7745c5c3_Var28 := templ.GetChildren(ctx) + if templ_7745c5c3_Var28 == nil { + templ_7745c5c3_Var28 = templ.NopComponent } ctx = templ.ClearChildren(ctx) @@ -502,38 +539,38 @@ func ColorDuration(d time.Duration, classes string) templ.Component { if d.Abs() < time.Minute { color = "text-neutral-300" } - var templ_7745c5c3_Var27 = []any{color + " " + classes} - templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var27...) + var templ_7745c5c3_Var29 = []any{color + " " + classes} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var29...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var29 string - templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDurationFill(d, true)) + var templ_7745c5c3_Var31 string + templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDurationFill(d, true)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 121, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 133, Col: 72} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/Backend/templates/presencePage.templ b/Backend/templates/presencePage.templ new file mode 100644 index 0000000..f1ca3d1 --- /dev/null +++ b/Backend/templates/presencePage.templ @@ -0,0 +1,29 @@ +package templates + +import "arbeitszeitmessung/models" +import "arbeitszeitmessung/helper" + +templ TeamPresencePage(teamPresence map[models.User]bool) { + @Base() + @headerComponent() +
+
+

Mitarbeiter

+
+ for user, present := range teamPresence { +
+
+ @timeGaugeComponent(helper.BoolToInt8(present)*100-1, false) +

{ user.Vorname } { user.Name }

+
+
+ if present { + Anwesend + } else { + Abwesend + } +
+
+ } +
+} diff --git a/Backend/templates/presencePage_templ.go b/Backend/templates/presencePage_templ.go new file mode 100644 index 0000000..c7eca82 --- /dev/null +++ b/Backend/templates/presencePage_templ.go @@ -0,0 +1,110 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.924 +package templates + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import "arbeitszeitmessung/models" +import "arbeitszeitmessung/helper" + +func TeamPresencePage(teamPresence map[models.User]bool) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = headerComponent().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

Mitarbeiter

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for user, present := range teamPresence { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = timeGaugeComponent(helper.BoolToInt8(present)*100-1, false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/presencePage.templ`, Line: 17, Col: 22} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/presencePage.templ`, Line: 17, Col: 36} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if present { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Anwesend") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "Abwesend") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/Backend/templates/timeComponents.templ b/Backend/templates/timeComponents.templ index 9730101..9fad41d 100644 --- a/Backend/templates/timeComponents.templ +++ b/Backend/templates/timeComponents.templ @@ -77,8 +77,8 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) { } }}
- - + +

@@ -89,7 +89,7 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) {

if isKurzarbeit { - + }
} @@ -97,7 +97,7 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) { templ newBookingComponent(d *models.WorkDay) {