feat: update media management and project status documentation
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 27s

- Updated project status to reflect the latest media management milestones and version increment to 0.8.44.
- Enhanced MEDIA_ASSETS_AND_ARCHIVE_SPEC.md with new API details for media asset lifecycle and inline media integration.
- Improved exercise media handling in the frontend, including new preview features and user prompts for media deletion.
- Adjusted backend API to ensure proper handling of media asset deletions without removing files, maintaining governance and user experience.
This commit is contained in:
Lars committed 2026-05-07 13:10:37 +02:00
1 parent 631ba1cb43
commit e2964a077d
7 files changed
+437 -195

No files matched your search

+118 -136
View File
@@ -6,6 +6,70 @@ import RichTextEditor from '../components/RichTextEditor'
import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGraphPanel'
import { SKILL_LEVEL_OPTIONS, normalizeSkillLevelSlug } from '../constants/skillLevels'
/** Kachelvorschau: Video nutzt ersten Frame (metadata), Bild = img. */
function ExerciseMediaThumbTile({ exerciseId, media, onOpenPreview }) {
const src = !media.embed_url ? resolveExerciseMediaFileUrl(exerciseId, media) : null
const commonStyle = {
width: '100%',
height: '100%',
objectFit: 'cover',
}
return (
<div
role="button"
tabIndex={0}
title="Vorschau"
onClick={() => onOpenPreview(media)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onOpenPreview(media)
}
}}
style={{
width: 72,
height: 72,
flexShrink: 0,
borderRadius: '8px',
overflow: 'hidden',
background: 'var(--surface2, rgba(127,127,127,0.12))',
border: '1px solid var(--border)',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{media.embed_url ? (
<span style={{ fontSize: '11px', padding: '4px', color: 'var(--text2)', textAlign: 'center' }}>
{media.embed_platform || 'Embed'}
</span>
) : (media.mime_type?.startsWith('image/') || media.media_type === 'image') && src ? (
<img alt="" src={src} style={commonStyle} />
) : (media.mime_type?.startsWith('video/') || media.media_type === 'video') && src ? (
<video
src={src}
muted
playsInline
preload="metadata"
style={{ ...commonStyle, pointerEvents: 'none' }}
onLoadedMetadata={(e) => {
try {
const el = e.currentTarget
const d = el.duration
el.currentTime = Number.isFinite(d) && d > 0 ? Math.min(0.05, d * 0.01) : 0.05
} catch (_) {
/* ignore */
}
}}
/>
) : (
<span style={{ fontSize: '11px', color: 'var(--text2)' }}>Datei</span>
)}
</div>
)
}
const INTENSITY_OPTIONS = [
{ value: '', label: '—' },
{ value: 'niedrig', label: 'niedrig' },
@@ -657,25 +721,32 @@ function ExerciseFormPage() {
}
const handleDeleteMedia = async (mid) => {
if (!confirm('Medium löschen?')) return
if (
!confirm(
'Dieses Medium aus der Übung entfernen? Nur die Verknüpfung wird gelöscht. Die Datei bleibt im Archiv, solange sie noch woanders genutzt wird.',
)
) {
return
}
try {
await api.deleteExerciseMedia(exerciseId, mid)
const res = await api.deleteExerciseMedia(exerciseId, mid)
await refreshMedia()
const oid = res?.orphan_media_asset_id
if (oid != null) {
if (
confirm(
'Dieses Archiv-Medium wird danach nirgendwo mehr verwendet. In den Papierkorb (Stufe 1) legen? (Später in der Medienverwaltung wiederherstellbar.)',
)
) {
await api.postMediaAssetLifecycle(oid, 'trash_soft')
await refreshMedia()
}
}
} catch (err) {
alert(err.message)
}
}
const runMediaLifecycle = async (assetId, action) => {
if (!assetId) return
try {
await api.postMediaAssetLifecycle(assetId, action)
await refreshMedia()
} catch (e) {
alert(e.message || String(e))
}
}
const moveMediaRow = async (idx, dir) => {
if (!exerciseId) return
const j = idx + dir
@@ -1282,8 +1353,8 @@ function ExerciseFormPage() {
<div className="card" style={{ marginTop: '16px' }}>
<h2 style={{ marginTop: 0, fontSize: '1.1rem' }}>Medien</h2>
<p style={{ color: 'var(--text2)', fontSize: '13px' }}>
Datei oder Embed (YouTube, Vimeo, Instagram, TikTok). Max. 10 pro Übung. Archiv-Medien können mehrfach
verknüpft werden.
Datei oder Embed (YouTube, Vimeo, Instagram, TikTok). Max. 10 pro Übung. Archiv-Medien mehrfach nutzbar.
Papierkorb und Freigaben steuern Sie zentral im Archiv — hier nur Verknüpfung zur Übung.
</p>
<div
style={{
@@ -1375,43 +1446,7 @@ function ExerciseFormPage() {
alignItems: 'flex-start',
}}
>
<button
type="button"
title="Vorschau"
onClick={() => setMediaPreview(m)}
style={{
width: 72,
height: 72,
flexShrink: 0,
borderRadius: '8px',
overflow: 'hidden',
background: 'var(--surface2, rgba(127,127,127,0.12))',
border: '1px solid var(--border)',
padding: 0,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{m.embed_url ? (
<span style={{ fontSize: '11px', padding: '4px', color: 'var(--text2)', textAlign: 'center' }}>
{m.embed_platform || 'Embed'}
</span>
) : m.mime_type?.startsWith('image/') ? (
<img
alt=""
src={resolveExerciseMediaFileUrl(exerciseId, m)}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : m.mime_type?.startsWith('video/') ? (
<span style={{ fontSize: '22px', opacity: 0.75 }} aria-hidden>
▶
</span>
) : (
<span style={{ fontSize: '11px', color: 'var(--text2)' }}>Datei</span>
)}
</button>
<ExerciseMediaThumbTile exerciseId={exerciseId} media={m} onOpenPreview={setMediaPreview} />
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', alignItems: 'center' }}>
<span style={{ fontSize: '12px', color: 'var(--text3)' }}>
@@ -1443,82 +1478,32 @@ function ExerciseFormPage() {
</>
)}
</div>
{m.media_asset_id ? (
<div style={{ marginTop: '8px', fontSize: '12px' }}>
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
<p style={{ color: 'var(--danger)', margin: '0 0 6px' }}>
Papierkorb (Stufe 1): für neue Zuordnungen gesperrt.
</p>
)}
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_hidden' && (
<p style={{ color: 'var(--danger)', margin: '0 0 6px' }}>
Ausgeblendet (Stufe 2): in der Übungsansicht nicht sichtbar.
</p>
)}
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center' }}>
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'active' && (
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: '11px', padding: '4px 8px' }}
onClick={() => {
if (confirm('Medium in den Papierkorb (Stufe 1)?')) {
runMediaLifecycle(m.media_asset_id, 'trash_soft')
}
}}
>
Papierkorb (Stufe 1)
</button>
)}
{['active', 'trash_soft'].includes(String(m.asset_lifecycle_state || 'active').toLowerCase()) && (
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: '11px', padding: '4px 8px' }}
onClick={() => {
if (confirm('Medium ausblenden (Stufe 2)? Lesende Nutzer sehen es nicht mehr.')) {
runMediaLifecycle(m.media_asset_id, 'trash_hidden')
}
}}
>
Ausblenden (Stufe 2)
</button>
)}
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_hidden' && (
<>
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: '11px', padding: '4px 8px' }}
onClick={() => runMediaLifecycle(m.media_asset_id, 'recover')}
>
Wiederherstellen (Stufe 1)
</button>
<button
type="button"
className="btn"
style={{
fontSize: '11px',
padding: '4px 8px',
background: 'var(--danger)',
color: '#fff',
border: 'none',
}}
onClick={() => {
if (
confirm('Endgültig löschen? Entfernt Datei und Verknüpfungen dieser Medien-ID.')
) {
runMediaLifecycle(m.media_asset_id, 'purge')
}
}}
>
Endgültig löschen
</button>
</>
)}
</div>
</div>
) : null}
<div
style={{
fontSize: '12px',
color: 'var(--text2)',
marginTop: '6px',
wordBreak: 'break-word',
lineHeight: 1.35,
}}
>
{(m.original_filename || '').trim() ||
(m.title || '').trim() ||
(m.embed_url ? m.embed_url : '') ||
'—'}
</div>
{m.media_asset_id &&
String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
<p style={{ color: 'var(--danger)', margin: '8px 0 0', fontSize: '12px' }}>
Hinweis: Dieses Archiv-Medium ist im Papierkorb (Stufe 1).
</p>
)}
{m.media_asset_id &&
String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_hidden' && (
<p style={{ color: 'var(--danger)', margin: '8px 0 0', fontSize: '12px' }}>
Hinweis: Archiv-Medium ausgeblendet (Stufe 2) — in der Übungsansicht unsichtbar.
</p>
)}
<div className="form-row" style={{ marginTop: '8px', display: 'grid', gap: '8px' }}>
<input
type="text"
@@ -1562,18 +1547,15 @@ function ExerciseFormPage() {
</div>
<button
type="button"
className="btn"
className="btn btn-secondary"
style={{
marginTop: '8px',
fontSize: '11px',
padding: '4px 10px',
background: 'var(--danger)',
color: '#fff',
border: 'none',
fontSize: '12px',
padding: '6px 12px',
}}
onClick={() => handleDeleteMedia(m.id)}
>
Löschen
Aus Übung entfernen
</button>
</div>
</li>
@@ -1740,13 +1722,13 @@ function ExerciseFormPage() {
{mediaPreview.embed_url}
</a>
</p>
) : mediaPreview.mime_type?.startsWith('video/') ? (
) : mediaPreview.mime_type?.startsWith('video/') || mediaPreview.media_type === 'video' ? (
<video
src={resolveExerciseMediaFileUrl(exerciseId, mediaPreview)}
controls
style={{ width: '100%', borderRadius: '8px', maxHeight: '70vh' }}
/>
) : mediaPreview.mime_type?.startsWith('image/') ? (
) : mediaPreview.mime_type?.startsWith('image/') || mediaPreview.media_type === 'image' ? (
<img
alt=""
src={resolveExerciseMediaFileUrl(exerciseId, mediaPreview)}