Enhance Maturity Matrix Tools and API Integration
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m19s
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m19s
- Added new functionality for exporting and importing matrix editor data in JSON and CSV formats within the MaturityMatrixToolsAdmin component. - Updated the API utility functions to support matrix editor exports and imports, enhancing the backend communication for Superadmin tasks. - Refactored the client API to streamline request handling and improve code clarity. - Included new UI elements for file upload and download actions, improving user experience in managing matrix data.
This commit is contained in:
1 parent
cdeddc7cec
commit
d58db3d5dd
6 files changed
+1089
-11
No files matched your search
@@ -13,6 +13,16 @@ function downloadJson(obj, filename) {
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function downloadText(text, filename, mime = 'text/csv;charset=utf-8') {
|
||||
const blob = new Blob([text], { type: mime })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = filename
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function groupModelSkills(model) {
|
||||
if (!model?.model_skills?.length) return []
|
||||
const groups = new Map()
|
||||
@@ -56,6 +66,8 @@ export default function MaturityMatrixToolsAdmin() {
|
||||
const [stackConfirmText, setStackConfirmText] = useState('')
|
||||
const [stackLoading, setStackLoading] = useState(false)
|
||||
const [stackImportLoading, setStackImportLoading] = useState(false)
|
||||
const [editorLoading, setEditorLoading] = useState(false)
|
||||
const [editorImportLoading, setEditorImportLoading] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
@@ -144,6 +156,94 @@ export default function MaturityMatrixToolsAdmin() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExportEditorJson() {
|
||||
setError('')
|
||||
setMessage('')
|
||||
setEditorLoading(true)
|
||||
try {
|
||||
const bundle = await api.exportMatrixEditorBundle()
|
||||
const name = `matrix-editor-${(bundle.bundle_export_id || 'export').slice(0, 8)}.json`
|
||||
downloadJson(bundle, name)
|
||||
setMessage('Editor-Export (JSON) heruntergeladen.')
|
||||
} catch (err) {
|
||||
setError(err.message || String(err))
|
||||
} finally {
|
||||
setEditorLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExportEditorCsv(part) {
|
||||
setError('')
|
||||
setMessage('')
|
||||
setEditorLoading(true)
|
||||
try {
|
||||
const { text, filename } = await api.exportMatrixEditorCsv(part)
|
||||
downloadText(
|
||||
text,
|
||||
filename || (part === 'skills' ? 'faehigkeiten-katalog.csv' : 'faehigkeitsmatrix-zellen.csv')
|
||||
)
|
||||
setMessage(part === 'skills' ? 'Katalog-CSV heruntergeladen.' : 'Matrix-CSV heruntergeladen.')
|
||||
} catch (err) {
|
||||
setError(err.message || String(err))
|
||||
} finally {
|
||||
setEditorLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleImportEditorJson(e) {
|
||||
const file = e.target.files?.[0]
|
||||
if (!file) return
|
||||
setError('')
|
||||
setMessage('')
|
||||
setEditorImportLoading(true)
|
||||
try {
|
||||
const data = JSON.parse(await file.text())
|
||||
if (data.kind !== 'shinkan.matrix_editor.v1') {
|
||||
setError('Erwartet wird kind: shinkan.matrix_editor.v1')
|
||||
return
|
||||
}
|
||||
const res = await api.importMatrixEditorBundle(data)
|
||||
const w = res.warnings || []
|
||||
setMessage(
|
||||
`Import OK: ${res.skills_updated || 0} Fähigkeit(en), ${res.matrix_cells_updated || 0} Matrix-Zelle(n) aktualisiert.` +
|
||||
(w.length ? ` ${w.length} Hinweis(e) in der Konsole.` : '')
|
||||
)
|
||||
if (w.length) console.warn('matrix_editor import warnings', w)
|
||||
} catch (err) {
|
||||
setError(err.message || String(err))
|
||||
} finally {
|
||||
setEditorImportLoading(false)
|
||||
e.target.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function handleImportEditorCsv(e, part) {
|
||||
const file = e.target.files?.[0]
|
||||
if (!file) return
|
||||
setError('')
|
||||
setMessage('')
|
||||
setEditorImportLoading(true)
|
||||
try {
|
||||
const csv_text = await file.text()
|
||||
const res = await api.importMatrixEditorBundle({
|
||||
kind: 'shinkan.matrix_editor.csv',
|
||||
part,
|
||||
csv_text
|
||||
})
|
||||
const w = res.warnings || []
|
||||
setMessage(
|
||||
`CSV-Import (${part}) OK: ${res.skills_updated || 0} Fähigkeit(en), ${res.matrix_cells_updated || 0} Matrix-Zelle(n) aktualisiert.` +
|
||||
(w.length ? ` ${w.length} Hinweis(e) in der Konsole.` : '')
|
||||
)
|
||||
if (w.length) console.warn('matrix_editor csv import warnings', w)
|
||||
} catch (err) {
|
||||
setError(err.message || String(err))
|
||||
} finally {
|
||||
setEditorImportLoading(false)
|
||||
e.target.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExportStack() {
|
||||
setError('')
|
||||
setMessage('')
|
||||
@@ -234,9 +334,8 @@ export default function MaturityMatrixToolsAdmin() {
|
||||
return (
|
||||
<div className="admin-matrix-tools">
|
||||
<p className="admin-matrix-tools__intro muted">
|
||||
Matrix nach Kontext auflösen, hierarchisch nach Hauptkategorie und Kategorie darstellen, sowie JSON
|
||||
exportieren oder importieren (gespeichertes Modell inkl. optional Kontext-Bindings, aufgelöste Matrix, oder{' '}
|
||||
<strong>Komplett-Stack</strong> mit Fähigkeitskatalog und allen Reifegradmodellen für Test → Prod).
|
||||
Zentral Beschreibungen und Gewichtungen pflegen (Superadmin), Matrix nach Kontext anzeigen, sowie
|
||||
vollständige JSON-Stacks für Test → Prod.
|
||||
</p>
|
||||
|
||||
{error ? (
|
||||
@@ -246,6 +345,76 @@ export default function MaturityMatrixToolsAdmin() {
|
||||
) : null}
|
||||
{message ? <p className="muted admin-matrix-tools__msg">{message}</p> : null}
|
||||
|
||||
<section className="card admin-matrix-tools__section">
|
||||
<h2 className="admin-matrix-tools__h2">Zentral bearbeiten (Export / Import)</h2>
|
||||
<p className="muted admin-matrix-tools__hint">
|
||||
Flaches Format für Excel oder JSON-Editor: Fähigkeits-Beschreibungen,{' '}
|
||||
<code className="admin-bindings__code">importance</code> (Gewichtung 1–5), globale Stufen-Texte (
|
||||
<code className="admin-bindings__code">level_1</code> … <code className="admin-bindings__code">level_5</code>
|
||||
), Matrix-Zelltexte und Zeilen-Relevanz pro Reifegradmodell. Import aktualisiert bestehende Einträge —
|
||||
es werden keine neuen Fähigkeiten oder Modelle angelegt.
|
||||
</p>
|
||||
<div className="admin-matrix-tools__actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
disabled={editorLoading || editorImportLoading}
|
||||
onClick={handleExportEditorJson}
|
||||
>
|
||||
{editorLoading ? 'Export…' : 'JSON exportieren'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={editorLoading || editorImportLoading}
|
||||
onClick={() => handleExportEditorCsv('skills')}
|
||||
>
|
||||
Katalog als CSV
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={editorLoading || editorImportLoading}
|
||||
onClick={() => handleExportEditorCsv('matrix')}
|
||||
>
|
||||
Matrix-Zellen als CSV
|
||||
</button>
|
||||
</div>
|
||||
<div className="admin-matrix-tools__io-grid admin-matrix-tools__io-grid--editor">
|
||||
<div>
|
||||
<h3 className="admin-matrix-tools__h3">JSON importieren</h3>
|
||||
<label className="form-label">Datei (<code className="admin-bindings__code">shinkan.matrix_editor.v1</code>)</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="application/json,.json"
|
||||
disabled={editorImportLoading}
|
||||
onChange={handleImportEditorJson}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="admin-matrix-tools__h3">CSV importieren</h3>
|
||||
<p className="muted admin-matrix-tools__hint">
|
||||
Nur geänderte Datei hochladen — Katalog-CSV oder Matrix-CSV getrennt.
|
||||
</p>
|
||||
<label className="form-label">Katalog-CSV</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="text/csv,.csv"
|
||||
disabled={editorImportLoading}
|
||||
onChange={(e) => handleImportEditorCsv(e, 'skills')}
|
||||
/>
|
||||
<label className="form-label admin-matrix-tools__btn-mt">Matrix-CSV</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="text/csv,.csv"
|
||||
disabled={editorImportLoading}
|
||||
onChange={(e) => handleImportEditorCsv(e, 'matrix')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{editorImportLoading ? <p className="muted admin-matrix-tools__msg">Import läuft…</p> : null}
|
||||
</section>
|
||||
|
||||
<section className="card admin-matrix-tools__section">
|
||||
<h2 className="admin-matrix-tools__h2">Kontext und Anzeige</h2>
|
||||
<div className="admin-matrix-tools__filters">
|
||||
|
||||
Reference in new issue
Block a user