Let each tenant create named API keys with content and visibility scope.
Deploy Development / deploy (push) Failing after 32s
Test Suite / pytest-backend (push) Failing after 26s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Failing after 6s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Canceled after 1m34s
Deploy Development / deploy (push) Failing after 32s
Test Suite / pytest-backend (push) Failing after 26s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Failing after 6s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Canceled after 1m34s
Superadmins enable a club for the interface. Club admins and members create the keys. Exercise release lives on its own tab and picks one of those keys. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fe3633ba8b
commit
1527a430b9
14 files changed
+842
-290
No files matched your search
@@ -326,11 +326,7 @@ const appRouter = createBrowserRouter([
|
||||
},
|
||||
{
|
||||
path: 'admin/distribution',
|
||||
element: (
|
||||
<PlatformAdminRoute>
|
||||
<AdminDistributionPage />
|
||||
</PlatformAdminRoute>
|
||||
),
|
||||
element: <AdminDistributionPage />,
|
||||
},
|
||||
{
|
||||
path: 'admin/rights',
|
||||
|
||||
@@ -76,3 +76,25 @@ export function assignDistributionExercise(publisherId, exerciseId) {
|
||||
export function getDistributionBacklog() {
|
||||
return request('/api/distribution/admin/backlog')
|
||||
}
|
||||
|
||||
export function getDistributionAccess() {
|
||||
return request('/api/distribution/access')
|
||||
}
|
||||
|
||||
export function setClubDistributionApi(clubId, enabled) {
|
||||
return request(`/api/distribution/access/clubs/${clubId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ enabled }),
|
||||
})
|
||||
}
|
||||
|
||||
export function createDistributionAccessKey(body) {
|
||||
return request('/api/distribution/access/keys', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
|
||||
export function revokeDistributionAccessKey(keyId) {
|
||||
return request(`/api/distribution/access/keys/${keyId}/revoke`, { method: 'POST', body: '{}' })
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export default function AdminPageNav() {
|
||||
{ to: '/admin/ai-prompts', label: 'KI Prompts', icon: Sparkles },
|
||||
{ to: '/admin/openrouter', label: 'KI-Modell', icon: Bot },
|
||||
{ to: '/admin/exercise-enrichment', label: 'Übungs-Anreicherung', icon: Wand2 },
|
||||
{ to: '/admin/distribution', label: 'Distribution', icon: Share2 },
|
||||
{ to: '/admin/distribution', label: 'API-Schnittstelle', icon: Share2 },
|
||||
]
|
||||
|
||||
return (
|
||||
|
||||
@@ -8,18 +8,7 @@ import {
|
||||
withdrawDistributionRelease,
|
||||
} from '../../api/distribution'
|
||||
|
||||
const ACTIONS = [
|
||||
'store',
|
||||
'render',
|
||||
'stream',
|
||||
'download',
|
||||
'print',
|
||||
'course_display',
|
||||
'commercial_course_use',
|
||||
'adapt',
|
||||
'public_preview',
|
||||
'grant_customer_use',
|
||||
]
|
||||
const RELEASE_ACTIONS = ['store', 'render', 'stream', 'course_display', 'commercial_course_use']
|
||||
|
||||
const REASONS = [
|
||||
['rights', 'Rechte'],
|
||||
@@ -32,11 +21,9 @@ const REASONS = [
|
||||
export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
const [overview, setOverview] = useState(null)
|
||||
const [error, setError] = useState('')
|
||||
const [publisherId, setPublisherId] = useState('')
|
||||
const [recipientId, setRecipientId] = useState('')
|
||||
const [keyId, setKeyId] = useState('')
|
||||
const [draft, setDraft] = useState(null)
|
||||
const [evidence, setEvidence] = useState('nachweis')
|
||||
const [actions, setActions] = useState(['store', 'render'])
|
||||
const [retirePrevious, setRetirePrevious] = useState(true)
|
||||
const [reason, setReason] = useState('rights')
|
||||
const [busy, setBusy] = useState(false)
|
||||
@@ -55,12 +42,6 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
function toggleAction(action) {
|
||||
setActions((current) =>
|
||||
current.includes(action) ? current.filter((item) => item !== action) : [...current, action]
|
||||
)
|
||||
}
|
||||
|
||||
function withRights(cut) {
|
||||
const rightsId = 'rights-main'
|
||||
const next = {
|
||||
@@ -70,7 +51,7 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
{
|
||||
id: rightsId,
|
||||
evidence_ref: evidence.trim(),
|
||||
actions,
|
||||
actions: RELEASE_ACTIONS,
|
||||
territories: ['DE'],
|
||||
valid_from: new Date(Date.now() - 60000).toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
||||
valid_until: null,
|
||||
@@ -87,10 +68,7 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
setBusy(true)
|
||||
setError('')
|
||||
try {
|
||||
const created = await createDistributionDraft(exerciseId, {
|
||||
publisher_id: publisherId.trim(),
|
||||
recipient_id: recipientId.trim(),
|
||||
})
|
||||
const created = await createDistributionDraft(exerciseId, { key_id: keyId })
|
||||
const cut = withRights(created.cut)
|
||||
const updated = await updateDistributionDraft(exerciseId, created.draft_id, cut)
|
||||
setDraft(updated)
|
||||
@@ -110,9 +88,10 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
await updateDistributionDraft(exerciseId, draft.draft_id, cut)
|
||||
const result = await confirmDistributionDraft(exerciseId, draft.draft_id)
|
||||
if (retirePrevious && overview?.releases?.length && !result.replayed) {
|
||||
const recipientId = (overview.keys || []).find((item) => item.id === keyId)?.recipient_id
|
||||
const previous = [...overview.releases]
|
||||
.reverse()
|
||||
.find((item) => item.recipient_id === recipientId.trim() && !item.fetch_blocked)
|
||||
.find((item) => item.recipient_id === recipientId && !item.fetch_blocked)
|
||||
if (previous) {
|
||||
await retireDistributionRelease(previous.release_id)
|
||||
}
|
||||
@@ -140,53 +119,32 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
}
|
||||
|
||||
if (!overview) {
|
||||
return <section className="card">Distribution wird geladen …</section>
|
||||
return <p>Freigabe wird geladen …</p>
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="card" style={{ marginBottom: 16 }}>
|
||||
<h2 style={{ marginTop: 0 }}>Externe Freigabe</h2>
|
||||
<div>
|
||||
{!overview.enabled ? (
|
||||
<p>Die Distribution ist auf dieser Instanz nicht aktiv. Bearbeitung und Planung bleiben davon unberührt.</p>
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Private Übungen gibt die Person frei, der sie gehören. Vereinsübungen gibt ein Vereinsadmin dieses Vereins frei.
|
||||
Globale Übungen gibt nur ein Superadmin frei.
|
||||
</p>
|
||||
{overview.release_block ? <p>{overview.release_block}</p> : null}
|
||||
<div className="form-row">
|
||||
<label className="form-label">
|
||||
Herausgeber
|
||||
<input className="form-input" value={publisherId} onChange={(event) => setPublisherId(event.target.value)} placeholder="UUID" />
|
||||
</label>
|
||||
<label className="form-label">
|
||||
Empfänger
|
||||
<input className="form-input" value={recipientId} onChange={(event) => setRecipientId(event.target.value)} placeholder="UUID" />
|
||||
</label>
|
||||
</div>
|
||||
{overview.publishers?.length ? (
|
||||
<ul>
|
||||
{overview.publishers.map((publisher) => (
|
||||
<li key={publisher.id}>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => setPublisherId(publisher.id)}>
|
||||
{publisher.name} ({publisher.kind})
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
<fieldset>
|
||||
<legend>Nutzungsumfang</legend>
|
||||
{ACTIONS.map((action) => (
|
||||
<label key={action} style={{ display: 'inline-flex', gap: 6, marginRight: 12 }}>
|
||||
<input type="checkbox" checked={actions.includes(action)} onChange={() => toggleAction(action)} />
|
||||
{action}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
<label className="form-label">
|
||||
Nachweisreferenz
|
||||
API-Schlüssel
|
||||
<select className="form-input" value={keyId} onChange={(event) => setKeyId(event.target.value)}>
|
||||
<option value="">Bitte wählen</option>
|
||||
{(overview.keys || []).map((item) => (
|
||||
<option key={item.id} value={item.id}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '13px' }}>
|
||||
Der Empfänger darf die Fassung übernehmen und im Kurs zeigen, auch kommerziell. Herunterladen und Bearbeiten sind nicht enthalten.
|
||||
</p>
|
||||
<label className="form-label">
|
||||
Nachweis
|
||||
<input className="form-input" value={evidence} onChange={(event) => setEvidence(event.target.value)} />
|
||||
</label>
|
||||
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
@@ -257,6 +215,6 @@ export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
</>
|
||||
) : null}
|
||||
{error ? <p role="alert">{error}</p> : null}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
} from '../../utils/activeClub'
|
||||
import { COMBINATION_ARCHETYPE_OPTIONS, ARCHETYPE_DEFAULT_REP_SERIES_COUNT, defaultRepSeriesCountForArchetype } from '../../constants/combinationArchetypes'
|
||||
import { readSlotProfilesV1, normalizeAdvanceMode, parseComboRepSeriesCountUi } from '../../utils/combinationMethodProfileUi'
|
||||
import { GripVertical, FileText, BookOpen, Tags, Layers, GitBranch, Image as ImageIcon } from 'lucide-react'
|
||||
import { GripVertical, FileText, BookOpen, Tags, Layers, GitBranch, Image as ImageIcon, Share2 } from 'lucide-react'
|
||||
import UnsavedChangesPrompt from '../UnsavedChangesPrompt'
|
||||
import PageFormEditorChrome from '../PageFormEditorChrome'
|
||||
import { ExerciseFormTabBar, ExerciseFormPanel } from './ExerciseFormLayout'
|
||||
@@ -668,9 +668,11 @@ function ExerciseFormPageRoot() {
|
||||
})
|
||||
}
|
||||
tabs.push({ id: 'medien', label: 'Medien & Mehr', icon: ImageIcon })
|
||||
tabs.push({ id: 'freigabe', label: 'Freigabe', icon: Share2 })
|
||||
} else {
|
||||
tabs.push({ id: 'varianten', label: 'Varianten', icon: GitBranch, disabled: true })
|
||||
tabs.push({ id: 'medien', label: 'Medien & Mehr', icon: ImageIcon, disabled: true })
|
||||
tabs.push({ id: 'freigabe', label: 'Freigabe', icon: Share2, disabled: true })
|
||||
}
|
||||
return tabs
|
||||
}, [formData.exercise_kind, isEdit, variants.length])
|
||||
@@ -1612,8 +1614,6 @@ function ExerciseFormPageRoot() {
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{isEdit && exerciseId ? <ExerciseDistributionPanel exerciseId={exerciseId} /> : null}
|
||||
|
||||
<div className="card exercise-form-edit">
|
||||
<form id="exercise-form" onSubmit={handleSubmit}>
|
||||
<ExerciseFormTabBar
|
||||
@@ -2905,6 +2905,14 @@ function ExerciseFormPageRoot() {
|
||||
/>
|
||||
)}
|
||||
</ExerciseFormPanel>
|
||||
<ExerciseFormPanel
|
||||
tab="freigabe"
|
||||
activeTab={activeFormTab}
|
||||
title="Freigabe"
|
||||
hint="Eingefrorene Fassung für einen Empfänger. Die Übung selbst bleibt davon unberührt."
|
||||
>
|
||||
<ExerciseDistributionPanel exerciseId={exerciseId} />
|
||||
</ExerciseFormPanel>
|
||||
) : null}
|
||||
|
||||
</form>
|
||||
|
||||
@@ -607,6 +607,10 @@ function AccountSettingsPage() {
|
||||
</div>
|
||||
|
||||
<p className="muted" style={{ marginTop: '1.75rem', fontSize: '0.875rem', lineHeight: 1.5 }}>
|
||||
<Link to="/admin/distribution">API-Schlüssel</Link>
|
||||
{' — Schnittstelle für Übungen und spätere Planungsinhalte'}
|
||||
</p>
|
||||
<p className="muted" style={{ marginTop: '0.6rem', fontSize: '0.875rem', lineHeight: 1.5 }}>
|
||||
<Link to="/settings/system">Technische Systeminformationen</Link>
|
||||
{' — App-Version, Build, Umgebung, Datenbankschema'}
|
||||
</p>
|
||||
|
||||
@@ -1,194 +1,236 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import AdminPageNav from '../components/AdminPageNav'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import {
|
||||
assignDistributionExercise,
|
||||
assignDistributionReleaser,
|
||||
createDistributionBinding,
|
||||
createDistributionPublisher,
|
||||
createDistributionRecipient,
|
||||
createDistributionRelationship,
|
||||
getDistributionBacklog,
|
||||
issueDistributionKey,
|
||||
createDistributionAccessKey,
|
||||
getDistributionAccess,
|
||||
revokeDistributionAccessKey,
|
||||
setClubDistributionApi,
|
||||
} from '../api/distribution'
|
||||
|
||||
export default function AdminDistributionPage() {
|
||||
const [message, setMessage] = useState('')
|
||||
const OBJECTS = [
|
||||
['exercise', 'Übung'],
|
||||
['training_plan', 'Trainingsplan'],
|
||||
['framework', 'Rahmenprogramm'],
|
||||
['training_module', 'Trainingsmodul'],
|
||||
]
|
||||
|
||||
const VISIBILITY = {
|
||||
official: 'Global',
|
||||
club: 'Verein',
|
||||
private: 'Eigene',
|
||||
}
|
||||
|
||||
function KeyForm({ contextKind, clubId, allowedVisibilities, onCreated }) {
|
||||
const [name, setName] = useState('')
|
||||
const [objects, setObjects] = useState(['exercise'])
|
||||
const [visibilities, setVisibilities] = useState(
|
||||
allowedVisibilities.length === 1 ? allowedVisibilities : [allowedVisibilities[0]]
|
||||
)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
const [token, setToken] = useState('')
|
||||
const [backlog, setBacklog] = useState(null)
|
||||
const [publisherName, setPublisherName] = useState('')
|
||||
const [kind, setKind] = useState('platform')
|
||||
const [clubId, setClubId] = useState('')
|
||||
const [recipientName, setRecipientName] = useState('')
|
||||
const [publisherId, setPublisherId] = useState('')
|
||||
const [recipientId, setRecipientId] = useState('')
|
||||
const [bindingName, setBindingName] = useState('Anbindung')
|
||||
const [bindingId, setBindingId] = useState('')
|
||||
const [profileId, setProfileId] = useState('')
|
||||
const [exerciseId, setExerciseId] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
getDistributionBacklog()
|
||||
.then((data) => setBacklog(data.count))
|
||||
.catch(() => setBacklog(null))
|
||||
}, [])
|
||||
function toggle(list, value, setter) {
|
||||
setter(list.includes(value) ? list.filter((item) => item !== value) : [...list, value])
|
||||
}
|
||||
|
||||
async function run(action) {
|
||||
async function submit(event) {
|
||||
event.preventDefault()
|
||||
setBusy(true)
|
||||
setError('')
|
||||
setMessage('')
|
||||
setToken('')
|
||||
try {
|
||||
const result = await action()
|
||||
setMessage(result?.id ? `Angelegt: ${result.id}` : 'Gespeichert.')
|
||||
return result
|
||||
const result = await createDistributionAccessKey({
|
||||
name: name.trim(),
|
||||
objects,
|
||||
visibilities,
|
||||
context_kind: contextKind,
|
||||
club_id: clubId || null,
|
||||
})
|
||||
setName('')
|
||||
onCreated(result)
|
||||
} catch (err) {
|
||||
setError(err.message || 'Speichern fehlgeschlagen.')
|
||||
return null
|
||||
setError(err.message || 'Schlüssel konnte nicht angelegt werden.')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ padding: 16 }}>
|
||||
<AdminPageNav />
|
||||
<h1>Distribution</h1>
|
||||
<p>Herausgeber, Empfänger und Schlüssel richtet der Betrieb ein. Der Schlüssel wird nur einmal angezeigt.</p>
|
||||
<p>Ausstehende Fristabläufe: {backlog === null ? '—' : backlog}</p>
|
||||
{message ? <p>{message}</p> : null}
|
||||
<form onSubmit={submit}>
|
||||
<label className="form-label">
|
||||
Name
|
||||
<input className="form-input" value={name} onChange={(event) => setName(event.target.value)} required />
|
||||
</label>
|
||||
<fieldset>
|
||||
<legend>Inhalte</legend>
|
||||
{OBJECTS.map(([value, label]) => (
|
||||
<label key={value} style={{ display: 'inline-flex', gap: 6, marginRight: 12 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={objects.includes(value)}
|
||||
onChange={() => toggle(objects, value, setObjects)}
|
||||
/>
|
||||
{label}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Sichtbarkeit</legend>
|
||||
{allowedVisibilities.map((value) => (
|
||||
<label key={value} style={{ display: 'inline-flex', gap: 6, marginRight: 12 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={visibilities.includes(value)}
|
||||
disabled={allowedVisibilities.length === 1}
|
||||
onChange={() => toggle(visibilities, value, setVisibilities)}
|
||||
/>
|
||||
{VISIBILITY[value]}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
{error ? <p role="alert">{error}</p> : null}
|
||||
<button type="submit" className="btn btn-primary" disabled={busy || !name.trim() || !objects.length || !visibilities.length}>
|
||||
Schlüssel erzeugen
|
||||
</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
function KeyList({ keys, onRevoke }) {
|
||||
if (!keys.length) return <p style={{ color: 'var(--text2)' }}>Noch kein Schlüssel.</p>
|
||||
return (
|
||||
<ul>
|
||||
{keys.map((item) => (
|
||||
<li key={item.id} style={{ marginBottom: 8 }}>
|
||||
<strong>{item.label}</strong>
|
||||
{' · '}
|
||||
{item.objects.map((object) => OBJECTS.find(([value]) => value === object)?.[1] || object).join(', ')}
|
||||
{' · '}
|
||||
{item.visibilities.map((value) => VISIBILITY[value] || value).join(', ')}
|
||||
<button type="button" className="btn btn-secondary" style={{ marginLeft: 8 }} onClick={() => onRevoke(item.id)}>
|
||||
Widerrufen
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
export default function AdminDistributionPage() {
|
||||
const { user } = useAuth()
|
||||
const superadmin = user?.role === 'superadmin'
|
||||
const [home, setHome] = useState(null)
|
||||
const [error, setError] = useState('')
|
||||
const [token, setToken] = useState('')
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
setHome(await getDistributionAccess())
|
||||
setError('')
|
||||
} catch (err) {
|
||||
setError(err.message || 'Die API-Schnittstelle konnte nicht geladen werden.')
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
async function toggleClub(club, enabled) {
|
||||
setError('')
|
||||
try {
|
||||
await setClubDistributionApi(club.id, enabled)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message || 'Die Freigabe konnte nicht gespeichert werden.')
|
||||
}
|
||||
}
|
||||
|
||||
async function revoke(keyId) {
|
||||
setError('')
|
||||
try {
|
||||
await revokeDistributionAccessKey(keyId)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message || 'Der Schlüssel konnte nicht widerrufen werden.')
|
||||
}
|
||||
}
|
||||
|
||||
function created(result) {
|
||||
setToken(result.token)
|
||||
load()
|
||||
}
|
||||
|
||||
const keys = home?.keys || []
|
||||
const clubs = home?.clubs || []
|
||||
|
||||
return (
|
||||
<div style={{ padding: 16, maxWidth: 880 }}>
|
||||
{superadmin ? <AdminPageNav /> : <p><Link to="/settings">Zurück zu Einstellungen</Link></p>}
|
||||
<h1>API-Schnittstelle</h1>
|
||||
<p style={{ color: 'var(--text2)', maxWidth: 68 * 8 }}>
|
||||
Ein Schlüssel hat einen Namen und legt fest, welche Inhalte und welche Sichtbarkeit ein externes Programm abrufen darf.
|
||||
Trainingsplan, Rahmenprogramm und Trainingsmodul können schon erlaubt werden. Ausgeliefert werden derzeit Übungen.
|
||||
</p>
|
||||
{error ? <p role="alert">{error}</p> : null}
|
||||
{token ? (
|
||||
<p>
|
||||
Schlüssel: <code>{token}</code>
|
||||
Schlüssel, nur jetzt sichtbar: <code>{token}</code>
|
||||
</p>
|
||||
) : null}
|
||||
{!home ? <p>Wird geladen …</p> : null}
|
||||
|
||||
{superadmin ? (
|
||||
<section className="card" style={{ marginBottom: 16 }}>
|
||||
<h2>Vereine</h2>
|
||||
<p>Ein Verein legt seine Schlüssel selbst an, sobald die Schnittstelle für ihn frei ist.</p>
|
||||
<ul>
|
||||
{clubs.map((club) => (
|
||||
<li key={club.id} style={{ marginBottom: 8 }}>
|
||||
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={club.api_enabled}
|
||||
onChange={(event) => toggleClub(club, event.target.checked)}
|
||||
/>
|
||||
{club.name}
|
||||
</label>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{superadmin ? (
|
||||
<section className="card" style={{ marginBottom: 16 }}>
|
||||
<h2>Plattform</h2>
|
||||
<p>Für globale Übungen und eigene Übungen des Superadmins.</p>
|
||||
<KeyForm contextKind="platform" allowedVisibilities={['official', 'private']} onCreated={created} />
|
||||
<KeyList keys={keys.filter((item) => item.context_kind === 'platform')} onRevoke={revoke} />
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{clubs.filter((club) => club.is_club_admin).map((club) => (
|
||||
<section className="card" key={club.id} style={{ marginBottom: 16 }}>
|
||||
<h2>{club.name}</h2>
|
||||
{club.api_enabled ? (
|
||||
<>
|
||||
<p>Schlüssel dieses Vereins. Sichtbar sind Vereinsübungen und, wenn angekreuzt, eigene Übungen der Mitglieder.</p>
|
||||
<KeyForm contextKind="club" clubId={club.id} allowedVisibilities={['club', 'private']} onCreated={created} />
|
||||
<KeyList keys={keys.filter((item) => item.context_kind === 'club' && item.club_id === club.id)} onRevoke={revoke} />
|
||||
</>
|
||||
) : (
|
||||
<p>Die Schnittstelle ist für diesen Verein noch nicht freigegeben.</p>
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
|
||||
<section className="card">
|
||||
<h2>Herausgeber</h2>
|
||||
<label className="form-label">
|
||||
Name
|
||||
<input className="form-input" value={publisherName} onChange={(event) => setPublisherName(event.target.value)} />
|
||||
</label>
|
||||
<label className="form-label">
|
||||
Bestand
|
||||
<select className="form-input" value={kind} onChange={(event) => setKind(event.target.value)}>
|
||||
<option value="platform">Plattformbestand</option>
|
||||
<option value="own">Eigener Bestand</option>
|
||||
<option value="club">Vereinsbestand</option>
|
||||
</select>
|
||||
</label>
|
||||
{kind === 'club' ? (
|
||||
<label className="form-label">
|
||||
Verein
|
||||
<input className="form-input" value={clubId} onChange={(event) => setClubId(event.target.value)} />
|
||||
</label>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() =>
|
||||
run(() =>
|
||||
createDistributionPublisher({
|
||||
name: publisherName,
|
||||
kind,
|
||||
club_id: kind === 'club' ? Number(clubId) : null,
|
||||
})
|
||||
).then((result) => result?.id && setPublisherId(result.id))
|
||||
}
|
||||
>
|
||||
Herausgeber anlegen
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h2>Empfänger und Anbindung</h2>
|
||||
<label className="form-label">
|
||||
Empfängername
|
||||
<input className="form-input" value={recipientName} onChange={(event) => setRecipientName(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() =>
|
||||
run(() => createDistributionRecipient({ name: recipientName })).then((result) => result?.id && setRecipientId(result.id))
|
||||
}
|
||||
>
|
||||
Empfänger anlegen
|
||||
</button>
|
||||
<label className="form-label">
|
||||
Herausgeber-ID
|
||||
<input className="form-input" value={publisherId} onChange={(event) => setPublisherId(event.target.value)} />
|
||||
</label>
|
||||
<label className="form-label">
|
||||
Empfänger-ID
|
||||
<input className="form-input" value={recipientId} onChange={(event) => setRecipientId(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => run(() => createDistributionRelationship({ publisher_id: publisherId, recipient_id: recipientId }))}
|
||||
>
|
||||
Beziehung zulassen
|
||||
</button>
|
||||
<label className="form-label">
|
||||
Name der Anbindung
|
||||
<input className="form-input" value={bindingName} onChange={(event) => setBindingName(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() =>
|
||||
run(() => createDistributionBinding({ recipient_id: recipientId, name: bindingName })).then(
|
||||
(result) => result?.id && setBindingId(result.id)
|
||||
)
|
||||
}
|
||||
>
|
||||
Anbindung anlegen
|
||||
</button>
|
||||
<label className="form-label">
|
||||
Anbindungs-ID
|
||||
<input className="form-input" value={bindingId} onChange={(event) => setBindingId(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={async () => {
|
||||
setError('')
|
||||
try {
|
||||
const result = await issueDistributionKey(bindingId)
|
||||
setToken(result.token)
|
||||
setMessage('Schlüssel erzeugt. Bitte jetzt sichern.')
|
||||
} catch (err) {
|
||||
setError(err.message || 'Schlüssel fehlgeschlagen.')
|
||||
}
|
||||
}}
|
||||
>
|
||||
Schlüssel erzeugen
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h2>Zuordnung</h2>
|
||||
<label className="form-label">
|
||||
Profil-ID der freigabeberechtigten Person
|
||||
<input className="form-input" value={profileId} onChange={(event) => setProfileId(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => run(() => assignDistributionReleaser(publisherId, Number(profileId)))}
|
||||
>
|
||||
Freigabebefugnis zuweisen
|
||||
</button>
|
||||
<label className="form-label">
|
||||
Übungs-ID
|
||||
<input className="form-input" value={exerciseId} onChange={(event) => setExerciseId(event.target.value)} />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => run(() => assignDistributionExercise(publisherId, Number(exerciseId)))}
|
||||
>
|
||||
Übung dem Herausgeber zuordnen
|
||||
</button>
|
||||
<h2>Eigene Übungen</h2>
|
||||
<p>Dieser Schlüssel gilt nur für Übungen, die dir gehören.</p>
|
||||
<KeyForm contextKind="personal" allowedVisibilities={['private']} onCreated={created} />
|
||||
<KeyList keys={keys.filter((item) => item.context_kind === 'personal')} onRevoke={revoke} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user