From 29730fa880c59911d71669fdc63eaec8f9677ac4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 11 Mar 2025 11:03:10 +0100 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Backend-internes=20Frontend=20f?= =?UTF-8?q?=C3=BCr=20API-=20und=20Druckertests=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implementiere eine Weboberfläche zur Verwaltung von Druckern, Druckaufträgen und Benutzern mit folgenden Funktionen: - Login/Registrierungsseiten - Dashboard mit Überblick - Drucker-Verwaltung (Hinzufügen, Bearbeiten, Löschen) - Auftrags-Verwaltung (Erstellen, Abbrechen, Verlängern) - Benutzer-Verwaltung (nur Admin) - Statistik-Dashboard 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/app.py | 62 +++++- backend/templates/base.html | 169 +++++++++++++++ backend/templates/dashboard.html | 68 ++++++ backend/templates/jobs.html | 346 +++++++++++++++++++++++++++++++ backend/templates/login.html | 37 ++++ backend/templates/printers.html | 248 ++++++++++++++++++++++ backend/templates/register.html | 45 ++++ backend/templates/stats.html | 137 ++++++++++++ backend/templates/users.html | 238 +++++++++++++++++++++ 9 files changed, 1349 insertions(+), 1 deletion(-) mode change 100644 => 100755 backend/app.py create mode 100644 backend/templates/base.html create mode 100644 backend/templates/dashboard.html create mode 100644 backend/templates/jobs.html create mode 100644 backend/templates/login.html create mode 100644 backend/templates/printers.html create mode 100644 backend/templates/register.html create mode 100644 backend/templates/stats.html create mode 100644 backend/templates/users.html diff --git a/backend/app.py b/backend/app.py old mode 100644 new mode 100755 index 56a02af..52b8f1e --- a/backend/app.py +++ b/backend/app.py @@ -1,4 +1,4 @@ -from flask import Flask, request, jsonify, g, redirect, url_for, session as flask_session +from flask import Flask, request, jsonify, g, redirect, url_for, session as flask_session, render_template, flash from flask_cors import CORS from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate @@ -725,6 +725,66 @@ def server_error(error): app.logger.error(f'Serverfehler: {error}') return jsonify({'message': 'Interner Serverfehler!'}), 500 +# Web UI Routen +@app.route('/') +def index(): + current_user = get_current_user() + if current_user: + return render_template('dashboard.html', current_user=current_user, active_page='home') + return redirect(url_for('login_page')) + +@app.route('/login') +def login_page(): + return render_template('login.html', active_page='login') + +@app.route('/register') +def register_page(): + return render_template('register.html', active_page='register') + +@app.route('/logout') +def logout_page(): + session_id = flask_session.get('session_id') + if session_id: + session = Session.query.get(session_id) + if session: + db.session.delete(session) + db.session.commit() + + flask_session.pop('session_id', None) + + flash('Sie wurden erfolgreich abgemeldet.', 'success') + return redirect(url_for('login_page')) + +@app.route('/admin/printers') +def printers_page(): + current_user = get_current_user() + if not current_user: + return redirect(url_for('login_page')) + return render_template('printers.html', current_user=current_user, active_page='printers') + +@app.route('/admin/jobs') +def jobs_page(): + current_user = get_current_user() + if not current_user: + return redirect(url_for('login_page')) + return render_template('jobs.html', current_user=current_user, active_page='jobs') + +@app.route('/admin/users') +def users_page(): + current_user = get_current_user() + if not current_user or current_user.role != 'admin': + flash('Sie haben keine Berechtigung, diese Seite zu besuchen.', 'danger') + return redirect(url_for('index')) + return render_template('users.html', current_user=current_user, active_page='users') + +@app.route('/admin/stats') +def stats_page(): + current_user = get_current_user() + if not current_user or current_user.role != 'admin': + flash('Sie haben keine Berechtigung, diese Seite zu besuchen.', 'danger') + return redirect(url_for('index')) + return render_template('stats.html', current_user=current_user, active_page='stats') + # Server starten if __name__ == '__main__': app.run(debug=True, host='0.0.0.0') \ No newline at end of file diff --git a/backend/templates/base.html b/backend/templates/base.html new file mode 100644 index 0000000..23588dd --- /dev/null +++ b/backend/templates/base.html @@ -0,0 +1,169 @@ + + + + + + {% block title %}MYP API Tester{% endblock %} + + + + + + +
+ {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} + + {% block content %}{% endblock %} +
+ + + + {% block scripts %}{% endblock %} + + \ No newline at end of file diff --git a/backend/templates/dashboard.html b/backend/templates/dashboard.html new file mode 100644 index 0000000..4cfb6ca --- /dev/null +++ b/backend/templates/dashboard.html @@ -0,0 +1,68 @@ +{% extends "base.html" %} + +{% block title %}Dashboard - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Willkommen, {{ current_user.display_name }}

