Compare commits

...

47 Commits

Author SHA1 Message Date
87dda38bc3 updated user to have a home laufwerk 2025-10-22 21:42:47 +02:00
9de501c7eb changed user creation into debian style 2025-10-22 21:28:48 +02:00
5c6a50ddcf changed alpine production build to debian prod build 2025-10-22 21:22:09 +02:00
017f5fb2e0 copy database files manually 2025-10-22 21:01:46 +02:00
527954befd fix database paht 2025-10-22 20:50:36 +02:00
e7d30151b7 copy database files manually 2025-10-22 20:30:08 +02:00
4a006a2e69 copy database files manually 2025-10-22 20:27:01 +02:00
4b699b05d3 changed production stage from debian to alpine 2025-10-22 20:16:45 +02:00
dcac0307a2 copying no database folder seperate 2025-10-22 20:11:43 +02:00
a0cc859935 Merge branch 'staging' of https://github.com/donpat1to/Schichtenplaner into staging 2025-10-22 20:01:03 +02:00
49afd75ed3 copying database folder seperate 2025-10-22 19:21:13 +02:00
ebb9e3f4fe copying database folder seperate 2025-10-22 19:17:46 +02:00
48f140f930 changed docker.yml only triggering workflow on push 2025-10-22 15:08:52 +02:00
b6b31659e3 changed ecosystem file type as well in Dockerfile 2025-10-22 14:42:25 +02:00
42e343777a changed ecosystem file type as well in Dockerfile 2025-10-22 14:42:01 +02:00
aa7af272d8 moved js file to es module compatible cjs file type 2025-10-22 14:39:15 +02:00
a0d96925c5 added id-token: write 2025-10-22 10:46:15 +02:00
donpat1to
28283fa8bc Update docker.yml 2025-10-22 09:28:41 +02:00
donpat1to
fdff2853bd Update docker.yml 2025-10-22 09:19:37 +02:00
09e08ff615 changed from alpine to debian 2025-10-22 00:54:52 +02:00
fb4a2f6f20 changed from alpine to debian 2025-10-22 00:54:43 +02:00
faaab74f07 added second check python package testing to simple health check 2025-10-22 00:49:34 +02:00
90e10b9cc2 added second check python package testing to simple health check 2025-10-22 00:44:04 +02:00
0821ca7711 changed python package testing to simple health check 2025-10-22 00:38:14 +02:00
02c1253f4f changed python package testing to simple health check 2025-10-22 00:33:00 +02:00
26417aaf88 changed python package testing to simple health check 2025-10-22 00:28:28 +02:00
eb8945ae97 updated python package testing to json format 2025-10-22 00:20:53 +02:00
980cfab637 updated python package testing to json format 2025-10-22 00:14:45 +02:00
accdc70165 changed pyhton package testing to json format 2025-10-22 00:03:58 +02:00
9ac0309917 changed python install to alpine python install 2025-10-21 23:53:12 +02:00
afe5e85add changed pip3 to pip 2025-10-21 23:44:37 +02:00
4689966783 changed to simple python installation 2025-10-21 23:42:11 +02:00
45509b1dbd changed up pyhton installation 2025-10-21 23:36:59 +02:00
590cf2d10f removed python installation for frontend 2025-10-21 23:29:24 +02:00
d43162aff6 removed unvalid paht 2025-10-21 23:24:47 +02:00
fd00c47b20 renamen module exports 2025-10-21 23:12:02 +02:00
3ff51f64eb if jest nono - nono tests 2025-10-21 23:02:11 +02:00
f64fb08566 added jest for tests 2025-10-21 22:57:33 +02:00
5e248c662f added test checks before running tests 2025-10-21 22:50:22 +02:00
b3a3a5680e added handling in case of desynced package.json package-lock.json 2025-10-21 22:42:06 +02:00
364fb41f0e removed dependencie worker_threads native 2025-10-21 22:36:54 +02:00
fb0d0b6711 added ci 2025-10-21 22:31:00 +02:00
eb33f47071 added ci 2025-10-21 22:20:26 +02:00
5809e6c44c fixed role naming instandhalter -> maintenance 2025-10-21 20:23:12 +02:00
2200ef6937 Remove progress_data from tracking 2025-10-21 18:15:40 +02:00
d6e0b45f07 changed gitignore 2025-10-21 18:13:46 +02:00
a45647bd87 changed gitignore 2025-10-21 18:02:12 +02:00
47 changed files with 1664 additions and 960 deletions

