Compare commits

...

2 Commits

Author SHA1 Message Date
Jaronim Pracht d412d5741b Add Dockerfile for coordinator service and progress controller
Add progress tracking functionality to frontend and backend
- Add progress controller endpoint to handle progress updates
- Implement socket.io progress updates in UploadPage
- Update import path for CircularProgressWithLabel component
2025-06-02 19:09:16 +02:00
Jaronim Pracht 1b06867d88 Fix showing pdfs in production
Removed redundant PDF.js worker initialization from
PDFViewer component and updated the worker source path in main.tsx.

Downgraded react-pdf to v8.0.2 to resolve compatibility issues and
fixed missing newline in nginx.conf.
2025-06-02 19:06:25 +02:00
11 changed files with 285 additions and 250 deletions

View File

@ -0,0 +1,21 @@
# 1. Python-Image verwenden
FROM python:3.11-alpine
# 2. Arbeitsverzeichnis im Container setzen
WORKDIR /app
# 3. production-style server mit gunicorn
RUN pip install gunicorn eventlet
# 4. requirements.txt kopieren und Pakete installieren
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 5. Quellcode kopieren (z.B. app.py)
COPY . .
ENV PYTHONUNBUFFERED=1
EXPOSE 5000
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:5000", "app:app"]

View File

@ -1,9 +1,11 @@
from controller.spacy_contoller import spacy_controller from controller.spacy_contoller import spacy_controller
from controller.kpi_setting_controller import kpi_setting_controller from controller.kpi_setting_controller import kpi_setting_controller
from controller.pitch_book_controller import pitch_book_controller from controller.pitch_book_controller import pitch_book_controller
from controller.progress_controller import progress_controller
def register_routes(app): def register_routes(app):
app.register_blueprint(kpi_setting_controller) app.register_blueprint(kpi_setting_controller)
app.register_blueprint(pitch_book_controller) app.register_blueprint(pitch_book_controller)
app.register_blueprint(spacy_controller) app.register_blueprint(spacy_controller)
app.register_blueprint(progress_controller)

View File

@ -0,0 +1,19 @@
from flask import Blueprint, request, jsonify
from controller.socketIO import socketio
progress_controller = Blueprint("progress", __name__, url_prefix="/api/progress")
@progress_controller.route("/", methods=["POST"])
def progress():
data = request.get_json()
if 'id' not in data or 'progress' not in data:
return jsonify({"error": "Missing required fields. [id, progress]"}), 400
if not isinstance(data['progress'], (int, float)) or data['progress'] < 0 or data['progress'] >= 100:
return jsonify({"error": "Invalid progress value"}), 400
socketio.emit("progress", {"id": data["id"], "progress": data["progress"]})
# Process the data and return a response
return jsonify({"message": "Progress updated"})

View File

@ -19,11 +19,11 @@ services:
coordinator: coordinator:
build: build:
context: backend/coordinator context: backend/coordinator
dockerfile: ../../Dockerfile
env_file: env_file:
- .env - .env
depends_on: depends_on:
- db db:
condition: service_healthy
healthcheck: healthcheck:
test: wget --spider --no-verbose http://127.0.0.1:5000/health || exit 1 test: wget --spider --no-verbose http://127.0.0.1:5000/health || exit 1
interval: 10s interval: 10s

View File

@ -12,7 +12,7 @@
}, },
"formatter": { "formatter": {
"enabled": true, "enabled": true,
"indentStyle": "space" "indentStyle": "tab"
}, },
"organizeImports": { "organizeImports": {
"enabled": true "enabled": true

Binary file not shown.

View File

@ -26,7 +26,7 @@
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-material-file-upload": "^0.0.4", "react-material-file-upload": "^0.0.4",
"react-pdf": "^9.2.1", "react-pdf": "^8.0.2",
"socket.io-client": "^4.8.1" "socket.io-client": "^4.8.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -4,7 +4,7 @@ import { useNavigate } from "@tanstack/react-router";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import FileUpload from "react-material-file-upload"; import FileUpload from "react-material-file-upload";
import { socket } from "../socket"; import { socket } from "../socket";
import { CircularProgressWithLabel } from "./circularProgressWithLabel"; import { CircularProgressWithLabel } from "./CircularProgressWithLabel";
const PROGRESS = false; const PROGRESS = false;

View File

@ -1,20 +1,14 @@
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { Document, Page, pdfjs } from "react-pdf"; import { Document, Page } from "react-pdf";
import "react-pdf/dist/esm/Page/AnnotationLayer.css"; import "react-pdf/dist/esm/Page/AnnotationLayer.css";
import "react-pdf/dist/esm/Page/TextLayer.css"; import "react-pdf/dist/esm/Page/TextLayer.css";
import ArrowCircleLeftIcon from "@mui/icons-material/ArrowCircleLeft"; import ArrowCircleLeftIcon from "@mui/icons-material/ArrowCircleLeft";
import ArrowCircleRightIcon from "@mui/icons-material/ArrowCircleRight"; import ArrowCircleRightIcon from "@mui/icons-material/ArrowCircleRight";
import { Box, IconButton } from "@mui/material"; import { Box, IconButton } from "@mui/material";
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
"pdfjs-dist/build/pdf.worker.min.mjs",
import.meta.url,
).toString();
interface PDFViewerProps { interface PDFViewerProps {
pitchBookId: string; pitchBookId: string;
} }
export default function PDFViewer({ pitchBookId }: PDFViewerProps) { export default function PDFViewer({ pitchBookId }: PDFViewerProps) {
const [numPages, setNumPages] = useState<number | null>(null); const [numPages, setNumPages] = useState<number | null>(null);
const [pageNumber, setPageNumber] = useState(1); const [pageNumber, setPageNumber] = useState(1);

View File

@ -34,9 +34,8 @@ declare module "@tanstack/react-router" {
} }
} }
// Initialize PDF.js worker
pdfjs.GlobalWorkerOptions.workerSrc = new URL( pdfjs.GlobalWorkerOptions.workerSrc = new URL(
"pdfjs-dist/build/pdf.worker.min.mjs", "pdfjs-dist/build/pdf.worker.min.js",
import.meta.url, import.meta.url,
).toString(); ).toString();