+
+
+

Benutzerdetails:

+
    +
  • ID: {{ current_user.id }}
  • +
  • Benutzername: {{ current_user.username }}
  • +
  • E-Mail: {{ current_user.email or "Nicht angegeben" }}
  • +
  • Rolle: {{ current_user.role }}
  • +
+
+ Drucker verwalten + Druckaufträge verwalten + {% if current_user.role == 'admin' %} + Benutzer verwalten + Statistiken + {% endif %} +
+
+
+
+
+ +
+
+
+
+
API-Test: GET /api/me
+
+
+
+ +
+
+
Antwort:
+

+                
+
+
+
+ +
+
+
+
API-Test: GET /api/test
+
+
+
+ +
+
+
Antwort:
+

+                
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/backend/templates/jobs.html b/backend/templates/jobs.html new file mode 100644 index 0000000..aceea93 --- /dev/null +++ b/backend/templates/jobs.html @@ -0,0 +1,346 @@ +{% extends "base.html" %} + +{% block title %}Druckaufträge - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Druckaufträge verwalten

+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
Antwort:
+

+                    
+
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
IDDruckerBenutzerStartDauer (Min)Verbleibend (Min)StatusKommentareAktionen
+
+ +
+
API-Antwort:
+

+                
+
+
+
+
+ + + + + + + + + + + + +{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/backend/templates/login.html b/backend/templates/login.html new file mode 100644 index 0000000..c8a5cd3 --- /dev/null +++ b/backend/templates/login.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} + +{% block title %}Anmelden - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Anmelden

+
+
+
+
+ + +
+
+ + +
+ +
+ +
+

Noch kein Konto? Registrieren

+
+ +
+
Antwort:
+

+                
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/backend/templates/printers.html b/backend/templates/printers.html new file mode 100644 index 0000000..773312f --- /dev/null +++ b/backend/templates/printers.html @@ -0,0 +1,248 @@ +{% extends "base.html" %} + +{% block title %}Drucker - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Drucker verwalten

+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
Antwort:
+

+                    
+
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + +
IDNameBeschreibungStatusIP-AdresseAktionen
+
+ +
+
API-Antwort:
+

+                
+
+
+
+
+ + + + + + +{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/backend/templates/register.html b/backend/templates/register.html new file mode 100644 index 0000000..1c5c168 --- /dev/null +++ b/backend/templates/register.html @@ -0,0 +1,45 @@ +{% extends "base.html" %} + +{% block title %}Registrieren - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Registrieren

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+

Bereits registriert? Anmelden

+
+ +
+
Antwort:
+

+                
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/backend/templates/stats.html b/backend/templates/stats.html new file mode 100644 index 0000000..cb06838 --- /dev/null +++ b/backend/templates/stats.html @@ -0,0 +1,137 @@ +{% extends "base.html" %} + +{% block title %}Statistiken - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Systemstatistiken

+
+
+
+ +
+ +
+ +
+ +
+
API-Antwort:
+

+                
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/backend/templates/users.html b/backend/templates/users.html new file mode 100644 index 0000000..7c68e4f --- /dev/null +++ b/backend/templates/users.html @@ -0,0 +1,238 @@ +{% extends "base.html" %} + +{% block title %}Benutzer - MYP API Tester{% endblock %} + +{% block content %} +
+
+
+
+

Benutzer verwalten

+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
Antwort:
+

+                    
+
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + +
IDBenutzernameAnzeigenameE-MailRolleAktionen
+
+ +
+
API-Antwort:
+

+                
+
+
+
+
+ + + + + + +{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file