170
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,170 @@
name: CI/CD Pipeline
on:
workflow_dispatch:
push:
branches: [ "development", "main", "staging" ]
tags: [ "v*.*.*" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
set-tag:
name: Set Tag Name
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for tags
- name: Determine next semantic version tag
id: set_tag
run: |
git fetch --tags
# Find latest tag matching vX.Y.Z
latest_tag=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
if [[ -z "$latest_tag" ]]; then
major=0
minor=0
patch=0
else
version="${latest_tag#v}"
IFS='.' read -r major minor patch <<< "$version"
fi
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]]; then
major=$((major + 1))
minor=0
patch=0
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
new_tag="v${major}.${minor}.${patch}"
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
echo "Next version tag: ${new_tag}"
test:
runs-on: ubuntu-latest
needs: set-tag
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies
working-directory: ./backend
run: |
# Try npm ci first, if it fails use npm install
npm ci || (echo "package-lock.json out of sync, using npm install..." && npm install)
- name: Run TypeScript check
working-directory: ./backend
run: npx tsc --noEmit
- name: Run backend tests
working-directory: ./backend
run: |
# Skip tests if jest is not installed
if [ -f "node_modules/.bin/jest" ]; then
npm test
else
echo "⚠️ Jest not installed. Skipping tests."
fi
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python dependencies
run: pip install ortools
- name: Test Python integration
run: |
python -c "from ortools.sat.python import cp_model; print('OR-Tools available')"
- name: Display next version
run: |
echo "Next version will be: ${{ needs.set-tag.outputs.tag_name }}"
build-and-push:
needs: [set-tag, test]
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
# Add the dynamically generated semantic version
${{ needs.set-tag.outputs.tag_name }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create Git Tag
if: success()
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag ${{ needs.set-tag.outputs.tag_name }}
git push origin ${{ needs.set-tag.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Display pushed images
run: |
echo "Docker images pushed successfully!"
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "- Tags: ${{ steps.meta.outputs.tags }}"
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"

View File

@@ -1,4 +1,54 @@
# Dependencies
backend/node_modules/
frontend/node_modules/
/.pnp
.pnp.js
# Testing
/coverage
# Production
/build
# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# IDEs
.vscode/
.idea/
*.swp
*.swo
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
----
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
@@ -25,6 +75,9 @@ database/*.db-journal
logs
*.log
# Privat
backend/src/python-scripts/progress_data/*.json
# Runtime data
pids
*.pid

87
Dockerfile Normal file
View File

@@ -0,0 +1,87 @@
# Multi-stage build for combined frontend + backend
FROM node:20-bullseye AS backend-builder
WORKDIR /app/backend
# Install Python + OR-Tools
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
&& pip install --no-cache-dir ortools
# Create symlink so python3 is callable as python
RUN ln -sf /usr/bin/python3 /usr/bin/python
# Copy backend files
COPY backend/package*.json ./
COPY backend/tsconfig.json ./
# Install backend dependencies
RUN npm ci
# Copy backend source
COPY backend/src/ ./src/
# Build backend
RUN npm run build
# Copy database files manually
RUN cp -r src/database/ dist/database/
# Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Frontend build stage
FROM node:20-bullseye AS frontend-builder
WORKDIR /app/frontend
# Copy frontend files
COPY frontend/package*.json ./
COPY frontend/tsconfig.json ./
# Install frontend dependencies
RUN npm ci
# Copy frontend source
COPY frontend/src/ ./src/
COPY frontend/public/ ./public/
# Build frontend
RUN npm run build
# Production stage
FROM node:20-bookworm
WORKDIR /app
# Install PM2 for process management
RUN npm install -g pm2
# Create data directory for SQLite database with proper permissions
RUN mkdir -p /app/data
# Copy backend built files
COPY --from=backend-builder /app/backend/package*.json ./
COPY --from=backend-builder /app/backend/dist/ ./dist/
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
# Copy frontend built files
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
# Copy PM2 configuration
COPY ecosystem.config.cjs ./
# Create a non-root user and group - DEBIAN STYLE
RUN groupadd -g 1001 nodejs && \
useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app && \
chmod 755 /app && \
chmod 775 /app/data
USER schichtplan
EXPOSE 3000 3002
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/api/health || exit 1
CMD ["pm2-runtime", "ecosystem.config.cjs"]

View File

@@ -1,8 +0,0 @@
# backend/Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3002
CMD ["node", "dist/server.js"]

View File

@@ -1,61 +0,0 @@
# Multi-stage Dockerfile for Node.js + Python application
FROM node:20-alpine AS node-base
# Install Python and build dependencies in Node stage
RUN apk add --no-cache \
python3 \
py3-pip \
build-base \
python3-dev
# Install Python dependencies
COPY python-scripts/requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install Node.js dependencies
RUN npm ci --only=production
# Build stage
FROM node-base AS builder
# Install all dependencies (including dev dependencies)
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node-base AS production
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
# Copy Python scripts
COPY --from=builder /app/python-scripts ./python-scripts
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Change to non-root user
USER nextjs
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node dist/health-check.js
# Start the application
CMD ["npm", "start"]

18
backend/jest.config.js Normal file
View File

@@ -0,0 +1,18 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/?(*.)+(spec|test).+(ts|tsx|js)'
],
transform: {
'^.+\.(ts|tsx)$': 'ts-jest',
},
collectCoverageFrom: [
'src/**/*.{js,ts}',
'!src/server.ts',
'!src/**/*.d.ts'
],
};

1044
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,11 @@
"dev": "npm run build && npx tsx src/server.ts",
"build": "tsc",
"start": "node dist/server.js",
"prestart": "npm run build"
"prestart": "npm run build",
"test": "jest",
"test:python": "python -c \"from ortools.sat.python import cp_model; print('OR-Tools OK')\"",
"docker:build": "docker build -t schichtplan-backend .",
"docker:run": "docker run -p 3001:3001 schichtplan-backend"
},
"dependencies": {
"@types/bcrypt": "^6.0.0",
@@ -16,8 +20,7 @@
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"sqlite3": "^5.1.6",
"uuid": "^9.0.0",
"worker_threads": "native"
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.2",
@@ -25,6 +28,7 @@
"@types/express": "^4.17.17",
"@types/jsonwebtoken": "^9.0.2",
"@types/uuid": "^9.0.2",
"@types/jest": "^29.5.0",
"ts-node": "^10.9.0",
"typescript": "^5.0.0",
"tsx": "^4.0.0"

View File

@@ -102,7 +102,6 @@ export const AVAILABILITY_PREFERENCES = {
} as const;
// Default availability for new employees (all shifts unavailable as level 3)
// UPDATED: Now uses shiftId instead of timeSlotId + dayOfWeek
export function createDefaultAvailabilities(employeeId: string, planId: string, shiftIds: string[]): Omit<EmployeeAvailability, 'id'>[] {
const availabilities: Omit<EmployeeAvailability, 'id'>[] = [];
@@ -120,7 +119,6 @@ export function createDefaultAvailabilities(employeeId: string, planId: string,
}
// Create complete manager availability for all days (default: only Mon-Tue available)
// NOTE: This function might need revision based on new schema requirements
export function createManagerDefaultSchedule(managerId: string, planId: string, timeSlotIds: string[]): Omit<ManagerAvailability, 'id'>[] {
const assignments: Omit<ManagerAvailability, 'id'>[] = [];

View File

@@ -1,32 +0,0 @@
{
"timestamp": "2025-10-21T11:16:11.693081",
"success": true,
"metadata": {
"solveTime": 0.0218085,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.00886988639831543,
"objective": 1050.0,
"bound": 2100.0,
"solution_count": 1
},
{
"timestamp": 0.009304285049438477,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 2
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.0218085,
"optimal": true
}
}

View File

@@ -1,38 +0,0 @@
{
"timestamp": "2025-10-21T11:16:16.813066",
"success": true,
"metadata": {
"solveTime": 0.0158702,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.008541107177734375,
"objective": 1050.0,
"bound": 2000.0,
"solution_count": 1
},
{
"timestamp": 0.00941777229309082,
"objective": 1250.0,
"bound": 1300.0,
"solution_count": 2
},
{
"timestamp": 0.009499549865722656,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 3
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.0158702,
"optimal": true
}
}

View File

@@ -1,38 +0,0 @@
{
"timestamp": "2025-10-21T14:34:06.393151",
"success": true,
"metadata": {
"solveTime": 0.046477700000000004,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.04335761070251465,
"objective": 1050.0,
"bound": 2100.0,
"solution_count": 1
},
{
"timestamp": 0.04459857940673828,
"objective": 1250.0,
"bound": 1700.0,
"solution_count": 2
},
{
"timestamp": 0.04603719711303711,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 3
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.046477700000000004,
"optimal": true
}
}

View File

@@ -1,44 +0,0 @@
{
"timestamp": "2025-10-21T14:37:10.936471",
"success": true,
"metadata": {
"solveTime": 0.022602300000000002,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.008664369583129883,
"objective": 1050.0,
"bound": 1300.0,
"solution_count": 1
},
{
"timestamp": 0.008890628814697266,
"objective": 1150.0,
"bound": 1300.0,
"solution_count": 2
},
{
"timestamp": 0.009119987487792969,
"objective": 1250.0,
"bound": 1300.0,
"solution_count": 3
},
{
"timestamp": 0.009514808654785156,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 4
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.022602300000000002,
"optimal": true
}
}

View File

@@ -1,38 +0,0 @@
{
"timestamp": "2025-10-21T14:38:04.517181",
"success": true,
"metadata": {
"solveTime": 0.017061200000000002,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.008075952529907227,
"objective": 1000.0,
"bound": 1300.0,
"solution_count": 1
},
{
"timestamp": 0.008380889892578125,
"objective": 1200.0,
"bound": 1300.0,
"solution_count": 2
},
{
"timestamp": 0.008938789367675781,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 3
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.017061200000000002,
"optimal": true
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T14:40:00.354343",
"success": false,
"metadata": {
"solveTime": 0.0013928,
"constraintsAdded": 248,
"variablesCreated": 99,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 248,
"solve_time": 0.0013928,
"optimal": false
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T14:43:01.616117",
"success": false,
"metadata": {
"solveTime": 0.0009529,
"constraintsAdded": 230,
"variablesCreated": 99,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 230,
"solve_time": 0.0009529,
"optimal": false
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T14:43:40.972769",
"success": false,
"metadata": {
"solveTime": 0.0009025000000000001,
"constraintsAdded": 230,
"variablesCreated": 99,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 230,
"solve_time": 0.0009025000000000001,
"optimal": false
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T15:15:30.967943",
"success": false,
"metadata": {
"solveTime": 0.0009660000000000001,
"constraintsAdded": 230,
"variablesCreated": 99,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 230,
"solve_time": 0.0009660000000000001,
"optimal": false
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T15:15:39.908329",
"success": false,
"metadata": {
"solveTime": 0.0009183,
"constraintsAdded": 230,
"variablesCreated": 99,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 230,
"solve_time": 0.0009183,
"optimal": false
}
}

View File

@@ -1,56 +0,0 @@
{
"timestamp": "2025-10-21T15:17:28.688727",
"success": true,
"metadata": {
"solveTime": 0.0175048,
"constraintsAdded": 230,
"variablesCreated": 99,
"optimal": true
},
"progress": [
{
"timestamp": 0.0076940059661865234,
"objective": 1150.0,
"bound": 2650.0,
"solution_count": 1
},
{
"timestamp": 0.008573293685913086,
"objective": 1200.0,
"bound": 1400.0,
"solution_count": 2
},
{
"timestamp": 0.00871133804321289,
"objective": 1250.0,
"bound": 1400.0,
"solution_count": 3
},
{
"timestamp": 0.008805990219116211,
"objective": 1300.0,
"bound": 1400.0,
"solution_count": 4
},
{
"timestamp": 0.00890493392944336,
"objective": 1350.0,
"bound": 1400.0,
"solution_count": 5
},
{
"timestamp": 0.009298324584960938,
"objective": 1400.0,
"bound": 1400.0,
"solution_count": 6
}
],
"solution_summary": {
"assignments_count": 16,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 230,
"solve_time": 0.0175048,
"optimal": true
}
}

View File

@@ -1,56 +0,0 @@
{
"timestamp": "2025-10-21T15:19:19.785803",
"success": true,
"metadata": {
"solveTime": 0.014216000000000001,
"constraintsAdded": 228,
"variablesCreated": 99,
"optimal": true
},
"progress": [
{
"timestamp": 0.008774042129516602,
"objective": 1200.0,
"bound": 2850.0,
"solution_count": 1
},
{
"timestamp": 0.009451627731323242,
"objective": 1250.0,
"bound": 1450.0,
"solution_count": 2
},
{
"timestamp": 0.009568452835083008,
"objective": 1300.0,
"bound": 1450.0,
"solution_count": 3
},
{
"timestamp": 0.009636402130126953,
"objective": 1350.0,
"bound": 1450.0,
"solution_count": 4
},
{
"timestamp": 0.009870052337646484,
"objective": 1400.0,
"bound": 1450.0,
"solution_count": 5
},
{
"timestamp": 0.009946584701538086,
"objective": 1450.0,
"bound": 1450.0,
"solution_count": 6
}
],
"solution_summary": {
"assignments_count": 17,
"violations_count": 0,
"variables_count": 99,
"constraints_count": 228,
"solve_time": 0.014216000000000001,
"optimal": true
}
}

View File

@@ -1,32 +0,0 @@
{
"timestamp": "2025-10-21T16:58:13.438358",
"success": true,
"metadata": {
"solveTime": 0.012495000000000001,
"constraintsAdded": 218,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.008534908294677734,
"objective": 1050.0,
"bound": 2100.0,
"solution_count": 1
},
{
"timestamp": 0.009073495864868164,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 2
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 218,
"solve_time": 0.012495000000000001,
"optimal": true
}
}

View File

@@ -1,32 +0,0 @@
{
"timestamp": "2025-10-21T16:58:37.184763",
"success": true,
"metadata": {
"solveTime": 0.0245485,
"constraintsAdded": 218,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.009514808654785156,
"objective": 1050.0,
"bound": 2100.0,
"solution_count": 1
},
{
"timestamp": 0.010115385055541992,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 2
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 218,
"solve_time": 0.0245485,
"optimal": true
}
}

View File

@@ -1,32 +0,0 @@
{
"timestamp": "2025-10-21T10:54:26.093544",
"success": false,
"metadata": {
"solveTime": 0,
"constraintsAdded": 0,
"variablesCreated": 0,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 1,
"variables_count": 0,
"constraints_count": 0,
"solve_time": 0,
"optimal": false
},
"full_result": {
"assignments": [],
"violations": [
"Error: 'SolutionCallback' object has no attribute 'HasObjective'"
],
"success": false,
"metadata": {
"solveTime": 0,
"constraintsAdded": 0,
"variablesCreated": 0,
"optimal": false
}
}
}

View File

@@ -1,19 +0,0 @@
{
"timestamp": "2025-10-21T10:59:36.646855",
"success": false,
"metadata": {
"solveTime": 0,
"constraintsAdded": 0,
"variablesCreated": 0,
"optimal": false
},
"progress": [],
"solution_summary": {
"assignments_count": 0,
"violations_count": 1,
"variables_count": 0,
"constraints_count": 0,
"solve_time": 0,
"optimal": false
}
}

View File

@@ -1,38 +0,0 @@
{
"timestamp": "2025-10-21T11:03:36.697986",
"success": true,
"metadata": {
"solveTime": 0.025875500000000003,
"constraintsAdded": 217,
"variablesCreated": 90,
"optimal": true
},
"progress": [
{
"timestamp": 0.008769989013671875,
"objective": 1050.0,
"bound": 2000.0,
"solution_count": 1
},
{
"timestamp": 0.009685516357421875,
"objective": 1250.0,
"bound": 1700.0,
"solution_count": 2
},
{
"timestamp": 0.010709047317504883,
"objective": 1300.0,
"bound": 1300.0,
"solution_count": 3
}
],
"solution_summary": {
"assignments_count": 15,
"violations_count": 0,
"variables_count": 90,
"constraints_count": 217,
"solve_time": 0.025875500000000003,
"optimal": true
}
}

View File

@@ -20,9 +20,9 @@ router.use(authMiddleware);
// Employee CRUD Routes
router.get('/', authMiddleware, getEmployees);
router.get('/:id', requireRole(['admin', 'instandhalter']), getEmployee);
router.get('/:id', requireRole(['admin', 'maintenance']), getEmployee);
router.post('/', requireRole(['admin']), createEmployee);
router.put('/:id', requireRole(['admin']), updateEmployee);
router.put('/:id', requireRole(['admin', 'maintenance']), updateEmployee);
router.delete('/:id', requireRole(['admin']), deleteEmployee);
router.put('/:id/password', authMiddleware, changePassword);
router.put('/:id/last-login', authMiddleware, updateLastLogin);

View File

@@ -14,9 +14,9 @@ const router = express.Router();
router.use(authMiddleware);
router.post('/:id/generate-shifts', requireRole(['admin', 'instandhalter']), generateScheduledShiftsForPlan);
router.post('/:id/generate-shifts', requireRole(['admin', 'maintenance']), generateScheduledShiftsForPlan);
router.post('/:id/regenerate-shifts', requireRole(['admin', 'instandhalter']), regenerateScheduledShifts);
router.post('/:id/regenerate-shifts', requireRole(['admin', 'maintenance']), regenerateScheduledShifts);
// GET all scheduled shifts for a plan
router.get('/plan/:planId', authMiddleware, getScheduledShiftsFromPlan);

View File

@@ -24,18 +24,18 @@ router.get('/' , authMiddleware, getShiftPlans);
router.get('/:id', authMiddleware, getShiftPlan);
// POST create new shift plan
router.post('/', requireRole(['admin', 'instandhalter']), createShiftPlan);
router.post('/', requireRole(['admin', 'maintenance']), createShiftPlan);
// POST create new plan from preset
router.post('/from-preset', requireRole(['admin', 'instandhalter']), createFromPreset);
router.post('/from-preset', requireRole(['admin', 'maintenance']), createFromPreset);
// PUT update shift plan or template
router.put('/:id', requireRole(['admin', 'instandhalter']), updateShiftPlan);
router.put('/:id', requireRole(['admin', 'maintenance']), updateShiftPlan);
// DELETE shift plan or template
router.delete('/:id', requireRole(['admin', 'instandhalter']), deleteShiftPlan);
router.delete('/:id', requireRole(['admin', 'maintenance']), deleteShiftPlan);
// POST clear assignments and reset to draft
router.post('/:id/clear-assignments', requireRole(['admin', 'instandhalter']), clearAssignments);
router.post('/:id/clear-assignments', requireRole(['admin', 'maintenance']), clearAssignments);
export default router;

View File

@@ -0,0 +1,27 @@
import { spawn } from 'child_process';
import path from 'path';
export function runPythonScript(scriptPath, args = []) {
return new Promise((resolve, reject) => {
const pythonProcess = spawn('python', [scriptPath, ...args]);
let stdout = '';
let stderr = '';
pythonProcess.stdout.on('data', (data) => {
stdout += data.toString();
});
pythonProcess.stderr.on('data', (data) => {
stderr += data.toString();
});
pythonProcess.on('close', (code) => {
if (code === 0) {
resolve(stdout);
} else {
reject(new Error(`Python script exited with code ${code}: ${stderr}`));
}
});
});
}

View File

@@ -1,10 +1,18 @@
import sqlite3 from 'sqlite3';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dbPath = path.join(__dirname, '../../database/schichtplan.db');
const dbPath = process.env.DB_PATH || '/app/data/schichtplan.db';
// Stelle sicher, dass das Verzeichnis existiert
const dbDir = path.dirname(dbPath);
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir, { recursive: true });
}
class Database {
private db: sqlite3.Database;

View File

@@ -1,18 +1,26 @@
version: '3.8'
services:
frontend:
build: ./frontend
ports:
- "80:80"
depends_on:
- backend
backend:
build: ./backend
services:
schichtplan:
build:
context: .
dockerfile: backend/Dockerfile
ports:
- "3001:3001"
- "3000:3000"
environment:
- DATABASE_URL=file:./dev.db
- JWT_SECRET=your-secret-key
- NODE_ENV=production
- DATABASE_URL=file:./prod.db
- JWT_SECRET=your-production-secret-key-change-this
- PYTHON_PATH=/usr/bin/python3
volumes:
- app_data:/app/data
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 30s
timeout: 10s
retries: 3
# Später: Database service hinzufügen
volumes:
app_data:

31
ecosystem.config.cjs Normal file
View File

@@ -0,0 +1,31 @@
// ecosystem.config.cjs
module.exports = {
apps: [
{
name: 'backend',
script: './dist/server.js',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
PORT: 3002
},
error_file: './logs/backend-err.log',
out_file: './logs/backend-out.log',
time: true
},
{
name: 'frontend',
script: 'npx',
args: 'serve -s frontend-build -l 3000',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production'
},
error_file: './logs/frontend-err.log',
out_file: './logs/frontend-out.log',
time: true
}
]
};

45
frontend/.gitignore vendored
View File

@@ -1,45 +0,0 @@
# Dependencies
node_modules/
/.pnp
.pnp.js
# Testing
/coverage
# Production
/build
# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# IDEs
.vscode/
.idea/
*.swp
*.swo
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

View File

@@ -1,8 +0,0 @@
# backend/Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3001
CMD ["node", "dist/server.js"]

View File

@@ -17,8 +17,7 @@
"react-router-dom": "^7.9.3",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4",
"worker_threads": "native"
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",

View File

@@ -19,7 +19,7 @@ import Setup from './pages/Setup/Setup';
// Protected Route Component
const ProtectedRoute: React.FC<{ children: React.ReactNode; roles?: string[] }> = ({
children,
roles = ['admin', 'instandhalter', 'user']
roles = ['admin', 'maintenance', 'user']
}) => {
const { user, loading, hasRole } = useAuth();
@@ -91,12 +91,12 @@ const AppContent: React.FC = () => {
</ProtectedRoute>
} />
<Route path="/shift-plans/new" element={
<ProtectedRoute roles={['admin', 'instandhalter']}>
<ProtectedRoute roles={['admin', 'maintenance']}>
<ShiftPlanCreate />
</ProtectedRoute>
} />
<Route path="/shift-plans/:id/edit" element={
<ProtectedRoute roles={['admin', 'instandhalter']}>
<ProtectedRoute roles={['admin', 'maintenance']}>
<ShiftPlanEdit />
</ProtectedRoute>
} />
@@ -106,7 +106,7 @@ const AppContent: React.FC = () => {
</ProtectedRoute>
} />
<Route path="/employees" element={
<ProtectedRoute roles={['admin', 'instandhalter']}>
<ProtectedRoute roles={['admin', 'maintenance']}>
<EmployeeManagement />
</ProtectedRoute>
} />

View File

@@ -30,11 +30,11 @@ const Navigation: React.FC = () => {
};
const navigationItems = [
{ path: '/', label: 'Dashboard', roles: ['admin', 'instandhalter', 'user'] },
{ path: '/shift-plans', label: 'Schichtpläne', roles: ['admin', 'instandhalter', 'user'] },
{ path: '/employees', label: 'Mitarbeiter', roles: ['admin', 'instandhalter'] },
{ path: '/help', label: 'Hilfe', roles: ['admin', 'instandhalter', 'user'] },
{ path: '/settings', label: 'Einstellungen', roles: ['admin', 'instandhalter', 'user'] },
{ path: '/', label: 'Dashboard', roles: ['admin', 'maintenance', 'user'] },
{ path: '/shift-plans', label: 'Schichtpläne', roles: ['admin', 'maintenance', 'user'] },
{ path: '/employees', label: 'Mitarbeiter', roles: ['admin', 'maintenance'] },
{ path: '/help', label: 'Hilfe', roles: ['admin', 'maintenance', 'user'] },
{ path: '/settings', label: 'Einstellungen', roles: ['admin', 'maintenance', 'user'] },
];
const filteredNavigation = navigationItems.filter(item =>

View File

@@ -393,7 +393,7 @@ const Dashboard: React.FC = () => {
</div>
{/* Quick Actions - Nur für Admins/Instandhalter */}
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<div style={{ marginBottom: '30px' }}>
<h2 style={{ marginBottom: '15px', color: '#2c3e50' }}>Schnellaktionen</h2>
<div style={{
@@ -535,7 +535,7 @@ const Dashboard: React.FC = () => {
<div style={{ textAlign: 'center', padding: '20px', color: '#666' }}>
<div style={{ fontSize: '48px', marginBottom: '10px' }}>📅</div>
<div>Kein aktiver Schichtplan</div>
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<Link to="/shift-plans/new">
<button style={{
marginTop: '10px',
@@ -643,7 +643,7 @@ const Dashboard: React.FC = () => {
)}
{/* Letzte Schichtpläne (für Admins/Instandhalter) */}
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<div style={{
backgroundColor: 'white',
padding: '20px',

View File

@@ -588,6 +588,31 @@ const AvailabilityManager: React.FC<AvailabilityManagerProps> = ({
return;
}
// Contract type validation
const availableShifts = validAvailabilities.filter(avail =>
avail.preferenceLevel === 1 || avail.preferenceLevel === 2
).length;
let contractRequirement = 0;
let contractTypeName = '';
if (employee.contractType === 'small') {
contractRequirement = 2;
contractTypeName = 'Kleiner Vertrag';
} else if (employee.contractType === 'large') {
contractRequirement = 3;
contractTypeName = 'Großer Vertrag';
}
if (contractRequirement > 0 && availableShifts < contractRequirement) {
setError(
`${contractTypeName} erfordert mindestens ${contractRequirement} verfügbare Shifts. ` +
`Aktuell sind nur ${availableShifts} Shifts mit Verfügbarkeit "Bevorzugt" oder "Möglich" ausgewählt.`
);
setSaving(false);
return;
}
// Convert to the format expected by the API - using shiftId directly
const requestData = {
planId: selectedPlanId,
@@ -633,6 +658,12 @@ const AvailabilityManager: React.FC<AvailabilityManagerProps> = ({
// Get full name for display
const employeeFullName = `${employee.firstname} ${employee.lastname}`;
// Mininmum amount of shifts per contract type
const availableShiftsCount = availabilities.filter(avail =>
avail.preferenceLevel === 1 || avail.preferenceLevel === 2
).length;
return (
<div style={{
maxWidth: '1900px',
@@ -660,6 +691,14 @@ const AvailabilityManager: React.FC<AvailabilityManagerProps> = ({
<p style={{ margin: 0, color: '#7f8c8d' }}>
<strong>Email:</strong> {employee.email}
</p>
{employee.contractType && (
<p style={{ margin: '5px 0 0 0', color: employee.contractType === 'small' ? '#f39c12' : '#27ae60' }}>
<strong>Vertrag:</strong>
{employee.contractType === 'small' ? ' Kleiner Vertrag (min. 2 verfügbare Shifts)' :
employee.contractType === 'large' ? ' Großer Vertrag (min. 3 verfügbare Shifts)' :
' Flexibler Vertrag'}
</p>
)}
</div>
{error && (
@@ -816,7 +855,7 @@ const AvailabilityManager: React.FC<AvailabilityManagerProps> = ({
fontWeight: 'bold'
}}
>
{saving ? '⏳ Wird gespeichert...' : 'Verfügbarkeiten speichern'}
{saving ? '⏳ Wird gespeichert...' : `Verfügbarkeiten speichern (${availableShiftsCount})`}
</button>
</div>
</div>

View File

@@ -99,21 +99,26 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
if (checked) {
return {
...prev,
roles: [...prev.roles, role]
roles: [role]
};
} else {
return {
const newRoles = prev.roles.filter(r => r !== role);
return{
...prev,
roles: prev.roles.filter(r => r !== role)
roles: newRoles.length > 0 ? newRoles : ['user']
};
}
});
};
const handleEmployeeTypeChange = (employeeType: EmployeeType) => {
// Determine if contract type should be shown and set default
const requiresContract = employeeType !== 'guest';
const defaultContractType = requiresContract ? 'small' as ContractType : undefined;
// Determine contract type based on employee type
let contractType: ContractType | undefined;
if (employeeType === 'manager' || employeeType === 'apprentice') {
contractType = 'flexible';
} else if (employeeType !== 'guest') {
contractType = 'small';
}
// Determine if can work alone based on employee type
const canWorkAlone = employeeType === 'manager' ||
@@ -125,7 +130,7 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
setFormData(prev => ({
...prev,
employeeType,
contractType: defaultContractType,
contractType,
canWorkAlone,
isTrainee
}));
@@ -273,7 +278,7 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
onChange={handleChange}
required
style={{
width: '100%',
width: '94%',
padding: '10px',
border: '1px solid #ddd',
borderRadius: '4px',
@@ -294,7 +299,7 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
onChange={handleChange}
required
style={{
width: '100%',
width: '94%',
padding: '10px',
border: '1px solid #ddd',
borderRadius: '4px',
@@ -311,7 +316,7 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
E-Mail Adresse (automatisch generiert)
</label>
<div style={{
width: '100%',
width: '97%',
padding: '10px',
border: '1px solid #ddd',
borderRadius: '4px',
@@ -340,7 +345,7 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
required
minLength={6}
style={{
width: '100%',
width: '97%',
padding: '10px',
border: '1px solid #ddd',
borderRadius: '4px',
@@ -355,78 +360,6 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
)}
</div>
{/* Vertragstyp (nur für Admins und interne Mitarbeiter) */}
{hasRole(['admin']) && showContractType && (
<div style={{
padding: '20px',
backgroundColor: '#e8f4fd',
borderRadius: '8px',
border: '1px solid #b6d7e8'
}}>
<h3 style={{ margin: '0 0 15px 0', color: '#0c5460' }}>📝 Vertragstyp</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{contractTypeOptions.map(contract => (
<div
key={contract.value}
style={{
display: 'flex',
alignItems: 'flex-start',
padding: '15px',
border: `2px solid ${formData.contractType === contract.value ? '#3498db' : '#e0e0e0'}`,
borderRadius: '8px',
backgroundColor: formData.contractType === contract.value ? '#f0f8ff' : 'white',
cursor: 'pointer',
transition: 'all 0.2s'
}}
onClick={() => handleContractTypeChange(contract.value)}
>
<input
type="radio"
name="contractType"
value={contract.value}
checked={formData.contractType === contract.value}
onChange={() => handleContractTypeChange(contract.value)}
style={{
marginRight: '12px',
marginTop: '2px',
width: '18px',
height: '18px'
}}
/>
<div style={{ flex: 1 }}>
<div style={{
fontWeight: 'bold',
color: '#2c3e50',
marginBottom: '4px',
fontSize: '16px'
}}>
{contract.label}
</div>
<div style={{
fontSize: '14px',
color: '#7f8c8d',
lineHeight: '1.4'
}}>
{contract.description}
</div>
</div>
<div style={{
padding: '6px 12px',
backgroundColor: formData.contractType === contract.value ? '#3498db' : '#95a5a6',
color: 'white',
borderRadius: '15px',
fontSize: '12px',
fontWeight: 'bold'
}}>
{contract.value.toUpperCase()}
</div>
</div>
))}
</div>
</div>
)}
{/* Mitarbeiter Kategorie */}
<div style={{
padding: '20px',
@@ -528,6 +461,107 @@ const EmployeeForm: React.FC<EmployeeFormProps> = ({
)}
</div>
{/* Vertragstyp (nur für Admins und interne Mitarbeiter) */}
{hasRole(['admin']) && showContractType && (
<div style={{
padding: '20px',
backgroundColor: '#e8f4fd',
borderRadius: '8px',
border: '1px solid #b6d7e8'
}}>
<h3 style={{ margin: '0 0 15px 0', color: '#0c5460' }}>📝 Vertragstyp</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{contractTypeOptions.map(contract => {
const isFlexibleDisabled = contract.value === 'flexible' && formData.employeeType === 'personell';
const isSmallLargeDisabled = (contract.value === 'small' || contract.value === 'large') &&
(formData.employeeType === 'manager' || formData.employeeType === 'apprentice');
const isDisabled = isFlexibleDisabled || isSmallLargeDisabled;
return (
<div
key={contract.value}
style={{
display: 'flex',
alignItems: 'flex-start',
padding: '15px',
border: `2px solid ${formData.contractType === contract.value ? '#3498db' : '#e0e0e0'}`,
borderRadius: '8px',
backgroundColor: formData.contractType === contract.value ? '#f0f8ff' : 'white',
cursor: isDisabled ? 'not-allowed' : 'pointer',
transition: 'all 0.2s',
opacity: isDisabled ? 0.6 : 1
}}
onClick={isDisabled ? undefined : () => handleContractTypeChange(contract.value)}
>
<input
type="radio"
name="contractType"
value={contract.value}
checked={formData.contractType === contract.value}
onChange={isDisabled ? undefined : () => handleContractTypeChange(contract.value)}
disabled={isDisabled}
style={{
marginRight: '12px',
marginTop: '2px',
width: '18px',
height: '18px'
}}
/>
<div style={{ flex: 1 }}>
<div style={{
fontWeight: 'bold',
color: '#2c3e50',
marginBottom: '4px',
fontSize: '16px'
}}>
{contract.label}
{isFlexibleDisabled && (
<span style={{
fontSize: '12px',
color: '#e74c3c',
marginLeft: '8px',
fontWeight: 'normal'
}}>
(Nicht verfügbar für Personell)
</span>
)}
{isSmallLargeDisabled && (
<span style={{
fontSize: '12px',
color: '#e74c3c',
marginLeft: '8px',
fontWeight: 'normal'
}}>
(Nicht verfügbar für {formData.employeeType === 'manager' ? 'Manager' : 'Auszubildende'})
</span>
)}
</div>
<div style={{
fontSize: '14px',
color: '#7f8c8d',
lineHeight: '1.4'
}}>
{contract.description}
</div>
</div>
<div style={{
padding: '6px 12px',
backgroundColor: isDisabled ? '#95a5a6' : (formData.contractType === contract.value ? '#3498db' : '#95a5a6'),
color: 'white',
borderRadius: '15px',
fontSize: '12px',
fontWeight: 'bold'
}}>
{contract.value.toUpperCase()}
</div>
</div>
);
})}
</div>
</div>
)}
{/* Eigenständigkeit */}
<div style={{
padding: '20px',

View File

@@ -48,6 +48,13 @@ const EmployeeList: React.FC<EmployeeListProps> = ({
return true;
});
// Helper to get highest role for sorting
const getHighestRole = (roles: string[]): string => {
if (roles.includes('admin')) return 'admin';
if (roles.includes('maintenance')) return 'maintenance';
return 'user';
};
// Sort employees based on selected field and direction
const sortedEmployees = [...filteredEmployees].sort((a, b) => {
let aValue: any;
@@ -67,7 +74,6 @@ const EmployeeList: React.FC<EmployeeListProps> = ({
bValue = b.canWorkAlone;
break;
case 'role':
// Use the highest role for sorting
aValue = getHighestRole(a.roles || []);
bValue = getHighestRole(b.roles || []);
break;
@@ -87,13 +93,6 @@ const EmployeeList: React.FC<EmployeeListProps> = ({
}
});
// Helper to get highest role for sorting
const getHighestRole = (roles: string[]): string => {
if (roles.includes('admin')) return 'admin';
if (roles.includes('maintenance')) return 'maintenance';
return 'user';
};
const handleSort = (field: SortField) => {
if (sortField === field) {
// Toggle direction if same field

View File

@@ -80,134 +80,6 @@ const Help: React.FC = () => {
<div style={{ padding: '20px', maxWidth: '1200px', margin: '0 auto' }}>
<h1> Hilfe & Support - Scheduling Algorithmus</h1>
{/* Algorithm Visualization */}
<div style={{
backgroundColor: 'white',
borderRadius: '12px',
padding: '30px',
marginTop: '20px',
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
border: '1px solid #e0e0e0'
}}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '20px' }}>
<h2 style={{ margin: 0, color: '#2c3e50' }}>🧠 Algorithmus Visualisierung</h2>
<button
onClick={toggleAnimation}
style={{
padding: '8px 16px',
backgroundColor: isAnimating ? '#e74c3c' : '#2ecc71',
color: 'white',
border: 'none',
borderRadius: '20px',
cursor: 'pointer',
fontWeight: 'bold'
}}
>
{isAnimating ? '⏸️ Animation pausieren' : '▶️ Animation starten'}
</button>
</div>
{/* Stage Indicators */}
<div style={{
display: 'flex',
justifyContent: 'space-between',
marginBottom: '30px',
position: 'relative'
}}>
{algorithmStages.map((stage, index) => (
<React.Fragment key={index}>
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
flex: 1
}}
>
<div
style={{
width: '60px',
height: '60px',
borderRadius: '50%',
backgroundColor: currentStage === index ? stage.color : '#ecf0f1',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: currentStage === index ? 'white' : '#7f8c8d',
fontWeight: 'bold',
fontSize: '18px',
transition: 'all 0.5s ease',
boxShadow: currentStage === index ? `0 0 20px ${stage.color}80` : 'none',
border: `3px solid ${stage.color}`
}}
>
{index + 1}
</div>
<div style={{
textAlign: 'center',
marginTop: '10px',
fontWeight: currentStage === index ? 'bold' : 'normal',
color: currentStage === index ? stage.color : '#7f8c8d'
}}>
{stage.title.split(':')[0]}
</div>
</div>
{index < algorithmStages.length - 1 && (
<div style={{
flex: 1,
height: '3px',
backgroundColor: currentStage > index ? stage.color : '#ecf0f1',
alignSelf: 'center',
margin: '0 10px',
transition: 'all 0.5s ease'
}} />
)}
</React.Fragment>
))}
</div>
{/* Current Stage Details */}
<div style={{
backgroundColor: algorithmStages[currentStage].color + '15',
border: `2px solid ${algorithmStages[currentStage].color}30`,
borderRadius: '8px',
padding: '20px',
marginBottom: '20px',
transition: 'all 0.5s ease'
}}>
<h3 style={{ color: algorithmStages[currentStage].color, marginTop: 0 }}>
{algorithmStages[currentStage].title}
</h3>
<p style={{ color: '#2c3e50', fontSize: '16px', marginBottom: '15px' }}>
{algorithmStages[currentStage].description}
</p>
<div style={{ display: 'grid', gap: '8px' }}>
{algorithmStages[currentStage].steps.map((step, stepIndex) => (
<div
key={stepIndex}
style={{
padding: '10px 15px',
backgroundColor: 'white',
borderRadius: '6px',
borderLeft: `4px solid ${algorithmStages[currentStage].color}`,
display: 'flex',
alignItems: 'center',
animation: isAnimating ? 'pulse 2s infinite' : 'none'
}}
>
<span style={{
marginRight: '10px',
color: algorithmStages[currentStage].color,
fontWeight: 'bold'
}}></span>
{step}
</div>
))}
</div>
</div>
</div>
{/* Business Rules */}
<div style={{
backgroundColor: 'white',
@@ -271,24 +143,7 @@ const Help: React.FC = () => {
<h4 style={{ color: '#3498db' }}>🏗 Phasen-basierter Ansatz</h4>
<p>Der Algorithmus arbeitet in klar definierten Phasen, um komplexe Probleme schrittweise zu lösen und Stabilität zu gewährleisten.</p>
</div>
<div>
<h4 style={{ color: '#e74c3c' }}> Wert-basierte Entscheidungen</h4>
<p>Jede Zuweisung wird anhand eines Wertesystems bewertet, das Verfügbarkeit, Erfahrung und aktuelle Auslastung berücksichtigt.</p>
</div>
<div>
<h4 style={{ color: '#2ecc71' }}>🔧 Automatische Reparatur</h4>
<p>Probleme werden automatisch erkannt und durch intelligente Tausch- und Bewegungsoperationen behoben.</p>
</div>
<div>
<h4 style={{ color: '#f39c12' }}>📊 Transparente Berichterstattung</h4>
<p>Detaillierte Berichte zeigen genau, welche Probleme behoben wurden und welche verbleiben.</p>
</div>
</div>
</div>
<div style={{

View File

@@ -74,7 +74,7 @@
border: '1px solid rgba(255, 255, 255, 0.8)',
boxShadow: '0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04)',
backdropFilter: 'blur(10px)',
minHeight: '200px',
minHeight: '100px',
},
section: {
marginBottom: '2rem',

View File

@@ -70,7 +70,7 @@ const ShiftPlanList: React.FC = () => {
marginBottom: '30px'
}}>
<h1>📅 Schichtpläne</h1>
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<Link to="/shift-plans/new">
<button style={{
padding: '10px 20px',
@@ -143,7 +143,7 @@ const ShiftPlanList: React.FC = () => {
>
Anzeigen
</button>
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<>
<button
onClick={() => navigate(`/shift-plans/${plan.id}/edit`)}

View File

@@ -1005,7 +1005,7 @@ const ShiftPlanView: React.FC = () => {
</div>
</div>
<div style={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
{shiftPlan.status === 'published' && hasRole(['admin', 'instandhalter']) && (
{shiftPlan.status === 'published' && hasRole(['admin', 'maintenance']) && (
<button
onClick={handleRecreateAssignments}
disabled={recreating}
@@ -1076,7 +1076,7 @@ const ShiftPlanView: React.FC = () => {
</div>
</div>
{hasRole(['admin', 'instandhalter']) && (
{hasRole(['admin', 'maintenance']) && (
<div>
<button
onClick={handlePreviewAssignment}

6
package-lock.json generated Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Schichtenplaner",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}