Vier zusammenhaengende Iterationen, die das Funktions-Geruest der AG aufbauen.
Alle 6 Migrationen sind idempotent und legen Schema-Erweiterungen + initiale
Seeds an (Mock-Projekte nur, falls Profil 100 existiert — auf prod nicht).
Software-Sektion (Etappe 3):
- software_seite-Tabelle: schlanker Karten-Katalog (slug, titel, urls,
plattform, kategorie, sortierung, Cover-BLOB)
- 7 Initial-Karten (Bambu Studio/Handy, Printables, MakerWorld,
TinkerCAD, Onshape, Gridfinity-Generator)
- Admin-Verwaltung: Liste, Anlegen-Form, Bearbeiten, Aktiv-Toggle,
Hart-Loeschen, Bild-Upload via Crop-Tool (Strg+V/Drag&Drop, 400x400)
Drucker-Verwaltung (Etappe 5-vorgezogen):
- drucker.freigegeben + gesperrt_grund (Lehrer-Sperre fuer Reparatur)
- drucker.manual_url + troubleshooting_url (Override fuer Modell-Defaults)
- SuS-View /drucker (eingeloggt): Kacheln + Sperre-Banner + Belegung
- Admin /admin/drucker: Status-Override (idle/printing/failed/...),
Sperren/Freigeben mit Grund, Inline-Edit fuer URLs
Slot-System / Reservierung (Etappe 7-vorgezogen):
- profil.reservieren_freigeschaltet (Lehrer schaltet manuell frei,
ersetzt L1-Gate-Automatismus)
- services/slots.py: Konflikt-Check, Belegungs-Helper
- SuS-Routen /cockpit/slot/neu (mit Konflikt-Check), /cockpit/slots,
Stornieren
- Admin /admin/slots Uebersicht + /admin/slot/neu (Lehrer reserviert
fuer SuS) + Hart-Loeschen + Profil-Freigabe-Toggle
Selbstlern-Loop (Etappe 6 — Kern):
- projekt-Spalten: 3-Achsen-Eval (Gesamt + Planung + Ausfuehrung),
was_klappte_nicht, cover_blob, modellier_software_slug,
drucker_id_used, makerworld_url
- Regel: max. 1 aktives Projekt pro SuS, neues nur nach Freigabe
(auto bei zufrieden/mittel, Lehrer-Review bei gelernt)
- SuS-Werkstatt-Sektion: Titel + Beschreibung + Software-Dropdown +
Drucker-Dropdown + MakerWorld-URL + Files-Upload (drag&drop,
base64, max 30 MB)
- Cover-Bild via Crop-Tool (Re-use admin_software_bild-Pattern)
- Abschluss-Block: Pflicht Cover + mindestens 1 Datei
- Eval-Form: visuelle 3x3 Radio-Karten + 2 Freitexte
- Lehrer-Review: /admin/projekte mit Filter (wartet/in_arbeit/
abgeschlossen/rueckfrage), Aktionen freigeben/rueckfrage/loeschen
- Oeffentlicher Katalog /projekte: Sortier-Tabelle (Titel/Person/
Status/Erfolg/Datum), aufklappbare Detail mit Cover/Beschreibung/
Datei-Downloads/MakerWorld-Link
- Wiederhol-Logik: "Sowas mache ich auch" via Verknuepfung
(vorlage_projekt_id), bidirektionale Lineage-Banner
Cockpit-Refactoring:
- Projekt-Karte ganz oben (vor Onboarding) mit "Hier weitermachen"
- Check-In-Quick-Actions: nach Auswahl direkt zu /cockpit/projekt/neu,
/drucker, /lektionen, /cockpit/projekt/<aktiv>
- "Modus aendern"-Button im Eingecheckt-Banner
- Admin-Dashboard-Hub mit Karten: SuS-Profile, Software, Lektionen,
Drucker, Reservierungen, Projekte (Badge bei wartenden), Alph
Bug-Fixes:
- Admin-Login redirected jetzt auf /admin/dashboard statt /admin/profile
- app.py: neue Jinja-Filter iso_format + dauer_min
- .gitignore: .claude/ ausschliessen (lokale launch.json)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
291 lines
12 KiB
HTML
291 lines
12 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Cover-Bild: {{ p.titel }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<p><a href="{{ url_for('profil.projekt_detail', projekt_id=p.id) }}">← Zurueck zum Projekt</a></p>
|
|
|
|
<div class="card">
|
|
<h1>Cover-Bild fuer: {{ p.titel }}</h1>
|
|
<p style="color: var(--text-light); font-size: 0.9rem;">
|
|
Ein Foto vom Druck oder ein Screenshot vom Modell — wird im Cockpit und spaeter im Katalog gezeigt.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Paste-Bereich -->
|
|
<div class="card" id="paste-bereich">
|
|
<h2>1. Bild einfuegen</h2>
|
|
<p style="color: var(--text-light); margin-bottom: 1rem;">
|
|
Kopiere ein Bild in die Zwischenablage (Snipping Tool, Handy-Foto) und druecke
|
|
<kbd style="background:#eee;padding:0.2rem 0.5rem;border-radius:4px;border:1px solid #ccc;">Strg+V</kbd>
|
|
hier auf der Seite. Oder waehle eine Datei aus.
|
|
</p>
|
|
|
|
<div id="drop-zone" style="border: 3px dashed var(--border); border-radius: 12px; padding: 3rem;
|
|
text-align: center; cursor: pointer; transition: border-color 0.2s; background: #fafafa;">
|
|
<p style="font-size: 1.2rem; color: var(--text-light);">Strg+V zum Einfuegen</p>
|
|
<p style="font-size: 0.85rem; color: var(--text-light);">oder klicken um Datei auszuwaehlen</p>
|
|
<input type="file" id="datei-input" accept="image/*" style="display: none;">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Crop-Bereich (anfangs versteckt) -->
|
|
<div class="card" id="crop-bereich" style="display: none;">
|
|
<h2>2. Ausschnitt waehlen</h2>
|
|
<p style="color: var(--text-light); margin-bottom: 1rem;">
|
|
Ziehe das Quadrat auf den gewuenschten Bildausschnitt. Ecken zum Vergroessern/Verkleinern ziehen.
|
|
</p>
|
|
|
|
<div style="display: flex; gap: 2rem; flex-wrap: wrap;">
|
|
<div style="flex: 1; min-width: 300px;">
|
|
<div id="crop-container" style="position: relative; display: inline-block; max-width: 100%; cursor: crosshair;">
|
|
<canvas id="quell-canvas" style="max-width: 100%; display: block;"></canvas>
|
|
<div id="crop-box" style="position: absolute; border: 3px solid var(--primary);
|
|
background: rgba(0,151,157,0.1); cursor: move; display: none;">
|
|
<div class="resize-handle" data-pos="tl" style="position:absolute;top:-6px;left:-6px;width:12px;height:12px;background:var(--primary);border-radius:50%;cursor:nw-resize;"></div>
|
|
<div class="resize-handle" data-pos="tr" style="position:absolute;top:-6px;right:-6px;width:12px;height:12px;background:var(--primary);border-radius:50%;cursor:ne-resize;"></div>
|
|
<div class="resize-handle" data-pos="bl" style="position:absolute;bottom:-6px;left:-6px;width:12px;height:12px;background:var(--primary);border-radius:50%;cursor:sw-resize;"></div>
|
|
<div class="resize-handle" data-pos="br" style="position:absolute;bottom:-6px;right:-6px;width:12px;height:12px;background:var(--primary);border-radius:50%;cursor:se-resize;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="min-width: 200px; text-align: center;">
|
|
<h3>Vorschau</h3>
|
|
<canvas id="vorschau-canvas" width="200" height="200"
|
|
style="border: 1px solid var(--border); border-radius: 8px; background: #f0f0f0;"></canvas>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin-top: 1.5rem; display: flex; gap: 1rem;">
|
|
<button onclick="speichern()" class="btn btn-primary" id="speichern-btn"
|
|
style="padding: 0.8rem 2rem; font-size: 1rem;">Bild speichern</button>
|
|
<button onclick="zuruecksetzen()" class="btn btn-secondary">Neues Bild</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Erfolg -->
|
|
<div class="card" id="erfolg-bereich" style="display: none; border-left: 4px solid var(--success);">
|
|
<h2 style="color: var(--success);">Bild gespeichert!</h2>
|
|
<p>Das Cover fuer <strong>{{ p.titel }}</strong> wurde erfolgreich gespeichert.</p>
|
|
<div style="margin-top: 1rem;">
|
|
<a href="{{ url_for('profil.projekt_detail', projekt_id=p.id) }}" class="btn btn-primary">Zurueck zum Projekt</a>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
var quellCanvas = document.getElementById('quell-canvas');
|
|
var quellCtx = quellCanvas.getContext('2d');
|
|
var vorschauCanvas = document.getElementById('vorschau-canvas');
|
|
var vorschauCtx = vorschauCanvas.getContext('2d');
|
|
var cropBox = document.getElementById('crop-box');
|
|
var cropContainer = document.getElementById('crop-container');
|
|
|
|
var originalBild = null;
|
|
var skalierung = 1;
|
|
var crop = { x: 0, y: 0, size: 100 };
|
|
var dragging = false, resizing = false, resizePos = '';
|
|
var startX, startY, startCropX, startCropY, startCropSize;
|
|
|
|
function bildLaden(quelle) {
|
|
var img = new Image();
|
|
img.onload = function() {
|
|
originalBild = img;
|
|
var maxBreite = 600;
|
|
skalierung = Math.min(1, maxBreite / img.width);
|
|
quellCanvas.width = img.width * skalierung;
|
|
quellCanvas.height = img.height * skalierung;
|
|
quellCtx.drawImage(img, 0, 0, quellCanvas.width, quellCanvas.height);
|
|
|
|
var minSeite = Math.min(quellCanvas.width, quellCanvas.height);
|
|
crop.size = Math.round(minSeite * 0.6);
|
|
crop.x = Math.round((quellCanvas.width - crop.size) / 2);
|
|
crop.y = Math.round((quellCanvas.height - crop.size) / 2);
|
|
|
|
cropBoxAktualisieren();
|
|
cropBox.style.display = 'block';
|
|
vorschauAktualisieren();
|
|
|
|
document.getElementById('paste-bereich').style.display = 'none';
|
|
document.getElementById('crop-bereich').style.display = 'block';
|
|
};
|
|
img.src = quelle;
|
|
}
|
|
|
|
document.addEventListener('paste', function(e) {
|
|
if (originalBild) return;
|
|
var items = e.clipboardData.items;
|
|
for (var i = 0; i < items.length; i++) {
|
|
if (items[i].type.indexOf('image') >= 0) {
|
|
var blob = items[i].getAsFile();
|
|
var reader = new FileReader();
|
|
reader.onload = function(ev) { bildLaden(ev.target.result); };
|
|
reader.readAsDataURL(blob);
|
|
e.preventDefault();
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
|
|
var dropZone = document.getElementById('drop-zone');
|
|
var dateiInput = document.getElementById('datei-input');
|
|
dropZone.addEventListener('click', function() { dateiInput.click(); });
|
|
dateiInput.addEventListener('change', function() {
|
|
if (this.files[0]) {
|
|
var reader = new FileReader();
|
|
reader.onload = function(ev) { bildLaden(ev.target.result); };
|
|
reader.readAsDataURL(this.files[0]);
|
|
}
|
|
});
|
|
dropZone.addEventListener('dragover', function(e) {
|
|
e.preventDefault(); this.style.borderColor = 'var(--primary)'; this.style.background = '#EBF5FB';
|
|
});
|
|
dropZone.addEventListener('dragleave', function() {
|
|
this.style.borderColor = 'var(--border)'; this.style.background = '#fafafa';
|
|
});
|
|
dropZone.addEventListener('drop', function(e) {
|
|
e.preventDefault();
|
|
this.style.borderColor = 'var(--border)'; this.style.background = '#fafafa';
|
|
if (e.dataTransfer.files[0] && e.dataTransfer.files[0].type.indexOf('image') >= 0) {
|
|
var reader = new FileReader();
|
|
reader.onload = function(ev) { bildLaden(ev.target.result); };
|
|
reader.readAsDataURL(e.dataTransfer.files[0]);
|
|
}
|
|
});
|
|
|
|
function cropBoxAktualisieren() {
|
|
cropBox.style.left = crop.x + 'px';
|
|
cropBox.style.top = crop.y + 'px';
|
|
cropBox.style.width = crop.size + 'px';
|
|
cropBox.style.height = crop.size + 'px';
|
|
}
|
|
|
|
function vorschauAktualisieren() {
|
|
if (!originalBild) return;
|
|
var sx = crop.x / skalierung, sy = crop.y / skalierung, ss = crop.size / skalierung;
|
|
vorschauCtx.clearRect(0, 0, 200, 200);
|
|
vorschauCtx.drawImage(originalBild, sx, sy, ss, ss, 0, 0, 200, 200);
|
|
}
|
|
|
|
function begrenzen() {
|
|
var maxX = quellCanvas.width - crop.size, maxY = quellCanvas.height - crop.size;
|
|
crop.x = Math.max(0, Math.min(crop.x, maxX));
|
|
crop.y = Math.max(0, Math.min(crop.y, maxY));
|
|
crop.size = Math.max(30, Math.min(crop.size,
|
|
Math.min(quellCanvas.width - crop.x, quellCanvas.height - crop.y)));
|
|
}
|
|
|
|
cropContainer.addEventListener('mousedown', function(e) {
|
|
if (!originalBild) return;
|
|
var rect = quellCanvas.getBoundingClientRect();
|
|
var mx = e.clientX - rect.left, my = e.clientY - rect.top;
|
|
var handle = e.target.closest('.resize-handle');
|
|
if (handle) {
|
|
resizing = true; resizePos = handle.dataset.pos;
|
|
startX = e.clientX; startY = e.clientY;
|
|
startCropX = crop.x; startCropY = crop.y; startCropSize = crop.size;
|
|
e.preventDefault(); return;
|
|
}
|
|
if (mx >= crop.x && mx <= crop.x + crop.size && my >= crop.y && my <= crop.y + crop.size) {
|
|
dragging = true;
|
|
startX = e.clientX; startY = e.clientY;
|
|
startCropX = crop.x; startCropY = crop.y;
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
document.addEventListener('mousemove', function(e) {
|
|
if (dragging) {
|
|
crop.x = startCropX + (e.clientX - startX);
|
|
crop.y = startCropY + (e.clientY - startY);
|
|
begrenzen(); cropBoxAktualisieren(); vorschauAktualisieren();
|
|
}
|
|
if (resizing) {
|
|
var dx = e.clientX - startX, dy = e.clientY - startY;
|
|
if (resizePos === 'br') crop.size = Math.max(30, startCropSize + Math.max(dx, dy));
|
|
else if (resizePos === 'tl') {
|
|
var delta = Math.min(dx, dy);
|
|
crop.x = startCropX + delta; crop.y = startCropY + delta;
|
|
crop.size = startCropSize - delta;
|
|
} else if (resizePos === 'tr') {
|
|
var delta = Math.max(dx, -dy);
|
|
crop.y = startCropY - delta; crop.size = startCropSize + delta;
|
|
} else if (resizePos === 'bl') {
|
|
var delta = Math.max(-dx, dy);
|
|
crop.x = startCropX - delta; crop.size = startCropSize + delta;
|
|
}
|
|
crop.size = Math.max(30, crop.size);
|
|
begrenzen(); cropBoxAktualisieren(); vorschauAktualisieren();
|
|
}
|
|
});
|
|
|
|
document.addEventListener('mouseup', function() { dragging = false; resizing = false; });
|
|
|
|
cropContainer.addEventListener('touchstart', function(e) {
|
|
if (!originalBild) return;
|
|
var t = e.touches[0], rect = quellCanvas.getBoundingClientRect();
|
|
var mx = t.clientX - rect.left, my = t.clientY - rect.top;
|
|
if (mx >= crop.x && mx <= crop.x + crop.size && my >= crop.y && my <= crop.y + crop.size) {
|
|
dragging = true;
|
|
startX = t.clientX; startY = t.clientY;
|
|
startCropX = crop.x; startCropY = crop.y;
|
|
e.preventDefault();
|
|
}
|
|
}, {passive: false});
|
|
|
|
document.addEventListener('touchmove', function(e) {
|
|
if (dragging) {
|
|
var t = e.touches[0];
|
|
crop.x = startCropX + (t.clientX - startX);
|
|
crop.y = startCropY + (t.clientY - startY);
|
|
begrenzen(); cropBoxAktualisieren(); vorschauAktualisieren();
|
|
e.preventDefault();
|
|
}
|
|
}, {passive: false});
|
|
|
|
document.addEventListener('touchend', function() { dragging = false; });
|
|
|
|
function speichern() {
|
|
if (!originalBild) return;
|
|
var btn = document.getElementById('speichern-btn');
|
|
btn.disabled = true; btn.textContent = 'Speichern...';
|
|
|
|
var exportCanvas = document.createElement('canvas');
|
|
exportCanvas.width = 400; exportCanvas.height = 400;
|
|
var ctx = exportCanvas.getContext('2d');
|
|
var sx = crop.x / skalierung, sy = crop.y / skalierung, ss = crop.size / skalierung;
|
|
ctx.drawImage(originalBild, sx, sy, ss, ss, 0, 0, 400, 400);
|
|
var dataUrl = exportCanvas.toDataURL('image/jpeg', 0.85);
|
|
|
|
fetch('{{ url_for("profil.projekt_cover", projekt_id=p.id) }}', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({bild_base64: dataUrl})
|
|
})
|
|
.then(function(r) { return r.json(); })
|
|
.then(function(data) {
|
|
if (data.error) {
|
|
alert('Fehler: ' + data.error);
|
|
btn.disabled = false; btn.textContent = 'Bild speichern';
|
|
} else {
|
|
document.getElementById('crop-bereich').style.display = 'none';
|
|
document.getElementById('erfolg-bereich').style.display = 'block';
|
|
}
|
|
})
|
|
.catch(function() {
|
|
alert('Verbindungsfehler');
|
|
btn.disabled = false; btn.textContent = 'Bild speichern';
|
|
});
|
|
}
|
|
|
|
function zuruecksetzen() {
|
|
originalBild = null;
|
|
cropBox.style.display = 'none';
|
|
vorschauCtx.clearRect(0, 0, 200, 200);
|
|
document.getElementById('crop-bereich').style.display = 'none';
|
|
document.getElementById('paste-bereich').style.display = 'block';
|
|
}
|
|
</script>
|
|
{% endblock %}
|