FastAPI-Backend und React-Frontend mit Konten, Sendungsverfolgung, Projekt-Artikeln, Vorrat & Einkauf mit Rezeptabgleich, Reise-Weltkarte, Kanban-Projekten mit Priorität, Server-Monitoring und den Designs Matrix und Blackwall. Betrieb per Docker hinter nginx (siehe DEPLOY.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
React
30 lines
1.2 KiB
React
// Bearbeitbare Schnellzugriff-Links (Jellyfin, Audiobookshelf, Homer), einmal geladen und überall verfügbar
|
|
import { createContext, useCallback, useContext, useEffect, useState } from 'react';
|
|
import { api } from './api.js';
|
|
|
|
export const LINK_SERVICES = [
|
|
{ key: 'jellyfin', name: 'Jellyfin', description: 'Filme & Serien', placeholder: 'http://jellyfin.local:8096' },
|
|
{ key: 'audiobookshelf', name: 'Audiobookshelf', description: 'Hörbücher & Podcasts', placeholder: 'http://audiobookshelf.local:13378' },
|
|
{ key: 'homer', name: 'Homer', description: 'Server-Startseite', placeholder: 'http://homer.local:8080' },
|
|
];
|
|
|
|
const LinksContext = createContext({ links: {}, saveLinks: async () => {} });
|
|
|
|
export function LinksProvider({ children }) {
|
|
const [links, setLinks] = useState({});
|
|
|
|
useEffect(() => {
|
|
api('GET', '/api/links').then(setLinks).catch(() => {});
|
|
}, []);
|
|
|
|
const saveLinks = useCallback(async (values) => {
|
|
const updated = await api('PUT', '/api/links', values);
|
|
setLinks(updated);
|
|
return updated;
|
|
}, []);
|
|
|
|
return <LinksContext.Provider value={{ links, saveLinks }}>{children}</LinksContext.Provider>;
|
|
}
|
|
|
|
export const useLinks = () => useContext(LinksContext);
|