diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml
index 80c1004..5bec07f 100644
--- a/.gitea/workflows/test.yaml
+++ b/.gitea/workflows/test.yaml
@@ -46,6 +46,8 @@ jobs:
key: arbeitszeitmessung-${{ steps.hash-go.outputs.hash }}
restore-keys: |-
arbeitszeitmessung-
+ - name: Render Templ files
+ run: cd Backend && go install github.com/a-h/templ/cmd/templ@v0.3.977 && templ generate
- name: Run Go Tests
run: cd Backend && mkdir .test && go test ./... -coverprofile=.test/coverage.out -json > .test/report.json
- name: Verify coverage report exists
diff --git a/.gitignore b/.gitignore
index cd09ad2..a1a3871 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,5 @@ atlas.hcl
.scannerwork
Backend/logs
.worktime.txt
+
+*_templ.go
diff --git a/Backend/.dockerignore b/Backend/.dockerignore
index 7ab2ceb..d03e4ff 100644
--- a/Backend/.dockerignore
+++ b/Backend/.dockerignore
@@ -1,2 +1,3 @@
db
Dockerfile
+*_templ.go
diff --git a/Backend/Dockerfile b/Backend/Dockerfile
index 2f5b0cd..7062a6d 100644
--- a/Backend/Dockerfile
+++ b/Backend/Dockerfile
@@ -1,16 +1,24 @@
# syntax=docker/dockerfile:1
-FROM --platform=$BUILDPLATFORM golang:alpine AS build
+FROM --platform=$BUILDPLATFORM golang:alpine AS base
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH
+FROM base AS fetch-stage
WORKDIR /app
COPY go.mod go.sum /app/
RUN go mod download && go mod verify
-COPY . .
+FROM ghcr.io/a-h/templ:v0.3.977 AS generate-stage
+COPY --chown=65532:65532 --chmod=755 . /app
+WORKDIR /app
+RUN ["templ", "generate"]
+
+FROM base AS build
+COPY --from=generate-stage /app /app
+WORKDIR /app
RUN go build -o server .
FROM alpine:3.22
diff --git a/Backend/database.go b/Backend/database.go
index 5ee9ac1..a0ea5c7 100644
--- a/Backend/database.go
+++ b/Backend/database.go
@@ -1,5 +1,8 @@
package main
+// this file handles the db connection and the
+// db migration
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
diff --git a/Backend/endpoints/auto-feiertage.go b/Backend/endpoints/auto-feiertage.go
index 6f32bca..c380ca6 100644
--- a/Backend/endpoints/auto-feiertage.go
+++ b/Backend/endpoints/auto-feiertage.go
@@ -1,5 +1,15 @@
+// endpoints contains all http endpoints
+// for more complex endpoints the *Handler function is executed first
+// by the main programm and it will then run other functions as needed
+//
+// the filenames represent the route/url for the given endpoint
+// when "-" is a "/" so this file is server at "/auto/feiertage"
+
package endpoints
+// this endpoint will be called by crontab and generates the public holidays for a given year
+// after that manually added holidays with a "wiederholen" flag are copied over to the new year
+
import (
"arbeitszeitmessung/helper/paramParser"
"arbeitszeitmessung/models"
diff --git a/Backend/endpoints/auto-kurzarbeit.go b/Backend/endpoints/auto-kurzarbeit.go
index 10b2cd5..48183df 100644
--- a/Backend/endpoints/auto-kurzarbeit.go
+++ b/Backend/endpoints/auto-kurzarbeit.go
@@ -1,5 +1,10 @@
package endpoints
+// this served as "/auto/kurzarbeit" will add a booking to every kurzarbeitstag
+// to make them reach the full lenght of workday.
+//
+// right now this is not in use because the time is calculated
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/helper/paramParser"
@@ -58,8 +63,8 @@ func fillKurzarbeit(r *http.Request, w http.ResponseWriter) {
workday, _ := day.(*models.WorkDay)
lastBookingTime := workday.Bookings[len(workday.Bookings)-1].Timestamp
- kurzarbeitBegin := (*models.Booking).New(nil, user.CardUID, 0, 1, bookingTypeKurzarbeit.Id)
- kurzarbeitEnd := (*models.Booking).New(nil, user.CardUID, 0, 2, bookingTypeKurzarbeit.Id)
+ kurzarbeitBegin := (*models.Booking).NewBooking(nil, user.CardUID, 0, 1, bookingTypeKurzarbeit.Id)
+ kurzarbeitEnd := (*models.Booking).NewBooking(nil, user.CardUID, 0, 2, bookingTypeKurzarbeit.Id)
kurzarbeitBegin.Timestamp = lastBookingTime.Add(time.Minute)
kurzarbeitEnd.Timestamp = lastBookingTime.Add(worktimeKurzarbeit)
diff --git a/Backend/endpoints/auto-logout.go b/Backend/endpoints/auto-logout.go
index e15f93a..5b45672 100644
--- a/Backend/endpoints/auto-logout.go
+++ b/Backend/endpoints/auto-logout.go
@@ -1,5 +1,8 @@
package endpoints
+// this endpoint served at "/auto/logout" will be executed by crontab
+// and will log out all users that are currently still logged in
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
diff --git a/Backend/endpoints/pdf-create.go b/Backend/endpoints/pdf-create.go
index c2d2b4b..b93be94 100644
--- a/Backend/endpoints/pdf-create.go
+++ b/Backend/endpoints/pdf-create.go
@@ -1,5 +1,8 @@
package endpoints
+// this endpoint served at "/pdf/create" accepts the contents from the pdf form
+// and renders a pdf according to this form
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/helper/paramParser"
diff --git a/Backend/endpoints/pdf.go b/Backend/endpoints/pdf.go
index e08ef6d..7a306fd 100644
--- a/Backend/endpoints/pdf.go
+++ b/Backend/endpoints/pdf.go
@@ -1,5 +1,7 @@
package endpoints
+// this endpoint served at "/pdf" handles the rendering of the pdf form
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
diff --git a/Backend/endpoints/team-presence.go b/Backend/endpoints/team-presence.go
index 414f8b6..debab41 100644
--- a/Backend/endpoints/team-presence.go
+++ b/Backend/endpoints/team-presence.go
@@ -1,5 +1,7 @@
package endpoints
+// this endpoint served at "/team/presence" shows the presence page
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
@@ -8,7 +10,7 @@ import (
"net/http"
)
-func TeamPresenceHandler(w http.ResponseWriter, r *http.Request) {
+func PresenceHandler(w http.ResponseWriter, r *http.Request) {
helper.RequiresLogin(Session, w, r)
helper.SetCors(w)
switch r.Method {
diff --git a/Backend/endpoints/team.go b/Backend/endpoints/team-report.go
similarity index 89%
rename from Backend/endpoints/team.go
rename to Backend/endpoints/team-report.go
index efc1c7b..1babc7b 100644
--- a/Backend/endpoints/team.go
+++ b/Backend/endpoints/team-report.go
@@ -1,5 +1,8 @@
package endpoints
+// this endpoint served at "/team/report" handles the report page
+// and also the submission/change of reports
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/helper/paramParser"
@@ -12,7 +15,7 @@ import (
"time"
)
-func TeamHandler(w http.ResponseWriter, r *http.Request) {
+func ReportHandler(w http.ResponseWriter, r *http.Request) {
helper.RequiresLogin(Session, w, r)
switch r.Method {
case http.MethodPost:
@@ -76,5 +79,5 @@ func showWeeks(w http.ResponseWriter, r *http.Request) {
workWeeks = append(workWeeks, weeks...)
}
// isRunningWeek := time.Since(lastSub) < 24*5*time.Hour //the last submission is this week and cannot be send yet
- templates.TeamPage(workWeeks, userWeek).Render(r.Context(), w)
+ templates.ReportPage(workWeeks, userWeek).Render(r.Context(), w)
}
diff --git a/Backend/endpoints/time-create.go b/Backend/endpoints/time-create.go
index f368b19..6e3097b 100644
--- a/Backend/endpoints/time-create.go
+++ b/Backend/endpoints/time-create.go
@@ -1,5 +1,8 @@
package endpoints
+// this endpoint served at "/time/create" is for the esp api and creates bookings
+// either via HTTP GET or HTTP PUT
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
diff --git a/Backend/endpoints/time.go b/Backend/endpoints/time.go
index 393044a..09e66f1 100644
--- a/Backend/endpoints/time.go
+++ b/Backend/endpoints/time.go
@@ -1,5 +1,9 @@
package endpoints
+// this endpoint served at "/time" handles the time page
+// this includes normal show + creation of bookings from the webpage +
+// edit functionality
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/helper/paramParser"
@@ -158,7 +162,7 @@ func updateBooking(w http.ResponseWriter, r *http.Request) {
return
}
- newBooking := (*models.Booking).New(nil, user.CardUID, 0, int16(check_in_out), 1)
+ newBooking := (*models.Booking).NewBooking(nil, user.CardUID, 0, int16(check_in_out), 1)
newBooking.Timestamp = timestamp
if newBooking.Verify() {
err = newBooking.InsertWithTimestamp()
diff --git a/Backend/endpoints/user-login.go b/Backend/endpoints/user-login.go
new file mode 100644
index 0000000..9b06160
--- /dev/null
+++ b/Backend/endpoints/user-login.go
@@ -0,0 +1,17 @@
+package endpoints
+
+// this endpoint server at "/user/login" will show the login page or
+// directly login the user based on the http method used
+
+import "net/http"
+
+func LoginHandler(w http.ResponseWriter, r *http.Request) {
+ switch r.Method {
+ case http.MethodGet:
+ showLoginPage(w, r, true, "")
+ case http.MethodPost:
+ loginUser(w, r)
+ default:
+ http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
+ }
+}
diff --git a/Backend/endpoints/user-session.go b/Backend/endpoints/user-session.go
deleted file mode 100644
index 3c2e314..0000000
--- a/Backend/endpoints/user-session.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package endpoints
-
-import (
- "arbeitszeitmessung/models"
- "arbeitszeitmessung/templates"
- "context"
- "log"
- "net/http"
- "strconv"
- "time"
-
- "github.com/alexedwards/scs/v2"
-)
-
-var Session *scs.SessionManager
-
-func CreateSessionManager(lifetime time.Duration) *scs.SessionManager {
- Session = scs.New()
- Session.Lifetime = lifetime
- return Session
-}
-
-func showLoginPage(w http.ResponseWriter, r *http.Request, success bool, errorMsg string) {
- r = r.WithContext(context.WithValue(r.Context(), "session", Session))
- if Session.Exists(r.Context(), "user") {
- http.Redirect(w, r, "/time", http.StatusSeeOther)
- }
- templates.LoginPage(success, errorMsg).Render(r.Context(), w)
-}
-
-func loginUser(w http.ResponseWriter, r *http.Request) {
- err := r.ParseForm()
- if err != nil {
- log.Println("Error parsing form!", err)
- showLoginPage(w, r, false, "Internal error!")
- return
- }
- _personal_nummer := r.FormValue("personal_nummer")
- if _personal_nummer == "" {
- log.Println("No personal_nummer provided!")
- showLoginPage(w, r, false, "Keine Personalnummer gesetzt.")
- return
- }
- personal_nummer, err := strconv.Atoi(_personal_nummer)
- if err != nil {
- log.Println("Cannot parse personal nubmer!")
- showLoginPage(w, r, false, "Personalnummer ist nicht valide gesetzt.")
- return
- }
- user, err := models.GetUserByPersonalNr(personal_nummer)
- if err != nil {
- log.Println("No user found under this personal number!", err)
- showLoginPage(w, r, false, "Nutzer unter dieser Personalnummer nicht gefunden.")
- return
- }
-
- password := r.FormValue("password")
- if user.Login(password) {
- log.Printf("New succesfull user login from %s %s (%d)!\n", user.Vorname, user.Name, user.PersonalNummer)
- Session.Put(r.Context(), "user", user.PersonalNummer)
- Session.Commit(r.Context())
- http.Redirect(w, r, "/time", http.StatusSeeOther) //with this browser always uses GET
- }
- showLoginPage(w, r, false, "")
-}
-
-func logoutUser(w http.ResponseWriter, r *http.Request) {
- log.Println("Loggin out user!")
- err := Session.Destroy(r.Context())
- if err != nil {
- log.Println("Error destroying session!", err)
- }
- http.Redirect(w, r, "/user/login", http.StatusSeeOther)
-}
diff --git a/Backend/endpoints/user-settings.go b/Backend/endpoints/user-settings.go
index 65b7ebd..78af065 100644
--- a/Backend/endpoints/user-settings.go
+++ b/Backend/endpoints/user-settings.go
@@ -1,6 +1,11 @@
package endpoints
+// this endpoint server at "/user/settings" will show the settings page
+// depeding on which action is taken the user will be logged out or
+// the password will be changed
+
import (
+ "arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
"arbeitszeitmessung/templates"
"context"
@@ -8,6 +13,23 @@ import (
"net/http"
)
+func UserSettingsHandler(w http.ResponseWriter, r *http.Request) {
+ helper.RequiresLogin(Session, w, r)
+ switch r.Method {
+ case http.MethodGet:
+ showUserPage(w, r, 0)
+ case http.MethodPost:
+ switch r.FormValue("action") {
+ case "change-pass":
+ changePassword(w, r)
+ case "logout-user":
+ logoutUser(w, r)
+ }
+ default:
+ http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
+ }
+}
+
// change user password and store salted hash in db
func changePassword(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
diff --git a/Backend/endpoints/user.go b/Backend/endpoints/user.go
index 342ca0c..69b44cb 100644
--- a/Backend/endpoints/user.go
+++ b/Backend/endpoints/user.go
@@ -1,8 +1,18 @@
package endpoints
+// this is not directly an endpoint as it servers all requests for "/user"
+// and routes the furter to "login", "logout", and "settings"
+
import (
- "arbeitszeitmessung/helper"
+ "arbeitszeitmessung/models"
+ "arbeitszeitmessung/templates"
+ "context"
+ "log"
"net/http"
+ "strconv"
+ "time"
+
+ "github.com/alexedwards/scs/v2"
)
func UserHandler(w http.ResponseWriter, r *http.Request) {
@@ -16,31 +26,63 @@ func UserHandler(w http.ResponseWriter, r *http.Request) {
}
}
-func LoginHandler(w http.ResponseWriter, r *http.Request) {
- switch r.Method {
- case http.MethodGet:
- showLoginPage(w, r, true, "")
- case http.MethodPost:
- loginUser(w, r)
- default:
- http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
- }
+var Session *scs.SessionManager
+
+func CreateSessionManager(lifetime time.Duration) *scs.SessionManager {
+ Session = scs.New()
+ Session.Lifetime = lifetime
+ return Session
}
-func UserSettingsHandler(w http.ResponseWriter, r *http.Request) {
- helper.RequiresLogin(Session, w, r)
-
- switch r.Method {
- case http.MethodGet:
- showUserPage(w, r, 0)
- case http.MethodPost:
- switch r.FormValue("action") {
- case "change-pass":
- changePassword(w, r)
- case "logout-user":
- logoutUser(w, r)
- }
- default:
- http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
+func showLoginPage(w http.ResponseWriter, r *http.Request, success bool, errorMsg string) {
+ r = r.WithContext(context.WithValue(r.Context(), "session", Session))
+ if Session.Exists(r.Context(), "user") {
+ http.Redirect(w, r, "/time", http.StatusSeeOther)
}
+ templates.LoginPage(success, errorMsg).Render(r.Context(), w)
+}
+
+func loginUser(w http.ResponseWriter, r *http.Request) {
+ err := r.ParseForm()
+ if err != nil {
+ log.Println("Error parsing form!", err)
+ showLoginPage(w, r, false, "Internal error!")
+ return
+ }
+ _personal_nummer := r.FormValue("personal_nummer")
+ if _personal_nummer == "" {
+ log.Println("No personal_nummer provided!")
+ showLoginPage(w, r, false, "Keine Personalnummer gesetzt.")
+ return
+ }
+ personal_nummer, err := strconv.Atoi(_personal_nummer)
+ if err != nil {
+ log.Println("Cannot parse personal nubmer!")
+ showLoginPage(w, r, false, "Personalnummer ist nicht valide gesetzt.")
+ return
+ }
+ user, err := models.GetUserByPersonalNr(personal_nummer)
+ if err != nil {
+ log.Println("No user found under this personal number!", err)
+ showLoginPage(w, r, false, "Nutzer unter dieser Personalnummer nicht gefunden.")
+ return
+ }
+
+ password := r.FormValue("password")
+ if user.Login(password) {
+ log.Printf("New succesfull user login from %s %s (%d)!\n", user.Vorname, user.Name, user.PersonalNummer)
+ Session.Put(r.Context(), "user", user.PersonalNummer)
+ Session.Commit(r.Context())
+ http.Redirect(w, r, "/time", http.StatusSeeOther) //with this browser always uses GET
+ }
+ showLoginPage(w, r, false, "")
+}
+
+func logoutUser(w http.ResponseWriter, r *http.Request) {
+ log.Println("Loggin out user!")
+ err := Session.Destroy(r.Context())
+ if err != nil {
+ log.Println("Error destroying session!", err)
+ }
+ http.Redirect(w, r, "/user/login", http.StatusSeeOther)
}
diff --git a/Backend/helper/logs/main.go b/Backend/helper/logs/main.go
index 9cad2bb..7744bf7 100644
--- a/Backend/helper/logs/main.go
+++ b/Backend/helper/logs/main.go
@@ -1,3 +1,6 @@
+// Helper package to create audit logs in the logs folder
+// these are by the time only generated, when a booking is
+// changed on the /time page
package logs
import (
diff --git a/Backend/helper/paramParser/main.go b/Backend/helper/paramParser/main.go
index 8dd6586..fe07459 100644
--- a/Backend/helper/paramParser/main.go
+++ b/Backend/helper/paramParser/main.go
@@ -1,3 +1,7 @@
+// this package contains different functions to parse URL.Values or Form.Values
+// into other datatypes see functionname
+// on fail the funktions either return a fallback or error
+
package paramParser
import (
diff --git a/Backend/helper/strings.go b/Backend/helper/strings.go
deleted file mode 100644
index 4a15702..0000000
--- a/Backend/helper/strings.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package helper
-
-func GetFirst[T, U any](val T, _ U) T {
- return val
-}
-
-func GetSecond[T, U any](_ T, val U) U {
- return val
-}
diff --git a/Backend/helper/strings_test.go b/Backend/helper/strings_test.go
deleted file mode 100644
index ac1b4f3..0000000
--- a/Backend/helper/strings_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package helper
-
-import "testing"
-
-func TestGetFirst(t *testing.T) {
- tests := []struct {
- name string
- a any
- b any
- want any
- }{
- {"ints", 10, 20, 10},
- {"strings", "first", "second", "first"},
- {"mixed", "abc", 123, "abc"},
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got := GetFirst(tt.a, tt.b)
- if got != tt.want {
- t.Errorf("GetFirst(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
- }
- })
- }
-}
-
-func TestGetSecond(t *testing.T) {
- tests := []struct {
- name string
- a any
- b any
- want any
- }{
- {"ints", 10, 20, 20},
- {"strings", "first", "second", "second"},
- {"mixed", "abc", 123, 123},
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got := GetSecond(tt.a, tt.b)
- if got != tt.want {
- t.Errorf("GetSecond(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
- }
- })
- }
-}
diff --git a/Backend/helper/system.go b/Backend/helper/system.go
index b1c28b5..da3f736 100644
--- a/Backend/helper/system.go
+++ b/Backend/helper/system.go
@@ -1,5 +1,7 @@
package helper
+// different system helpers for environment variables + cache
+
import (
"os"
"time"
diff --git a/Backend/helper/time.go b/Backend/helper/time.go
index 1337485..7434a0e 100644
--- a/Backend/helper/time.go
+++ b/Backend/helper/time.go
@@ -1,5 +1,7 @@
package helper
+// time helpers
+
import (
"fmt"
"time"
@@ -27,11 +29,6 @@ func IsWeekend(ts time.Time) bool {
return ts.Weekday() == time.Saturday || ts.Weekday() == time.Sunday
}
-func GetKW(t time.Time) int {
- _, kw := t.ISOWeek()
- return kw
-}
-
func FormatDuration(d time.Duration) string {
return FormatDurationFill(d, false)
}
diff --git a/Backend/helper/time_test.go b/Backend/helper/time_test.go
index 4e6e67e..7905898 100644
--- a/Backend/helper/time_test.go
+++ b/Backend/helper/time_test.go
@@ -132,41 +132,3 @@ func TestFormatGermanDayOfWeek(t *testing.T) {
})
}
}
-
-func TestGetKW(t *testing.T) {
- tests := []struct {
- name string
- date time.Time
- want int
- }{
- {
- name: "First week of year",
- date: time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC), // Monday
- want: 1,
- },
- {
- name: "Middle of year",
- date: time.Date(2023, 6, 15, 0, 0, 0, 0, time.UTC),
- want: 24,
- },
- {
- name: "Last week of year",
- date: time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC),
- want: 52,
- },
- {
- name: "ISO week crossing into next year",
- date: time.Date(2020, 12, 31, 0, 0, 0, 0, time.UTC),
- want: 53,
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got := GetKW(tt.date)
- if got != tt.want {
- t.Errorf("GetKW(%v) = %d, want %d", tt.date, got, tt.want)
- }
- })
- }
-}
diff --git a/Backend/helper/types.go b/Backend/helper/types.go
index 7dd6cce..112d6b1 100644
--- a/Backend/helper/types.go
+++ b/Backend/helper/types.go
@@ -1,12 +1,6 @@
package helper
-import "time"
-
-type TimeFormValue struct {
- TsFrom time.Time
- TsTo time.Time
- CardUID string
-}
+// type conversion
func BoolToInt(b bool) int {
var i int = 0
diff --git a/Backend/helper/web.go b/Backend/helper/web.go
index 32fca7a..3fcaadd 100644
--- a/Backend/helper/web.go
+++ b/Backend/helper/web.go
@@ -1,5 +1,7 @@
package helper
+// web helpers to either set Cross Origin Request Security or block all requests without a user
+
import (
"context"
"net/http"
diff --git a/Backend/main.go b/Backend/main.go
index e0817dd..b909882 100644
--- a/Backend/main.go
+++ b/Backend/main.go
@@ -1,5 +1,7 @@
package main
+// this is the main file where the webserver is configured and all endpoints are added with their routes
+
import (
"arbeitszeitmessung/endpoints"
"arbeitszeitmessung/helper"
@@ -50,10 +52,12 @@ func main() {
defer models.DB.(*sql.DB).Close()
- err = Migrate()
- if err != nil {
- slog.Error("Failed to migrate the database to newest version", "Error", err)
- return
+ if helper.GetEnv("GO_ENV", "production") != "debug" {
+ err = Migrate()
+ if err != nil {
+ slog.Error("Failed to migrate the database to newest version", "Error", err)
+ return
+ }
}
fs := http.FileServer(http.Dir("./static"))
@@ -63,17 +67,15 @@ func main() {
// handles the different http routes
server.HandleFunc("/time/new", endpoints.TimeCreateHandler)
- server.Handle("/absence", ParamsMiddleware(endpoints.AbsencHandler))
- server.Handle("/time", ParamsMiddleware(endpoints.TimeHandler))
+ server.Handle("/absence", paramsMiddleware(endpoints.AbsencHandler))
+ server.Handle("/time", paramsMiddleware(endpoints.TimeHandler))
server.HandleFunc("/auto/logout", endpoints.LogoutHandler)
server.HandleFunc("/auto/kurzarbeit", endpoints.KurzarbeitFillHandler)
server.HandleFunc("/auto/feiertage", endpoints.FeiertagsHandler)
server.HandleFunc("/user/{action}", endpoints.UserHandler)
- // server.HandleFunc("/user/login", endpoints.LoginHandler)
- // server.HandleFunc("/user/settings", endpoints.UserSettingsHandler)
- server.HandleFunc("/team", endpoints.TeamHandler)
- server.HandleFunc("/presence", endpoints.TeamPresenceHandler)
- server.Handle("/pdf", ParamsMiddleware(endpoints.PDFFormHandler))
+ server.HandleFunc("/team/report", endpoints.ReportHandler)
+ server.HandleFunc("/team/presence", endpoints.PresenceHandler)
+ server.Handle("/pdf", paramsMiddleware(endpoints.PDFFormHandler))
server.HandleFunc("/pdf/generate", endpoints.PDFCreateController)
server.Handle("/", http.RedirectHandler("/time", http.StatusPermanentRedirect))
server.Handle("/static/", http.StripPrefix("/static/", fs))
@@ -87,7 +89,7 @@ func main() {
slog.Error("Error starting Server", "Error", http.ListenAndServe(":8080", serverSessionMiddleware))
}
-func ParamsMiddleware(next http.HandlerFunc) http.Handler {
+func paramsMiddleware(next http.HandlerFunc) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
queryParams := r.URL.Query()
ctx := context.WithValue(r.Context(), "urlParams", queryParams)
diff --git a/Backend/models/absence.go b/Backend/models/absence.go
index 0f1f03b..7c99e76 100644
--- a/Backend/models/absence.go
+++ b/Backend/models/absence.go
@@ -1,8 +1,19 @@
+// the models package contains the datamodels for the whole webserver
+// most of them are also in the DB
+//
+// in the future it would be good to change it to create a repository structure,
+// so that there would be a second pacakge handling db requests
+
package models
+// this file has all functions and types to handle absences
+// the absence type implements the iWorkDay interface so that
+// it can be used as one workday
+//
+// the absence data is based on the entries in the "abwesenheit" database table
+
import (
"encoding/json"
- "errors"
"log"
"time"
)
@@ -27,25 +38,6 @@ func (a *Absence) IsEmpty() bool {
return false
}
-func NewAbsence(card_uid string, abwesenheit_typ int, datum time.Time) (Absence, error) {
- if abwesenheit_typ < 0 {
- return Absence{
- CardUID: card_uid,
- AbwesenheitTyp: AbsenceType{0, "Custom absence", 100},
- DateFrom: datum,
- }, nil
- }
- _absenceType, ok := GetAbsenceTypesCached()[int8(abwesenheit_typ)]
- if !ok {
- return Absence{}, errors.New("Invalid absencetype")
- }
- return Absence{
- CardUID: card_uid,
- AbwesenheitTyp: _absenceType,
- DateFrom: datum,
- }, nil
-}
-
func (a *Absence) Date() time.Time {
return a.Day.Truncate(24 * time.Hour)
}
diff --git a/Backend/models/absence_test.go b/Backend/models/absence_test.go
index 235579b..fc0bfc7 100644
--- a/Backend/models/absence_test.go
+++ b/Backend/models/absence_test.go
@@ -1,5 +1,8 @@
package models_test
+// all the files with *_test.go are used to test the functions inside the respective file
+// the tests are partially complete
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
diff --git a/Backend/models/booking.go b/Backend/models/booking.go
index 463da92..6704913 100644
--- a/Backend/models/booking.go
+++ b/Backend/models/booking.go
@@ -1,5 +1,11 @@
package models
+// this file has all functions and types to handle bookings
+// the bookings itself are later combined to a workday to save on
+// db requests and computation
+//
+// the booking data is based on the entries in the "anwesenheit" database table
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/helper/logs"
@@ -39,7 +45,7 @@ type IDatabase interface {
var DB IDatabase
-func (b *Booking) New(cardUid string, gereatId int16, checkInOut int16, typeId int8) Booking {
+func (b *Booking) NewBooking(cardUid string, gereatId int16, checkInOut int16, typeId int8) Booking {
bookingType, err := GetBookingTypeById(typeId)
if err != nil {
log.Printf("Cannot get booking type %d, from database!", typeId)
diff --git a/Backend/models/compoundDay.go b/Backend/models/compoundDay.go
index 7bc4490..323cea7 100644
--- a/Backend/models/compoundDay.go
+++ b/Backend/models/compoundDay.go
@@ -1,5 +1,12 @@
package models
+// this file contains all functions for the compound day class
+// the compound can merge all kinds of daytypes together, as long as they
+// implement the IWorkDay interface. This is used to have an absence + bookings
+// in one day
+//
+// the compound day is a meta type, which means its not in the database
+
import (
"log/slog"
"time"
diff --git a/Backend/models/database.go b/Backend/models/database.go
index c114c4a..515614e 100644
--- a/Backend/models/database.go
+++ b/Backend/models/database.go
@@ -1,5 +1,8 @@
package models
+// this file is only used as cache for the diffenrent absence and booking types,
+// in the future this should be two chaching variables each in their own place
+
import (
"arbeitszeitmessung/helper"
)
diff --git a/Backend/models/iworkday.go b/Backend/models/iworkday.go
index 1170aa1..2f7d038 100644
--- a/Backend/models/iworkday.go
+++ b/Backend/models/iworkday.go
@@ -1,5 +1,10 @@
package models
+// this file desribes the IWorkDay interface which is used, to combine the diffent kinds
+// of day types (absence, holidy, workday) and make them more compatimble with the rest
+//
+// the IWorkDay as an interface is not in the database
+
import (
"log/slog"
"time"
diff --git a/Backend/models/publicHoliday.go b/Backend/models/publicHoliday.go
index 567a610..1a6707a 100644
--- a/Backend/models/publicHoliday.go
+++ b/Backend/models/publicHoliday.go
@@ -1,5 +1,10 @@
package models
+// the public holiday is used the describe all holidays
+// the publicholiday implements the IWorkDay interface
+//
+// the PublicHoliday data is based on the entries in the "s_feiertage" database table
+
import (
"time"
diff --git a/Backend/models/user.go b/Backend/models/user.go
index 5cfb559..605687c 100644
--- a/Backend/models/user.go
+++ b/Backend/models/user.go
@@ -1,5 +1,11 @@
package models
+// the user type represents the user of the software
+// it has functions to request the bookings and other data based
+// on either the "PersonalNummer" or "CardUID"
+//
+// users and their passwords are stored in the "s_personal_daten" and "user_pass" tables
+
import (
"arbeitszeitmessung/helper"
"context"
@@ -149,7 +155,7 @@ func (u *User) CheckAnwesenheit() bool {
// Creates a new booking for the user -> check_in_out will be 254 for automatic check out
func (u *User) CheckOut() error {
- booking := (*Booking).New(nil, u.CardUID, 0, 254, 1)
+ booking := (*Booking).NewBooking(nil, u.CardUID, 0, 254, 1)
err := booking.Insert()
if err != nil {
fmt.Printf("Error inserting booking %v -> %v\n", booking, err)
@@ -282,15 +288,6 @@ func (u *User) GetNextWeek() WorkWeek {
}
-func parseUser(rows *sql.Rows) (User, error) {
- var user User
- if err := rows.Scan(&user.PersonalNummer, &user.CardUID, &user.Vorname, &user.Name, &user.ArbeitszeitPerTag); err != nil {
- log.Println("Error scanning row!", err)
- return user, err
- }
- return user, nil
-}
-
// returns the start of the week, the last submission was made, submission == first booking or last send wochen_report to team leader
func (u *User) GetLastWorkWeekSubmission() time.Time {
var lastSub time.Time
diff --git a/Backend/models/workDay.go b/Backend/models/workDay.go
index b69a388..e1fec9f 100644
--- a/Backend/models/workDay.go
+++ b/Backend/models/workDay.go
@@ -1,5 +1,10 @@
package models
+// the workday combines all bookings of a day into a single type and is the third
+// type of workday which implements the IWorkDay interface
+//
+// this is a meta type and not present in the db
+
import (
"arbeitszeitmessung/helper"
"encoding/json"
diff --git a/Backend/models/workWeek.go b/Backend/models/workWeek.go
index 168365a..ef7d284 100644
--- a/Backend/models/workWeek.go
+++ b/Backend/models/workWeek.go
@@ -1,5 +1,10 @@
package models
+// the WorkWeek describes the weekly reports used the check on worktimes and
+// calculate the running overtime
+//
+// this type is based on the "wochen_report" table
+
import (
"database/sql"
"errors"
diff --git a/Backend/src/main.css b/Backend/src/main.css
index 2e260d6..7b06187 100644
--- a/Backend/src/main.css
+++ b/Backend/src/main.css
@@ -1,163 +1,157 @@
@import "tailwindcss";
@source "../templates/*.templ";
@plugin "@iconify/tailwind4" {
- scale: 1.25;
+ scale: 1.25;
}
@theme {
- --color-accent-50: #e7fdea;
- --color-accent-100: #cbfbd1;
- --color-accent-200: #9cf7a8;
- --color-accent-300: #68f37a;
- --color-accent-400: #33ef4d;
- --color-accent-500: #11db2d;
- --color-accent-600: #0eaf23;
- --color-accent-700: #0a851b;
- --color-accent-800: #075a12;
- --color-accent-900: #032b09;
- --color-accent-950: #021805;
- --color-accent: #0eaf23;
- --color-text-50: #f7f8f7;
- --color-text-100: #f2f3f2;
- --color-text-200: #e2e4e2;
- --color-text-300: #d2d6d2;
- --color-text-400: #c2c7c2;
- --color-text-500: #afb6af;
- --color-text-600: #97a097;
- --color-text-700: #7d877d;
- --color-text-800: #5a625a;
- --color-text-900: #161816;
- --color-text-950: #000000;
+ --color-accent-50: #e7fdea;
+ --color-accent-100: #cbfbd1;
+ --color-accent-200: #9cf7a8;
+ --color-accent-300: #68f37a;
+ --color-accent-400: #33ef4d;
+ --color-accent-500: #11db2d;
+ --color-accent-600: #0eaf23;
+ --color-accent-700: #0a851b;
+ --color-accent-800: #075a12;
+ --color-accent-900: #032b09;
+ --color-accent-950: #021805;
+ --color-accent: #0eaf23;
+ --color-text-50: #f7f8f7;
+ --color-text-100: #f2f3f2;
+ --color-text-200: #e2e4e2;
+ --color-text-300: #d2d6d2;
+ --color-text-400: #c2c7c2;
+ --color-text-500: #afb6af;
+ --color-text-600: #97a097;
+ --color-text-700: #7d877d;
+ --color-text-800: #5a625a;
+ --color-text-900: #161816;
+ --color-text-950: #000000;
}
@layer base {
- body {
- -webkit-print-color-adjust: exact !important;
- print-color-adjust: exact !important;
- background-color: white;
- }
+ body {
+ -webkit-print-color-adjust: exact !important;
+ print-color-adjust: exact !important;
+ background-color: white;
+ }
}
@layer components {
- .grid-main {
- display: grid;
- grid-template-columns: 4fr 3fr 3fr 1fr;
- align-items: stretch;
- }
-
- .grid-sub {
- display: grid;
- grid-template-columns: subgrid;
- grid-column: 1 / -1;
- border-color: var(--color-neutral-400);
- transition: background-color 0.2s ease-in-out;
- }
-
- .grid-sub.responsive {
- display: flex;
- flex-direction: column;
- }
-
- .grid-sub:hover {
- background-color: var(--color-neutral-200);
- }
-
- .grid-cell {
- padding: calc(var(--spacing) * 2);
- border-color: var(--color-neutral-400);
- }
-
- .btn {
- width: 100%;
- cursor: pointer;
- border-radius: var(--radius-md);
- color: var(--color-neutral-800);
- font-size: var(--text-sm);
- text-align: center;
- padding: calc(var(--spacing) * 2);
- border-style: var(--tw-border-style);
- border-width: 1px;
- border-color: var(--color-neutral-800);
- transition-property:
- color, background-color, border-color, outline-color,
- text-decoration-color, fill, stroke, --tw-gradient-from,
- --tw-gradient-via, --tw-gradient-to;
- transition-timing-function: var(
- --tw-ease,
- var(--default-transition-timing-function)
- );
- transition-duration: var(--tw-duration, var(--default-transition-duration));
- }
-
- input.btn,
- select.btn {
- transition-duration: 300ms;
- }
-
- .btn:hover {
- color: var(--color-white);
- background-color: var(--color-neutral-700);
- }
-
- .btn:disabled {
- opacity: 50%;
- pointer-events: none;
- }
-
- input.btn,
- select.btn {
- text-align: left;
- }
-
- input.btn:hover,
- select.btn:hover {
- border-color: var(--color-neutral-300);
- background-color: var(--color-neutral-100);
- color: var(--color-neutral-800);
- }
-
- .edit-box {
- border-radius: var(--radius-md);
- overflow: hidden;
- border-color: var(--color-neutral-500);
- transition-property: background-color, border-color;
- transition-timing-function: var(--default-transition-timing-function) * 2;
- transition-duration: var(--default-transition-duration);
- outline: none;
-
- &:is(:where(.group):is(.edit) *) {
- border-width: 1px;
- }
- }
-
- .edit-box:hover {
- &:is(:where(.group):is(.edit) *) {
- background-color: var(--color-white);
- border-color: var(--color-neutral-300);
- }
- }
-
- .edit-box input:focus {
- outline: none;
- }
-
- div.edit {
- border-width: 1px;
- background-color: var(--color-neutral-300);
- }
-
- @media (width >=48rem) {
.grid-main {
- grid-template-columns: repeat(5, 1fr);
- margin: 0 10%;
+ display: grid;
+ grid-template-columns: 4fr 3fr 3fr 1fr;
+ align-items: stretch;
+ }
+
+ .grid-sub {
+ display: grid;
+ grid-template-columns: subgrid;
+ grid-column: 1 / -1;
+ border-color: var(--color-neutral-400);
+ transition: background-color 0.2s ease-in-out;
}
.grid-sub.responsive {
- display: grid;
+ display: flex;
+ flex-direction: column;
+ }
+
+ .grid-sub:hover {
+ background-color: var(--color-neutral-200);
+ }
+
+ .grid-cell {
+ padding: calc(var(--spacing) * 2);
+ border-color: var(--color-neutral-400);
}
.btn {
- padding-inline: calc(var(--spacing) * 4);
+ width: 100%;
+ cursor: pointer;
+ border-radius: var(--radius-md);
+ color: var(--color-neutral-800);
+ font-size: var(--text-sm);
+ text-align: center;
+ padding: calc(var(--spacing) * 2);
+ border-style: var(--tw-border-style);
+ border-width: 1px;
+ border-color: var(--color-neutral-800);
+ transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
+ }
+
+ input.btn,
+ select.btn {
+ transition-duration: 300ms;
+ }
+
+ .btn:hover {
+ color: var(--color-white);
+ background-color: var(--color-neutral-700);
+ }
+
+ .btn:disabled {
+ opacity: 50%;
+ pointer-events: none;
+ }
+
+ input.btn,
+ select.btn {
+ text-align: left;
+ }
+
+ input.btn:hover,
+ select.btn:hover {
+ border-color: var(--color-neutral-300);
+ background-color: var(--color-neutral-100);
+ color: var(--color-neutral-800);
+ }
+
+ .edit-box {
+ border-radius: var(--radius-md);
+ overflow: hidden;
+ border-color: var(--color-neutral-500);
+ transition-property: background-color, border-color;
+ transition-timing-function: var(--default-transition-timing-function) * 2;
+ transition-duration: var(--default-transition-duration);
+ outline: none;
+
+ &:is(:where(.group):is(.edit) *) {
+ border-width: 1px;
+ }
+ }
+
+ .edit-box:hover {
+ &:is(:where(.group):is(.edit) *) {
+ background-color: var(--color-white);
+ border-color: var(--color-neutral-300);
+ }
+ }
+
+ .edit-box input:focus {
+ outline: none;
+ }
+
+ div.edit {
+ border-width: 1px;
+ background-color: var(--color-neutral-300);
+ }
+
+ @media (width >=48rem) {
+ .grid-main {
+ grid-template-columns: repeat(5, 1fr);
+ margin: 0 10%;
+ }
+
+ .grid-sub.responsive {
+ display: grid;
+ }
+
+ .btn {
+ padding-inline: calc(var(--spacing) * 4);
+ }
}
- }
}
diff --git a/Backend/templates/baseComponents.templ b/Backend/templates/baseComponents.templ
new file mode 100644
index 0000000..69c88bd
--- /dev/null
+++ b/Backend/templates/baseComponents.templ
@@ -0,0 +1,97 @@
+// templates are used for the templ templates
+// these will render the html page with data from the webserver
+package templates
+
+import (
+ "arbeitszeitmessung/models"
+ "fmt"
+)
+
+// this file includes the basic components, which are used in many other components and pages
+templ headerComponent() {
+ // {{ user := ctx.Value("user").(models.User) }}
+
+}
+
+templ statusCheckMark(status models.WeekStatus, target models.WeekStatus) {
+ if status >= target {
+
+ } else {
+
+ }
+}
+
+templ lineComponent() {
+
+}
+
+templ timeGaugeComponent(progress int8, today bool) {
+ {{
+ var bgColor string
+ switch {
+ case (0 > progress):
+ bgColor = "bg-red-600"
+ break
+ case (progress > 0 && progress < 95):
+ bgColor = "bg-orange-500"
+ break
+ case (95 <= progress && progress <= 105):
+ bgColor = "bg-accent"
+ break
+ case (progress > 105):
+ bgColor = "bg-purple-600"
+ break
+ default:
+ bgColor = "bg-neutral-400"
+ break
+ }
+ }}
+ if today {
+
+ } else {
+
+ }
+}
+
+templ legendComponent() {
+
+
+
Arbeitszeit unter regulär
+
+
+
+
+}
+
+templ CheckboxComponent(pNr int, label string) {
+ {{ id := fmt.Sprintf("pdf-%d", pNr) }}
+
+}
diff --git a/Backend/templates/pages.templ b/Backend/templates/basePages.templ
similarity index 91%
rename from Backend/templates/pages.templ
rename to Backend/templates/basePages.templ
index 55735f8..7dd131c 100644
--- a/Backend/templates/pages.templ
+++ b/Backend/templates/basePages.templ
@@ -1,9 +1,12 @@
package templates
+// this file includes the basic pages, that have no further complexity,
+// like the login and settings page, the more complex pages have their own files
+
import "arbeitszeitmessung/models"
import "arbeitszeitmessung/helper"
-templ Base() {
+templ BasePage() {
Arbeitszeit
@@ -14,7 +17,7 @@ templ Base() {
}
templ LoginPage(success bool, errorMsg string) {
- @Base()
+ @BasePage()
}
-
-templ statusCheckMark(status models.WeekStatus, target models.WeekStatus) {
- if status >= target {
-
- } else {
-
- }
-}
-
-templ LogoutButton() {
- Abmelden
-}
diff --git a/Backend/templates/headerComponent.templ b/Backend/templates/headerComponent.templ
deleted file mode 100644
index abcf693..0000000
--- a/Backend/templates/headerComponent.templ
+++ /dev/null
@@ -1,15 +0,0 @@
-package templates
-
-templ headerComponent() {
- // {{ user := ctx.Value("user").(models.User) }}
-
-}
diff --git a/Backend/templates/headerComponent_templ.go b/Backend/templates/headerComponent_templ.go
deleted file mode 100644
index 53d8123..0000000
--- a/Backend/templates/headerComponent_templ.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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"
-
-func headerComponent() 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Zeitverwaltung Abrechnung ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if true {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
Monatsabrechnung Anwesenheit ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
Einstellungen ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = LogoutButton().Render(ctx, templ_7745c5c3_Buffer)
- 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
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/pages_templ.go b/Backend/templates/pages_templ.go
deleted file mode 100644
index 0e5daff..0000000
--- a/Backend/templates/pages_templ.go
+++ /dev/null
@@ -1,288 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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 Base() 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Arbeitszeit ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func LoginPage(success bool, errorMsg string) 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_Var2 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var2 == nil {
- templ_7745c5c3_Var2 = 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Benutzer Anmelden ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !success {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "Login fehlgeschlagen, bitte erneut versuchen!
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- 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}
- }
- _, 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, 4, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "Login ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-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 {
- 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_Var4 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var4 == nil {
- templ_7745c5c3_Var4 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- user := ctx.Value("user").(models.User)
- 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, 6, "Passwort ändern Ändern
Nutzerdaten Nutzername: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- 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: 59, Col: 64}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- 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: 59, Col: 78}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "
Personalnummer: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- 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: 60, Col: 75}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
Arbeitszeit pro Tag: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(user.ArbeitszeitProTag()))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 108}
- }
- _, 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, 14, "
Arbeitszeit pro Woche: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var9 string
- templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(user.ArbeitszeitProWoche()))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 62, Col: 112}
- }
- _, 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, 15, "
Nutzer abmelden Nutzer von Weboberfläche abmelden.
Abmelden
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func statusCheckMark(status models.WeekStatus, target models.WeekStatus) 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)
- if status >= target {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
")
- 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
- 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_Var11 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var11 == nil {
- templ_7745c5c3_Var11 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "Abmelden ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/pdf.templ b/Backend/templates/pdf.templ
deleted file mode 100644
index ab297a1..0000000
--- a/Backend/templates/pdf.templ
+++ /dev/null
@@ -1,134 +0,0 @@
-package templates
-
-import (
- "arbeitszeitmessung/helper"
- "arbeitszeitmessung/models"
- "fmt"
- "time"
-)
-
-templ PDFForm(teamMembers []models.User) {
- @Base()
- @headerComponent()
-
-
-
Monatsabrechnung erstellen
-
-
-
Zeitraum wählen
-
- Abrechnungsmonat
-
-
-
-
-
-
Mitarbeiter wählen
-
-
- Alle
- Keine
-
- for _, member := range teamMembers {
- @CheckboxComponent(member.PersonalNummer, fmt.Sprintf("%s %s", member.Vorname, member.Name))
- }
-
-
-
-
-
PDFs Bündeln
-
- Einzeln
- Bündel
-
-
-
-}
-
-templ CheckboxComponent(pNr int, label string) {
- {{ id := fmt.Sprintf("pdf-%d", pNr) }}
-
-}
-
-// templ PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays []models.IWorkDay, tsStart time.Time, tsEnd time.Time) {
-// {{
-// _, kw := tsStart.ISOWeek()
-// noBorder := ""
-// }}
-// @Base()
-//
-//
-//
{ e.Vorname } { e.Name }
-//
Zeitraum: { tsStart.Format("02.01.2006") } - { tsEnd.Format("02.01.2006") }
-//
Arbeitszeit: { helper.FormatDuration(worktime) }
-//
Überstunden: { helper.FormatDuration(overtime) }
-//
-//
-//
{ kw }
-//
Kommen
-//
Gehen
-//
Arbeitsart
-//
Stunden
-//
Pause
-//
Überstunden
-// for index, day := range workDays {
-// {{
-// if index == len(workDays)-1 {
-// noBorder = "border-b-0"
-// }
-// }}
-//
{ day.Date().Format("02.01.2006") }
-//
-// if day.IsWorkDay() {
-// {{
-// workDay, _ := day.(*models.WorkDay)
-// }}
-// for bookingI := 0; bookingI < len(workDay.Bookings); bookingI+= 2 {
-//
{ workDay.Bookings[bookingI].Timestamp.Format("15:04") }
-//
{ workDay.Bookings[bookingI+1].Timestamp.Format("15:04") }
-//
{ workDay.Bookings[bookingI].BookingType.Name }
-// }
-// if workDay.IsKurzArbeit() {
-// {{
-// timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e)
-// }}
-//
{ timeFrom.Format("15:04") }
-//
{ timeTo.Format("15:04") }
-//
Kurzarbeit
-// }
-// } else {
-// {{
-// absentDay, _ := day.(*models.Absence)
-// }}
-//
{ absentDay.AbwesenheitTyp.Name }
-// }
-//
-// {{ work, pause, overtime := day.GetTimesVirtual(e) }}
-// @ColorDuration(work, noBorder)
-// @ColorDuration(pause, noBorder)
-// @ColorDuration(overtime, noBorder+" border-r-0")
-// if day.Date().Weekday() == time.Friday {
-//
Wochenende
-// }
-// }
-//
-//
-// }
-templ ColorDuration(d time.Duration, classes string) {
- {{
- color := ""
- if d.Abs() < time.Minute {
- color = "text-neutral-300"
- }
- }}
- { helper.FormatDurationFill(d, true) }
-}
diff --git a/Backend/templates/pdfPage.templ b/Backend/templates/pdfPage.templ
new file mode 100644
index 0000000..e3ef0b7
--- /dev/null
+++ b/Backend/templates/pdfPage.templ
@@ -0,0 +1,48 @@
+package templates
+
+// this file has all templates for the /pdf page
+
+import (
+ "arbeitszeitmessung/helper"
+ "arbeitszeitmessung/models"
+ "fmt"
+ "time"
+)
+
+templ PDFForm(teamMembers []models.User) {
+ @BasePage()
+ @headerComponent()
+
+
+
Monatsabrechnung erstellen
+
+
+
Zeitraum wählen
+
+ Abrechnungsmonat
+
+
+
+
+
+
Mitarbeiter wählen
+
+
+ Alle
+ Keine
+
+ for _, member := range teamMembers {
+ @CheckboxComponent(member.PersonalNummer, fmt.Sprintf("%s %s", member.Vorname, member.Name))
+ }
+
+
+
+
+
PDFs Bündeln
+
+ Einzeln
+ Bündel
+
+
+
+}
diff --git a/Backend/templates/pdf_templ.go b/Backend/templates/pdf_templ.go
deleted file mode 100644
index 312984f..0000000
--- a/Backend/templates/pdf_templ.go
+++ /dev/null
@@ -1,335 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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/helper"
- "arbeitszeitmessung/models"
- "fmt"
- "time"
-)
-
-func PDFForm(teamMembers []models.User) 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, "
Monatsabrechnung erstellen Zeitraum wählen
Abrechnungsmonat
Mitarbeiter wählen
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("true")))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "Alle ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("false")))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "Keine
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- for _, member := range teamMembers {
- templ_7745c5c3_Err = CheckboxComponent(member.PersonalNummer, fmt.Sprintf("%s %s", member.Vorname, member.Name)).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
PDFs Bündeln
Einzeln Bündel
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func CheckboxComponent(pNr int, label string) 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_Var5 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var5 == nil {
- templ_7745c5c3_Var5 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- id := fmt.Sprintf("pdf-%d", pNr)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-// templ PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays []models.IWorkDay, tsStart time.Time, tsEnd time.Time) {
-// {{
-// _, kw := tsStart.ISOWeek()
-// noBorder := ""
-// }}
-// @Base()
-//
-//
-//
{ e.Vorname } { e.Name }
-//
Zeitraum: { tsStart.Format("02.01.2006") } - { tsEnd.Format("02.01.2006") }
-//
Arbeitszeit: { helper.FormatDuration(worktime) }
-//
Überstunden: { helper.FormatDuration(overtime) }
-//
-//
-//
{ kw }
-//
Kommen
-//
Gehen
-//
Arbeitsart
-//
Stunden
-//
Pause
-//
Überstunden
-// for index, day := range workDays {
-// {{
-// if index == len(workDays)-1 {
-// noBorder = "border-b-0"
-// }
-// }}
-//
{ day.Date().Format("02.01.2006") }
-//
-// if day.IsWorkDay() {
-// {{
-// workDay, _ := day.(*models.WorkDay)
-// }}
-// for bookingI := 0; bookingI < len(workDay.Bookings); bookingI+= 2 {
-//
{ workDay.Bookings[bookingI].Timestamp.Format("15:04") }
-//
{ workDay.Bookings[bookingI+1].Timestamp.Format("15:04") }
-//
{ workDay.Bookings[bookingI].BookingType.Name }
-// }
-// if workDay.IsKurzArbeit() {
-// {{
-// timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e)
-// }}
-//
{ timeFrom.Format("15:04") }
-//
{ timeTo.Format("15:04") }
-//
Kurzarbeit
-// }
-// } else {
-// {{
-// absentDay, _ := day.(*models.Absence)
-// }}
-//
{ absentDay.AbwesenheitTyp.Name }
-// }
-//
-// {{ work, pause, overtime := day.GetTimesVirtual(e) }}
-// @ColorDuration(work, noBorder)
-// @ColorDuration(pause, noBorder)
-// @ColorDuration(overtime, noBorder+" border-r-0")
-// if day.Date().Weekday() == time.Friday {
-//
Wochenende
-// }
-// }
-//
-//
-// }
-func ColorDuration(d time.Duration, classes string) 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_Var11 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var11 == nil {
- templ_7745c5c3_Var11 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- color := ""
- if d.Abs() < time.Minute {
- color = "text-neutral-300"
- }
- var templ_7745c5c3_Var12 = []any{color + " " + classes}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var14 string
- templ_7745c5c3_Var14, 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: 133, Col: 72}
- }
- _, 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, 16, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/presencePage.templ b/Backend/templates/presencePage.templ
index f1ca3d1..4735011 100644
--- a/Backend/templates/presencePage.templ
+++ b/Backend/templates/presencePage.templ
@@ -1,10 +1,12 @@
package templates
+// this file has all the templates for the /team/presence page
+
import "arbeitszeitmessung/models"
import "arbeitszeitmessung/helper"
templ TeamPresencePage(teamPresence map[models.User]bool) {
- @Base()
+ @BasePage()
@headerComponent()
@@ -27,3 +29,14 @@ templ TeamPresencePage(teamPresence map[models.User]bool) {
}
}
+
+templ userPresenceComponent(user models.User, present bool) {
+
+ if present {
+
Anwesend
+ } else {
+
Abwesend
+ }
+
{ user.Vorname } { user.Name }
+
+}
diff --git a/Backend/templates/presencePage_templ.go b/Backend/templates/presencePage_templ.go
deleted file mode 100644
index 7655580..0000000
--- a/Backend/templates/presencePage_templ.go
+++ /dev/null
@@ -1,110 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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/reportPage.templ b/Backend/templates/reportPage.templ
index bc74e34..cf1e1cb 100644
--- a/Backend/templates/reportPage.templ
+++ b/Backend/templates/reportPage.templ
@@ -1,5 +1,7 @@
package templates
+// this file has all the templates for the team/report page
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
@@ -8,11 +10,11 @@ import (
"time"
)
-templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
- @Base()
+templ ReportPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
+ @BasePage()
@headerComponent()
-
-
+
+
Eigene Abrechnung
@@ -34,7 +36,7 @@ templ workWeekComponent(week models.WorkWeek, onlyAccept bool) {
year, kw := week.WeekStart.ISOWeek()
progress := (float32(week.WorktimeVirtual.Hours()) / week.User.ArbeitszeitPerWoche) * 100
}}
-
+
if !onlyAccept {
@@ -144,3 +146,39 @@ templ weekDayTypeSwitcher(day models.IWorkDay) {
{ day.ToString() }
}
}
+
+templ weekPicker(weekStart time.Time) {
+ {{ year, kw := weekStart.ISOWeek() }}
+
+
+
+
+
+
+
+ KW { fmt.Sprintf("%02d, %d", kw, year) }
+
+
+
+
+
+
+}
+
+templ workDayWeekComponent(workDay *models.WorkDay) {
+ if !workDay.RequiresAction() {
+
+
+ switch {
+ case !workDay.TimeFrom.Equal(workDay.TimeTo):
+
{ workDay.TimeFrom.Format("15:04") }
+
-
+
{ workDay.TimeTo.Format("15:04") }
+ default:
+
Keine Anwesenheit
+ }
+
+ } else {
+
Bitte anpassen
+ }
+}
diff --git a/Backend/templates/reportPage_templ.go b/Backend/templates/reportPage_templ.go
deleted file mode 100644
index 96ed8f5..0000000
--- a/Backend/templates/reportPage_templ.go
+++ /dev/null
@@ -1,545 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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/helper"
- "arbeitszeitmessung/models"
- "fmt"
- "strconv"
- "time"
-)
-
-func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) 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, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = workWeekComponent(userWeek, false).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if len(weeks) > 0 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
Abrechnung Mitarbeiter ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- for _, week := range weeks {
- templ_7745c5c3_Err = workWeekComponent(week, true).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
- }
- return nil
- })
-}
-
-func workWeekComponent(week models.WorkWeek, onlyAccept 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_Var2 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var2 == nil {
- templ_7745c5c3_Var2 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- year, kw := week.WeekStart.ISOWeek()
- progress := (float32(week.WorktimeVirtual.Hours()) / week.User.ArbeitszeitPerWoche) * 100
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !onlyAccept {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = weekPicker(week.WeekStart).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var3 string
- templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Vorname)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 44, Col: 53}
- }
- _, 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, 8, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var4 string
- templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Name)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 44, Col: 72}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
- 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
- }
- if !onlyAccept {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = statusCheckMark(week.CheckStatus(), models.WeekStatusSent).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "Gesendet ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = statusCheckMark(week.CheckStatus(), models.WeekStatusAccepted).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "Akzeptiert
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = timeGaugeComponent(int8(progress), false).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
Arbeitszeit: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var5 string
- templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDuration(week.Worktime)))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 61, Col: 79}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
Überstunden: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var6 string
- templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDurationFill(week.Overtime, true)))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 62, Col: 90}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
- 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
- }
- for _, day := range week.Days {
- templ_7745c5c3_Err = defaultWeekDayComponent(week.User, day).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if onlyAccept {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
Woche: ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var7 string
- templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d-%d", kw, year))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 74, Col: 86}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
- 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
- }
- } else {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = weekPicker(week.WeekStart).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
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- week.CheckStatus()
- method := "accept"
- if !onlyAccept {
- method = "send"
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if onlyAccept {
- if week.Status == models.WeekStatusDifferences {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "Unterschiedliche Arbeitszeit zwischen Abrechnung und individuellen Buchungen
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " Bestätigen ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- switch {
- case week.RequiresAction():
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "bitte zuerst Buchungen anpassen
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case time.Since(week.WeekStart) < 24*7*time.Hour:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "Die Woche kann erst am nächsten Montag gesendet werden!
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case week.Status == models.WeekStatusNone:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "an Vorgesetzten senden
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case week.Status == models.WeekStatusSent:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "an Vorgesetzten gesendet
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case week.Status == models.WeekStatusAccepted:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "vom Vorgesetzten bestätigt
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " Korrigieren = models.WeekStatusSent || week.RequiresAction() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, " disabled")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " type=\"submit\" class=\"btn\">Senden ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func defaultWeekDayComponent(u models.User, day models.IWorkDay) 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_Var11 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var11 == nil {
- templ_7745c5c3_Var11 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = timeGaugeComponent(day.GetDayProgress(u), false).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var12 string
- templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 121, Col: 108}
- }
- _, 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, 44, ": ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var13 string
- templ_7745c5c3_Var13, 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/reportPage.templ`, Line: 121, Col: 152}
- }
- _, 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, 45, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- work, pause, _ := day.GetTimes(u, models.WorktimeBaseDay, false)
- if day.IsWorkDay() || day.GetDayProgress(u) < 100 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var14 string
- templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(work))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 125, Col: 60}
- }
- _, 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, 47, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var15 string
- templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(pause))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 126, Col: 66}
- }
- _, 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, 48, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = weekDayTypeSwitcher(day).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func weekDayTypeSwitcher(day models.IWorkDay) 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_Var16 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var16 == nil {
- templ_7745c5c3_Var16 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- switch day.Type() {
- case models.DayTypeWorkday:
- workDay, _ := day.(*models.WorkDay)
- templ_7745c5c3_Err = workDayWeekComponent(workDay).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case models.DayTypeCompound:
- for _, c := range day.(*models.CompoundDay).DayParts {
- templ_7745c5c3_Err = weekDayTypeSwitcher(c).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- default:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var17 string
- templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reportPage.templ`, Line: 144, Col: 24}
- }
- _, 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, 51, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/teamComponents.templ b/Backend/templates/teamComponents.templ
deleted file mode 100644
index fd09824..0000000
--- a/Backend/templates/teamComponents.templ
+++ /dev/null
@@ -1,54 +0,0 @@
-package templates
-
-import (
- "arbeitszeitmessung/models"
- "fmt"
- "time"
-)
-
-templ weekPicker(weekStart time.Time) {
- {{ year, kw := weekStart.ISOWeek() }}
-
-
-
-
-
-
-
- KW { fmt.Sprintf("%02d, %d", kw, year) }
-
-
-
-
-
-
-}
-
-templ workDayWeekComponent(workDay *models.WorkDay) {
- if !workDay.RequiresAction() {
-
-
- switch {
- case !workDay.TimeFrom.Equal(workDay.TimeTo):
-
{ workDay.TimeFrom.Format("15:04") }
-
-
-
{ workDay.TimeTo.Format("15:04") }
- default:
-
Keine Anwesenheit
- }
-
- } else {
-
Bitte anpassen
- }
-}
-
-templ userPresenceComponent(user models.User, present bool) {
-
- if present {
-
Anwesend
- } else {
-
Abwesend
- }
-
{ user.Vorname } { user.Name }
-
-}
diff --git a/Backend/templates/teamComponents_templ.go b/Backend/templates/teamComponents_templ.go
deleted file mode 100644
index 0078d43..0000000
--- a/Backend/templates/teamComponents_templ.go
+++ /dev/null
@@ -1,265 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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"
- "fmt"
- "time"
-)
-
-func weekPicker(weekStart time.Time) 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)
- year, kw := weekStart.ISOWeek()
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("navigateWeek", templ.JSExpression("this"), templ.JSExpression("event"), "-1"))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "KW ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var4 string
- templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d, %d", kw, year))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 18, Col: 69}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
- 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
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("navigateWeek", templ.JSExpression("this"), templ.JSExpression("event"), "1"))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func workDayWeekComponent(workDay *models.WorkDay) 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_Var6 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var6 == nil {
- templ_7745c5c3_Var6 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- if !workDay.RequiresAction() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- switch {
- case !workDay.TimeFrom.Equal(workDay.TimeTo):
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var7 string
- templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.TimeFrom.Format("15:04"))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 33, Col: 45}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " - ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.TimeTo.Format("15:04"))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 43}
- }
- _, 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, 13, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- default:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
Keine Anwesenheit
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
Bitte anpassen
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return nil
- })
-}
-
-func userPresenceComponent(user models.User, present 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_Var9 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var9 == nil {
- templ_7745c5c3_Var9 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if present {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
Anwesend
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
Abwesend
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var10 string
- templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 52, Col: 19}
- }
- _, 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, 21, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var11 string
- templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 52, Col: 33}
- }
- _, 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
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/timeComponents.templ b/Backend/templates/timeComponents.templ
index 4641a1e..7f2d066 100644
--- a/Backend/templates/timeComponents.templ
+++ b/Backend/templates/timeComponents.templ
@@ -2,23 +2,10 @@ package templates
import (
"arbeitszeitmessung/models"
- "fmt"
"strconv"
"time"
)
-templ lineComponent() {
-
-}
-
templ changeButtonComponent(id string, workDay bool) {
Ändern
@@ -31,36 +18,6 @@ templ changeButtonComponent(id string, workDay bool) {
}
-templ timeGaugeComponent(progress int8, today bool) {
- {{
- var bgColor string
- switch {
- case (0 > progress):
- bgColor = "bg-red-600"
- break
- case (progress > 0 && progress < 95):
- bgColor = "bg-orange-500"
- break
- case (95 <= progress && progress <= 105):
- bgColor = "bg-accent"
- break
- case (progress > 105):
- bgColor = "bg-purple-600"
- break
- default:
- bgColor = "bg-neutral-400"
- break
- }
- }}
- if today {
-
- } else {
-
- }
-}
-
templ newAbsenceComponent() {
@@ -131,12 +88,20 @@ templ bookingComponent(booking models.Booking) {
}
-templ LegendComponent() {
-
-
-
Arbeitszeit unter regulär
-
-
-
-
+templ workdayComponent(workDay *models.WorkDay) {
+ if len(workDay.Bookings) < 1 {
+ Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
+ } else {
+ if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
+ @absenceComponent(workDay.GetKurzArbeit(), true)
+ }
+ for _, booking := range workDay.Bookings {
+ @bookingComponent(booking)
+ }
+ 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0 }/>
+ }
+}
+
+templ holidayComponent(d models.IWorkDay) {
+ { d.ToString() }
}
diff --git a/Backend/templates/timeComponents_templ.go b/Backend/templates/timeComponents_templ.go
deleted file mode 100644
index c37d703..0000000
--- a/Backend/templates/timeComponents_templ.go
+++ /dev/null
@@ -1,647 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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"
- "fmt"
- "strconv"
- "time"
-)
-
-func lineComponent() 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func changeButtonComponent(id string, workDay 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_Var2 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var2 == nil {
- templ_7745c5c3_Var2 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), id, workDay))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Ändern
Speichern
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("clearEditState"))
- 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
- }
- return nil
- })
-}
-
-func timeGaugeComponent(progress int8, today 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_Var5 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var5 == nil {
- templ_7745c5c3_Var5 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- var bgColor string
- switch {
- case (0 > progress):
- bgColor = "bg-red-600"
- break
- case (progress > 0 && progress < 95):
- bgColor = "bg-orange-500"
- break
- case (95 <= progress && progress <= 105):
- bgColor = "bg-accent"
- break
- case (progress > 105):
- bgColor = "bg-purple-600"
- break
- default:
- bgColor = "bg-neutral-400"
- break
- }
- if today {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var6 = []any{"flex w-full items-center justify-center overflow-hidden rounded-full", bgColor}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- var templ_7745c5c3_Var9 = []any{"w-2 h-full bg-accent rounded-md flex-shrink-0", bgColor}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var9...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return nil
- })
-}
-
-func newAbsenceComponent() 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_Var11 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var11 == nil {
- templ_7745c5c3_Var11 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), 0, false))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "Neue Abwesenheit
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func absenceComponent(a *models.Absence, isKurzarbeit 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_Var13 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var13 == nil {
- templ_7745c5c3_Var13 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- editBox := ""
- if isKurzarbeit {
- editBox = "edit-box"
- }
- var templ_7745c5c3_Var14 = []any{"flex flex-row items-center gap-2", editBox}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var14...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = absentInput(a).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var16 string
- templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(a.ToString())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 82, Col: 17}
- }
- _, 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, 18, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if a.IsMultiDay() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "bis ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var17 string
- templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("02.01.2006"))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 84, Col: 70}
- }
- _, 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, 20, " ")
- 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
- }
- if isKurzarbeit {
- templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format(time.DateOnly), false))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "
Bearbeiten ")
- 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
- }
- return nil
- })
-}
-
-func absentInput(a *models.Absence) 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_Var19 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var19 == nil {
- templ_7745c5c3_Var19 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-// js function to select the right entry
-func newBookingComponent(d models.IWorkDay) 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_Var24 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var24 == nil {
- templ_7745c5c3_Var24 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func bookingComponent(booking models.Booking) 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_Var28 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var28 == nil {
- templ_7745c5c3_Var28 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var29 string
- templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04"))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 124, Col: 91}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var32 string
- templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(booking.GetBookingType())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 126, Col: 29}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if booking.IsSubmittedAndChecked() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
submitted
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func LegendComponent() 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_Var33 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var33 == nil {
- templ_7745c5c3_Var33 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "
Arbeitszeit unter regulär ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/Backend/templates/timePage.templ b/Backend/templates/timePage.templ
index d449d4a..4ac2e6c 100644
--- a/Backend/templates/timePage.templ
+++ b/Backend/templates/timePage.templ
@@ -1,5 +1,9 @@
package templates
+// this files includes the largest templates from the time page,
+// because this page is so complex the smaller components are in
+// the timeComponents.templ file
+
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
@@ -10,7 +14,7 @@ import (
templ TimePage(workDays []models.WorkDay, lastSub time.Time) {
{{ allDays := ctx.Value("days").([]models.IWorkDay) }}
- @Base()
+ @BasePage()
@headerComponent()
@inputForm()
@@ -21,7 +25,7 @@ templ TimePage(workDays []models.WorkDay, lastSub time.Time) {
}
}
- @LegendComponent()
+ @legendComponent()
}
templ inputForm() {
@@ -160,21 +164,3 @@ templ timeDayTypeSwitch(day models.IWorkDay, fromCompound bool) {
{ day.ToString() }
}
}
-
-templ workdayComponent(workDay *models.WorkDay) {
- if len(workDay.Bookings) < 1 {
- Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
- } else {
- if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
- @absenceComponent(workDay.GetKurzArbeit(), true)
- }
- for _, booking := range workDay.Bookings {
- @bookingComponent(booking)
- }
- 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0 }/>
- }
-}
-
-templ holidayComponent(d models.IWorkDay) {
- { d.ToString() }
-}
diff --git a/Backend/templates/timePage_templ.go b/Backend/templates/timePage_templ.go
deleted file mode 100644
index 6aced07..0000000
--- a/Backend/templates/timePage_templ.go
+++ /dev/null
@@ -1,623 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.3.960
-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/helper"
- "arbeitszeitmessung/models"
- "net/url"
- "strconv"
- "time"
-)
-
-func TimePage(workDays []models.WorkDay, lastSub time.Time) 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)
- allDays := ctx.Value("days").([]models.IWorkDay)
- 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, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = inputForm().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- for _, day := range allDays {
- templ_7745c5c3_Err = defaultDayComponent(day).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if day.Date().Weekday() == time.Monday {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
")
- 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
- }
- templ_7745c5c3_Err = LegendComponent().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func inputForm() 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_Var2 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var2 == nil {
- templ_7745c5c3_Var2 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- urlParams := ctx.Value("urlParams").(url.Values)
- user := ctx.Value("user").(models.User)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var3 string
- templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname + " " + user.Name)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 35, Col: 67}
- }
- _, 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, 6, "
Überstunden
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var4 string
- templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(user.Overtime)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 38, Col: 43}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = lineComponent().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "
Abwesenheitsart ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- for _, absence := range models.GetAbsenceTypesCached() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(absence.Name)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 62, Col: 69}
- }
- _, 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, 13, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " Abwesenheit ab
Abwesenheit bis
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func defaultDayComponent(day models.IWorkDay) 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_Var9 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var9 == nil {
- templ_7745c5c3_Var9 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- user := ctx.Value("user").(models.User)
- justify := "justify-center"
- if day.IsWorkDay() && !day.IsEmpty() {
- justify = "justify-between"
- }
- var templ_7745c5c3_Var10 = []any{"grid-sub divide-x-1 hover:bg-neutral-200 transition-colors group"}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var10...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = timeGaugeComponent(day.GetDayProgress(user), day.Date().Equal(time.Now().Truncate(24*time.Hour))).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var12 string
- templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 98}
- }
- _, 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, 18, ": ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var13 string
- templ_7745c5c3_Var13, 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/timePage.templ`, Line: 101, Col: 142}
- }
- _, 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, 19, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if day.IsWorkDay() {
- work, pause, overtime := day.GetTimes(user, models.WorktimeBaseDay, true)
- work = day.GetWorktime(user, models.WorktimeBaseDay, false)
- if day.RequiresAction() {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
Bitte anpassen
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- if work > 0 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
Arbeitszeit:
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var14 string
- templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(work))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 113, Col: 155}
- }
- _, 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, 22, "
")
- 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 pause > 0 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var15 string
- templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(pause))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 116, Col: 173}
- }
- _, 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, 25, "
")
- 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
- }
- if !day.IsEmpty() && overtime != 0 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var16 string
- templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 121, Col: 41}
- }
- _, 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, 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
- }
- templ_7745c5c3_Err = lineComponent().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var17 = []any{"bookings flex flex-col gap-2 w-full", justify}
- 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, 30, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if day.GetDayProgress(user) < 100 || day.IsWorkDay() {
- templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = timeDayTypeSwitch(day, true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = newBookingComponent(day).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- templ_7745c5c3_Err = timeDayTypeSwitch(day, true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, " ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = changeButtonComponent("time-"+day.Date().Format(time.DateOnly), true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-func timeDayTypeSwitch(day models.IWorkDay, fromCompound 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_Var20 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var20 == nil {
- templ_7745c5c3_Var20 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- switch day.Type() {
- case models.DayTypeWorkday:
- workDay, _ := day.(*models.WorkDay)
- templ_7745c5c3_Err = workdayComponent(workDay).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case models.DayTypeAbsence:
- absentDay, _ := day.(*models.Absence)
- templ_7745c5c3_Err = absenceComponent(absentDay, fromCompound).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- case models.DayTypeCompound:
- for _, c := range day.(*models.CompoundDay).DayParts {
- templ_7745c5c3_Err = timeDayTypeSwitch(c, true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- default:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var21 string
- templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 160, Col: 22}
- }
- _, 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, 38, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return nil
- })
-}
-
-func workdayComponent(workDay *models.WorkDay) 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_Var22 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var22 == nil {
- templ_7745c5c3_Var22 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- if len(workDay.Bookings) < 1 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
- templ_7745c5c3_Err = absenceComponent(workDay.GetKurzArbeit(), true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- for _, booking := range workDay.Bookings {
- templ_7745c5c3_Err = bookingComponent(booking).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 174, Col: 140}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\">")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return nil
- })
-}
-
-func holidayComponent(d models.IWorkDay) 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_Var24 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var24 == nil {
- templ_7745c5c3_Var24 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var25 string
- templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(d.ToString())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 179, Col: 18}
- }
- _, 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, 43, "
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return nil
- })
-}
-
-var _ = templruntime.GeneratedTemplate
diff --git a/DBB/initdb/01_create_user.sh b/DBB/initdb/01_create_user.sh
new file mode 100755
index 0000000..91c3259
--- /dev/null
+++ b/DBB/initdb/01_create_user.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -e # Exit on error
+
+echo "Creating PostgreSQL user and setting permissions... $POSTGRES_USER for API user $POSTGRES_API_USER"
+
+
+
+psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
+ CREATE ROLE migrate LOGIN ENCRYPTED PASSWORD '$POSTGRES_PASSWORD';
+ GRANT USAGE, CREATE ON SCHEMA public TO migrate;
+ GRANT CONNECT ON DATABASE arbeitszeitmessung TO migrate;
+EOSQL
+
+# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
+
+# GRANT SELECT, INSERT, UPDATE ON anwesenheit, abwesenheit, user_password, wochen_report, s_feiertage TO $POSTGRES_API_USER;
+# GRANT DELETE ON abwesenheit TO $POSTGRES_API_USER;
+# GRANT SELECT ON s_personal_daten, s_abwesenheit_typen, s_anwesenheit_typen, s_feiertage TO $POSTGRES_API_USER;
+# GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO $POSTGRES_API_USER;
+# EOSQL
+
+echo "User creation and permissions setup complete!"
+
+
+psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
+
+-- privilege roles
+DO \$\$
+BEGIN
+ IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'app_base') THEN
+ CREATE ROLE app_base NOLOGIN;
+ END IF;
+END
+\$\$;
+
+-- dynamic login role
+DO \$\$
+BEGIN
+ IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '$POSTGRES_API_USER') THEN
+ CREATE ROLE $POSTGRES_API_USER
+ LOGIN
+ ENCRYPTED PASSWORD '$POSTGRES_API_PASS';
+ END IF;
+END
+\$\$;
+
+-- grant base privileges
+GRANT app_base TO $POSTGRES_API_USER;
+GRANT CONNECT ON DATABASE $POSTGRES_DB TO $POSTGRES_API_USER;
+GRANT USAGE ON SCHEMA public TO $POSTGRES_API_USER;
+
+CREATE EXTENSION IF NOT EXISTS pgcrypto;
+
+EOSQL
+
+# psql -v ON_ERROR_STOP=1 --username root --dbname arbeitszeitmessung
diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml
index cec5dd3..f7c3c11 100644
--- a/Docker/docker-compose.yml
+++ b/Docker/docker-compose.yml
@@ -13,9 +13,14 @@ services:
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
ports:
- ${POSTGRES_PORT}:5432
+ healthcheck:
+ test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "--dbname", "${POSTGRES_DB}"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
backend:
- image: git.letsstein.de/tom/arbeitszeitmessung-webserver
+ image: git.letsstein.de/tom/arbeitszeitmessung-webserver:dev
env_file:
- .env
environment:
@@ -24,7 +29,8 @@ services:
ports:
- ${WEB_PORT}:8080
depends_on:
- - db
+ db:
+ condition: service_healthy
volumes:
- ${LOG_PATH}:/app/logs
restart: unless-stopped
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index a5d5f5c..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,66 +0,0 @@
-pipeline {
- environment {
- DOCKER_USERNAME = 'jenkins'
- DOCKER_PASSWORD = credentials('gitea_jenkins')
- SONAR_TOKEN = credentials('sonarcube_token')
- POSTGRES_USER = 'postgres'
- POSTGRES_PASSWORD = 'password'
- POSTGRES_DB = 'arbeitszeitmessung'
- }
-
- agent any
-
- stages {
- stage('Test') {
- agent {
- docker {
- image ''
- args ''
- args ''
- }
- }
- steps {
- script {
- sh '''
- docker run -d --rm \
- --name test-db \
- -e POSTGRES_USER={$POSTGRES_USER} \
- -e POSTGRES_PASSWORD={$POSTGRES_PASSWORD} \
- -e POSTGRES_DB={$POSTGRES_DB} \
- -v ./DB/initdb:/docker-entrypoint-initdb.d\
- -p "5432:5432" \
- postgres:16
- '''
- // docker.image('golang:1.24.5').withRun(
- // '-u root:root --network=host'
- // ) { go ->
- // // wait for DB to start
- // sh '''
- // cd Backend \
- // go mod download && go mod tidy \
- // go test ./... -v
-
- // '''
- // }
- }
- }
- }
- stage('SonarCube Analysis') {
- steps {
- sh 'make scan'
- }
- }
- stage('Building image arbeitszeit-backend') {
- when {
- anyOf {
- changeset 'Jenkinsfile'
- changeset 'Makefile'
- changeset 'Backend/**'
- }
- }
- steps {
- sh 'make backend'
- }
- }
- }
-}
diff --git a/Readme.md b/Readme.md
index 2f4bbdd..c058ab8 100644
--- a/Readme.md
+++ b/Readme.md
@@ -120,3 +120,29 @@ Antwort `202` Akzeptiert und eingefügt
Antwort `409` Konflikt
Die vorherige Buchung am selben Tag hat den gleichen Buchungstyp
+
+# Filestrukture
+
+```
+├── Backend (Webserver)
+│ ├── doc (Templates for Document Creator --> typst used to create PDF Reports)
+│ │ ├── static
+│ │ └── templates
+│ ├── endpoints (HTML Server endpoints (see main.go for Routes))
+│ ├── helper (Helper classes)
+│ │ ├── logs
+│ │ └── paramParser
+│ ├── logs (Log Folder, no sourcecode)
+│ ├── migrations (DB Migrations Folder, no direct sourcecode)
+│ ├── models (DB Models and their function)
+│ ├── src (Tailwind src --> used to config css formatter)
+│ ├── static (Webserver static, used to server static content, e.g. JS and CSS files)
+│ │ └── css
+│ └── templates (HTML Templates for every page written in templ and compiled to go)
+├── Cron (all Cron Scripts)
+├── DB (local Database mount Point)
+│ └── initdb (initialization scripts for DB)
+├── Docker (Docker Files, only docker-compose.yaml used)
+├── docs
+└── └── images
+```