feat: add exercise progression graph functionality and update versioning
Deploy Development / deploy (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Failing after 41s

- Integrated exercise progression graphs into the backend and frontend, allowing users to visualize relationships between exercises.
- Updated API endpoints for managing exercise progression graphs and edges, enhancing the exercise management capabilities.
- Added a new tab in the ExercisesListPage for displaying progression graphs and included a panel in the ExerciseFormPage for editing.
- Incremented application version to 0.8.6 and updated changelog to reflect new features and improvements.
This commit is contained in:
Lars committed 2026-04-30 11:47:50 +02:00
1 parent 362eb4145f
commit 1b7a0405e9
11 files changed
+1436 -11

No files matched your search

@@ -0,0 +1,599 @@
/**
* Verwaltung mehrerer Progressionsgraphen (Übung → Übung) mit Kantentypen Nachfolger / Schwester.
* Varianten-Ketten bleiben unter „Übungsvarianten“ der jeweiligen Übung.
*/
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { Link } from 'react-router-dom'
import api from '../utils/api'
import ExercisePickerModal from './ExercisePickerModal'
const VIS_OPTIONS = [
{ value: 'private', label: 'Privat' },
{ value: 'club', label: 'Verein' },
{ value: 'official', label: 'Offiziell' },
]
function edgeTypeLabel(type) {
if (type === 'next_exercise') return 'Nachfolger'
if (type === 'sibling') return 'Schwester'
return type || '—'
}
export default function ExerciseProgressionGraphPanel({
anchorExerciseId = null,
anchorTitle = null,
}) {
const [graphs, setGraphs] = useState([])
const [selectedGraphId, setSelectedGraphId] = useState(null)
const [edges, setEdges] = useState([])
const [busy, setBusy] = useState(false)
const [loadErr, setLoadErr] = useState(null)
const [newGraphName, setNewGraphName] = useState('')
const [newGraphVisibility, setNewGraphVisibility] = useState('private')
const [metaName, setMetaName] = useState('')
const [metaDescription, setMetaDescription] = useState('')
const [metaVisibility, setMetaVisibility] = useState('private')
const [relationKind, setRelationKind] = useState('progression')
const [firstEx, setFirstEx] = useState(null)
const [secondEx, setSecondEx] = useState(null)
const [edgeNotes, setEdgeNotes] = useState('')
const [pickSlot, setPickSlot] = useState(null)
const [filterAnchorOnly, setFilterAnchorOnly] = useState(!!anchorExerciseId)
const [editingEdgeNotes, setEditingEdgeNotes] = useState(null)
const [notesDraft, setNotesDraft] = useState('')
const refreshGraphs = useCallback(async () => {
const list = await api.listExerciseProgressionGraphs()
setGraphs(Array.isArray(list) ? list : [])
return list
}, [])
const refreshEdges = useCallback(async (gid) => {
if (!gid) {
setEdges([])
return
}
const list = await api.listExerciseProgressionEdges(gid)
setEdges(Array.isArray(list) ? list : [])
}, [])
useEffect(() => {
let cancelled = false
;(async () => {
setBusy(true)
setLoadErr(null)
try {
await refreshGraphs()
} catch (e) {
if (!cancelled) setLoadErr(e.message || String(e))
} finally {
if (!cancelled) setBusy(false)
}
})()
return () => {
cancelled = true
}
}, [refreshGraphs])
useEffect(() => {
if (!selectedGraphId) {
setEdges([])
setMetaName('')
setMetaDescription('')
setMetaVisibility('private')
return
}
const g = graphs.find((x) => x.id === selectedGraphId)
if (g) {
setMetaName(g.name || '')
setMetaDescription(g.description || '')
setMetaVisibility(g.visibility || 'private')
}
let cancelled = false
;(async () => {
try {
await refreshEdges(selectedGraphId)
} catch (e) {
if (!cancelled) alert(e.message || String(e))
}
})()
return () => {
cancelled = true
}
}, [selectedGraphId, graphs, refreshEdges])
const filteredEdges = useMemo(() => {
if (!filterAnchorOnly || anchorExerciseId == null) return edges
return edges.filter(
(e) =>
e.from_exercise_id === anchorExerciseId || e.to_exercise_id === anchorExerciseId,
)
}, [edges, filterAnchorOnly, anchorExerciseId])
const handleCreateGraph = async (e) => {
e.preventDefault()
const name = newGraphName.trim()
if (!name) {
alert('Name für den Graphen eingeben')
return
}
setBusy(true)
try {
const created = await api.createExerciseProgressionGraph({
name,
visibility: newGraphVisibility,
})
setNewGraphName('')
await refreshGraphs()
if (created?.id != null) setSelectedGraphId(created.id)
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const handleSaveMeta = async () => {
if (!selectedGraphId) return
const name = metaName.trim()
if (!name) {
alert('Name ist Pflicht')
return
}
setBusy(true)
try {
await api.updateExerciseProgressionGraph(selectedGraphId, {
name,
description: metaDescription.trim() || null,
visibility: metaVisibility,
})
await refreshGraphs()
alert('Graph gespeichert.')
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const handleDeleteGraph = async () => {
if (!selectedGraphId) return
if (!confirm('Diesen Progressionsgraphen und alle Kanten wirklich löschen?')) return
setBusy(true)
try {
await api.deleteExerciseProgressionGraph(selectedGraphId)
setSelectedGraphId(null)
await refreshGraphs()
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const handleAddEdge = async () => {
if (!selectedGraphId) {
alert('Zuerst einen Graphen wählen oder anlegen.')
return
}
if (!firstEx?.id || !secondEx?.id) {
alert('Beide Übungen auswählen.')
return
}
if (firstEx.id === secondEx.id) {
alert('Es müssen zwei verschiedene Übungen sein.')
return
}
const edge_type = relationKind === 'sibling' ? 'sibling' : 'next_exercise'
const notes = edgeNotes.trim() || null
const body =
relationKind === 'sibling'
? {
from_exercise_id: firstEx.id,
to_exercise_id: secondEx.id,
edge_type,
notes,
}
: {
from_exercise_id: firstEx.id,
to_exercise_id: secondEx.id,
edge_type: 'next_exercise',
notes,
}
setBusy(true)
try {
await api.createExerciseProgressionEdge(selectedGraphId, body)
setEdgeNotes('')
await refreshEdges(selectedGraphId)
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const handleDeleteEdge = async (edgeId) => {
if (!selectedGraphId) return
if (!confirm('Kante löschen?')) return
setBusy(true)
try {
await api.deleteExerciseProgressionEdge(selectedGraphId, edgeId)
await refreshEdges(selectedGraphId)
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const startEditNotes = (edge) => {
setEditingEdgeNotes(edge.id)
setNotesDraft(edge.notes || '')
}
const saveNotes = async (edgeId) => {
if (!selectedGraphId) return
setBusy(true)
try {
await api.updateExerciseProgressionEdge(selectedGraphId, edgeId, {
notes: notesDraft.trim() || null,
})
setEditingEdgeNotes(null)
await refreshEdges(selectedGraphId)
} catch (err) {
alert(err.message || String(err))
} finally {
setBusy(false)
}
}
const swapEnds = () => {
const a = firstEx
setFirstEx(secondEx)
setSecondEx(a)
}
const onPicked = (ex) => {
const row = { id: ex.id, title: ex.title || `Übung #${ex.id}` }
if (pickSlot === 'first') setFirstEx(row)
else if (pickSlot === 'second') setSecondEx(row)
setPickSlot(null)
}
return (
<div className="exercise-progression-panel">
{anchorExerciseId != null && (
<p style={{ fontSize: '13px', color: 'var(--text2)', marginBottom: '12px' }}>
Kontext:{' '}
<strong>{anchorTitle?.trim() || `Übung #${anchorExerciseId}`}</strong>
{' · '}
<Link to={`/exercises/${anchorExerciseId}`}>Ansehen</Link>
</p>
)}
<p style={{ fontSize: '13px', color: 'var(--text2)', marginBottom: '16px' }}>
Graphen bilden einen gerichteten Wald aus Übungen: <strong>Nachfolger</strong> ist „zuerst A, dann B“;
<strong> Schwestern</strong> markieren Alternativen oder parallele Entwicklungsschritte. Fortschritt{' '}
<em>innerhalb einer Übung</em> (Varianten, Progressionsstufen) pflegst du unter „Übungsvarianten“.
</p>
{loadErr && (
<div className="card" style={{ borderColor: 'var(--danger)', marginBottom: '12px' }}>
<p style={{ margin: 0, color: 'var(--danger)' }}>{loadErr}</p>
</div>
)}
<div className="card" style={{ marginBottom: '12px' }}>
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>Graph auswählen</h3>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '10px', alignItems: 'flex-end' }}>
<div className="form-row" style={{ flex: '1 1 220px', marginBottom: 0 }}>
<label className="form-label">Aktiver Graph</label>
<select
className="form-input"
value={selectedGraphId ?? ''}
onChange={(e) => setSelectedGraphId(e.target.value ? parseInt(e.target.value, 10) : null)}
>
<option value="">— wählen —</option>
{graphs.map((g) => (
<option key={g.id} value={g.id}>
{g.name} ({g.edges_count ?? 0} Kanten)
</option>
))}
</select>
</div>
<button
type="button"
className="btn"
disabled={busy || !selectedGraphId}
onClick={() => refreshEdges(selectedGraphId)}
>
Kanten neu laden
</button>
<button type="button" className="btn" disabled={busy || !selectedGraphId} onClick={handleDeleteGraph}>
Graph löschen
</button>
</div>
<form onSubmit={handleCreateGraph} style={{ marginTop: '16px', paddingTop: '16px', borderTop: '1px solid var(--border)' }}>
<h4 style={{ margin: '0 0 8px', fontSize: '0.95rem' }}>Neuen Graphen anlegen</h4>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '10px', alignItems: 'flex-end' }}>
<div className="form-row" style={{ flex: '2 1 200px', marginBottom: 0 }}>
<label className="form-label">Name</label>
<input
className="form-input"
value={newGraphName}
onChange={(e) => setNewGraphName(e.target.value)}
placeholder="z. B. Kumite-Einstieg Verein Nord"
/>
</div>
<div className="form-row" style={{ flex: '1 1 140px', marginBottom: 0 }}>
<label className="form-label">Sichtbarkeit</label>
<select
className="form-input"
value={newGraphVisibility}
onChange={(e) => setNewGraphVisibility(e.target.value)}
>
{VIS_OPTIONS.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
</select>
</div>
<button type="submit" className="btn btn-primary" disabled={busy}>
Graph erstellen
</button>
</div>
</form>
</div>
{selectedGraphId && (
<div className="card" style={{ marginBottom: '12px' }}>
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>Graph bearbeiten</h3>
<div className="form-row">
<label className="form-label">Name</label>
<input className="form-input" value={metaName} onChange={(e) => setMetaName(e.target.value)} />
</div>
<div className="form-row">
<label className="form-label">Beschreibung</label>
<textarea
className="form-input"
rows={2}
value={metaDescription}
onChange={(e) => setMetaDescription(e.target.value)}
/>
</div>
<div className="form-row">
<label className="form-label">Sichtbarkeit</label>
<select className="form-input" value={metaVisibility} onChange={(e) => setMetaVisibility(e.target.value)}>
{VIS_OPTIONS.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
</select>
</div>
<button type="button" className="btn btn-secondary" disabled={busy} onClick={handleSaveMeta}>
Metadaten speichern
</button>
</div>
)}
{selectedGraphId && (
<div className="card" style={{ marginBottom: '12px' }}>
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>Kante hinzufügen</h3>
<div className="form-row">
<label className="form-label">Beziehung</label>
<select
className="form-input"
value={relationKind}
onChange={(e) => setRelationKind(e.target.value)}
>
<option value="progression">Nachfolger (zuerst Übung A, danach Übung B)</option>
<option value="sibling">Schwester (gleiche Entwicklungslage / Alternative)</option>
</select>
</div>
<p style={{ fontSize: '12px', color: 'var(--text3)', marginTop: 0 }}>
{relationKind === 'progression'
? '„Vorgänger von B ist A“ entspricht dieser Kante: A kommt vor B. Bei Bedarf „Reihenfolge tauschen“.'
: 'Eine gerichtete Schwester-Kante reicht; semantisch gilt die Paarbeziehung als bidirektional.'}
</p>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))', gap: '12px' }}>
<div className="form-row" style={{ marginBottom: 0 }}>
<label className="form-label">
{relationKind === 'progression' ? 'Übung A (kommt zuerst)' : 'Übung A'}
</label>
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap', alignItems: 'center' }}>
<span style={{ flex: '1 1 160px', fontSize: '13px' }}>
{firstEx ? (
<>
<strong>{firstEx.title}</strong>
<span style={{ color: 'var(--text3)' }}> (#{firstEx.id})</span>
</>
) : (
<span style={{ color: 'var(--text3)' }}>— nicht gewählt —</span>
)}
</span>
<button type="button" className="btn btn-secondary" onClick={() => setPickSlot('first')}>
Übung wählen…
</button>
{anchorExerciseId != null && (
<button
type="button"
className="btn"
style={{ fontSize: '12px', padding: '4px 10px' }}
onClick={() =>
setFirstEx({
id: anchorExerciseId,
title: anchorTitle?.trim() || `Übung #${anchorExerciseId}`,
})
}
>
Diese Übung
</button>
)}
</div>
</div>
<div className="form-row" style={{ marginBottom: 0 }}>
<label className="form-label">
{relationKind === 'progression' ? 'Übung B (kommt danach)' : 'Übung B'}
</label>
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap', alignItems: 'center' }}>
<span style={{ flex: '1 1 160px', fontSize: '13px' }}>
{secondEx ? (
<>
<strong>{secondEx.title}</strong>
<span style={{ color: 'var(--text3)' }}> (#{secondEx.id})</span>
</>
) : (
<span style={{ color: 'var(--text3)' }}>— nicht gewählt —</span>
)}
</span>
<button type="button" className="btn btn-secondary" onClick={() => setPickSlot('second')}>
Übung wählen…
</button>
{anchorExerciseId != null && (
<button
type="button"
className="btn"
style={{ fontSize: '12px', padding: '4px 10px' }}
onClick={() =>
setSecondEx({
id: anchorExerciseId,
title: anchorTitle?.trim() || `Übung #${anchorExerciseId}`,
})
}
>
Diese Übung
</button>
)}
</div>
</div>
</div>
{relationKind === 'progression' && (
<button type="button" className="btn" style={{ marginTop: '8px' }} onClick={swapEnds}>
Reihenfolge tauschen (A ↔ B)
</button>
)}
<div className="form-row">
<label className="form-label">Entwicklungsziel / Notiz (optional)</label>
<textarea
className="form-input"
rows={2}
value={edgeNotes}
onChange={(e) => setEdgeNotes(e.target.value)}
placeholder="z. B. Fokus auf sicheren Abstand, dann dynamischer Eintritt …"
/>
</div>
<button type="button" className="btn btn-primary" disabled={busy} onClick={handleAddEdge}>
Kante speichern
</button>
</div>
)}
{selectedGraphId && anchorExerciseId != null && (
<label style={{ display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '12px', fontSize: '13px' }}>
<input
type="checkbox"
checked={filterAnchorOnly}
onChange={(e) => setFilterAnchorOnly(e.target.checked)}
/>
Nur Kanten anzeigen, die diese Übung betreffen
</label>
)}
{selectedGraphId && (
<div className="card">
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>
Kanten ({filteredEdges.length}
{edges.length !== filteredEdges.length ? ` von ${edges.length}` : ''})
</h3>
{filteredEdges.length === 0 ? (
<p style={{ color: 'var(--text2)', margin: 0 }}>Noch keine Kanten in diesem Graph.</p>
) : (
<div style={{ overflowX: 'auto' }}>
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: '13px' }}>
<thead>
<tr style={{ textAlign: 'left', borderBottom: '1px solid var(--border)' }}>
<th style={{ padding: '8px 6px' }}>Von</th>
<th style={{ padding: '8px 6px' }} />
<th style={{ padding: '8px 6px' }}>Nach</th>
<th style={{ padding: '8px 6px' }}>Art</th>
<th style={{ padding: '8px 6px' }}>Entwicklungsziel</th>
<th style={{ padding: '8px 6px' }} />
</tr>
</thead>
<tbody>
{filteredEdges.map((row) => (
<tr key={row.id} style={{ borderBottom: '1px solid var(--border)' }}>
<td style={{ padding: '8px 6px', verticalAlign: 'top' }}>
<Link to={`/exercises/${row.from_exercise_id}`}>{row.from_exercise_title || `#${row.from_exercise_id}`}</Link>
</td>
<td style={{ padding: '8px 6px', color: 'var(--text3)', verticalAlign: 'top' }}>
{row.edge_type === 'sibling' ? '·' : '→'}
</td>
<td style={{ padding: '8px 6px', verticalAlign: 'top' }}>
<Link to={`/exercises/${row.to_exercise_id}`}>{row.to_exercise_title || `#${row.to_exercise_id}`}</Link>
</td>
<td style={{ padding: '8px 6px', verticalAlign: 'top' }}>{edgeTypeLabel(row.edge_type)}</td>
<td style={{ padding: '8px 6px', verticalAlign: 'top', maxWidth: '280px' }}>
{editingEdgeNotes === row.id ? (
<>
<textarea
className="form-input"
rows={2}
value={notesDraft}
onChange={(e) => setNotesDraft(e.target.value)}
style={{ marginBottom: '6px' }}
/>
<button type="button" className="btn btn-secondary" disabled={busy} onClick={() => saveNotes(row.id)}>
Notiz speichern
</button>
<button type="button" className="btn" disabled={busy} onClick={() => setEditingEdgeNotes(null)}>
Abbrechen
</button>
</>
) : (
<>
<span style={{ whiteSpace: 'pre-wrap' }}>{row.notes || '—'}</span>
<button
type="button"
className="btn"
style={{ marginLeft: '8px', fontSize: '12px', padding: '4px 8px' }}
onClick={() => startEditNotes(row)}
>
Bearbeiten
</button>
</>
)}
</td>
<td style={{ padding: '8px 6px', verticalAlign: 'top' }}>
<button
type="button"
className="btn"
style={{ fontSize: '12px', padding: '4px 8px', background: 'var(--danger)', color: '#fff', border: 'none' }}
onClick={() => handleDeleteEdge(row.id)}
>
Löschen
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
)}
<ExercisePickerModal open={pickSlot != null} onClose={() => setPickSlot(null)} onSelectExercise={onPicked} />
</div>
)
}
+13
View File
@@ -2,6 +2,7 @@ import React, { useEffect, useState, useRef } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import api, { buildExerciseApiPayload } from '../utils/api'
import RichTextEditor from '../components/RichTextEditor'
import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGraphPanel'
import { SKILL_LEVEL_OPTIONS, normalizeSkillLevelSlug } from '../constants/skillLevels'
const INTENSITY_OPTIONS = [
@@ -1151,6 +1152,18 @@ function ExerciseFormPage() {
</details>
)}
{isEdit && (
<details className="card exercise-variants-details" style={{ marginTop: '16px' }}>
<summary className="exercise-variants-summary">
<span className="exercise-variants-summary__title">Progressionsgraph</span>
<span className="exercise-variants-summary__badge">Übung → Übung</span>
</summary>
<div className="exercise-variants-details__body">
<ExerciseProgressionGraphPanel anchorExerciseId={exerciseId} anchorTitle={formData.title} />
</div>
</details>
)}
{isEdit && (
<div className="card" style={{ marginTop: '16px' }}>
<h2 style={{ marginTop: 0, fontSize: '1.1rem' }}>Medien</h2>
+43 -6
View File
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'
import api from '../utils/api'
import { SKILL_LEVEL_OPTIONS } from '../constants/skillLevels'
import MultiSelectCombo from '../components/MultiSelectCombo'
import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGraphPanel'
const PAGE_SIZE = 100
const LEVEL_FILTER_OPTS = SKILL_LEVEL_OPTIONS.filter((o) => o.level != null)
@@ -44,6 +45,7 @@ function ExercisesListPage() {
const [debouncedAiSearch, setDebouncedAiSearch] = useState('')
const [filters, setFilters] = useState(() => ({ ...INITIAL_FILTERS }))
const [filterModalOpen, setFilterModalOpen] = useState(false)
const [pageTab, setPageTab] = useState('list')
useEffect(() => {
const t = setTimeout(() => setDebouncedSearch(searchInput.trim()), 400)
@@ -287,7 +289,7 @@ function ExercisesListPage() {
}, [])
useEffect(() => {
if (!catalogsReady) return
if (!catalogsReady || pageTab !== 'list') return
let cancelled = false
const run = async () => {
setListFetching(true)
@@ -311,7 +313,7 @@ function ExercisesListPage() {
return () => {
cancelled = true
}
}, [queryBase, catalogsReady])
}, [queryBase, catalogsReady, pageTab])
const loadMore = async () => {
if (loadingMore || !hasMore) return
@@ -340,7 +342,7 @@ function ExercisesListPage() {
const resetAllFilters = useCallback(() => setFilters({ ...INITIAL_FILTERS }), [])
if (!catalogsReady) {
if (!catalogsReady && pageTab === 'list') {
return (
<div style={{ padding: '2rem', textAlign: 'center' }}>
<div className="spinner"></div>
@@ -362,11 +364,44 @@ function ExercisesListPage() {
}}
>
<h1 style={{ fontSize: '1.35rem' }}>Übungen</h1>
<Link to="/exercises/new" className="btn btn-primary">
+ Neu
</Link>
{pageTab === 'list' ? (
<Link to="/exercises/new" className="btn btn-primary">
+ Neu
</Link>
) : (
<span />
)}
</div>
<div
role="tablist"
aria-label="Übungen Bereiche"
style={{ display: 'flex', gap: '8px', marginBottom: '14px', flexWrap: 'wrap' }}
>
<button
type="button"
role="tab"
aria-selected={pageTab === 'list'}
className={pageTab === 'list' ? 'btn btn-primary' : 'btn btn-secondary'}
onClick={() => setPageTab('list')}
>
Liste
</button>
<button
type="button"
role="tab"
aria-selected={pageTab === 'progression'}
className={pageTab === 'progression' ? 'btn btn-primary' : 'btn btn-secondary'}
onClick={() => setPageTab('progression')}
>
Progressionsgraphen
</button>
</div>
{pageTab === 'progression' ? (
<ExerciseProgressionGraphPanel />
) : (
<>
<div className="card exercise-search-bar" style={{ marginBottom: '12px' }}>
<label className="form-label">Volltextsuche (Titel, Ziel, …)</label>
<datalist id="exercise-search-titles">
@@ -687,6 +722,8 @@ function ExercisesListPage() {
)}
</>
)}
</>
)}
</div>
)
}
+63
View File
@@ -443,6 +443,60 @@ export async function reorderExerciseVariants(exerciseId, variantIds) {
})
}
// Progressionsgraphen (Übung → Übung), Migration 032/033
export async function listExerciseProgressionGraphs() {
return request('/api/exercise-progression-graphs')
}
export async function getExerciseProgressionGraph(id, { includeEdges = false } = {}) {
const q = includeEdges ? '?include_edges=true' : ''
return request(`/api/exercise-progression-graphs/${id}${q}`)
}
export async function createExerciseProgressionGraph(data) {
return request('/api/exercise-progression-graphs', {
method: 'POST',
body: JSON.stringify(data),
})
}
export async function updateExerciseProgressionGraph(id, data) {
return request(`/api/exercise-progression-graphs/${id}`, {
method: 'PUT',
body: JSON.stringify(data),
})
}
export async function deleteExerciseProgressionGraph(id) {
return request(`/api/exercise-progression-graphs/${id}`, { method: 'DELETE' })
}
export async function listExerciseProgressionEdges(graphId, query = {}) {
const q = new URLSearchParams()
if (query.from_exercise_id != null) q.set('from_exercise_id', String(query.from_exercise_id))
if (query.to_exercise_id != null) q.set('to_exercise_id', String(query.to_exercise_id))
const qs = q.toString()
return request(`/api/exercise-progression-graphs/${graphId}/edges${qs ? `?${qs}` : ''}`)
}
export async function createExerciseProgressionEdge(graphId, data) {
return request(`/api/exercise-progression-graphs/${graphId}/edges`, {
method: 'POST',
body: JSON.stringify(data),
})
}
export async function updateExerciseProgressionEdge(graphId, edgeId, data) {
return request(`/api/exercise-progression-graphs/${graphId}/edges/${edgeId}`, {
method: 'PUT',
body: JSON.stringify(data),
})
}
export async function deleteExerciseProgressionEdge(graphId, edgeId) {
return request(`/api/exercise-progression-graphs/${graphId}/edges/${edgeId}`, { method: 'DELETE' })
}
/** KI-Ausbaustufe (EXERCISES_API_SPEC): benötigt Backend + z. B. OPENROUTER_API_KEY. */
export async function suggestExerciseAi(payload) {
return request('/api/exercises/ai/suggest', {
@@ -951,6 +1005,15 @@ export const api = {
updateExerciseMedia,
deleteExerciseMedia,
reorderExerciseMedia,
listExerciseProgressionGraphs,
getExerciseProgressionGraph,
createExerciseProgressionGraph,
updateExerciseProgressionGraph,
deleteExerciseProgressionGraph,
listExerciseProgressionEdges,
createExerciseProgressionEdge,
updateExerciseProgressionEdge,
deleteExerciseProgressionEdge,
// Training Planning
listTrainingUnits,