style: Add tutorial management features with video display and admin upload functionality
This commit is contained in:
@@ -2394,6 +2394,93 @@ def my_instance_management():
|
||||
)
|
||||
|
||||
|
||||
@app.route('/my/tutorials', methods=['GET'])
|
||||
@login_required
|
||||
def my_tutorials():
|
||||
"""Display tutorial videos for the logged-in user."""
|
||||
client = None
|
||||
try:
|
||||
client, col = _get_collection("tutorials")
|
||||
tutorials = list(col.find({"published": True}, {"_id": 1, "title": 1, "description": 1, "video_url": 1, "thumbnail_url": 1, "duration": 1, "category": 1, "created_at": 1}).sort("created_at", -1))
|
||||
except PyMongoError:
|
||||
flash("Tutorials konnten nicht geladen werden.", "error")
|
||||
tutorials = []
|
||||
finally:
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
if not tutorials:
|
||||
tutorials = [
|
||||
{
|
||||
"_id": "1",
|
||||
"title": "Erste Schritte mit Invario",
|
||||
"description": "Lernen Sie die Grundlagen von Invario und wie Sie Ihre erste Instanz einrichten.",
|
||||
"video_url": "https://www.youtube.com/embed/dQw4w9WgXcQ",
|
||||
"thumbnail_url": "/static/images/tutorial-thumb-1.jpg",
|
||||
"duration": "12:34",
|
||||
"category": "Anfänger"
|
||||
},
|
||||
{
|
||||
"_id": "2",
|
||||
"title": "Inventarverwaltung",
|
||||
"description": "Alles über die Verwaltung Ihres Inventars und der Ausleihvorgänge.",
|
||||
"video_url": "https://www.youtube.com/embed/dQw4w9WgXcQ",
|
||||
"thumbnail_url": "/static/images/tutorial-thumb-2.jpg",
|
||||
"duration": "18:45",
|
||||
"category": "Funktionen"
|
||||
},
|
||||
{
|
||||
"_id": "3",
|
||||
"title": "Admin-Funktionen",
|
||||
"description": "Erweiterte Administratorfunktionen und Systemverwaltung.",
|
||||
"video_url": "https://www.youtube.com/embed/dQw4w9WgXcQ",
|
||||
"thumbnail_url": "/static/images/tutorial-thumb-3.jpg",
|
||||
"duration": "22:15",
|
||||
"category": "Admin"
|
||||
}
|
||||
]
|
||||
|
||||
return render_template("my_tutorials.html", tutorials=tutorials)
|
||||
|
||||
@app.route('/append_video', methods=['POST'])
|
||||
@admin_required
|
||||
def append_video():
|
||||
title = _sanitize_text(request.form.get("title") or "", 200)
|
||||
description = _sanitize_text(request.form.get("description") or "", 500)
|
||||
video_url = _sanitize_text(request.form.get("video_url") or "", 300)
|
||||
thumbnail_url = _sanitize_text(request.form.get("thumbnail_url") or "", 300)
|
||||
duration = _sanitize_text(request.form.get("duration") or "", 20)
|
||||
category = _sanitize_text(request.form.get("category") or "", 50)
|
||||
|
||||
if not title or not video_url:
|
||||
flash("Bitte Titel und Video-URL angeben.", "error")
|
||||
return redirect(url_for("admin_blog"))
|
||||
|
||||
client = None
|
||||
try:
|
||||
client, col = _get_collection("tutorials")
|
||||
col.insert_one(
|
||||
{
|
||||
"title": title,
|
||||
"description": description,
|
||||
"video_url": video_url,
|
||||
"thumbnail_url": thumbnail_url,
|
||||
"duration": duration,
|
||||
"category": category,
|
||||
"published": True,
|
||||
"created_at": datetime.utcnow().isoformat(timespec="seconds") + "Z",
|
||||
}
|
||||
)
|
||||
flash("Tutorial-Video hinzugefügt.", "success")
|
||||
except PyMongoError:
|
||||
flash("Tutorial-Video konnte nicht hinzugefügt werden.", "error")
|
||||
finally:
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
return redirect(url_for("admin_blog"))
|
||||
|
||||
|
||||
@app.route('/chat', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def user_chat():
|
||||
|
||||
@@ -527,6 +527,7 @@
|
||||
<a class="nav-user-link" href="{{ url_for('admin_tickets') }}">Support-Center</a>
|
||||
<a class="nav-user-link" href="{{ url_for('admin_system_tools') }}">System-Tools</a>
|
||||
{% elif 'username' in session %}
|
||||
<a class="nav-user-link" href="{{ url_for('my_tutorials') }}">📚 Tutorials</a>
|
||||
<a class="nav-user-link" href="{{ url_for('my_invoices') }}">Meine Rechnungen</a>
|
||||
<a class="nav-user-link" href="{{ url_for('my_instance_management') }}">Meine Instanz</a>
|
||||
<a class="nav-user-link" href="{{ url_for('user_chat') }}">Chat mit Admin</a>
|
||||
@@ -557,6 +558,7 @@
|
||||
<details class="nav-dropdown">
|
||||
<summary class="nav-btn">Nutzerbereich</summary>
|
||||
<div class="dropdown-menu">
|
||||
<a href="{{ url_for('my_tutorials') }}">📚 Tutorials</a>
|
||||
<a href="{{ url_for('my_invoices') }}">Meine Rechnungen</a>
|
||||
<a href="{{ url_for('my_instance_management') }}">Meine Instanz</a>
|
||||
<a href="{{ url_for('user_chat') }}">Chat mit Admin</a>
|
||||
|
||||
@@ -0,0 +1,419 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Meine Tutorials{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<style>
|
||||
.tutorials-header {
|
||||
margin-bottom: 2rem;
|
||||
padding: 1.5rem;
|
||||
background: linear-gradient(135deg, #296f78 0%, #1a5057 100%);
|
||||
border-radius: 14px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.tutorials-header h1 {
|
||||
color: white;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.tutorials-header p {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.tutorials-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.tutorial-player-section {
|
||||
background: white;
|
||||
border: 1px solid #d0d7d0;
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 30px rgba(18, 40, 44, 0.08);
|
||||
}
|
||||
|
||||
.video-player-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-bottom: 56.25%; /* 16:9 aspect ratio */
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.video-player-wrapper iframe {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.video-player-wrapper video {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.video-details {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.video-title {
|
||||
font-size: 1.8rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 0.5rem;
|
||||
font-family: "Merriweather", Georgia, serif;
|
||||
}
|
||||
|
||||
.video-meta {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.video-meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-soft);
|
||||
}
|
||||
|
||||
.video-meta-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.4rem 0.8rem;
|
||||
background: #dbe8e5;
|
||||
color: #1f5158;
|
||||
border-radius: 999px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.video-description {
|
||||
color: var(--text-soft);
|
||||
line-height: 1.6;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.tutorials-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.tutorial-card {
|
||||
background: white;
|
||||
border: 1px solid #d0d7d0;
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 8px rgba(18, 40, 44, 0.04);
|
||||
}
|
||||
|
||||
.tutorial-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 10px 30px rgba(18, 40, 44, 0.12);
|
||||
border-color: #296f78;
|
||||
}
|
||||
|
||||
.tutorial-thumbnail {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-bottom: 56.25%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #296f78 0%, #1a5057 100%);
|
||||
}
|
||||
|
||||
.tutorial-thumbnail img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.play-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.tutorial-card:hover .play-icon {
|
||||
background: rgba(255, 255, 255, 1);
|
||||
transform: translate(-50%, -50%) scale(1.1);
|
||||
}
|
||||
|
||||
.play-icon::after {
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 20px solid #296f78;
|
||||
border-top: 12px solid transparent;
|
||||
border-bottom: 12px solid transparent;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.tutorial-info {
|
||||
padding: 1.2rem;
|
||||
}
|
||||
|
||||
.tutorial-card-title {
|
||||
font-size: 1.1rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
font-family: "Merriweather", Georgia, serif;
|
||||
}
|
||||
|
||||
.tutorial-card-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-soft);
|
||||
}
|
||||
|
||||
.tutorial-duration {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.tutorial-category {
|
||||
font-size: 0.75rem;
|
||||
background: #f0f3f0;
|
||||
color: #1f5158;
|
||||
padding: 0.3rem 0.6rem;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 3rem 2rem;
|
||||
background: #f9faf8;
|
||||
border: 1px dashed #d0d7d0;
|
||||
border-radius: 14px;
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
.empty-state-icon {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 1rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
color: var(--text-main);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
color: var(--text-soft);
|
||||
max-width: 60ch;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.controls-row {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-top: 1.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.7rem 1.4rem;
|
||||
background: white;
|
||||
color: #296f78;
|
||||
border: 2px solid #296f78;
|
||||
border-radius: 999px;
|
||||
font-weight: 600;
|
||||
font-size: 0.95rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #296f78;
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.tutorials-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.video-title {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.video-meta {
|
||||
flex-direction: column;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.video-details {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="tutorials-header">
|
||||
<h1>📚 Tutorial-Videos</h1>
|
||||
<p>Lernen Sie mit unseren umfassenden Tutorials, wie Sie Invario optimal nutzen können.</p>
|
||||
</section>
|
||||
|
||||
{% if tutorials %}
|
||||
<section class="tutorial-player-section">
|
||||
<div class="video-player-wrapper" id="mainVideoPlayer">
|
||||
<!-- YouTube embed or local video will be loaded here -->
|
||||
<iframe id="videoFrame"
|
||||
width="100%"
|
||||
height="100%"
|
||||
src="{{ tutorials[0].video_url }}"
|
||||
title="{{ tutorials[0].title }}"
|
||||
frameborder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
<div class="video-details">
|
||||
<h2 class="video-title" id="videoTitle">{{ tutorials[0].title }}</h2>
|
||||
<div class="video-meta">
|
||||
<div class="video-meta-item">
|
||||
<span class="video-meta-badge">
|
||||
📂 {{ tutorials[0].category or 'Allgemein' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="video-meta-item">
|
||||
<span class="video-meta-badge">
|
||||
⏱️ {{ tutorials[0].duration or 'Unbekannt' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="video-description" id="videoDescription">
|
||||
{{ tutorials[0].description }}
|
||||
</p>
|
||||
<div class="controls-row">
|
||||
<button class="btn-secondary" onclick="downloadTutorial()">
|
||||
💾 Herunterladen
|
||||
</button>
|
||||
<button class="btn-secondary" onclick="shareTutorial()">
|
||||
🔗 Teilen
|
||||
</button>
|
||||
<button class="btn-secondary" onclick="reportIssue()">
|
||||
⚠️ Problem melden
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3 style="margin: 2rem 0 1.5rem; font-size: 1.5rem; color: var(--text-main);">
|
||||
Alle Tutorials
|
||||
</h3>
|
||||
<div class="tutorials-grid">
|
||||
{% for tutorial in tutorials %}
|
||||
<div class="tutorial-card" onclick="loadVideo('{{ tutorial.video_url }}', '{{ tutorial.title|safe }}', '{{ tutorial.description|safe }}', '{{ tutorial.category|default('Allgemein') }}', '{{ tutorial.duration|default('') }}')">
|
||||
<div class="tutorial-thumbnail">
|
||||
{% if tutorial.thumbnail_url %}
|
||||
<img src="{{ tutorial.thumbnail_url }}" alt="{{ tutorial.title }}" />
|
||||
{% endif %}
|
||||
<div class="play-icon"></div>
|
||||
</div>
|
||||
<div class="tutorial-info">
|
||||
<h4 class="tutorial-card-title">{{ tutorial.title }}</h4>
|
||||
<div class="tutorial-card-meta">
|
||||
{% if tutorial.duration %}
|
||||
<span class="tutorial-duration">⏱️ {{ tutorial.duration }}</span>
|
||||
{% endif %}
|
||||
<span class="tutorial-category">{{ tutorial.category|default('Allgemein') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
function loadVideo(videoUrl, title, description, category, duration) {
|
||||
// Update main video player
|
||||
const videoFrame = document.getElementById('videoFrame');
|
||||
const videoTitle = document.getElementById('videoTitle');
|
||||
const videoDescription = document.getElementById('videoDescription');
|
||||
|
||||
videoFrame.src = videoUrl;
|
||||
videoTitle.textContent = title;
|
||||
videoDescription.textContent = description;
|
||||
|
||||
// Scroll to player
|
||||
document.querySelector('.tutorial-player-section').scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
function downloadTutorial() {
|
||||
alert('Die Download-Funktion wird in Kürze verfügbar sein.');
|
||||
}
|
||||
|
||||
function shareTutorial() {
|
||||
const url = window.location.href;
|
||||
if (navigator.share) {
|
||||
navigator.share({
|
||||
title: document.getElementById('videoTitle').textContent,
|
||||
text: document.getElementById('videoDescription').textContent,
|
||||
url: url
|
||||
});
|
||||
} else {
|
||||
const text = `${document.getElementById('videoTitle').textContent}\n${url}`;
|
||||
navigator.clipboard.writeText(text);
|
||||
alert('Link kopiert!');
|
||||
}
|
||||
}
|
||||
|
||||
function reportIssue() {
|
||||
const title = document.getElementById('videoTitle').textContent;
|
||||
window.location.href = `{{ url_for('user_tickets') }}?subject=Tutorial-Feedback: ${encodeURIComponent(title)}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">🎬</div>
|
||||
<h3>Keine Tutorials verfügbar</h3>
|
||||
<p>Es sind derzeit keine Tutorial-Videos verfügbar. Bitte versuchen Sie es später erneut oder kontaktieren Sie den Support.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user