feat: add MEDIAWIKI_CATEGORY_MODELS to docker-compose and refactor MediaLibraryPage
Some checks failed
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 25s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Failing after 1m43s

- Introduced MEDIAWIKI_CATEGORY_MODELS environment variable in docker-compose.yml for better configuration.
- Refactored MediaLibraryPage to simplify video rendering by replacing createElement with JSX syntax, enhancing readability and maintainability.
- Removed lazy loading and Suspense for MediaLibraryPage to streamline component rendering.
This commit is contained in:
Lars 2026-05-08 09:07:51 +02:00
parent c1d1c2d7e0
commit d758de3852
3 changed files with 34 additions and 53 deletions

View File

@ -51,6 +51,7 @@ services:
MEDIAWIKI_CATEGORY_EXERCISES: "${MEDIAWIKI_CATEGORY_EXERCISES:-Übungen}"
MEDIAWIKI_CATEGORY_SKILLS: "${MEDIAWIKI_CATEGORY_SKILLS:-Fähigkeitsbeschreibung}"
MEDIAWIKI_CATEGORY_METHODS: "${MEDIAWIKI_CATEGORY_METHODS:-Methodenbeschreibung}"
MEDIAWIKI_CATEGORY_MODELS: "${MEDIAWIKI_CATEGORY_MODELS:-Reifegradmodelle}"
# Medien: Container-Pfad MEDIA_ROOT; Host-Pfad SHINKAN_MEDIA_HOST (in .env überschreiben; Default /shinkan-media).
MEDIA_ROOT: "${MEDIA_ROOT:-/app/media}"
volumes:

View File

@ -1,4 +1,4 @@
import React, { lazy, Suspense } from 'react'
import React from 'react'
import {
BrowserRouter as Router,
Routes,
@ -32,11 +32,10 @@ import AdminMaturityModelsPage from './pages/AdminMaturityModelsPage'
import TrainerContextsPage from './pages/TrainerContextsPage'
import MediaWikiImportPage from './pages/MediaWikiImportPage'
import AdminUsersPage from './pages/AdminUsersPage'
import MediaLibraryPage from './pages/MediaLibraryPage'
import ActiveClubSwitcher from './components/ActiveClubSwitcher'
import './app.css'
const MediaLibraryPage = lazy(() => import('./pages/MediaLibraryPage'))
// Bottom Navigation (Mobile)
function Nav({ isAdmin }) {
const items = getMainNavItems(isAdmin)
@ -160,28 +159,7 @@ function AppRoutes() {
<Route path="profile" element={<Navigate to="/settings" replace />} />
<Route path="settings" element={<AccountSettingsPage />} />
<Route path="settings/system" element={<SettingsSystemInfoPage />} />
<Route
path="media"
element={
<Suspense
fallback={
<div
style={{
minHeight: '50vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'var(--bg)',
}}
>
<div className="spinner" />
</div>
}
>
<MediaLibraryPage />
</Suspense>
}
/>
<Route path="media" element={<MediaLibraryPage />} />
<Route path="exercises">
<Route index element={<ExercisesListPage />} />
<Route path="new" element={<ExerciseFormPage />} />

View File

@ -1,4 +1,4 @@
import { useEffect, useState, useCallback, useRef, createElement } from 'react'
import { useEffect, useState, useCallback, useRef } from 'react'
import { Link } from 'react-router-dom'
import {
LayoutGrid,
@ -162,22 +162,24 @@ function MediaThumb({ mediaId, mimeType }) {
return <div className="media-library__thumb-ph">HEIC</div>
}
if (mime.startsWith('video/')) {
return createElement('video', {
className: 'media-library__thumb-video',
src: url,
muted: true,
playsInline: true,
preload: 'metadata',
onLoadedMetadata: (e) => {
const el = e.target
try {
const d = el.duration
el.currentTime = Number.isFinite(d) && d > 0 ? Math.min(0.05, d * 0.01) : 0.05
} catch {
/* ignore */
}
},
})
return (
<video
className="media-library__thumb-video"
src={url}
muted
playsInline
preload="metadata"
onLoadedMetadata={(e) => {
const el = e.target
try {
const d = el.duration
el.currentTime = Number.isFinite(d) && d > 0 ? Math.min(0.05, d * 0.01) : 0.05
} catch {
/* ignore */
}
}}
/>
)
}
if (mime.startsWith('image/')) {
return (
@ -905,17 +907,17 @@ export default function MediaLibraryPage() {
)
}
if (kind === 'video') {
return createElement(
'video',
{
key: preview.id,
className: 'media-library__preview-video',
src: url,
controls: true,
playsInline: true,
preload: 'metadata',
},
'Wiedergabe nicht unterstützt.',
return (
<video
key={preview.id}
className="media-library__preview-video"
src={url}
controls
playsInline
preload="metadata"
>
Wiedergabe nicht unterstützt.
</video>
)
}
if (kind === 'pdf') {