Compare commits
27 Commits
db507259c7
...
0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| dafcd95428 | |||
| 23cb312644 | |||
| 4dbd1ced0d | |||
| 27bac5ff84 | |||
| 54104d5a0e | |||
| 0ddca8b9ce | |||
| d68a19790e | |||
| 478fd53d4f | |||
| db98eecd87 | |||
| 0bb12318cc | |||
| 5de50b6304 | |||
| a4e0bf82c9 | |||
| fdd6416ad9 | |||
| 64468271d1 | |||
| f73cf0884c | |||
| 6a264a20c0 | |||
| 5274a165a3 | |||
| 9987cc226d | |||
| 04f9eb33d4 | |||
| 4a0d3a850a | |||
| 5f886a46c5 | |||
| 01a24506ad | |||
| 3be2a47c56 | |||
| f6e77bda66 | |||
| 5fb6254c04 | |||
| f2a5e9874d | |||
| 32a4f5277a |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -31,3 +31,8 @@ DB/pg_data
|
|||||||
.env.*
|
.env.*
|
||||||
.env
|
.env
|
||||||
!.env.example
|
!.env.example
|
||||||
|
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
|||||||
19
.vscode/launch.json
vendored
19
.vscode/launch.json
vendored
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Backend",
|
|
||||||
"type": "go",
|
|
||||||
"request": "launch",
|
|
||||||
"mode": "auto",
|
|
||||||
"program": "${workspaceFolder}/Backend",
|
|
||||||
"dlvFlags": ["--check-go-version=false"],
|
|
||||||
"env": {
|
|
||||||
"DEBUG": "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"sqltools.connections": [
|
|
||||||
{
|
|
||||||
"previewLimit": 50,
|
|
||||||
"server": "localhost",
|
|
||||||
"port": 5432,
|
|
||||||
"askForPassword": true,
|
|
||||||
"driver": "PostgreSQL",
|
|
||||||
"name": "arbeitszeiten",
|
|
||||||
"database": "arbeitszeitmessung",
|
|
||||||
"username": "arbeit_zeit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"makefile.configureOnOpen": false
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
FROM golang:alpine
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
ENV CGO_ENABLED=0 \
|
||||||
|
GOOS=$TARGETOS \
|
||||||
|
GOARCH=$TARGETARCH
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY go.mod go.sum /app/
|
COPY go.mod go.sum /app/
|
||||||
|
|
||||||
RUN go mod download && go mod verify
|
RUN go mod download && go mod verify
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go build -o /usr/local/bin/app
|
RUN go build -o server .
|
||||||
|
|
||||||
CMD ["app"]
|
FROM alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/server /app/server
|
||||||
|
|
||||||
|
COPY /static /app/static
|
||||||
|
ENTRYPOINT ["./server"]
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import (
|
|||||||
func OpenDatabase() (*sql.DB, error) {
|
func OpenDatabase() (*sql.DB, error) {
|
||||||
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
||||||
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
||||||
dbUser := helper.GetEnv("POSTGRES_USER", "arbeit_zeit")
|
dbUser := helper.GetEnv("POSTGRES_API_USER", "arbeit_zeit")
|
||||||
dbPassword := helper.GetEnv("POSTGRES_PASS", "password")
|
dbPassword := helper.GetEnv("POSTGRES_API_PASS", "password")
|
||||||
|
|
||||||
connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable", dbUser, dbPassword, dbHost, dbName)
|
connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable&TimeZone=Europe/Berlin", dbUser, dbPassword, dbHost, dbName)
|
||||||
return sql.Open("postgres", connStr)
|
return sql.Open("postgres", connStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
117
Backend/endpoints/team.go
Normal file
117
Backend/endpoints/team.go
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package endpoints
|
||||||
|
|
||||||
|
import (
|
||||||
|
"arbeitszeitmessung/helper"
|
||||||
|
"arbeitszeitmessung/models"
|
||||||
|
"arbeitszeitmessung/templates"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TeamHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
helper.RequiresLogin(Session, w, r)
|
||||||
|
switch r.Method {
|
||||||
|
case http.MethodPost:
|
||||||
|
submitReport(w, r)
|
||||||
|
break
|
||||||
|
case http.MethodGet:
|
||||||
|
showWeeks(w, r)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// user, err := (*models.User).GetUserFromSession(nil, Session, r.Context())
|
||||||
|
// if err != nil {
|
||||||
|
// log.Println("No user found with the given personal number!")
|
||||||
|
// http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// var userWorkDays []models.WorkDay
|
||||||
|
// userWorkDays = (*models.WorkDay).GetWorkDays(nil, user.CardUID, time.Date(2025, time.February, 24, 0, 0, 0, 0, time.Local), time.Date(2025, time.February, 24+7, 0, 0, 0, 0, time.Local))
|
||||||
|
// log.Println("User:", user)
|
||||||
|
// teamMembers, err := user.GetTeamMembers()
|
||||||
|
// getWeeksTillNow(time.Now().AddDate(0, 0, -14))
|
||||||
|
// templates.TeamPage(teamMembers, userWorkDays).Render(r.Context(), w)
|
||||||
|
}
|
||||||
|
|
||||||
|
func submitReport(w http.ResponseWriter, r *http.Request) {
|
||||||
|
err := r.ParseForm()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing form", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userPN, _ := strconv.Atoi(r.FormValue("user"))
|
||||||
|
_weekTs := r.FormValue("week")
|
||||||
|
weekTs, err := time.Parse(time.DateOnly, _weekTs)
|
||||||
|
user, err := (*models.User).GetByPersonalNummer(nil, userPN)
|
||||||
|
workWeek := (*models.WorkWeek).GetWeek(nil, user, weekTs, false)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Could not get user!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch r.FormValue("method") {
|
||||||
|
case "send":
|
||||||
|
err = workWeek.Send()
|
||||||
|
break
|
||||||
|
case "accept":
|
||||||
|
err = workWeek.Accept()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if errors.Is(err, models.ErrRunningWeek) {
|
||||||
|
showWeeks(w, r.WithContext(context.WithValue(r.Context(), "error", true)))
|
||||||
|
}
|
||||||
|
showWeeks(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
func showWeeks(w http.ResponseWriter, r *http.Request) {
|
||||||
|
user, err := (*models.User).GetUserFromSession(nil, Session, r.Context())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No user found with the given personal number!")
|
||||||
|
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var workWeeks []models.WorkWeek
|
||||||
|
teamMembers, err := user.GetTeamMembers()
|
||||||
|
for _, member := range teamMembers {
|
||||||
|
weeks := (*models.WorkWeek).GetSendWeeks(nil, member)
|
||||||
|
workWeeks = append(workWeeks, weeks...)
|
||||||
|
}
|
||||||
|
lastSub := user.GetLastSubmission()
|
||||||
|
log.Println(lastSub)
|
||||||
|
userWeek := (*models.WorkWeek).GetWeek(nil, user, lastSub, true)
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getWeeksTillNow(lastWeek time.Time) []time.Time {
|
||||||
|
var weeks []time.Time
|
||||||
|
if lastWeek.After(time.Now()) {
|
||||||
|
log.Println("Timestamp is after today, no weeks till now!")
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
if lastWeek.Weekday() != time.Monday {
|
||||||
|
if lastWeek.Weekday() == time.Sunday {
|
||||||
|
lastWeek = lastWeek.AddDate(0, 0, -6)
|
||||||
|
} else {
|
||||||
|
lastWeek = lastWeek.AddDate(0, 0, -int(lastWeek.Weekday()-1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if time.Since(lastWeek) < 24*5*time.Hour {
|
||||||
|
log.Println("Timestamp in running week, cannot split!")
|
||||||
|
}
|
||||||
|
|
||||||
|
for t := lastWeek; t.Before(time.Now()); t = t.Add(7 * 24 * time.Hour) {
|
||||||
|
weeks = append(weeks, t)
|
||||||
|
}
|
||||||
|
log.Println(weeks)
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
@@ -14,58 +14,55 @@ import (
|
|||||||
|
|
||||||
// Frontend relevant backend functionality -> not used by the arduino devices
|
// Frontend relevant backend functionality -> not used by the arduino devices
|
||||||
func TimeHandler(w http.ResponseWriter, r *http.Request) {
|
func TimeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
helper.RequiresLogin(Session, w, r)
|
||||||
helper.SetCors(w)
|
helper.SetCors(w)
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case http.MethodGet:
|
||||||
getBookings(w, r)
|
getBookings(w, r)
|
||||||
case "POST":
|
break
|
||||||
|
case http.MethodPost:
|
||||||
updateBooking(w, r)
|
updateBooking(w, r)
|
||||||
case "OPTIONS":
|
break
|
||||||
|
case http.MethodOptions:
|
||||||
// just support options header for non GET Requests from SWAGGER
|
// just support options header for non GET Requests from SWAGGER
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTimestamp(r *http.Request, get_key string, fallback string) (time.Time, error) {
|
func parseTimestamp(r *http.Request, get_key string, fallback string) (time.Time, error) {
|
||||||
_timestamp_get := r.URL.Query().Get(get_key)
|
_timestamp_get := r.URL.Query().Get(get_key)
|
||||||
if(_timestamp_get == "") {
|
if _timestamp_get == "" {
|
||||||
_timestamp_get = fallback
|
_timestamp_get = fallback
|
||||||
}
|
}
|
||||||
timestamp_get, err := time.Parse("2006-01-02", _timestamp_get)
|
timestamp_get, err := time.Parse("2006-01-02", _timestamp_get)
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
return time.Now(), err
|
return time.Now(), err
|
||||||
}
|
}
|
||||||
return timestamp_get, nil
|
return timestamp_get, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns bookings from DB with similar card uid -> checks for card uid in http query params
|
// Returns bookings from DB with similar card uid -> checks for card uid in http query params
|
||||||
func getBookings(w http.ResponseWriter, r *http.Request) {
|
func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||||
// if(!Session.Exists(r.Context(), "user")){
|
user, err := (*models.User).GetUserFromSession(nil, Session, r.Context())
|
||||||
// log.Println("No user in session storage!")
|
if err != nil {
|
||||||
// http.Error(w, "Not logged in!", http.StatusForbidden)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// user, err := (*models.User).GetByPersonalNummer(nil, Session.GetInt(r.Context(), "user"))
|
|
||||||
user, err := (*models.User).GetByPersonalNummer(nil, 123)
|
|
||||||
if(err != nil){
|
|
||||||
log.Println("No user found with the given personal number!")
|
log.Println("No user found with the given personal number!")
|
||||||
http.Error(w, "No user found", http.StatusNotFound)
|
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add config for timeoffset
|
||||||
tsFrom, err := parseTimestamp(r, "time_from", "2000-01-01")
|
tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format("2006-01-02"))
|
||||||
if(err != nil ){
|
if err != nil {
|
||||||
log.Println("Error parsing 'from' time", err)
|
log.Println("Error parsing 'from' time", err)
|
||||||
http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest)
|
http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02"))
|
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02"))
|
||||||
if(err != nil ){
|
if err != nil {
|
||||||
log.Println("Error parsing 'to' time", err)
|
log.Println("Error parsing 'to' time", err)
|
||||||
http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest)
|
http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
@@ -78,37 +75,83 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.Header.Get("Accept") == "application/json" {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
json.NewEncoder(w).Encode(bookings)
|
||||||
|
return
|
||||||
|
}
|
||||||
ctx := context.WithValue(r.Context(), "user", user)
|
ctx := context.WithValue(r.Context(), "user", user)
|
||||||
templates.TimeDashboard(bookings).Render(ctx, w)
|
templates.TimePage(bookings).Render(ctx, w)
|
||||||
// w.Header().Set("Content-Type", "application/json")
|
|
||||||
// json.NewEncoder(w).Encode(bookings)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateBooking(w http.ResponseWriter, r *http.Request) {
|
func updateBooking(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
for index, possibleBooking := range r.PostForm {
|
for index, possibleBooking := range r.PostForm {
|
||||||
if(index[:7] == "booking"){
|
if index[:7] == "booking" {
|
||||||
booking_id, err := strconv.Atoi(index[8:])
|
booking_id, err := strconv.Atoi(index[8:])
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("Error parsing bookingId", err)
|
log.Println("Error parsing bookingId", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
booking, err := (*models.Booking).GetBookingById(nil, booking_id)
|
booking, err := (*models.Booking).GetBookingById(nil, booking_id)
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("Error getting booking!", err)
|
log.Println("Error getting booking!", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
parsedTime, err := time.Parse("15:04", possibleBooking[0])
|
parsedTime, err := time.ParseInLocation("15:04", possibleBooking[0], time.Local)
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("Error parsing time!", err)
|
log.Println("Error parsing time!", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Println("Parsing time", parsedTime)
|
||||||
booking.UpdateTime(parsedTime)
|
booking.UpdateTime(parsedTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getBookings(w, r)
|
getBookings(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getBookingsAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
|
_user_pn := r.URL.Query().Get("personal_nummer")
|
||||||
|
user_pn, err := strconv.Atoi(_user_pn)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No personal numver found!")
|
||||||
|
http.Error(w, "No personal number found", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := (*models.User).GetByPersonalNummer(nil, user_pn)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No user found with the given personal number!")
|
||||||
|
http.Error(w, "No user found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO add config for timeoffset
|
||||||
|
tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format("2006-01-02"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing 'from' time", err)
|
||||||
|
http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing 'to' time", err)
|
||||||
|
http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
||||||
|
|
||||||
|
bookings, err := (*models.Booking).GetBookingsGrouped(nil, user.CardUID, tsFrom, tsTo)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting bookings: ", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(bookings)
|
||||||
|
}
|
||||||
|
|
||||||
// Updates a booking form the given json body
|
// Updates a booking form the given json body
|
||||||
func updateBookingAPI(w http.ResponseWriter, r *http.Request) {
|
func updateBookingAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
_booking_id := r.URL.Query().Get("counter_id")
|
_booking_id := r.URL.Query().Get("counter_id")
|
||||||
|
|||||||
@@ -13,25 +13,31 @@ import (
|
|||||||
// GET only for demo purpose
|
// GET only for demo purpose
|
||||||
func TimeCreateHandler(w http.ResponseWriter, r *http.Request) {
|
func TimeCreateHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
helper.SetCors(w)
|
helper.SetCors(w)
|
||||||
// switch with request methods
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "PUT":
|
case http.MethodPut:
|
||||||
createBooking(w, r)
|
createBooking(w, r)
|
||||||
case "GET":
|
break
|
||||||
|
case http.MethodGet:
|
||||||
createBooking(w, r)
|
createBooking(w, r)
|
||||||
case "OPTIONS":
|
break
|
||||||
|
case http.MethodOptions:
|
||||||
// just support options header for non GET Requests from SWAGGER
|
// just support options header for non GET Requests from SWAGGER
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Creates a booking from the http query params -> no body needed
|
// Creates a booking from the http query params -> no body needed
|
||||||
// after that entry wi'll be written to database and the booking is returned as json
|
// after that entry wi'll be written to database and the booking is returned as json
|
||||||
func createBooking(w http.ResponseWriter, r *http.Request) {
|
func createBooking(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if !checkPassword(r) {
|
||||||
|
log.Println("Wrong or no API key provided!")
|
||||||
|
http.Error(w, "Wrong or no API key provided", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
booking := (*models.Booking).FromUrlParams(nil, r.URL.Query())
|
booking := (*models.Booking).FromUrlParams(nil, r.URL.Query())
|
||||||
if booking.Verify() {
|
if booking.Verify() {
|
||||||
@@ -51,3 +57,18 @@ func createBooking(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkPassword(r *http.Request) bool {
|
||||||
|
authToken := helper.GetEnv("API_TOKEN", "dont_access")
|
||||||
|
authHeaders := r.Header.Get("Authorization")
|
||||||
|
_authStart := len("Bearer ")
|
||||||
|
if len(authHeaders) <= _authStart {
|
||||||
|
authHeaders = r.URL.Query().Get("api_key")
|
||||||
|
_authStart = 0
|
||||||
|
if len(authHeaders) <= _authStart {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Println(authHeaders)
|
||||||
|
return authToken == authHeaders[_authStart:]
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"arbeitszeitmessung/helper"
|
||||||
"arbeitszeitmessung/models"
|
"arbeitszeitmessung/models"
|
||||||
"arbeitszeitmessung/templates"
|
"arbeitszeitmessung/templates"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alexedwards/scs/v2"
|
"github.com/alexedwards/scs/v2"
|
||||||
@@ -20,18 +22,35 @@ func CreateSessionManager(lifetime time.Duration) *scs.SessionManager {
|
|||||||
|
|
||||||
func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet: showForm(w, r)
|
case http.MethodGet:
|
||||||
|
showLoginPage(w, r, false)
|
||||||
break
|
break
|
||||||
case http.MethodPost: loginUser(w, r)
|
case http.MethodPost:
|
||||||
|
loginUser(w, r)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
showForm(w, r)
|
http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func showForm(w http.ResponseWriter, r *http.Request){
|
func UserHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
templates.LoginForm().Render(r.Context(), w)
|
helper.RequiresLogin(Session, w, r)
|
||||||
|
switch r.Method {
|
||||||
|
case http.MethodGet:
|
||||||
|
showUserPage(w, r, 0)
|
||||||
|
break
|
||||||
|
case http.MethodPost:
|
||||||
|
changePassword(w, r)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func showLoginPage(w http.ResponseWriter, r *http.Request, failed bool) {
|
||||||
|
templates.LoginPage(failed).Render(r.Context(), w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loginUser(w http.ResponseWriter, r *http.Request) {
|
func loginUser(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -39,24 +58,71 @@ func loginUser(w http.ResponseWriter, r *http.Request){
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error parsing form!", err)
|
log.Println("Error parsing form!", err)
|
||||||
http.Error(w, "Internal error", http.StatusBadRequest)
|
http.Error(w, "Internal error", http.StatusBadRequest)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
card_uid := r.FormValue("card_uid")
|
_personal_nummer := r.FormValue("personal_nummer")
|
||||||
if(card_uid == ""){
|
if _personal_nummer == "" {
|
||||||
log.Println("No card_uid provided!")
|
log.Println("No personal_nummer provided!")
|
||||||
http.Error(w, "No card_uid provided", http.StatusBadRequest)
|
http.Error(w, "No personal_nummer provided", http.StatusBadRequest)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
user, err := (*models.User).GetByCardUID(nil, card_uid)
|
personal_nummer, err := strconv.Atoi(_personal_nummer)
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("No user found under this card_uid!")
|
log.Println("Cannot parse personal nubmer!")
|
||||||
|
http.Error(w, "Cannot parse number", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := (*models.User).GetByPersonalNummer(nil, personal_nummer)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No user found under this personal number!")
|
||||||
http.Error(w, "No user found!", http.StatusNotFound)
|
http.Error(w, "No user found!", http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
password := r.FormValue("password")
|
password := r.FormValue("password")
|
||||||
if(user.Login(password)){
|
if user.Login(password) {
|
||||||
log.Printf("New succesfull user login from %s %s!\n", user.Vorname, user.Name)
|
log.Printf("New succesfull user login from %s %s!\n", user.Vorname, user.Name)
|
||||||
Session.Put(r.Context(), "user", user.PersonalNummer)
|
Session.Put(r.Context(), "user", user.PersonalNummer)
|
||||||
http.Redirect(w, r, "/time", http.StatusSeeOther) //with this browser always uses GET
|
http.Redirect(w, r, "/time", http.StatusSeeOther) //with this browser always uses GET
|
||||||
|
} else {
|
||||||
|
showLoginPage(w, r, true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
showLoginPage(w, r, false)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showForm(w, r)
|
// change user password and store salted hash in db
|
||||||
|
func changePassword(w http.ResponseWriter, r *http.Request) {
|
||||||
|
err := r.ParseForm()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing form!", err)
|
||||||
|
http.Error(w, "Error parsing form error", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
password := r.FormValue("password")
|
||||||
|
newPassword := r.FormValue("new_password")
|
||||||
|
if password == "" || newPassword == "" || newPassword != r.FormValue("new_password_repeat") {
|
||||||
|
showUserPage(w, r, http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user, err := (*models.User).GetByPersonalNummer(nil, Session.GetInt(r.Context(), "user"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting user!", err)
|
||||||
|
showUserPage(w, r, http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
auth, err := user.ChangePass(password, newPassword)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error when changing password!", err)
|
||||||
|
}
|
||||||
|
if auth {
|
||||||
|
showUserPage(w, r, http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
showUserPage(w, r, http.StatusUnauthorized)
|
||||||
|
}
|
||||||
|
|
||||||
|
func showUserPage(w http.ResponseWriter, r *http.Request, status int) {
|
||||||
|
templates.UserPage(status).Render(r.Context(), w)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ require github.com/lib/pq v1.10.9
|
|||||||
|
|
||||||
require github.com/a-h/templ v0.3.833
|
require github.com/a-h/templ v0.3.833
|
||||||
|
|
||||||
require github.com/alexedwards/scs/v2 v2.8.0 // indirect
|
require github.com/alexedwards/scs/v2 v2.8.0
|
||||||
|
|
||||||
|
require github.com/joho/godotenv v1.5.1
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ github.com/alexedwards/scs/v2 v2.8.0 h1:h31yUYoycPuL0zt14c0gd+oqxfRwIj6SOjHdKRZx
|
|||||||
github.com/alexedwards/scs/v2 v2.8.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
|
github.com/alexedwards/scs/v2 v2.8.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
|||||||
@@ -3,15 +3,28 @@ package helper
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/alexedwards/scs/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// setting cors, important for later frontend use
|
// setting cors, important for later frontend use
|
||||||
//
|
//
|
||||||
// in DEBUG == "true" everything is set to "*" so that no cors errors will be happen
|
// in DEBUG == "true" everything is set to "*" so that no cors errors will be happen
|
||||||
func SetCors(w http.ResponseWriter) {
|
func SetCors(w http.ResponseWriter) {
|
||||||
if os.Getenv("DEBUG") == "true" {
|
if os.Getenv("NO_CORS") == "true" {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Methods", "*")
|
w.Header().Set("Access-Control-Allow-Methods", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "*")
|
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||||
|
// log.Println("Setting cors to *")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RequiresLogin(session *scs.SessionManager, w http.ResponseWriter, r *http.Request) {
|
||||||
|
if GetEnv("GO_ENV", "production") == "debug" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if session.Exists(r.Context(), "user") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,19 +4,26 @@ import (
|
|||||||
"arbeitszeitmessung/endpoints"
|
"arbeitszeitmessung/endpoints"
|
||||||
"arbeitszeitmessung/helper"
|
"arbeitszeitmessung/helper"
|
||||||
"arbeitszeitmessung/models"
|
"arbeitszeitmessung/models"
|
||||||
|
"arbeitszeitmessung/templates"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/a-h/templ"
|
||||||
|
"github.com/joho/godotenv"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
err = godotenv.Load(".env")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No .env file found in directory!")
|
||||||
|
}
|
||||||
|
|
||||||
models.DB, err = OpenDatabase()
|
models.DB, err = OpenDatabase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -29,11 +36,13 @@ func main() {
|
|||||||
server := http.NewServeMux()
|
server := http.NewServeMux()
|
||||||
|
|
||||||
// handles the different http routes
|
// handles the different http routes
|
||||||
withMiddleware := ParamsMiddleware(endpoints.TimeHandler)
|
|
||||||
server.HandleFunc("/time/new", endpoints.TimeCreateHandler)
|
server.HandleFunc("/time/new", endpoints.TimeCreateHandler)
|
||||||
server.Handle("/time", withMiddleware)
|
server.Handle("/time", ParamsMiddleware(endpoints.TimeHandler))
|
||||||
server.HandleFunc("/logout", endpoints.LogoutHandler)
|
server.HandleFunc("/logout", endpoints.LogoutHandler)
|
||||||
server.HandleFunc("/", endpoints.LoginHandler)
|
server.HandleFunc("/user/login", endpoints.LoginHandler)
|
||||||
|
server.HandleFunc("/user", endpoints.UserHandler)
|
||||||
|
server.HandleFunc("/team", endpoints.TeamHandler)
|
||||||
|
server.Handle("/", templ.Handler(templates.NavPage()))
|
||||||
server.Handle("/static/", http.StripPrefix("/static/", fs))
|
server.Handle("/static/", http.StripPrefix("/static/", fs))
|
||||||
|
|
||||||
serverSessionMiddleware := endpoints.Session.LoadAndSave(server)
|
serverSessionMiddleware := endpoints.Session.LoadAndSave(server)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (b *Booking) GetBookingsByCardID(card_uid string, tsFrom time.Time, tsTo ti
|
|||||||
func (b *Booking) GetBookingsGrouped(card_uid string, tsFrom time.Time, tsTo time.Time) ([]WorkDay, error) {
|
func (b *Booking) GetBookingsGrouped(card_uid string, tsFrom time.Time, tsTo time.Time) ([]WorkDay, error) {
|
||||||
var grouped = make(map[string][]Booking)
|
var grouped = make(map[string][]Booking)
|
||||||
bookings, err := b.GetBookingsByCardID(card_uid, tsFrom, tsTo)
|
bookings, err := b.GetBookingsByCardID(card_uid, tsFrom, tsTo)
|
||||||
if (err != nil){
|
if err != nil {
|
||||||
log.Println("Failed to get bookings", err)
|
log.Println("Failed to get bookings", err)
|
||||||
return []WorkDay{}, nil
|
return []WorkDay{}, nil
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,9 @@ func (b *Booking) GetBookingsGrouped(card_uid string, tsFrom time.Time, tsTo tim
|
|||||||
sort.Slice(bookings, func(i, j int) bool {
|
sort.Slice(bookings, func(i, j int) bool {
|
||||||
return bookings[i].Timestamp.Before(bookings[j].Timestamp)
|
return bookings[i].Timestamp.Before(bookings[j].Timestamp)
|
||||||
})
|
})
|
||||||
result = append(result, WorkDay{Day: day, Bookings: bookings})
|
workDay := WorkDay{Day: day, Bookings: bookings}
|
||||||
|
workDay.GetWorkTime()
|
||||||
|
result = append(result, workDay)
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(result, func(i, j int) bool {
|
sort.Slice(result, func(i, j int) bool {
|
||||||
@@ -181,7 +183,7 @@ func (b *Booking) Update(nb Booking) {
|
|||||||
if b.GeraetID != nb.GeraetID && nb.GeraetID != 0 {
|
if b.GeraetID != nb.GeraetID && nb.GeraetID != 0 {
|
||||||
b.GeraetID = nb.GeraetID
|
b.GeraetID = nb.GeraetID
|
||||||
}
|
}
|
||||||
if(b.Timestamp != nb.Timestamp){
|
if b.Timestamp != nb.Timestamp {
|
||||||
b.Timestamp = nb.Timestamp
|
b.Timestamp = nb.Timestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +203,7 @@ func checkLastBooking(b Booking) bool {
|
|||||||
log.Println("Error checking last booking: ", err)
|
log.Println("Error checking last booking: ", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if int16(check_in_out) == b.CheckInOut {
|
if int16(check_in_out)%2 == b.CheckInOut%2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -209,17 +211,17 @@ func checkLastBooking(b Booking) bool {
|
|||||||
|
|
||||||
func (b *Booking) UpdateTime(newTime time.Time) {
|
func (b *Booking) UpdateTime(newTime time.Time) {
|
||||||
hour, minute, _ := newTime.Clock()
|
hour, minute, _ := newTime.Clock()
|
||||||
if(hour == b.Timestamp.Local().Hour() && minute == b.Timestamp.Local().Minute()){
|
if hour == b.Timestamp.Hour() && minute == b.Timestamp.Minute() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO: add check for time overlap
|
// TODO: add check for time overlap
|
||||||
|
|
||||||
var newBooking Booking
|
var newBooking Booking
|
||||||
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local).UTC()
|
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local)
|
||||||
if(b.CheckInOut < 3){
|
if b.CheckInOut < 3 {
|
||||||
newBooking.CheckInOut = b.CheckInOut + 2
|
newBooking.CheckInOut = b.CheckInOut + 2
|
||||||
}
|
}
|
||||||
if(b.CheckInOut == 255){
|
if b.CheckInOut == 255 {
|
||||||
newBooking.CheckInOut = 4
|
newBooking.CheckInOut = 4
|
||||||
}
|
}
|
||||||
b.Update(newBooking)
|
b.Update(newBooking)
|
||||||
|
|||||||
@@ -1,20 +1,46 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"arbeitszeitmessung/helper"
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/alexedwards/scs/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
CardUID string `json:"card_uid"`
|
CardUID string `json:"card_uid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Vorname string `json:"vorname"`
|
Vorname string `json:"vorname"`
|
||||||
HauptbeschaeftigungsOrt int8 `json:"hauptbeschaeftigungsort"`
|
|
||||||
PersonalNummer int `json:"personal_nummer"`
|
PersonalNummer int `json:"personal_nummer"`
|
||||||
|
Arbeitszeit float32 `json:"arbeitszeit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetUserFromSession(Session *scs.SessionManager, ctx context.Context) (User, error) {
|
||||||
|
var user User
|
||||||
|
var err error
|
||||||
|
if helper.GetEnv("GO_ENV", "production") == "debug" {
|
||||||
|
user, err = (*User).GetByPersonalNummer(nil, 123)
|
||||||
|
} else {
|
||||||
|
if !Session.Exists(ctx, "user") {
|
||||||
|
log.Println("No user in session storage!")
|
||||||
|
return user, errors.New("No user in session storage!")
|
||||||
|
}
|
||||||
|
user, err = (*User).GetByPersonalNummer(nil, Session.GetInt(ctx, "user"))
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Cannot get user from session!")
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetAll() ([]User, error) {
|
func (u *User) GetAll() ([]User, error) {
|
||||||
qStr, err := DB.Prepare((`SELECT card_uid, vorname, nachname, hauptbeschaeftigung_ort FROM personal_daten;`))
|
qStr, err := DB.Prepare((`SELECT card_uid, vorname, nachname FROM personal_daten;`))
|
||||||
var users []User
|
var users []User
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error preparing query statement %v\n", err)
|
fmt.Printf("Error preparing query statement %v\n", err)
|
||||||
@@ -28,7 +54,7 @@ func (u *User) GetAll() ([]User, error) {
|
|||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var user User
|
var user User
|
||||||
if err := rows.Scan(&user.CardUID, &user.Vorname, &user.Name, &user.HauptbeschaeftigungsOrt); err != nil {
|
if err := rows.Scan(&user.CardUID, &user.Vorname, &user.Name); err != nil {
|
||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
users = append(users, user)
|
users = append(users, user)
|
||||||
@@ -67,27 +93,15 @@ func (u *User) Logout() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetByCardUID(card_uid string) (User, error) {
|
|
||||||
var user User
|
|
||||||
qStr, err := DB.Prepare((`SELECT personal_nummer, card_uid, vorname, nachname, hauptbeschaeftigung_ort FROM personal_daten WHERE card_uid = $1;`))
|
|
||||||
if err != nil {
|
|
||||||
return user, err
|
|
||||||
}
|
|
||||||
err = qStr.QueryRow(card_uid).Scan(&user.PersonalNummer, &user.CardUID, &user.Vorname, &user.Name, &user.HauptbeschaeftigungsOrt)
|
|
||||||
if err != nil{
|
|
||||||
return user, err
|
|
||||||
}
|
|
||||||
return user, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *User) GetByPersonalNummer(personalNummer int) (User, error) {
|
func (u *User) GetByPersonalNummer(personalNummer int) (User, error) {
|
||||||
var user User
|
var user User
|
||||||
|
|
||||||
qStr, err := DB.Prepare((`SELECT personal_nummer, card_uid, vorname, nachname, hauptbeschaeftigung_ort FROM personal_daten WHERE personal_nummer = $1;`))
|
qStr, err := DB.Prepare((`SELECT personal_nummer, card_uid, vorname, nachname, arbeitszeit_per_tag FROM personal_daten WHERE personal_nummer = $1;`))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
err = qStr.QueryRow(personalNummer).Scan(&user.PersonalNummer, &user.CardUID, &user.Vorname, &user.Name, &user.HauptbeschaeftigungsOrt)
|
err = qStr.QueryRow(personalNummer).Scan(&user.PersonalNummer, &user.CardUID, &user.Vorname, &user.Name, &user.Arbeitszeit)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
@@ -95,6 +109,123 @@ func (u *User) GetByPersonalNummer (personalNummer int) (User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) Login(password string) bool {
|
func (u *User) Login(password string) bool {
|
||||||
userPassword := strings.ToLower(fmt.Sprintf("%s_%s", u.Vorname, u.Name)) //temp password: "max_mustermann"
|
var loginSuccess bool
|
||||||
return userPassword == password
|
qStr, err := DB.Prepare((`SELECT (pass_hash = crypt($2, pass_hash)) AS pass_hash FROM user_password WHERE personal_nummer = $1;`))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing db statement", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer qStr.Close()
|
||||||
|
err = qStr.QueryRow(u.PersonalNummer, password).Scan(&loginSuccess)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error queriing db", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return loginSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks if old password matches and changes to new password
|
||||||
|
//
|
||||||
|
// returns auth(bool), error
|
||||||
|
func (u *User) ChangePass(password, newPassword string) (bool, error) {
|
||||||
|
if !u.Login(password) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
qStr, err := DB.Prepare((`UPDATE user_password SET pass_hash = crypt($2, gen_salt('bf')) WHERE personal_nummer = $1;`))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
_, err = qStr.Exec(u.PersonalNummer, newPassword)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetTeamMembers() ([]User, error) {
|
||||||
|
var teamMembers []User
|
||||||
|
qStr, err := DB.Prepare(`SELECT personal_nummer, card_uid, vorname, nachname, arbeitszeit_per_tag FROM personal_daten WHERE vorgesetzter_pers_nr = $1`)
|
||||||
|
if err != nil {
|
||||||
|
return teamMembers, err
|
||||||
|
}
|
||||||
|
defer qStr.Close()
|
||||||
|
rows, err := qStr.Query(u.PersonalNummer)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting rows!")
|
||||||
|
return teamMembers, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
user, err := parseUser(rows)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing user!")
|
||||||
|
return teamMembers, err
|
||||||
|
}
|
||||||
|
teamMembers = append(teamMembers, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
return teamMembers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetWeek(tsFrom time.Time) WorkWeek {
|
||||||
|
var bookings []WorkDay
|
||||||
|
weekStart := tsFrom.AddDate(0, 0, -1*int(tsFrom.Local().Weekday())-1)
|
||||||
|
bookings, err := (*Booking).GetBookingsGrouped(nil, u.CardUID, weekStart, time.Now())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error fetching bookings!")
|
||||||
|
return WorkWeek{WorkDays: bookings}
|
||||||
|
}
|
||||||
|
return WorkWeek{WorkDays: bookings}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gets the first week, that needs to be submitted
|
||||||
|
func (u *User) GetNextWeek() WorkWeek {
|
||||||
|
var week WorkWeek
|
||||||
|
return week
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseUser(rows *sql.Rows) (User, error) {
|
||||||
|
var user User
|
||||||
|
if err := rows.Scan(&user.PersonalNummer, &user.CardUID, &user.Vorname, &user.Name, &user.Arbeitszeit); 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 booking_report to team leader
|
||||||
|
func (u *User) GetLastSubmission() time.Time {
|
||||||
|
var lastSub time.Time
|
||||||
|
qStr, err := DB.Prepare(`
|
||||||
|
SELECT COALESCE(
|
||||||
|
(SELECT woche_start + INTERVAL '1 week' FROM wochen_report WHERE personal_nummer = $1 ORDER BY woche_start DESC LIMIT 1),
|
||||||
|
(SELECT timestamp FROM anwesenheit WHERE card_uid = $2 ORDER BY timestamp LIMIT 1)
|
||||||
|
) AS letzte_buchung;
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing statement!", err)
|
||||||
|
return lastSub
|
||||||
|
}
|
||||||
|
err = qStr.QueryRow(u.PersonalNummer, u.CardUID).Scan(&lastSub)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error executing query!", err)
|
||||||
|
return lastSub
|
||||||
|
}
|
||||||
|
log.Println("From DB: ", lastSub)
|
||||||
|
lastSub = getMonday(lastSub)
|
||||||
|
lastSub = lastSub.Round(24 * time.Hour)
|
||||||
|
log.Println("After truncate: ", lastSub)
|
||||||
|
return lastSub
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMonday(ts time.Time) time.Time {
|
||||||
|
if ts.Weekday() != time.Monday {
|
||||||
|
if ts.Weekday() == time.Sunday {
|
||||||
|
ts = ts.AddDate(0, 0, -6)
|
||||||
|
} else {
|
||||||
|
ts = ts.AddDate(0, 0, -int(ts.Weekday()-1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ts
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,166 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkDay struct {
|
type WorkDay struct {
|
||||||
Day time.Time
|
Day time.Time `json:"day"`
|
||||||
Bookings []Booking
|
Bookings []Booking `json:"bookings"`
|
||||||
workTime time.Duration
|
workTime time.Duration
|
||||||
|
pauseTime time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *WorkDay) GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay {
|
||||||
|
var workDays []WorkDay
|
||||||
|
var workSec, pauseSec float64
|
||||||
|
qStr, err := DB.Prepare(`
|
||||||
|
WITH ordered_bookings AS (
|
||||||
|
SELECT
|
||||||
|
timestamp::DATE AS work_date, -- Extract date for grouping
|
||||||
|
timestamp,
|
||||||
|
check_in_out,
|
||||||
|
LAG(timestamp) OVER (
|
||||||
|
PARTITION BY card_uid, timestamp::DATE -- Reset for each day
|
||||||
|
ORDER BY timestamp
|
||||||
|
) AS prev_timestamp,
|
||||||
|
LAG(check_in_out) OVER (
|
||||||
|
PARTITION BY card_uid, timestamp::DATE
|
||||||
|
ORDER BY timestamp
|
||||||
|
) AS prev_check
|
||||||
|
FROM anwesenheit
|
||||||
|
WHERE card_uid = $1 -- Replace with actual card_uid
|
||||||
|
AND timestamp::DATE >= $2 -- Set date range
|
||||||
|
AND timestamp::DATE <= $3
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
work_date,
|
||||||
|
|
||||||
|
-- Total work time per day
|
||||||
|
COALESCE(
|
||||||
|
EXTRACT(EPOCH FROM SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (1, 3) AND check_in_out IN (2, 4, 254)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
)), 0
|
||||||
|
) AS total_work,
|
||||||
|
|
||||||
|
-- Extract total pause time in seconds
|
||||||
|
COALESCE(
|
||||||
|
EXTRACT(EPOCH FROM SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (2, 4, 254) AND check_in_out IN (1, 3)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
)), 0
|
||||||
|
) AS total_pause
|
||||||
|
|
||||||
|
FROM ordered_bookings
|
||||||
|
GROUP BY work_date
|
||||||
|
ORDER BY work_date;`)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing SQL statement", err)
|
||||||
|
return workDays
|
||||||
|
}
|
||||||
|
|
||||||
|
defer qStr.Close()
|
||||||
|
rows, err := qStr.Query(card_uid, tsFrom, tsTo)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting rows!")
|
||||||
|
return workDays
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var workDay WorkDay
|
||||||
|
if err := rows.Scan(&workDay.Day, &workSec, &pauseSec); err != nil {
|
||||||
|
log.Println("Error scanning row!", err)
|
||||||
|
return workDays
|
||||||
|
}
|
||||||
|
workDay.workTime = time.Duration(workSec * float64(time.Second))
|
||||||
|
workDay.pauseTime = time.Duration(pauseSec * float64(time.Second))
|
||||||
|
workDay.calcPauseTime()
|
||||||
|
workDays = append(workDays, workDay)
|
||||||
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return workDays
|
||||||
|
}
|
||||||
|
return workDays
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *WorkDay) calcPauseTime() {
|
||||||
|
if d.workTime > 6*time.Hour && d.pauseTime < 45*time.Minute {
|
||||||
|
if d.workTime < 9*time.Hour && d.pauseTime < 30*time.Minute {
|
||||||
|
diff := 30*time.Minute - d.pauseTime
|
||||||
|
d.workTime -= diff
|
||||||
|
d.pauseTime += diff
|
||||||
|
} else if d.pauseTime < 45*time.Minute {
|
||||||
|
diff := 45*time.Minute - d.pauseTime
|
||||||
|
d.workTime -= diff
|
||||||
|
d.pauseTime += diff
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the duration someone worked that day
|
// Gets the duration someone worked that day
|
||||||
func (d WorkDay) GetWorkTime() time.Duration{
|
func (d *WorkDay) GetWorkTime() {
|
||||||
d.workTime = 0
|
var workTime, pauseTime time.Duration
|
||||||
for i := 0; i < len(d.Bookings) - (1 + len(d.Bookings)%2); i += 2{
|
var lastBooking Booking
|
||||||
start := d.Bookings[i].Timestamp
|
for _, booking := range d.Bookings {
|
||||||
end := d.Bookings[i+1].Timestamp
|
if booking.CheckInOut%2 == 1 {
|
||||||
d.workTime += end.Sub(start)
|
if !lastBooking.Timestamp.IsZero() {
|
||||||
|
pauseTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
workTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
||||||
|
}
|
||||||
|
lastBooking = booking
|
||||||
|
}
|
||||||
|
// checks if booking is today and has no gehen yet, so the time since last kommen booking is added to workTime
|
||||||
|
if d.Day.Day() == time.Now().Day() && len(d.Bookings)%2 == 1 {
|
||||||
|
workTime += time.Since(lastBooking.Timestamp.Local())
|
||||||
|
}
|
||||||
|
d.workTime = workTime
|
||||||
|
d.pauseTime = pauseTime
|
||||||
|
|
||||||
|
d.calcPauseTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if booking is today and has no gehen yet, so the time since last kommen booking is added to workTime
|
func formatDuration(d time.Duration) string {
|
||||||
if(d.Day.Equal(time.Now().Truncate(24 * time.Hour)) && len(d.Bookings) % 2 == 1){
|
hours := int(d.Abs().Hours())
|
||||||
d.workTime += time.Since(d.Bookings[len(d.Bookings)-1].Timestamp)
|
minutes := int(d.Abs().Minutes()) % 60
|
||||||
|
switch {
|
||||||
|
case hours > 0:
|
||||||
|
return fmt.Sprintf("%dh %dmin", hours, minutes)
|
||||||
|
case minutes > 0:
|
||||||
|
return fmt.Sprintf("%dmin", minutes)
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
return d.workTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts duration to string and replaces 0s with in
|
// Converts duration to string and replaces 0s with in
|
||||||
//
|
//
|
||||||
// -> output xhxmin
|
// -> output xhxmin
|
||||||
func (d WorkDay) GetWorkTimeString() string {
|
func (d *WorkDay) GetWorkTimeString() (string, string) {
|
||||||
str := d.GetWorkTime().Abs().Round(time.Minute).String()
|
workString := formatDuration(d.workTime)
|
||||||
str = str[:len(str)-2] + "in"
|
pauseString := formatDuration(d.pauseTime)
|
||||||
if(len(str) > 2){
|
return workString, pauseString
|
||||||
return str
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns bool wheter the workday was ended with an automatic logout
|
// returns bool wheter the workday was ended with an automatic logout
|
||||||
func (d WorkDay) RequiresAction() bool {
|
func (d *WorkDay) RequiresAction() bool {
|
||||||
return d.Bookings[len(d.Bookings)-1].CheckInOut == 255
|
return d.Bookings[len(d.Bookings)-1].CheckInOut == 255
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a integer percentage of how much day has been worked of
|
// returns a integer percentage of how much day has been worked of
|
||||||
func (d WorkDay) GetWorkDayProgress() uint8 {
|
func (d *WorkDay) GetWorkDayProgress(user User) uint8 {
|
||||||
defaultWorkTime, _ := time.ParseDuration("7h42m")
|
defaultWorkTime := time.Duration(user.Arbeitszeit * float32(time.Hour))
|
||||||
progress := (d.GetWorkTime().Seconds()/defaultWorkTime.Seconds())*100
|
progress := (d.workTime.Seconds() / defaultWorkTime.Seconds()) * 100
|
||||||
return uint8(progress)
|
return uint8(progress)
|
||||||
}
|
}
|
||||||
|
|||||||
107
Backend/models/workWeek.go
Normal file
107
Backend/models/workWeek.go
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WorkWeek struct {
|
||||||
|
Id int
|
||||||
|
WorkDays []WorkDay
|
||||||
|
User User
|
||||||
|
WeekStart time.Time
|
||||||
|
WorkHours time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkWeek) GetWeek(user User, tsMonday time.Time, populateDays bool) WorkWeek {
|
||||||
|
var week WorkWeek
|
||||||
|
if populateDays {
|
||||||
|
week.WorkDays = (*WorkDay).GetWorkDays(nil, user.CardUID, tsMonday, tsMonday.Add(7*24*time.Hour))
|
||||||
|
week.WorkHours = aggregateWorkTime(week.WorkDays)
|
||||||
|
}
|
||||||
|
week.User = user
|
||||||
|
week.WeekStart = tsMonday
|
||||||
|
return week
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkWeek) GetWorkHourString() string {
|
||||||
|
return formatDuration(w.WorkHours)
|
||||||
|
}
|
||||||
|
|
||||||
|
func aggregateWorkTime(days []WorkDay) time.Duration {
|
||||||
|
var workTime time.Duration
|
||||||
|
for _, day := range days {
|
||||||
|
workTime += day.workTime
|
||||||
|
}
|
||||||
|
return workTime
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkWeek) GetSendWeeks(user User) []WorkWeek {
|
||||||
|
var weeks []WorkWeek
|
||||||
|
qStr, err := DB.Prepare(`SELECT id, woche_start::DATE FROM wochen_report WHERE bestaetigt = FALSE AND personal_nummer = $1;`)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing SQL statement", err)
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
defer qStr.Close()
|
||||||
|
|
||||||
|
rows, err := qStr.Query(user.PersonalNummer)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error querining db!", err)
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var week WorkWeek
|
||||||
|
week.User = user
|
||||||
|
if err := rows.Scan(&week.Id, &week.WeekStart); err != nil {
|
||||||
|
log.Println("Error scanning row!", err)
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
week.WorkDays = (*WorkDay).GetWorkDays(nil, user.CardUID, week.WeekStart, week.WeekStart.Add(7*24*time.Hour))
|
||||||
|
week.WorkHours = aggregateWorkTime(week.WorkDays)
|
||||||
|
weeks = append(weeks, week)
|
||||||
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
|
||||||
|
return weeks
|
||||||
|
}
|
||||||
|
|
||||||
|
var ErrRunningWeek = errors.New("Week is in running week")
|
||||||
|
|
||||||
|
// creates a new entry in the woche_report table with the given workweek
|
||||||
|
func (w *WorkWeek) Send() error {
|
||||||
|
if time.Since(w.WeekStart) < 5*24*time.Hour {
|
||||||
|
log.Println("Cannot send week, because it's the running week!")
|
||||||
|
return ErrRunningWeek
|
||||||
|
}
|
||||||
|
qStr, err := DB.Prepare(`INSERT INTO wochen_report (personal_nummer, woche_start) VALUES ($1, $2);`)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing SQL statement", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = qStr.Exec(w.User.PersonalNummer, w.WeekStart)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error executing query!", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkWeek) Accept() error {
|
||||||
|
qStr, err := DB.Prepare(`UPDATE "wochen_report" SET bestaetigt = TRUE WHERE personal_nummer = $1 AND woche_start = $2;`)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error preparing SQL statement", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = qStr.Exec(w.User.PersonalNummer, w.WeekStart)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error executing query!", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -26,3 +26,38 @@
|
|||||||
--color-text-900: #161816;
|
--color-text-900: #161816;
|
||||||
--color-text-950: #000000;
|
--color-text-950: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@layer components {
|
||||||
|
.grid-main {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(6, 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:hover {
|
||||||
|
background-color: var(--color-neutral-200);
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-cell {
|
||||||
|
padding: calc(var(--spacing) * 2);
|
||||||
|
border-color: var(--color-neutral-400);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width >=48rem) {
|
||||||
|
.grid-main {
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
margin: 0 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-sub {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -541,12 +541,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@layer utilities {
|
@layer utilities {
|
||||||
.collapse {
|
|
||||||
visibility: collapse;
|
|
||||||
}
|
|
||||||
.relative {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.static {
|
.static {
|
||||||
position: static;
|
position: static;
|
||||||
}
|
}
|
||||||
@@ -556,36 +550,24 @@
|
|||||||
.col-span-3 {
|
.col-span-3 {
|
||||||
grid-column: span 3 / span 3;
|
grid-column: span 3 / span 3;
|
||||||
}
|
}
|
||||||
.col-span-full {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
.-my-1 {
|
.-my-1 {
|
||||||
margin-block: calc(var(--spacing) * -1);
|
margin-block: calc(var(--spacing) * -1);
|
||||||
}
|
}
|
||||||
.mt-1 {
|
.mt-1 {
|
||||||
margin-top: calc(var(--spacing) * 1);
|
margin-top: calc(var(--spacing) * 1);
|
||||||
}
|
}
|
||||||
.block {
|
.mb-2 {
|
||||||
display: block;
|
margin-bottom: calc(var(--spacing) * 2);
|
||||||
}
|
}
|
||||||
.flex {
|
.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.grid {
|
|
||||||
display: grid;
|
|
||||||
}
|
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.inline {
|
.inline {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
.inline-flex {
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
.list-item {
|
|
||||||
display: list-item;
|
|
||||||
}
|
|
||||||
.table {
|
.table {
|
||||||
display: table;
|
display: table;
|
||||||
}
|
}
|
||||||
@@ -600,6 +582,9 @@
|
|||||||
.h-4 {
|
.h-4 {
|
||||||
height: calc(var(--spacing) * 4);
|
height: calc(var(--spacing) * 4);
|
||||||
}
|
}
|
||||||
|
.h-\[100vh\] {
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
.h-full {
|
.h-full {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@@ -609,6 +594,9 @@
|
|||||||
.w-4 {
|
.w-4 {
|
||||||
width: calc(var(--spacing) * 4);
|
width: calc(var(--spacing) * 4);
|
||||||
}
|
}
|
||||||
|
.w-9\/10 {
|
||||||
|
width: calc(9/10 * 100%);
|
||||||
|
}
|
||||||
.w-\[2px\] {
|
.w-\[2px\] {
|
||||||
width: 2px;
|
width: 2px;
|
||||||
}
|
}
|
||||||
@@ -621,23 +609,11 @@
|
|||||||
.grow-1 {
|
.grow-1 {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
.border-collapse {
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
.transform {
|
|
||||||
transform: var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y);
|
|
||||||
}
|
|
||||||
.cursor-pointer {
|
.cursor-pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.resize {
|
.grid-cols-2 {
|
||||||
resize: both;
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
|
||||||
.grid-cols-6 {
|
|
||||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
.grid-cols-subgrid {
|
|
||||||
grid-template-columns: subgrid;
|
|
||||||
}
|
}
|
||||||
.flex-col {
|
.flex-col {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -645,6 +621,9 @@
|
|||||||
.flex-row {
|
.flex-row {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
.content-end {
|
||||||
|
align-content: flex-end;
|
||||||
|
}
|
||||||
.items-center {
|
.items-center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@@ -677,10 +656,13 @@
|
|||||||
border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.divide-neutral-400 {
|
.justify-self-end {
|
||||||
:where(& > :not(:last-child)) {
|
justify-self: flex-end;
|
||||||
border-color: var(--color-neutral-400);
|
|
||||||
}
|
}
|
||||||
|
.truncate {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.overflow-hidden {
|
.overflow-hidden {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -695,13 +677,15 @@
|
|||||||
border-style: var(--tw-border-style);
|
border-style: var(--tw-border-style);
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
}
|
}
|
||||||
.border-r-0 {
|
|
||||||
border-right-style: var(--tw-border-style);
|
|
||||||
border-right-width: 0px;
|
|
||||||
}
|
|
||||||
.border-neutral-200 {
|
.border-neutral-200 {
|
||||||
border-color: var(--color-neutral-200);
|
border-color: var(--color-neutral-200);
|
||||||
}
|
}
|
||||||
|
.border-neutral-300 {
|
||||||
|
border-color: var(--color-neutral-300);
|
||||||
|
}
|
||||||
|
.border-neutral-800 {
|
||||||
|
border-color: var(--color-neutral-800);
|
||||||
|
}
|
||||||
.border-neutral-900 {
|
.border-neutral-900 {
|
||||||
border-color: var(--color-neutral-900);
|
border-color: var(--color-neutral-900);
|
||||||
}
|
}
|
||||||
@@ -711,9 +695,6 @@
|
|||||||
.bg-neutral-100 {
|
.bg-neutral-100 {
|
||||||
background-color: var(--color-neutral-100);
|
background-color: var(--color-neutral-100);
|
||||||
}
|
}
|
||||||
.bg-neutral-200 {
|
|
||||||
background-color: var(--color-neutral-200);
|
|
||||||
}
|
|
||||||
.bg-neutral-300 {
|
.bg-neutral-300 {
|
||||||
background-color: var(--color-neutral-300);
|
background-color: var(--color-neutral-300);
|
||||||
}
|
}
|
||||||
@@ -745,6 +726,10 @@
|
|||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
line-height: var(--tw-leading, var(--text-sm--line-height));
|
line-height: var(--tw-leading, var(--text-sm--line-height));
|
||||||
}
|
}
|
||||||
|
.text-xl {
|
||||||
|
font-size: var(--text-xl);
|
||||||
|
line-height: var(--tw-leading, var(--text-xl--line-height));
|
||||||
|
}
|
||||||
.font-bold {
|
.font-bold {
|
||||||
--tw-font-weight: var(--font-weight-bold);
|
--tw-font-weight: var(--font-weight-bold);
|
||||||
font-weight: var(--font-weight-bold);
|
font-weight: var(--font-weight-bold);
|
||||||
@@ -767,20 +752,9 @@
|
|||||||
.uppercase {
|
.uppercase {
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.underline {
|
|
||||||
text-decoration-line: underline;
|
|
||||||
}
|
|
||||||
.outline {
|
|
||||||
outline-style: var(--tw-outline-style);
|
|
||||||
outline-width: 1px;
|
|
||||||
}
|
|
||||||
.filter {
|
.filter {
|
||||||
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
||||||
}
|
}
|
||||||
.backdrop-filter {
|
|
||||||
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
|
|
||||||
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
|
|
||||||
}
|
|
||||||
.transition {
|
.transition {
|
||||||
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
|
||||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||||
@@ -817,6 +791,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.hover\:border-neutral-500 {
|
||||||
|
&:hover {
|
||||||
|
@media (hover: hover) {
|
||||||
|
border-color: var(--color-neutral-500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.hover\:bg-neutral-200 {
|
.hover\:bg-neutral-200 {
|
||||||
&:hover {
|
&:hover {
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
@@ -824,13 +805,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.hover\:bg-neutral-300 {
|
|
||||||
&:hover {
|
|
||||||
@media (hover: hover) {
|
|
||||||
background-color: var(--color-neutral-300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.hover\:bg-neutral-700 {
|
.hover\:bg-neutral-700 {
|
||||||
&:hover {
|
&:hover {
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
@@ -838,6 +812,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.hover\:text-accent {
|
||||||
|
&:hover {
|
||||||
|
@media (hover: hover) {
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.hover\:text-white {
|
.hover\:text-white {
|
||||||
&:hover {
|
&:hover {
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
@@ -876,6 +857,21 @@
|
|||||||
opacity: 50%;
|
opacity: 50%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.max-md\:flex {
|
||||||
|
@media (width < 48rem) {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.max-md\:grid {
|
||||||
|
@media (width < 48rem) {
|
||||||
|
display: grid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.max-md\:flex-col {
|
||||||
|
@media (width < 48rem) {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
.md\:col-span-1 {
|
.md\:col-span-1 {
|
||||||
@media (width >= 48rem) {
|
@media (width >= 48rem) {
|
||||||
grid-column: span 1 / span 1;
|
grid-column: span 1 / span 1;
|
||||||
@@ -901,9 +897,14 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.md\:grid-cols-5 {
|
.md\:inline {
|
||||||
@media (width >= 48rem) {
|
@media (width >= 48rem) {
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.md\:w-1\/2 {
|
||||||
|
@media (width >= 48rem) {
|
||||||
|
width: calc(1/2 * 100%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.md\:px-4 {
|
.md\:px-4 {
|
||||||
@@ -924,6 +925,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@layer components {
|
||||||
|
.grid-main {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(6, 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:hover {
|
||||||
|
background-color: var(--color-neutral-200);
|
||||||
|
}
|
||||||
|
.grid-cell {
|
||||||
|
padding: calc(var(--spacing) * 2);
|
||||||
|
border-color: var(--color-neutral-400);
|
||||||
|
}
|
||||||
|
@media (width >=48rem) {
|
||||||
|
.grid-main {
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
margin: 0 10%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
@@ -950,31 +978,6 @@
|
|||||||
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@property --tw-rotate-x {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: rotateX(0);
|
|
||||||
}
|
|
||||||
@property --tw-rotate-y {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: rotateY(0);
|
|
||||||
}
|
|
||||||
@property --tw-rotate-z {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: rotateZ(0);
|
|
||||||
}
|
|
||||||
@property --tw-skew-x {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: skewX(0);
|
|
||||||
}
|
|
||||||
@property --tw-skew-y {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: skewY(0);
|
|
||||||
}
|
|
||||||
@property --tw-divide-x-reverse {
|
@property --tw-divide-x-reverse {
|
||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
@@ -994,11 +997,6 @@
|
|||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
}
|
}
|
||||||
@property --tw-outline-style {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
initial-value: solid;
|
|
||||||
}
|
|
||||||
@property --tw-blur {
|
@property --tw-blur {
|
||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
@@ -1035,42 +1033,6 @@
|
|||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
}
|
}
|
||||||
@property --tw-backdrop-blur {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-brightness {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-contrast {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-grayscale {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-hue-rotate {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-invert {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-opacity {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-saturate {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-backdrop-sepia {
|
|
||||||
syntax: "*";
|
|
||||||
inherits: false;
|
|
||||||
}
|
|
||||||
@property --tw-duration {
|
@property --tw-duration {
|
||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
function editDay(element, event, formId) {
|
function editDay(element, event, formId) {
|
||||||
var form = element
|
var form = element
|
||||||
.closest(".grid-cols-subgrid")
|
.closest(".grid-sub")
|
||||||
.querySelector(".time-component > form");
|
.querySelector(".time-component > form");
|
||||||
form.classList.toggle("edit");
|
form.classList.toggle("edit");
|
||||||
element.classList.toggle("edit");
|
element.classList.toggle("edit");
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package templates
|
|
||||||
|
|
||||||
templ Style(){
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<head>
|
|
||||||
<title>Arbeitszeit</title>
|
|
||||||
<link rel="stylesheet" href="/static/css/styles.css"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<script src="/static/script.js" defer></script>
|
|
||||||
</head>
|
|
||||||
}
|
|
||||||
9
Backend/templates/headerComponent.templ
Normal file
9
Backend/templates/headerComponent.templ
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package templates
|
||||||
|
|
||||||
|
templ headerComponent() {
|
||||||
|
<div class="flex flex-row justify-between md:mx-[10%] py-2">
|
||||||
|
<a href="/time">Zeitverwaltung</a>
|
||||||
|
<a href="/team">Mitarbeiter</a>
|
||||||
|
<a href="/user">Nutzer</a>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ package templates
|
|||||||
import "github.com/a-h/templ"
|
import "github.com/a-h/templ"
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
import templruntime "github.com/a-h/templ/runtime"
|
||||||
|
|
||||||
func Style() templ.Component {
|
func headerComponent() templ.Component {
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
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
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||||
@@ -29,7 +29,7 @@ func Style() templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><head><title>Arbeitszeit</title><link rel=\"stylesheet\" href=\"/static/css/styles.css\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script src=\"/static/script.js\" defer></script></head>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-row justify-between md:mx-[10%] py-2\"><a href=\"/time\">Zeitverwaltung</a> <a href=\"/team\">Mitarbeiter</a> <a href=\"/user\">Nutzer</a></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package templates
|
|
||||||
|
|
||||||
templ Hello(name string) {
|
|
||||||
<div>Hello, { name }</div>
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.3.833
|
|
||||||
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 Hello(name 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_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, "<div>Hello, ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var2 string
|
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(name)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/hello.templ`, Line: 4, Col: 19}
|
|
||||||
}
|
|
||||||
_, 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, 2, "</div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
117
Backend/templates/pages.templ
Normal file
117
Backend/templates/pages.templ
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package templates
|
||||||
|
|
||||||
|
import (
|
||||||
|
"arbeitszeitmessung/models"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
templ Base() {
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<title>Arbeitszeit</title>
|
||||||
|
<link rel="stylesheet" href="/static/css/styles.css"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
|
<script src="/static/script.js" defer></script>
|
||||||
|
</head>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ TimePage(workDays []models.WorkDay) {
|
||||||
|
@Base()
|
||||||
|
@headerComponent()
|
||||||
|
<div class="grid-main divide-y-1">
|
||||||
|
@inputForm()
|
||||||
|
for _, bookingGroup := range workDays {
|
||||||
|
@dayComponent(bookingGroup)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
@LegendComponent()
|
||||||
|
}
|
||||||
|
|
||||||
|
templ LoginPage(failed bool) {
|
||||||
|
@Base()
|
||||||
|
<div class="w-full h-[100vh] flex flex-col justify-center items-center">
|
||||||
|
<form method="POST" class="w-9/10 md:w-1/2 flex flex-col gap-4 p-2 mb-2">
|
||||||
|
<h1 class="font-bold uppercase text-xl text-center mb-2">Benutzer Anmelden</h1>
|
||||||
|
<input name="personal_nummer" placeholder="Personalnummer" type="text" class="w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500"/>
|
||||||
|
<input name="password" placeholder="Passwort" type="password" class="w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500"/>
|
||||||
|
if failed {
|
||||||
|
<p class="text-red-600 text-sm">Login fehlgeschlagen, bitte erneut versuchen!</p>
|
||||||
|
}
|
||||||
|
<button type="submit" class="cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-300 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">Login</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ UserPage(status int) {
|
||||||
|
@Base()
|
||||||
|
@headerComponent()
|
||||||
|
<div class="grid-main divide-y-1">
|
||||||
|
<div class="grid-sub"></div>
|
||||||
|
<form method="POST" class="grid-sub divide-x-1">
|
||||||
|
<h1 class="grid-cell font-bold uppercase text-xl text-center">Passwort ändern</h1>
|
||||||
|
<div class="grid-cell col-span-3 flex flex-col gap-2">
|
||||||
|
<input name="password" placeholder="Aktuelles Passwort" type="password" class="w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500"/>
|
||||||
|
<input name="new_password" placeholder="Neues Passwort" type="password" class="w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500"/>
|
||||||
|
<input name="new_password_repeat" placeholder="Neues Passwort wiederholen" type="password" class="w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500"/>
|
||||||
|
switch {
|
||||||
|
case status == 401:
|
||||||
|
<p class="text-red-600 text-sm">Aktuelles Passwort nicht korrekt!</p>
|
||||||
|
case status >= 400:
|
||||||
|
<p class="text-red-600 text-sm">Passwortwechsel fehlgeschlagen, bitte erneut versuchen!</p>
|
||||||
|
case status == 200:
|
||||||
|
<p class="text-accent text-sm">Passwortänderung erfolgreich</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell">
|
||||||
|
<button type="submit" class="w-full cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-300 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">Ändern</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
|
||||||
|
{{
|
||||||
|
year, kw := userWeek.WeekStart.ISOWeek()
|
||||||
|
}}
|
||||||
|
@Base()
|
||||||
|
@headerComponent()
|
||||||
|
<div class="grid-main divide-y-1">
|
||||||
|
<div class="grid-sub divide-x-1 bg-neutral-300">
|
||||||
|
<div class="grid-cell font-bold uppercase">{ fmt.Sprintf("%s %s", userWeek.User.Vorname, userWeek.User.Name) }</div>
|
||||||
|
<div class="grid-cell col-span-3 flex flex-col gap-2">
|
||||||
|
for _, day := range userWeek.WorkDays {
|
||||||
|
@weekDayComponent(userWeek.User, day)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<form class="grid-cell flex flex-col gap-2" method="post">
|
||||||
|
<div>
|
||||||
|
<p class="text-sm"><span class="">Woche:</span> { fmt.Sprintf("%02d-%d", kw, year) }</p>
|
||||||
|
<p class="text-sm">an Vorgesetzten senden</p>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="method" value="send"/>
|
||||||
|
<input type="hidden" name="user" value={ strconv.Itoa(userWeek.User.PersonalNummer) }/>
|
||||||
|
<input type="hidden" name="week" value={ userWeek.WeekStart.Format(time.DateOnly) }/>
|
||||||
|
// if failed {
|
||||||
|
// <p>Fehlgeschlagen</p>
|
||||||
|
// }
|
||||||
|
<button type="submit" class="w-full cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-800 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">Senden</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
for _, week := range weeks {
|
||||||
|
@employeComponent(week)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ NavPage() {
|
||||||
|
@Base()
|
||||||
|
<div class="w-full h-[100vh] flex flex-col justify-center items-center">
|
||||||
|
<div class="flex flex-col justify-between w-full md:w-1/2 py-2">
|
||||||
|
<a class="text-xl hover:text-accent transition-colors1" href="/time">Zeitverwaltung</a>
|
||||||
|
<a class="text-xl hover:text-accent transition-colors1" href="/team">Mitarbeiter</a>
|
||||||
|
<a class="text-xl hover:text-accent transition-colors1" href="/user">Nutzer</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
347
Backend/templates/pages_templ.go
Normal file
347
Backend/templates/pages_templ.go
Normal file
@@ -0,0 +1,347 @@
|
|||||||
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
|
// templ: version: v0.3.833
|
||||||
|
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 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, "<!doctype html><head><title>Arbeitszeit</title><link rel=\"stylesheet\" href=\"/static/css/styles.css\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script src=\"/static/script.js\" defer></script></head>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TimePage(workDays []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_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 = headerComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"grid-main divide-y-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 _, bookingGroup := range workDays {
|
||||||
|
templ_7745c5c3_Err = dayComponent(bookingGroup).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
|
||||||
|
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 LoginPage(failed 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_Var3 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var3 == nil {
|
||||||
|
templ_7745c5c3_Var3 = 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, 4, "<div class=\"w-full h-[100vh] flex flex-col justify-center items-center\"><form method=\"POST\" class=\"w-9/10 md:w-1/2 flex flex-col gap-4 p-2 mb-2\"><h1 class=\"font-bold uppercase text-xl text-center mb-2\">Benutzer Anmelden</h1><input name=\"personal_nummer\" placeholder=\"Personalnummer\" type=\"text\" class=\"w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500\"> <input name=\"password\" placeholder=\"Passwort\" type=\"password\" class=\"w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500\"> ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
if failed {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<p class=\"text-red-600 text-sm\">Login fehlgeschlagen, bitte erneut versuchen!</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<button type=\"submit\" class=\"cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-300 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\">Login</button></form></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func UserPage(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)
|
||||||
|
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, 7, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub\"></div><form method=\"POST\" class=\"grid-sub divide-x-1\"><h1 class=\"grid-cell font-bold uppercase text-xl text-center\">Passwort ändern</h1><div class=\"grid-cell col-span-3 flex flex-col gap-2\"><input name=\"password\" placeholder=\"Aktuelles Passwort\" type=\"password\" class=\"w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500\"> <input name=\"new_password\" placeholder=\"Neues Passwort\" type=\"password\" class=\"w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500\"> <input name=\"new_password_repeat\" placeholder=\"Neues Passwort wiederholen\" type=\"password\" class=\"w-full placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-300 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none hover:border-neutral-500\"> ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case status == 401:
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<p class=\"text-red-600 text-sm\">Aktuelles Passwort nicht korrekt!</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
case status >= 400:
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<p class=\"text-red-600 text-sm\">Passwortwechsel fehlgeschlagen, bitte erneut versuchen!</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
case status == 200:
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<p class=\"text-accent text-sm\">Passwortänderung erfolgreich</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div><div class=\"grid-cell\"><button type=\"submit\" class=\"w-full cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-300 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\">Ändern</button></div></form></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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_Var5 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var5 == nil {
|
||||||
|
templ_7745c5c3_Var5 = templ.NopComponent
|
||||||
|
}
|
||||||
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
|
||||||
|
year, kw := userWeek.WeekStart.ISOWeek()
|
||||||
|
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, 12, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub divide-x-1 bg-neutral-300\"><div class=\"grid-cell font-bold uppercase\">")
|
||||||
|
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 %s", userWeek.User.Vorname, userWeek.User.Name))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 82, Col: 111}
|
||||||
|
}
|
||||||
|
_, 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, 13, "</div><div class=\"grid-cell col-span-3 flex flex-col gap-2\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, day := range userWeek.WorkDays {
|
||||||
|
templ_7745c5c3_Err = weekDayComponent(userWeek.User, day).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</div><form class=\"grid-cell flex flex-col gap-2\" method=\"post\"><div><p class=\"text-sm\"><span class=\"\">Woche:</span> ")
|
||||||
|
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/pages.templ`, Line: 90, Col: 87}
|
||||||
|
}
|
||||||
|
_, 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, 15, "</p><p class=\"text-sm\">an Vorgesetzten senden</p></div><input type=\"hidden\" name=\"method\" value=\"send\"> <input type=\"hidden\" name=\"user\" value=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var8 string
|
||||||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(userWeek.User.PersonalNummer))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 94, Col: 87}
|
||||||
|
}
|
||||||
|
_, 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, 16, "\"> <input type=\"hidden\" name=\"week\" value=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var9 string
|
||||||
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(userWeek.WeekStart.Format(time.DateOnly))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 95, Col: 85}
|
||||||
|
}
|
||||||
|
_, 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, 17, "\"><button type=\"submit\" class=\"w-full cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-800 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\">Senden</button></form></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, week := range weeks {
|
||||||
|
templ_7745c5c3_Err = employeComponent(week).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NavPage() templ.Component {
|
||||||
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||||
|
return templ_7745c5c3_CtxErr
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||||
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
defer func() {
|
||||||
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err == nil {
|
||||||
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
ctx = templ.InitializeContext(ctx)
|
||||||
|
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var10 == nil {
|
||||||
|
templ_7745c5c3_Var10 = templ.NopComponent
|
||||||
|
}
|
||||||
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<div class=\"w-full h-[100vh] flex flex-col justify-center items-center\"><div class=\"flex flex-col justify-between w-full md:w-1/2 py-2\"><a class=\"text-xl hover:text-accent transition-colors1\" href=\"/time\">Zeitverwaltung</a> <a class=\"text-xl hover:text-accent transition-colors1\" href=\"/team\">Mitarbeiter</a> <a class=\"text-xl hover:text-accent transition-colors1\" href=\"/user\">Nutzer</a></div></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = templruntime.GeneratedTemplate
|
||||||
49
Backend/templates/teamComponents.templ
Normal file
49
Backend/templates/teamComponents.templ
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package templates
|
||||||
|
|
||||||
|
import (
|
||||||
|
"arbeitszeitmessung/models"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
templ weekDayComponent(user models.User, day models.WorkDay) {
|
||||||
|
{{ work, pause := day.GetWorkTimeString() }}
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
@timeGaugeComponent(day.GetWorkDayProgress(user), false, false)
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<p class=""><span class="font-bold uppercase hidden md:inline">{ day.Day.Format("Mon") }:</span> { day.Day.Format("02.01.2006") }</p>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<span class="text-accent">{ work }</span>
|
||||||
|
<span class="text-neutral-500">{ pause }</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ employeComponent(week models.WorkWeek) {
|
||||||
|
{{
|
||||||
|
year, kw := week.WeekStart.ISOWeek()
|
||||||
|
}}
|
||||||
|
<div class="grid-sub divide-x-1">
|
||||||
|
<div class="grid-cell">
|
||||||
|
<p class="font-bold uppercase">{ week.User.Vorname } { week.User.Name }</p>
|
||||||
|
<p class="text-sm">Arbeitszeit</p>
|
||||||
|
<p class="text-accent">{ week.GetWorkHourString() }</p>
|
||||||
|
</div>
|
||||||
|
<div class="grid-cell col-span-3 flex flex-col gap-2">
|
||||||
|
for _, day := range week.WorkDays {
|
||||||
|
@weekDayComponent(week.User, day)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<form class="grid-cell flex flex-col justify-between gap-2" method="post">
|
||||||
|
<p class="text-sm"><span class="">Woche:</span> { fmt.Sprintf("%02d-%d", kw, year) }</p>
|
||||||
|
<input type="hidden" name="method" value="accept"/>
|
||||||
|
<input type="hidden" name="user" value={ strconv.Itoa(week.User.PersonalNummer) }/>
|
||||||
|
<input type="hidden" name="week" value={ week.WeekStart.Format(time.DateOnly) }/>
|
||||||
|
<button type="submit" class="w-full bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">
|
||||||
|
<p class="">Bestätigen</p>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
227
Backend/templates/teamComponents_templ.go
Normal file
227
Backend/templates/teamComponents_templ.go
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
|
// templ: version: v0.3.833
|
||||||
|
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 weekDayComponent(user models.User, day 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_Var1 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var1 == nil {
|
||||||
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
|
}
|
||||||
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
work, pause := day.GetWorkTimeString()
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-row gap-2\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = timeGaugeComponent(day.GetWorkDayProgress(user), false, false).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"flex flex-col\"><p class=\"\"><span class=\"font-bold uppercase hidden md:inline\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var2 string
|
||||||
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(day.Day.Format("Mon"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 15, Col: 89}
|
||||||
|
}
|
||||||
|
_, 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, 3, ":</span> ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var3 string
|
||||||
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(day.Day.Format("02.01.2006"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 15, Col: 130}
|
||||||
|
}
|
||||||
|
_, 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, "</p><div class=\"flex flex-row gap-2\"><span class=\"text-accent\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var4 string
|
||||||
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(work)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 17, Col: 36}
|
||||||
|
}
|
||||||
|
_, 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, "</span> <span class=\"text-neutral-500\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var5 string
|
||||||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(pause)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 18, Col: 42}
|
||||||
|
}
|
||||||
|
_, 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, 6, "</span></div></div></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func employeComponent(week 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_Var6 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var6 == nil {
|
||||||
|
templ_7745c5c3_Var6 = templ.NopComponent
|
||||||
|
}
|
||||||
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
|
||||||
|
year, kw := week.WeekStart.ISOWeek()
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"grid-sub divide-x-1\"><div class=\"grid-cell\"><p class=\"font-bold uppercase\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var7 string
|
||||||
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Vorname)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 30, Col: 53}
|
||||||
|
}
|
||||||
|
_, 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, 8, " ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var8 string
|
||||||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Name)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 30, Col: 72}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</p><p class=\"text-sm\">Arbeitszeit</p><p class=\"text-accent\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var9 string
|
||||||
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(week.GetWorkHourString())
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 32, Col: 52}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</p></div><div class=\"grid-cell col-span-3 flex flex-col gap-2\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, day := range week.WorkDays {
|
||||||
|
templ_7745c5c3_Err = weekDayComponent(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, 11, "</div><form class=\"grid-cell flex flex-col justify-between gap-2\" method=\"post\"><p class=\"text-sm\"><span class=\"\">Woche:</span> ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var10 string
|
||||||
|
templ_7745c5c3_Var10, 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: 40, Col: 85}
|
||||||
|
}
|
||||||
|
_, 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, 12, "</p><input type=\"hidden\" name=\"method\" value=\"accept\"> <input type=\"hidden\" name=\"user\" value=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var11 string
|
||||||
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(week.User.PersonalNummer))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 42, Col: 82}
|
||||||
|
}
|
||||||
|
_, 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, 13, "\"> <input type=\"hidden\" name=\"week\" value=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var12 string
|
||||||
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(week.WeekStart.Format(time.DateOnly))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 43, Col: 80}
|
||||||
|
}
|
||||||
|
_, 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, 14, "\"> <button type=\"submit\" class=\"w-full bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\"><p class=\"\">Bestätigen</p></button></form></div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = templruntime.GeneratedTemplate
|
||||||
@@ -2,10 +2,10 @@ package templates
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"arbeitszeitmessung/models"
|
"arbeitszeitmessung/models"
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ inputForm() {
|
templ inputForm() {
|
||||||
@@ -13,46 +13,48 @@ templ inputForm(){
|
|||||||
urlParams := ctx.Value("urlParams").(url.Values)
|
urlParams := ctx.Value("urlParams").(url.Values)
|
||||||
user := ctx.Value("user").(models.User)
|
user := ctx.Value("user").(models.User)
|
||||||
}}
|
}}
|
||||||
<div class="col-span-full grid grid-cols-subgrid divide-x-1 divide-neutral-400">
|
<div class="grid-sub divide-x-1 bg-neutral-300 max-md:flex max-md:flex-col">
|
||||||
<div class="bg-neutral-300 p-2 col-span-2 md:col-span-1">
|
<div class="grid-cell col-span-2 md:col-span-1 max-md:grid grid-cols-2">
|
||||||
<p class="font-bold uppercase">{ user.Vorname + " " + user.Name }</p>
|
<p class="font-bold uppercase">{ user.Vorname + " " + user.Name }</p>
|
||||||
|
<div class="justify-self-end">
|
||||||
<p class="text-sm">Überstunden</p>
|
<p class="text-sm">Überstunden</p>
|
||||||
<p class="text-accent">4h 32min</p>
|
<p class="text-accent">4h 32min</p>
|
||||||
</div>
|
</div>
|
||||||
<form id="timeRangeForm" method="GET" class="bg-neutral-300 flex flex-row col-span-3 md:col-span-3 p-2 gap-2 ">
|
</div>
|
||||||
// <input type="hidden" value={urlParams.Get("card_uid")} name="card_uid" class="">
|
<form id="timeRangeForm" method="GET" class="grid-cell flex flex-row col-span-3 md:col-span-3 gap-2 ">
|
||||||
@lineComponent()
|
@lineComponent()
|
||||||
<div class="flex flex-col gap-2 justify-between grow-1">
|
<div class="flex flex-col gap-2 justify-between grow-1">
|
||||||
<input type="date" value={urlParams.Get("time_from")} name="time_from" class="w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300" placeholder="Zeitraum von...">
|
<input type="date" value={ urlParams.Get("time_from") } name="time_from" class="w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300" placeholder="Zeitraum von..."/>
|
||||||
<input type="date" value={urlParams.Get("time_to")} name="time_to" class="w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300" placeholder="Zeitraum bis...">
|
<input type="date" value={ urlParams.Get("time_to") } name="time_to" class="w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300" placeholder="Zeitraum bis..."/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="bg-neutral-300 border-r-0 p-2">
|
<div class="grid-cell content-end">
|
||||||
<button type="submit" form="timeRangeForm" class="bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">
|
<button type="submit" form="timeRangeForm" class="w-full bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50">
|
||||||
<p class="hidden md:block" >Senden</p>
|
<p class="">Anzeigen</p>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4 md:hidden">
|
|
||||||
<path d="m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
templ dayComponent(workDay models.WorkDay) {
|
templ dayComponent(workDay models.WorkDay) {
|
||||||
<div class="col-span-full grid grid-cols-subgrid divide-x-1 divide-neutral-400 hover:bg-neutral-200 transition-colors">
|
{{
|
||||||
<div class="p-2 col-span-2 md:col-span-1 flex flex-row gap-2">
|
work, pause := workDay.GetWorkTimeString()
|
||||||
@timeGaugeComponent(workDay.GetWorkDayProgress(), workDay.Day.Equal(time.Now().Truncate(24 * time.Hour)), workDay.RequiresAction())
|
}}
|
||||||
|
<div class="grid-sub divide-x-1 hover:bg-neutral-200 transition-colors">
|
||||||
|
<div class="grid-cell col-span-2 md:col-span-1 flex flex-row gap-2">
|
||||||
|
@timeGaugeComponent(workDay.GetWorkDayProgress(ctx.Value("user").(models.User)), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)), workDay.RequiresAction())
|
||||||
<div>
|
<div>
|
||||||
<p class="" ><span class="font-bold uppercase" >{workDay.Day.Format("Mon")}:</span> {workDay.Day.Format("02.01.2006")}</p>
|
<p class=""><span class="font-bold uppercase hidden md:inline">{ workDay.Day.Format("Mon") }:</span> { workDay.Day.Format("02.01.2006") }</p>
|
||||||
<p class=" text-sm mt-1">Arbeitszeit</p>
|
<p class=" text-sm mt-1">Arbeitszeit:</p>
|
||||||
if (workDay.RequiresAction()) {
|
if (workDay.RequiresAction()) {
|
||||||
<p class="text-red-600">Bitte anpassen</p>
|
<p class="text-red-600">Bitte anpassen</p>
|
||||||
} else {
|
} else {
|
||||||
<p class=" text-accent">{workDay.GetWorkTimeString()}</p>
|
<p class=" text-accent">{ work }</p>
|
||||||
}
|
}
|
||||||
|
<p class="text-neutral-500">{ pause }</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="time-component flex flex-row col-span-3 md:col-span-3 gap-2 w-full p-2">
|
<div class="time-component flex flex-row col-span-3 md:col-span-3 gap-2 w-full grid-cell">
|
||||||
@lineComponent()
|
@lineComponent()
|
||||||
<form id={ "time-" + workDay.Day.Format("2006-01-02") } class="flex flex-col gap-2 justify-between group w-full" method="post">
|
<form id={ "time-" + workDay.Day.Format("2006-01-02") } class="flex flex-col gap-2 justify-between group w-full" method="post">
|
||||||
for _, booking := range workDay.Bookings {
|
for _, booking := range workDay.Bookings {
|
||||||
@@ -60,7 +62,7 @@ templ dayComponent(workDay models.WorkDay){
|
|||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-2">
|
<div class="grid-cell">
|
||||||
@changeButtonComponent("time-" + workDay.Day.Format("2006-01-02"))
|
@changeButtonComponent("time-" + workDay.Day.Format("2006-01-02"))
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,7 +73,7 @@ templ changeButtonComponent(id string){
|
|||||||
<p class="hidden md:block group-[.edit]:hidden">Ändern</p>
|
<p class="hidden md:block group-[.edit]:hidden">Ändern</p>
|
||||||
<p class="hidden group-[.edit]:md:block">Submit</p>
|
<p class="hidden group-[.edit]:md:block">Submit</p>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4 md:hidden">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4 md:hidden">
|
||||||
<path d="m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z" />
|
<path d="m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
@@ -83,10 +85,10 @@ templ timeGaugeComponent(progress uint8, today bool, warning bool){
|
|||||||
case (warning):
|
case (warning):
|
||||||
bgColor = "bg-red-600"
|
bgColor = "bg-red-600"
|
||||||
break
|
break
|
||||||
case (progress > 0 && progress < 80):
|
case (progress > 0 && progress < 90):
|
||||||
bgColor = "bg-orange-500"
|
bgColor = "bg-orange-500"
|
||||||
break
|
break
|
||||||
case (80 < progress && progress <=110):
|
case (90 <= progress && progress <= 110):
|
||||||
bgColor = "bg-accent"
|
bgColor = "bg-accent"
|
||||||
break
|
break
|
||||||
case (progress > 110):
|
case (progress > 110):
|
||||||
@@ -103,18 +105,17 @@ templ timeGaugeComponent(progress uint8, today bool, warning bool){
|
|||||||
</div>
|
</div>
|
||||||
} else {
|
} else {
|
||||||
<div class={ "w-2 h-full bg-accent rounded-md", bgColor }></div>
|
<div class={ "w-2 h-full bg-accent rounded-md", bgColor }></div>
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
templ lineComponent() {
|
templ lineComponent() {
|
||||||
<div class="flex flex-col w-2 py-2 items-center text-accent print:hidden">
|
<div class="flex flex-col w-2 py-2 items-center text-accent print:hidden">
|
||||||
<svg class="size-2" viewBox="0 0 24 24" fill="currentColor">
|
<svg class="size-2" viewBox="0 0 24 24" fill="currentColor">
|
||||||
<polygon points="12,2 22,12 12,22 2,12" />
|
<polygon points="12,2 22,12 12,22 2,12"></polygon>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="w-[2px] bg-accent flex-grow -my-1"></div>
|
<div class="w-[2px] bg-accent flex-grow -my-1"></div>
|
||||||
<svg class="size-2" viewBox="0 0 24 24" fill="currentColor">
|
<svg class="size-2" viewBox="0 0 24 24" fill="currentColor">
|
||||||
<polygon points="12,2 22,12 12,22 2,12" />
|
<polygon points="12,2 22,12 12,22 2,12"></polygon>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -122,9 +123,10 @@ templ lineComponent(){
|
|||||||
templ bookingComponent(booking models.Booking) {
|
templ bookingComponent(booking models.Booking) {
|
||||||
<div>
|
<div>
|
||||||
<p class="text-neutral-500">
|
<p class="text-neutral-500">
|
||||||
<span class="text-neutral-700 group-[.edit]:hidden inline">{booking.Timestamp.Local().Format("15:04")}</span>
|
<span class="text-neutral-700 group-[.edit]:hidden inline">{ booking.Timestamp.Format("15:04") }</span>
|
||||||
<input name={"booking_" + strconv.Itoa(booking.CounterId)} class="text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm border border-neutral-200 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300" type="time" value={booking.Timestamp.Local().Format("15:04")} />
|
<input name={ "booking_" + strconv.Itoa(booking.CounterId) } type="time" value={ booking.Timestamp.Format("15:04") } class="text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm border border-neutral-200 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300"/>
|
||||||
{booking.GetBookingType()}</p>
|
{ booking.GetBookingType() }
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,20 +40,20 @@ func inputForm() templ.Component {
|
|||||||
|
|
||||||
urlParams := ctx.Value("urlParams").(url.Values)
|
urlParams := ctx.Value("urlParams").(url.Values)
|
||||||
user := ctx.Value("user").(models.User)
|
user := ctx.Value("user").(models.User)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"col-span-full grid grid-cols-subgrid divide-x-1 divide-neutral-400\"><div class=\"bg-neutral-300 p-2 col-span-2 md:col-span-1\"><p class=\"font-bold uppercase\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"grid-sub divide-x-1 bg-neutral-300 max-md:flex max-md:flex-col\"><div class=\"grid-cell col-span-2 md:col-span-1 max-md:grid grid-cols-2\"><p class=\"font-bold uppercase\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var2 string
|
var templ_7745c5c3_Var2 string
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname + " " + user.Name)
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname + " " + user.Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 18, Col: 64}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 18, Col: 66}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</p><p class=\"text-sm\">Überstunden</p><p class=\"text-accent\">4h 32min</p></div><form id=\"timeRangeForm\" method=\"GET\" class=\"bg-neutral-300 flex flex-row col-span-3 md:col-span-3 p-2 gap-2 \">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</p><div class=\"justify-self-end\"><p class=\"text-sm\">Überstunden</p><p class=\"text-accent\">4h 32min</p></div></div><form id=\"timeRangeForm\" method=\"GET\" class=\"grid-cell flex flex-row col-span-3 md:col-span-3 gap-2 \">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func inputForm() templ.Component {
|
|||||||
var templ_7745c5c3_Var3 string
|
var templ_7745c5c3_Var3 string
|
||||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(urlParams.Get("time_from"))
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(urlParams.Get("time_from"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 26, Col: 55}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 27, Col: 57}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -81,13 +81,13 @@ func inputForm() templ.Component {
|
|||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(urlParams.Get("time_to"))
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(urlParams.Get("time_to"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 27, Col: 53}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 28, Col: 55}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" name=\"time_to\" class=\"w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300\" placeholder=\"Zeitraum bis...\"></div></form><div class=\"bg-neutral-300 border-r-0 p-2\"><button type=\"submit\" form=\"timeRangeForm\" class=\"bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\"><p class=\"hidden md:block\">Senden</p><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" class=\"w-4 h-4 md:hidden\"><path d=\"m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z\"></path></svg></button></div></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" name=\"time_to\" class=\"w-full bg-neutral-100 placeholder:text-neutral-400 text-neutral-700 text-sm border border-neutral-0 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300\" placeholder=\"Zeitraum bis...\"></div></form><div class=\"grid-cell content-end\"><button type=\"submit\" form=\"timeRangeForm\" class=\"w-full bg-neutral-100 cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 focus:bg-neutral-700 active:bg-neutral-700 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50\"><p class=\"\">Anzeigen</p></button></div></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -116,22 +116,24 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
templ_7745c5c3_Var5 = templ.NopComponent
|
templ_7745c5c3_Var5 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"col-span-full grid grid-cols-subgrid divide-x-1 divide-neutral-400 hover:bg-neutral-200 transition-colors\"><div class=\"p-2 col-span-2 md:col-span-1 flex flex-row gap-2\">")
|
|
||||||
|
work, pause := workDay.GetWorkTimeString()
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"grid-sub divide-x-1 hover:bg-neutral-200 transition-colors\"><div class=\"grid-cell col-span-2 md:col-span-1 flex flex-row gap-2\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = timeGaugeComponent(workDay.GetWorkDayProgress(), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)), workDay.RequiresAction()).Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = timeGaugeComponent(workDay.GetWorkDayProgress(ctx.Value("user").(models.User)), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)), workDay.RequiresAction()).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div><p class=\"\"><span class=\"font-bold uppercase\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div><p class=\"\"><span class=\"font-bold uppercase hidden md:inline\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var6 string
|
var templ_7745c5c3_Var6 string
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Day.Format("Mon"))
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Day.Format("Mon"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 46, Col: 77}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 47, Col: 94}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -144,13 +146,13 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Day.Format("02.01.2006"))
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Day.Format("02.01.2006"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 46, Col: 120}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 47, Col: 139}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</p><p class=\" text-sm mt-1\">Arbeitszeit</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</p><p class=\" text-sm mt-1\">Arbeitszeit:</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -165,9 +167,9 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var8 string
|
var templ_7745c5c3_Var8 string
|
||||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.GetWorkTimeString())
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(work)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 51, Col: 56}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 52, Col: 35}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -178,7 +180,20 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div></div><div class=\"time-component flex flex-row col-span-3 md:col-span-3 gap-2 w-full p-2\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<p class=\"text-neutral-500\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var9 string
|
||||||
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(pause)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 54, Col: 39}
|
||||||
|
}
|
||||||
|
_, 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, 14, "</p></div></div><div class=\"time-component flex flex-row col-span-3 md:col-span-3 gap-2 w-full grid-cell\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -186,20 +201,20 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<form id=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<form id=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var10 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs("time-" + workDay.Day.Format("2006-01-02"))
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs("time-" + workDay.Day.Format("2006-01-02"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 57, Col: 54}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 59, Col: 56}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\" class=\"flex flex-col gap-2 justify-between group w-full\" method=\"post\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\" class=\"flex flex-col gap-2 justify-between group w-full\" method=\"post\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -209,7 +224,7 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</form></div><div class=\"p-2\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</form></div><div class=\"grid-cell\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -217,7 +232,7 @@ func dayComponent(workDay models.WorkDay) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</div></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -241,25 +256,25 @@ func changeButtonComponent(id string) templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var10 == nil {
|
if templ_7745c5c3_Var11 == nil {
|
||||||
templ_7745c5c3_Var10 = templ.NopComponent
|
templ_7745c5c3_Var11 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editDay", templ.JSExpression("this"), templ.JSExpression("event"), id))
|
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editDay", templ.JSExpression("this"), templ.JSExpression("event"), id))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<button type=\"button\" class=\"cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50 group\" type=\"button\" onclick=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<button type=\"button\" class=\"cursor-pointer rounded-md text-neutral-800 p-2 md:px-4 border text-center text-sm hover:text-white transition-colors border-neutral-900 hover:bg-neutral-700 disabled:pointer-events-none disabled:opacity-50 group\" type=\"button\" onclick=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var11 templ.ComponentScript = templ.JSFuncCall("editDay", templ.JSExpression("this"), templ.JSExpression("event"), id)
|
var templ_7745c5c3_Var12 templ.ComponentScript = templ.JSFuncCall("editDay", templ.JSExpression("this"), templ.JSExpression("event"), id)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11.Call)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12.Call)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\"><p class=\"hidden md:block group-[.edit]:hidden\">Ändern</p><p class=\"hidden group-[.edit]:md:block\">Submit</p><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" class=\"w-4 h-4 md:hidden\"><path d=\"m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z\"></path></svg></button>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"><p class=\"hidden md:block group-[.edit]:hidden\">Ändern</p><p class=\"hidden group-[.edit]:md:block\">Submit</p><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" class=\"w-4 h-4 md:hidden\"><path d=\"m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z\"></path></svg></button>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -283,9 +298,9 @@ func timeGaugeComponent(progress uint8, today bool, warning bool) templ.Componen
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var12 == nil {
|
if templ_7745c5c3_Var13 == nil {
|
||||||
templ_7745c5c3_Var12 = templ.NopComponent
|
templ_7745c5c3_Var13 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
|
||||||
@@ -294,10 +309,10 @@ func timeGaugeComponent(progress uint8, today bool, warning bool) templ.Componen
|
|||||||
case (warning):
|
case (warning):
|
||||||
bgColor = "bg-red-600"
|
bgColor = "bg-red-600"
|
||||||
break
|
break
|
||||||
case (progress > 0 && progress < 80):
|
case (progress > 0 && progress < 90):
|
||||||
bgColor = "bg-orange-500"
|
bgColor = "bg-orange-500"
|
||||||
break
|
break
|
||||||
case (80 < progress && progress <= 110):
|
case (90 <= progress && progress <= 110):
|
||||||
bgColor = "bg-accent"
|
bgColor = "bg-accent"
|
||||||
break
|
break
|
||||||
case (progress > 110):
|
case (progress > 110):
|
||||||
@@ -308,65 +323,65 @@ func timeGaugeComponent(progress uint8, today bool, warning bool) templ.Componen
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if today {
|
if today {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div class=\"flex-start flex w-2 h-full overflow-hidden rounded-full bg-neutral-300 print:hidden\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div class=\"flex-start flex w-2 h-full overflow-hidden rounded-full bg-neutral-300 print:hidden\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var13 = []any{"flex w-full items-center justify-center overflow-hidden rounded-full", bgColor}
|
var templ_7745c5c3_Var14 = []any{"flex w-full items-center justify-center overflow-hidden rounded-full", bgColor}
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var13...)
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var14...)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div class=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<div class=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var14 string
|
|
||||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var13).String())
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 1, Col: 0}
|
|
||||||
}
|
|
||||||
_, 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, "\" style=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var15 string
|
var templ_7745c5c3_Var15 string
|
||||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues(fmt.Sprintf("height: %d%%", int(progress)))
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var14).String())
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 102, Col: 146}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 1, Col: 0}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\"></div></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\" style=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var16 string
|
||||||
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues(fmt.Sprintf("height: %d%%", int(progress)))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 104, Col: 149}
|
||||||
|
}
|
||||||
|
_, 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, 24, "\"></div></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var templ_7745c5c3_Var16 = []any{"w-2 h-full bg-accent rounded-md", bgColor}
|
var templ_7745c5c3_Var17 = []any{"w-2 h-full bg-accent rounded-md", bgColor}
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var16...)
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var17...)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<div class=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<div class=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var17 string
|
var templ_7745c5c3_Var18 string
|
||||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var16).String())
|
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var17).String())
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 1, Col: 0}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 1, Col: 0}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\"></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "\"></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -391,12 +406,12 @@ func lineComponent() templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var18 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var19 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var18 == nil {
|
if templ_7745c5c3_Var19 == nil {
|
||||||
templ_7745c5c3_Var18 = templ.NopComponent
|
templ_7745c5c3_Var19 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<div class=\"flex flex-col w-2 py-2 items-center text-accent print:hidden\"><svg class=\"size-2\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"12,2 22,12 12,22 2,12\"></polygon></svg><div class=\"w-[2px] bg-accent flex-grow -my-1\"></div><svg class=\"size-2\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"12,2 22,12 12,22 2,12\"></polygon></svg></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<div class=\"flex flex-col w-2 py-2 items-center text-accent print:hidden\"><svg class=\"size-2\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"12,2 22,12 12,22 2,12\"></polygon></svg><div class=\"w-[2px] bg-accent flex-grow -my-1\"></div><svg class=\"size-2\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"12,2 22,12 12,22 2,12\"></polygon></svg></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -420,64 +435,64 @@ func bookingComponent(booking models.Booking) templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var19 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var20 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var19 == nil {
|
if templ_7745c5c3_Var20 == nil {
|
||||||
templ_7745c5c3_Var19 = templ.NopComponent
|
templ_7745c5c3_Var20 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<div><p class=\"text-neutral-500\"><span class=\"text-neutral-700 group-[.edit]:hidden inline\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<div><p class=\"text-neutral-500\"><span class=\"text-neutral-700 group-[.edit]:hidden inline\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var20 string
|
|
||||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Local().Format("15:04"))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 125, Col: 103}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</span> <input name=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var21 string
|
var templ_7745c5c3_Var21 string
|
||||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs("booking_" + strconv.Itoa(booking.CounterId))
|
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 126, Col: 59}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 126, Col: 97}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "\" class=\"text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm border border-neutral-200 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300\" type=\"time\" value=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</span> <input name=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var22 string
|
var templ_7745c5c3_Var22 string
|
||||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Local().Format("15:04"))
|
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs("booking_" + strconv.Itoa(booking.CounterId))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 126, Col: 342}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 127, Col: 61}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\"> ")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\" type=\"time\" value=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var23 string
|
var templ_7745c5c3_Var23 string
|
||||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(booking.GetBookingType())
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 127, Col: 27}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 127, Col: 117}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</p></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "\" class=\"text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm border border-neutral-200 rounded-md px-3 py-2 transition duration-300 ease focus:outline-none focus:border-neutral-400 hover:border-neutral-300\"> ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var24 string
|
||||||
|
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(booking.GetBookingType())
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 128, Col: 29}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</p></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -501,12 +516,12 @@ func LegendComponent() templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var24 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var25 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var24 == nil {
|
if templ_7745c5c3_Var25 == nil {
|
||||||
templ_7745c5c3_Var24 = templ.NopComponent
|
templ_7745c5c3_Var25 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<div class=\"flex flex-row gap-4 md:mx-[10%] print:hidden\"><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-red-600\"></div><span>Fehler</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-orange-500\"></div><span>Arbeitszeit unter regulär</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-accent\"></div><span>Arbeitszeit vollständig</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-purple-600\"></div><span>Überstunden</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-neutral-400\"></div><span>Keine Buchungen</span></div></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<div class=\"flex flex-row gap-4 md:mx-[10%] print:hidden\"><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-red-600\"></div><span>Fehler</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-orange-500\"></div><span>Arbeitszeit unter regulär</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-accent\"></div><span>Arbeitszeit vollständig</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-purple-600\"></div><span>Überstunden</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-neutral-400\"></div><span>Keine Buchungen</span></div></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package templates
|
|
||||||
|
|
||||||
import "arbeitszeitmessung/models"
|
|
||||||
|
|
||||||
templ TimeDashboard(workDays []models.WorkDay){
|
|
||||||
@Style()
|
|
||||||
<div class="grid grid-cols-6 md:grid-cols-5 items-strech md:mx-[10%] divide-y-1 divide-neutral-400" >
|
|
||||||
@inputForm()
|
|
||||||
for _, bookingGroup := range workDays {
|
|
||||||
@dayComponent(bookingGroup)
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
@LegendComponent()
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.3.833
|
|
||||||
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"
|
|
||||||
|
|
||||||
func TimeDashboard(workDays []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_Var1 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var1 == nil {
|
|
||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
templ_7745c5c3_Err = Style().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"grid grid-cols-6 md:grid-cols-5 items-strech md:mx-[10%] divide-y-1 divide-neutral-400\">")
|
|
||||||
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 _, bookingGroup := range workDays {
|
|
||||||
templ_7745c5c3_Err = dayComponent(bookingGroup).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div>")
|
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package templates
|
|
||||||
|
|
||||||
templ LoginForm(){
|
|
||||||
@Style()
|
|
||||||
<form method="POST">
|
|
||||||
<input name="card_uid" type="text" placeholder="card_uid"/>
|
|
||||||
<input name="password" type="passwort" placeholder="password"/>
|
|
||||||
<button type="submit">Send</button>
|
|
||||||
</form>
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
|
||||||
|
|
||||||
// templ: version: v0.3.833
|
|
||||||
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 LoginForm() 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 = Style().Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<form method=\"POST\"><input name=\"card_uid\" type=\"text\" placeholder=\"card_uid\"> <input name=\"password\" type=\"passwort\" placeholder=\"password\"> <button type=\"submit\">Send</button></form>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = templruntime.GeneratedTemplate
|
|
||||||
84
DB/initdb/01_create_tables.sql
Normal file
84
DB/initdb/01_create_tables.sql
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for anwesenheit
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS "anwesenheit";
|
||||||
|
CREATE TABLE "anwesenheit" (
|
||||||
|
"counter_id" bigserial PRIMARY KEY,
|
||||||
|
"timestamp" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"card_uid" varchar(255),
|
||||||
|
"check_in_out" int2,
|
||||||
|
"geraet_id" int2
|
||||||
|
);
|
||||||
|
COMMENT ON COLUMN "anwesenheit"."check_in_out" IS '1=Check In 2=Check Out , 3=Check in Manuell, 4=Check out manuell255=Automatic Check Out';
|
||||||
|
COMMENT ON COLUMN "anwesenheit"."geraet_id" IS 'ID des Lesegerätes';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for personal_daten
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS "personal_daten";
|
||||||
|
CREATE TABLE "personal_daten" (
|
||||||
|
"personal_nummer" int4 NOT NULL PRIMARY KEY,
|
||||||
|
"aktiv_beschaeftigt" bool,
|
||||||
|
"vorname" varchar(255),
|
||||||
|
"nachname" varchar(255),
|
||||||
|
"geburtsdatum" date,
|
||||||
|
"plz" varchar(255),
|
||||||
|
"adresse" varchar(255),
|
||||||
|
"geschlecht" int2,
|
||||||
|
"card_uid" varchar(255),
|
||||||
|
"hauptbeschaeftigungs_ort" int2,
|
||||||
|
"arbeitszeit_per_tag" float4,
|
||||||
|
"arbeitszeit_min_start" time(6),
|
||||||
|
"arbeitszeit_max_ende" time(6),
|
||||||
|
"vorgesetzter_pers_nr" int4
|
||||||
|
);
|
||||||
|
COMMENT ON COLUMN "personal_daten"."geschlecht" IS '1==weiblich, 2==maennlich, 3==divers';
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS "user_password";
|
||||||
|
CREATE TABLE "user_password" (
|
||||||
|
"personal_nummer" int4 NOT NULL PRIMARY KEY,
|
||||||
|
"pass_hash" TEXT,
|
||||||
|
"zuletzt_geandert" timestamp(6) DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- update Funktion für pass_hash
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION update_zuletzt_geandert()
|
||||||
|
RETURNS TRIGGER AS $$
|
||||||
|
BEGIN
|
||||||
|
-- Nur wenn hash geändert wurde
|
||||||
|
IF NEW.pass_hash IS DISTINCT FROM OLD.pass_hash THEN
|
||||||
|
NEW.zuletzt_geandert = now();
|
||||||
|
END IF;
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE TRIGGER pass_hash_update
|
||||||
|
BEFORE UPDATE ON user_password
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION update_zuletzt_geandert();
|
||||||
|
|
||||||
|
-- audittabelle für arbeitsstunden bestätigung
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS "wochen_report";
|
||||||
|
CREATE TABLE "wochen_report" (
|
||||||
|
"id" serial PRIMARY KEY,
|
||||||
|
"personal_nummer" int4,
|
||||||
|
"woche_start" date,
|
||||||
|
"bestaetigt" bool DEFAULT FALSE,
|
||||||
|
UNIQUE ("personal_nummer", "woche_start")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Adds crypto extension
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
|
|
||||||
|
|
||||||
|
-- Insert into personal_daten
|
||||||
|
|
||||||
|
INSERT INTO "personal_daten" ("personal_nummer", "aktiv_beschaeftigt", "vorname", "nachname", "geburtsdatum", "plz", "adresse", "geschlecht", "card_uid", "hauptbeschaeftigungs_ort", "arbeitszeit_per_tag", "arbeitszeit_min_start", "arbeitszeit_max_ende", "vorgesetzter_pers_nr") VALUES
|
||||||
|
(123, 't', 'Max', 'Mustermann', '2003-02-01', '08963', 'Altenburger Str. 44A', 1, 'acde-edca', 1, 7.5, '07:00:00', '20:00:00', 0);
|
||||||
|
|
||||||
|
INSERT INTO "user_password" ("personal_nummer", "pass_hash") VALUES
|
||||||
|
(123, crypt('max_pass', gen_salt('bf')));
|
||||||
16
DB/initdb/02_create_user.sh
Normal file
16
DB/initdb/02_create_user.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/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 USER $POSTGRES_API_USER WITH ENCRYPTED PASSWORD '$POSTGRES_API_PASSWORD';
|
||||||
|
GRANT CONNECT ON DATABASE $POSTGRES_DB TO $POSTGRES_API_USER;
|
||||||
|
GRANT USAGE ON SCHEMA public TO $POSTGRES_API_USER;
|
||||||
|
GRANT SELECT, INSERT, UPDATE ON anwesenheit, personal_daten, user_password, wochen_report 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 root --dbname arbeitszeitmessung
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
POSTGRES_ADMIN=root
|
POSTGRES_USER=root
|
||||||
POSTGRES_ADMIN_PASS=very_secure
|
POSTGRES_PASSWORD=very_secure
|
||||||
POSTGRES_USER=api_nuter
|
POSTGRES_API_USER=api_nuter
|
||||||
POSTGRES_PASSWORD=password
|
POSTGRES_API_PASSWORD=password
|
||||||
POSTGRES_PATH=../DB
|
POSTGRES_PATH=../DB
|
||||||
POSTGRES_DB=arbeitszeitmessung
|
POSTGRES_DB=arbeitszeitmessung
|
||||||
EXPOSED_PORT=8000
|
EXPOSED_PORT=8000
|
||||||
|
TZ=Europe/Berlin
|
||||||
|
PGTZ=Europe/Berlin
|
||||||
|
API_TOKEN=dont_access
|
||||||
|
|||||||
@@ -11,7 +11,12 @@
|
|||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"url": "http://localhost:8000"
|
"url": "http://localhost:8000",
|
||||||
|
"description": "Docker Server"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://localhost:8080",
|
||||||
|
"description": "Local Development"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -22,55 +27,11 @@
|
|||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"/time": {
|
"/time": {
|
||||||
"put": {
|
|
||||||
"tags": ["booking"],
|
|
||||||
"summary": "Update a existing booking",
|
|
||||||
"description": "Update an existing booking by Id",
|
|
||||||
"operationId": "updateBooking",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "counter_id",
|
|
||||||
"in": "query",
|
|
||||||
"description": "Booking ID to update",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"requestBody": {
|
|
||||||
"description": "Update an existent booking in the db. Not all values have to be updated",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/Booking"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "Booking Updated",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/Booking"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Invalid ID supplied"
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Server Error"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"get": {
|
"get": {
|
||||||
"tags": ["booking"],
|
"tags": [
|
||||||
"summary": "Gets all the bookings limited",
|
"booking"
|
||||||
|
],
|
||||||
|
"summary": "Gets all the bookings from one card_uid",
|
||||||
"description": "Returns all the bookings optionally filtered with cardID",
|
"description": "Returns all the bookings optionally filtered with cardID",
|
||||||
"operationId": "getBooking",
|
"operationId": "getBooking",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@@ -78,10 +39,30 @@
|
|||||||
"name": "card_uid",
|
"name": "card_uid",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"description": "CardID to filter for",
|
"description": "CardID to filter for",
|
||||||
"required": false,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "time_from",
|
||||||
|
"in": "query",
|
||||||
|
"description": "Timestamp since when all bookings are shown (default=1 month ago)",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2025-02-28"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "time_to",
|
||||||
|
"in": "query",
|
||||||
|
"description": "Timestamp till when all bookings are shown (default=today)",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2025-02-28"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -92,7 +73,51 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/Booking"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"day": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date"
|
||||||
|
},
|
||||||
|
"bookings": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,11 +131,21 @@
|
|||||||
},
|
},
|
||||||
"/time/new": {
|
"/time/new": {
|
||||||
"put": {
|
"put": {
|
||||||
"tags": ["booking"],
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
"summary": "Create new Booking",
|
"summary": "Create new Booking",
|
||||||
"description": "Creates a new booking with the supplied parameters",
|
"description": "Creates a new booking with the supplied parameters",
|
||||||
"operationId": "pcreateBooking",
|
"operationId": "pcreateBooking",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "header",
|
||||||
|
"name": "Authorization",
|
||||||
|
"description": "Predefined API Key to authorize access",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "card_uid",
|
"name": "card_uid",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
@@ -136,7 +171,11 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"enum": [1, 2, 255]
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -146,7 +185,39 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/Booking"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,11 +228,30 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"get": {
|
"get": {
|
||||||
"tags": ["booking"],
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
"summary": "Create new Booking",
|
"summary": "Create new Booking",
|
||||||
"description": "Creates a new booking with the supplied parameters",
|
"description": "Creates a new booking with the supplied parameters",
|
||||||
"operationId": "gcreateBooking",
|
"operationId": "gcreateBooking",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "header",
|
||||||
|
"name": "Authorization",
|
||||||
|
"description": "Predefined API Key to authorize access",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "api_key",
|
||||||
|
"description": "Predefined API Key to authorize access",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "card_uid",
|
"name": "card_uid",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
@@ -187,7 +277,11 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"enum": [1, 2, 255]
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -197,10 +291,45 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/Booking"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "none or wrong api key provided!"
|
||||||
},
|
},
|
||||||
"409": {
|
"409": {
|
||||||
"description": "Same booking type as last booking"
|
"description": "Same booking type as last booking"
|
||||||
@@ -210,7 +339,9 @@
|
|||||||
},
|
},
|
||||||
"/logout": {
|
"/logout": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": ["booking"],
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
"summary": "Logs out all logged in users",
|
"summary": "Logs out all logged in users",
|
||||||
"description": "With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)",
|
"description": "With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)",
|
||||||
"operationId": "autoLogout",
|
"operationId": "autoLogout",
|
||||||
@@ -222,7 +353,26 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/User"
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Mustermann"
|
||||||
|
},
|
||||||
|
"vorname": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Max"
|
||||||
|
},
|
||||||
|
"hauptbeschäftigungsort": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int8",
|
||||||
|
"example": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,6 +384,53 @@
|
|||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"BookingGrouped": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"day": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date"
|
||||||
|
},
|
||||||
|
"bookings": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"counter_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"example": 100
|
||||||
|
},
|
||||||
|
"card_uid": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_card"
|
||||||
|
},
|
||||||
|
"geraet_id": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "test_reader"
|
||||||
|
},
|
||||||
|
"check_in_out": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1,
|
||||||
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"example": "2024-09-05T08:51:12.670Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"xml": {
|
||||||
|
"name": "booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Booking": {
|
"Booking": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -253,7 +450,11 @@
|
|||||||
"check_in_out": {
|
"check_in_out": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"example": 1,
|
"example": 1,
|
||||||
"enum": [1, 2, 255]
|
"enum": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
255
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"timestamp": {
|
"timestamp": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -1,74 +1,58 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Arbeitszeitmessung - OpenAPI 3.0
|
title: Arbeitszeitmessung - OpenAPI 3.0
|
||||||
description: 'This demos the API for the Arbeitszeitmessung Project '
|
description: "This demos the API for the Arbeitszeitmessung Project "
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Git-Repository
|
description: Git-Repository
|
||||||
url: https://git.letsstein.de/tom/arbeitszeitmessung
|
url: https://git.letsstein.de/tom/arbeitszeitmessung
|
||||||
servers:
|
servers:
|
||||||
- url: http://localhost:8000
|
- url: http://localhost:8000
|
||||||
|
description: Docker Server
|
||||||
|
- url: http://localhost:8080
|
||||||
|
description: Local Development
|
||||||
tags:
|
tags:
|
||||||
- name: booking
|
- name: booking
|
||||||
description: all Bookings
|
description: all Bookings
|
||||||
paths:
|
paths:
|
||||||
/time:
|
/time:
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- booking
|
|
||||||
summary: Update a existing booking
|
|
||||||
description: Update an existing booking by Id
|
|
||||||
operationId: updateBooking
|
|
||||||
parameters:
|
|
||||||
- name: counter_id
|
|
||||||
in: query
|
|
||||||
description: Booking ID to update
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
requestBody:
|
|
||||||
description: >-
|
|
||||||
Update an existent booking in the db. Not all values have to be
|
|
||||||
updated
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Booking'
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Booking Updated
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Booking'
|
|
||||||
'400':
|
|
||||||
description: Invalid ID supplied
|
|
||||||
'500':
|
|
||||||
description: Server Error
|
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- booking
|
- booking
|
||||||
summary: Gets all the bookings limited
|
summary: Gets all the bookings from one card_uid
|
||||||
description: Returns all the bookings optionally filtered with cardID
|
description: Returns all the bookings optionally filtered with cardID
|
||||||
operationId: getBooking
|
operationId: getBooking
|
||||||
parameters:
|
parameters:
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: CardID to filter for
|
description: CardID to filter for
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: time_from
|
||||||
|
in: query
|
||||||
|
description: Timestamp since when all bookings are shown (default=1 month ago)
|
||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
example: "2025-02-28"
|
||||||
|
- name: time_to
|
||||||
|
in: query
|
||||||
|
description: Timestamp till when all bookings are shown (default=today)
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: "2025-02-28"
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Booking'
|
$ref: "#/components/schemas/BookingGrouped"
|
||||||
'400':
|
"400":
|
||||||
description: Invalid cardID
|
description: Invalid cardID
|
||||||
/time/new:
|
/time/new:
|
||||||
put:
|
put:
|
||||||
@@ -78,6 +62,11 @@ paths:
|
|||||||
description: Creates a new booking with the supplied parameters
|
description: Creates a new booking with the supplied parameters
|
||||||
operationId: pcreateBooking
|
operationId: pcreateBooking
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: Authorization
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: id of the RFID card scanned
|
description: id of the RFID card scanned
|
||||||
@@ -101,13 +90,13 @@ paths:
|
|||||||
- 2
|
- 2
|
||||||
- 255
|
- 255
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: successfully created booking
|
description: successfully created booking
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Booking'
|
$ref: "#/components/schemas/Booking"
|
||||||
'409':
|
"409":
|
||||||
description: Same booking type as last booking
|
description: Same booking type as last booking
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -116,6 +105,17 @@ paths:
|
|||||||
description: Creates a new booking with the supplied parameters
|
description: Creates a new booking with the supplied parameters
|
||||||
operationId: gcreateBooking
|
operationId: gcreateBooking
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: Authorization
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: api_key
|
||||||
|
description: Predefined API Key to authorize access
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
- name: card_uid
|
- name: card_uid
|
||||||
in: query
|
in: query
|
||||||
description: id of the RFID card scanned
|
description: id of the RFID card scanned
|
||||||
@@ -139,13 +139,15 @@ paths:
|
|||||||
- 2
|
- 2
|
||||||
- 255
|
- 255
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: successfully created booking
|
description: successfully created booking
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Booking'
|
$ref: "#/components/schemas/Booking"
|
||||||
'409':
|
"401":
|
||||||
|
description: none or wrong api key provided!
|
||||||
|
"409":
|
||||||
description: Same booking type as last booking
|
description: Same booking type as last booking
|
||||||
/logout:
|
/logout:
|
||||||
get:
|
get:
|
||||||
@@ -155,16 +157,26 @@ paths:
|
|||||||
description: With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)
|
description: With this call all actively logged in users (last booking today has check_in_out=1) will be logged out automaticly (check_in_out=255)
|
||||||
operationId: autoLogout
|
operationId: autoLogout
|
||||||
responses:
|
responses:
|
||||||
'200':
|
"200":
|
||||||
description: Succesful
|
description: Succesful
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: "#/components/schemas/User"
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
BookingGrouped:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
day:
|
||||||
|
type: string
|
||||||
|
format: date
|
||||||
|
bookings:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Booking"
|
||||||
Booking:
|
Booking:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -188,7 +200,7 @@ components:
|
|||||||
timestamp:
|
timestamp:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
example: '2024-09-05T08:51:12.670Z'
|
example: "2024-09-05T08:51:12.670Z"
|
||||||
xml:
|
xml:
|
||||||
name: booking
|
name: booking
|
||||||
User:
|
User:
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_ADMIN}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_ADMIN_PASS}
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
|
||||||
PGDATA: /var/lib/postgresql/data/pg_data
|
PGDATA: /var/lib/postgresql/data/pg_data
|
||||||
volumes:
|
volumes:
|
||||||
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
||||||
|
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
@@ -22,18 +20,16 @@ services:
|
|||||||
- 8001:8080
|
- 8001:8080
|
||||||
backend:
|
backend:
|
||||||
build: ../Backend
|
build: ../Backend
|
||||||
image: git.letsstein.de/tom/arbeitszeit-backend
|
image: git.letsstein.de/tom/arbeitszeit-backend:0.1.1
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST: db
|
POSTGRES_HOST: db
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
POSTGRES_PASS: ${POSTGRES_PASSWORD}
|
|
||||||
EXPOSED_PORT: ${EXPOSED_PORT}
|
EXPOSED_PORT: ${EXPOSED_PORT}
|
||||||
DEBUG: true
|
NO_CORS: true
|
||||||
ports:
|
ports:
|
||||||
- 8000:8080
|
- ${EXPOSED_PORT}:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
swagger:
|
swagger:
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_ADMIN}
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_ADMIN_PASS}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
PGDATA: /var/lib/postgresql/data/pg_data
|
PGDATA: /var/lib/postgresql/data/pg_data
|
||||||
volumes:
|
volumes:
|
||||||
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
||||||
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: git.letsstein.de/tom/arbeitszeit-backend
|
image: git.letsstein.de/tom/arbeitszeit-backend
|
||||||
@@ -21,10 +23,9 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST: db
|
POSTGRES_HOST: db
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
POSTGRES_PASS: ${POSTGRES_PASSWORD}
|
|
||||||
EXPOSED_PORT: ${EXPOSED_PORT}
|
EXPOSED_PORT: ${EXPOSED_PORT}
|
||||||
ports:
|
ports:
|
||||||
- ${EXPOSED_PORT}:8080
|
- ${EXPOSED_PORT}:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
restart: unless-stopped
|
||||||
|
|||||||
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@@ -16,22 +16,9 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'make build_backend'
|
sh 'make backend'
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
stage('Deploying image arbeitszeit-backend') {
|
|
||||||
when {
|
|
||||||
anyOf{
|
|
||||||
changeset 'Jenkinsfile'
|
|
||||||
changeset 'Makefile'
|
|
||||||
changeset 'Backend/**'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'make push_backend'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -36,3 +36,12 @@ push_%:
|
|||||||
full_%:
|
full_%:
|
||||||
make build_$*
|
make build_$*
|
||||||
make push_$*
|
make push_$*
|
||||||
|
|
||||||
|
generateFrontend:
|
||||||
|
cd Backend && templ generate
|
||||||
|
cd Backend && npx @tailwindcss/cli -i ./src/main.css -o ./static/css/styles.css
|
||||||
|
|
||||||
|
|
||||||
|
backend: generateFrontend login_registry
|
||||||
|
docker buildx build --platform linux/amd64,linux/arm64 -t git.letsstein.de/tom/arbeitszeit-backend:latest Backend --push
|
||||||
|
docker buildx build --platform linux/amd64,linux/arm64 -t git.letsstein.de/tom/arbeitszeit-backend:${GIT_COMMIT} Backend --push
|
||||||
|
|||||||
90
db.sql
90
db.sql
@@ -8,6 +8,7 @@ CREATE TABLE "public"."anwesenheit" (
|
|||||||
);
|
);
|
||||||
COMMENT ON COLUMN "public"."anwesenheit"."check_in_out" IS '1=Check In 2=Check Out 255=Automatic Check Out';
|
COMMENT ON COLUMN "public"."anwesenheit"."check_in_out" IS '1=Check In 2=Check Out 255=Automatic Check Out';
|
||||||
COMMENT ON COLUMN "public"."anwesenheit"."geraet_id" IS 'ID des Lesegerätes';
|
COMMENT ON COLUMN "public"."anwesenheit"."geraet_id" IS 'ID des Lesegerätes';
|
||||||
|
|
||||||
-- @block create table personaldaten
|
-- @block create table personaldaten
|
||||||
CREATE TABLE "public"."personal_daten" (
|
CREATE TABLE "public"."personal_daten" (
|
||||||
"personal_nummer" SERIAL PRIMARY KEY,
|
"personal_nummer" SERIAL PRIMARY KEY,
|
||||||
@@ -25,9 +26,13 @@ COMMENT ON COLUMN "public"."personal_daten"."akiv_beschaeftig" IS 'derzeit aktiv
|
|||||||
COMMENT ON COLUMN "public"."personal_daten"."geschlecht" IS 'w:1 m:2 div:3 kA:null ';
|
COMMENT ON COLUMN "public"."personal_daten"."geschlecht" IS 'w:1 m:2 div:3 kA:null ';
|
||||||
COMMENT ON COLUMN "public"."personal_daten"."card_uid" IS 'RFID-Karten-UID';
|
COMMENT ON COLUMN "public"."personal_daten"."card_uid" IS 'RFID-Karten-UID';
|
||||||
COMMENT ON COLUMN "public"."personal_daten"."hauptbeschaeftigung_ort" IS 'Chemnitz:1 Sayda:2';
|
COMMENT ON COLUMN "public"."personal_daten"."hauptbeschaeftigung_ort" IS 'Chemnitz:1 Sayda:2';
|
||||||
|
|
||||||
|
|
||||||
-- @block drop tables
|
-- @block drop tables
|
||||||
DROP TABLE IF EXISTS "public"."anwesenheit";
|
DROP TABLE IF EXISTS "public"."anwesenheit";
|
||||||
DROP TABLE IF EXISTS "public"."personal_daten";
|
DROP TABLE IF EXISTS "public"."personal_daten";
|
||||||
|
|
||||||
|
|
||||||
-- @block insert into personal_daten
|
-- @block insert into personal_daten
|
||||||
INSERT INTO personal_daten (
|
INSERT INTO personal_daten (
|
||||||
personal_nummer,
|
personal_nummer,
|
||||||
@@ -53,6 +58,91 @@ VALUES (
|
|||||||
'test_card',
|
'test_card',
|
||||||
'1'
|
'1'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- @block select
|
-- @block select
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM personal_daten;
|
FROM personal_daten;
|
||||||
|
|
||||||
|
-- @block work and pause time
|
||||||
|
WITH ordered_bookings AS (
|
||||||
|
SELECT
|
||||||
|
timestamp,
|
||||||
|
check_in_out,
|
||||||
|
LAG(timestamp) OVER (PARTITION BY card_uid ORDER BY timestamp) AS prev_timestamp,
|
||||||
|
LAG(check_in_out) OVER (PARTITION BY card_uid ORDER BY timestamp) AS prev_check
|
||||||
|
FROM anwesenheit
|
||||||
|
WHERE card_uid = 'acde-edca' -- Replace with actual card_uid
|
||||||
|
AND timestamp::DATE = '2025-02-23' -- Replace with actual date
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
-- Total work time: Duration between check-in (1,3) and check-out (2,4,254)
|
||||||
|
COALESCE(
|
||||||
|
SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (1, 3) AND check_in_out IN (2, 4, 254)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
), INTERVAL '0'
|
||||||
|
) AS total_work,
|
||||||
|
|
||||||
|
-- Total pause time: Duration between check-out (2,4,254) and next check-in (1,3)
|
||||||
|
COALESCE(
|
||||||
|
SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (2, 4, 254) AND check_in_out IN (1, 3)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
), INTERVAL '0'
|
||||||
|
) AS total_pause
|
||||||
|
|
||||||
|
FROM ordered_bookings;
|
||||||
|
|
||||||
|
-- @block work and pause time multi day
|
||||||
|
WITH ordered_bookings AS (
|
||||||
|
SELECT
|
||||||
|
timestamp::DATE AS work_date, -- Extract date for grouping
|
||||||
|
timestamp,
|
||||||
|
check_in_out,
|
||||||
|
LAG(timestamp) OVER (
|
||||||
|
PARTITION BY card_uid, timestamp::DATE -- Reset for each day
|
||||||
|
ORDER BY timestamp
|
||||||
|
) AS prev_timestamp,
|
||||||
|
LAG(check_in_out) OVER (
|
||||||
|
PARTITION BY card_uid, timestamp::DATE
|
||||||
|
ORDER BY timestamp
|
||||||
|
) AS prev_check
|
||||||
|
FROM anwesenheit
|
||||||
|
WHERE card_uid = $1 -- Replace with actual card_uid
|
||||||
|
AND timestamp::DATE >= $2 -- Set date range
|
||||||
|
AND timestamp::DATE < $3
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
work_date,
|
||||||
|
|
||||||
|
-- Total work time per day
|
||||||
|
COALESCE(
|
||||||
|
EXTRACT(EPOCH FROM SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (1, 3) AND check_in_out IN (2, 4, 254)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
)), 0
|
||||||
|
) AS total_work,
|
||||||
|
|
||||||
|
-- Extract total pause time in seconds
|
||||||
|
COALESCE(
|
||||||
|
EXTRACT(EPOCH FROM SUM(
|
||||||
|
CASE
|
||||||
|
WHEN prev_check IN (2, 4, 254) AND check_in_out IN (1, 3)
|
||||||
|
THEN timestamp - prev_timestamp
|
||||||
|
ELSE INTERVAL '0'
|
||||||
|
END
|
||||||
|
)), 0
|
||||||
|
) AS total_pause
|
||||||
|
|
||||||
|
FROM ordered_bookings
|
||||||
|
GROUP BY work_date
|
||||||
|
ORDER BY work_date;
|
||||||
|
|||||||
Reference in New Issue
Block a user