feat: enhance exercise management and media handling
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 1m54s

- Introduced new API endpoints for managing exercise media, including upload, update, delete, and reorder functionalities.
- Updated the exercise creation and update logic to ensure goal and execution fields are validated and normalized.
- Refactored frontend components to support the new exercise media features, including a dedicated import section for complete stack files.
- Removed the deprecated ExercisesPage component and replaced it with a more modular structure for exercise management.
- Incremented database schema version to 20260427028 and updated changelog to reflect these changes.
This commit is contained in:
Lars committed 2026-04-27 14:27:25 +02:00
1 parent 2452b5e2e8
commit cb11e39201
13 files changed
+1837 -776

No files matched your search

@@ -55,6 +55,7 @@ export default function MaturityMatrixToolsAdmin() {
const [stackWipe, setStackWipe] = useState(false)
const [stackConfirmText, setStackConfirmText] = useState('')
const [stackLoading, setStackLoading] = useState(false)
const [stackImportLoading, setStackImportLoading] = useState(false)
useEffect(() => {
let cancelled = false
@@ -159,6 +160,45 @@ export default function MaturityMatrixToolsAdmin() {
}
}
async function handleImportStackFile(e) {
const file = e.target.files?.[0]
if (!file) return
setError('')
setMessage('')
setStackImportLoading(true)
try {
const data = JSON.parse(await file.text())
if (data.kind !== 'shinkan.matrix_stack.v1') {
setError('Erwartet wird eine Datei mit kind: shinkan.matrix_stack.v1 (Komplett-Stack-Export).')
e.target.value = ''
return
}
if (stackWipe && stackConfirmText !== 'DELETE_MATURITY_STACK') {
setError('Vollständiges Ersetzen: Bestätigung exakt „DELETE_MATURITY_STACK“ eintragen (Superadmin).')
e.target.value = ''
return
}
const payload = {
...data,
replace_all_maturity_models: stackWipe,
confirm_replace_all: stackWipe ? stackConfirmText : undefined
}
const res = await api.importMatrixStackBundle(payload)
const w = res.warnings || []
setMessage(
`Stack-Import OK. Modell-Zuordnung: ${Object.keys(res.model_id_map || {}).length} Modell(e), Skills gemappt: ${Object.keys(res.skill_id_map || {}).length}.` +
(w.length ? ` ${w.length} Hinweis(e) (Konsole).` : '')
)
if (w.length) console.warn('matrix_stack import warnings', w)
setModels(await api.listMaturityModels({}))
} catch (err) {
setError(err.message || String(err))
} finally {
setStackImportLoading(false)
e.target.value = ''
}
}
async function handleImportFile(e) {
const file = e.target.files?.[0]
if (!file) return
@@ -167,24 +207,9 @@ export default function MaturityMatrixToolsAdmin() {
try {
const data = JSON.parse(await file.text())
if (data.kind === 'shinkan.matrix_stack.v1') {
if (stackWipe && stackConfirmText !== 'DELETE_MATURITY_STACK') {
setError('Vollständiges Ersetzen: Bestätigung exakt „DELETE_MATURITY_STACK“ eintragen (Superadmin).')
e.target.value = ''
return
}
const payload = {
...data,
replace_all_maturity_models: stackWipe,
confirm_replace_all: stackWipe ? stackConfirmText : undefined
}
const res = await api.importMatrixStackBundle(payload)
const w = res.warnings || []
setMessage(
`Stack-Import OK. Modell-Zuordnung: ${Object.keys(res.model_id_map || {}).length} Modell(e).` +
(w.length ? ` ${w.length} Hinweis(e).` : '')
)
if (w.length) console.warn('matrix_stack import warnings', w)
setModels(await api.listMaturityModels({}))
setError('Komplett-Stack: bitte die Datei im Abschnitt „Komplett-Stack“ importieren (eigenes Dateifeld).')
e.target.value = ''
return
} else {
const payload = { ...data, mode: importMode, import_bindings: importBindings }
if (importMode === 'replace') {
@@ -362,17 +387,17 @@ export default function MaturityMatrixToolsAdmin() {
<button
type="button"
className="btn btn-primary"
disabled={stackLoading}
disabled={stackLoading || stackImportLoading}
onClick={handleExportStack}
>
{stackLoading ? 'Export…' : 'Komplett-Stack exportieren'}
</button>
</div>
<h3 className="admin-matrix-tools__h3">Stack-Import (JSON-Datei unten)</h3>
<h3 className="admin-matrix-tools__h3">Komplett-Stack importieren</h3>
<p className="muted admin-matrix-tools__hint">
Datei mit <code className="admin-bindings__code">kind: shinkan.matrix_stack.v1</code>. Katalog wird per Slug
zusammengeführt; Skills per Kategorie + Name. Optional alle Reifegradmodelle auf der Ziel-DB vorher löschen
(nur Superadmin, Vorsicht).
JSON vom Export dieses Dialogs (<code className="admin-bindings__code">shinkan.matrix_stack.v1</code>). Katalog
wird per Slug zusammengeführt; Skills per Kategorie + Name. Reifegradmodelle werden neu angelegt; Kontext-Bindings
über Namen der Fokus-/Stil-/Trainingsstil-Kataloge auf der Ziel-DB.
</p>
<label className="form-label admin-matrix-tools__check">
<input
@@ -397,6 +422,14 @@ export default function MaturityMatrixToolsAdmin() {
/>
</>
) : null}
<label className="form-label">Stack-JSON-Datei</label>
<input
type="file"
accept="application/json,.json"
disabled={stackImportLoading}
onChange={handleImportStackFile}
/>
{stackImportLoading ? <p className="muted admin-matrix-tools__msg">Import läuft…</p> : null}
</section>
<section className="card admin-matrix-tools__section">
@@ -431,10 +464,10 @@ export default function MaturityMatrixToolsAdmin() {
<div>
<h3 className="admin-matrix-tools__h3">Import</h3>
<p className="muted admin-matrix-tools__hint">
<code className="admin-bindings__code">shinkan.matrix_stack.v1</code> (Komplett-Stack),{' '}
<code className="admin-bindings__code">shinkan.maturity_model.v1</code> oder{' '}
<code className="admin-bindings__code">shinkan.maturity_matrix_resolved.v1</code>. Aufgelöste Matrizen
legen ein neues Modell an bzw. ersetzen den Inhalt des Zielmodells (ohne Bindings).
<code className="admin-bindings__code">shinkan.maturity_matrix_resolved.v1</code>. Komplett-Stack bitte im
Abschnitt <strong>Komplett-Stack</strong> oben importieren. Aufgelöste Matrizen legen ein neues Modell an bzw.
ersetzen den Inhalt des Zielmodells (ohne Bindings).
</p>
<label className="form-label">Modus</label>
<select