HifiPlanet-Website/hifi/assets/DatabaseSettings-Cb0c_VcO.js
Maaxxs 54928d1411 Add package badges/visibility and a download area, speed up the site
Customer feedback round (4 items):

- Packages: one-click "Sichtbar/Ausgeblendet" toggle per package (saved
  immediately). Hidden packages disappear from the model page; the tier
  look of the remaining cards is ranked across all packages so it stays
  stable.
- Packages: badge per card (Empfohlen, Am beliebtesten, Tipp, Coming soon
  or custom text) plus an optional video link shown as "Zum Video". Legacy
  is_featured maps to "Empfohlen".
- New download area (/downloads + Admin -> Downloads): upload with
  progress, inline audio player, allow-listed file types, optional access
  password, new permission downloads.manage. Files live in
  api/uploads/downloads/ (gitignored, created at runtime).
- Performance:
  - SetupGate no longer refetches and remounts the whole app on every
    navigation.
  - Page loader waits only for pending API calls and above-the-fold images
    (fixes an 8 s hang on /leistungen caused by lazy images inside the
    hidden container).
  - Admin pages lazy-loaded; icon library moved out of the main bundle
    (initial JS 2.2 MB -> 0.48 MB).
  - Background video loads only near the viewport and was re-encoded to
    720p (32 MB -> 8.5 MB).
  - Visitors without a session cookie get no PHP session, so their parallel
    API requests no longer queue on the session lock.
  - index.html is served with Cache-Control: no-cache so browsers don't
    keep a stale build after deploys.
- Fonts (Barlow, Barlow Condensed, Michroma) are self-hosted instead of
  loaded from Google Fonts; the default privacy policy mentions this, lists
  all local storage uses and uses the new TDDDG name.
- A code update that adds a table no longer sends the site into the setup
  wizard while an admin exists.

Run "Datenbankstruktur aktualisieren" after deploying (new package
columns, downloads table, app_settings.downloads_password).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:15:48 +02:00

1 line
8.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{r as s,a as l,j as e}from"./index-CA8nTsDv.js";function q(){const[r,n]=s.useState({host:"",name:"",user:"",password:"",charset:"utf8mb4"}),[x,h]=s.useState(!1),[F,g]=s.useState(!0),[p,H]=s.useState(!1),[k,f]=s.useState(!1),[j,w]=s.useState(""),[V,v]=s.useState(!1),[a,u]=s.useState(null),[o,N]=s.useState(!0),[y,S]=s.useState(!1),[C,m]=s.useState(null),[B,D]=s.useState(!1),[c,P]=s.useState(null),[z,E]=s.useState(""),[d,A]=s.useState(null),T=()=>{g(!0),l.get("/settings/database").then(t=>{n({...t.config,password:""}),h(t.has_password)}).finally(()=>g(!1))},b=()=>{N(!0),l.get("/settings/schema-check").then(u).catch(t=>u({ok:!1,error:t.message,tables:[]})).finally(()=>N(!1))};s.useEffect(()=>{T(),b(),l.get("/settings/compress-status").then(t=>A(t.gd_available)).catch(()=>A(!1))},[]);const M=async()=>{S(!0),m(null);try{const t=await l.post("/settings/schema-migrate",{});m(t.actions),u(t.report)}catch(t){m(["Fehler: "+t.message])}finally{S(!1)}},R=async()=>{D(!0),E(""),P(null);try{const t=await l.post("/settings/compress-uploads",{});P(t)}catch(t){E(t.message)}finally{D(!1)}},_=async t=>{t.preventDefault(),f(!0),w(""),v(!1);try{await l.post("/settings/database",r),v(!0),n(i=>({...i,password:""})),h(!0),b()}catch(i){w(i.message)}finally{f(!1)}};return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("section",{className:"rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"Datenbank-Zugangsdaten"}),e.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Wichtig für einen Umzug auf einen anderen Server/Webspace: Trage hier die Zugangsdaten der dortigen Datenbank ein. Die Verbindung wird vor dem Speichern getestet, damit du dich nicht aussperrst."}),F?e.jsx("p",{className:"text-sm text-neutral-400",children:"Lädt…"}):e.jsxs("form",{onSubmit:_,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Host *"}),e.jsx("input",{required:!0,value:r.host,onChange:t=>n({...r,host:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Datenbankname *"}),e.jsx("input",{required:!0,value:r.name,onChange:t=>n({...r,name:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Benutzer *"}),e.jsx("input",{required:!0,value:r.user,onChange:t=>n({...r,user:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Passwort ",x?"(leer lassen = unverändert)":""]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:p?"text":"password",value:r.password,onChange:t=>n({...r,password:t.target.value}),placeholder:x?"••••••••":"",className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"}),e.jsx("button",{type:"button",onClick:()=>H(t=>!t),className:"shrink-0 rounded-md border border-neutral-300 px-3 text-sm dark:border-neutral-700",children:p?"Verbergen":"Anzeigen"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Zeichensatz"}),e.jsx("input",{value:r.charset,onChange:t=>n({...r,charset:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),j&&e.jsx("p",{className:"text-sm text-red-600",children:j}),V&&e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"Verbindung erfolgreich getestet und gespeichert."}),e.jsx("button",{type:"submit",disabled:k,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:k?"Teste & speichere…":"Verbindung testen & speichern"})]})]}),e.jsxs("section",{className:"rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"font-semibold text-neutral-900 dark:text-white",children:"Datenbankstruktur"}),!o&&a&&e.jsx("span",{className:`rounded-full px-3 py-1 text-xs font-semibold ${a.ok?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"}`,children:a.ok?"Datenbank OK":"Datenbank nicht OK"})]}),e.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Prüft, ob diese Datenbank alle Tabellen und Spalten hat, die der aktuelle Code-Stand braucht – wichtig, wenn deine Live-Version auf einem anderen Server einen älteren Stand hat."}),o&&e.jsx("p",{className:"text-sm text-neutral-400",children:"Prüfe…"}),!o&&a&&!a.ok&&e.jsx("ul",{className:"mb-4 space-y-1 rounded-md bg-red-50 p-3 text-sm text-red-800 dark:bg-red-900/20 dark:text-red-300",children:a.tables.filter(t=>!t.ok).map(t=>e.jsx("li",{children:t.exists?e.jsxs(e.Fragment,{children:["Tabelle ",e.jsx("code",{className:"font-mono",children:t.table}),": Spalte(n) fehlen – ",t.missing_columns.join(", ")]}):e.jsxs(e.Fragment,{children:["Tabelle ",e.jsx("code",{className:"font-mono",children:t.table})," fehlt komplett"]})},t.table))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:b,disabled:o,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm font-medium hover:bg-neutral-50 disabled:opacity-50 dark:border-neutral-700 dark:hover:bg-neutral-800",children:"Erneut prüfen"}),a&&!a.ok&&e.jsx("button",{onClick:M,disabled:y,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:y?"Aktualisiere…":"Datenbankstruktur aktualisieren"})]}),C&&e.jsx("ul",{className:"mt-3 space-y-1 rounded-md bg-neutral-50 p-3 text-sm text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300",children:C.map((t,i)=>e.jsx("li",{children:t},i))})]}),e.jsxs("section",{className:"rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"font-semibold text-neutral-900 dark:text-white",children:"Bilder optimieren"}),d!==null&&e.jsx("span",{className:`rounded-full px-3 py-1 text-xs font-semibold ${d?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"}`,children:d?"Aktiv":"Nicht verfügbar"})]}),e.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Neu hochgeladene Bilder werden seit Kurzem automatisch verkleinert und komprimiert. Dieser Button holt das für alle bereits vorhandenen Bilder nach – nützlich, wenn die Seite durch zu hoch aufgelöste Fotos spürbar langsam lädt."}),d===!1&&e.jsx("p",{className:"mb-4 rounded-md bg-amber-50 p-3 text-sm text-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:'Diese Funktion braucht die PHP-Erweiterung "gd", die auf diesem Server aktuell nicht aktiv ist. Bei den meisten Hostern (auch All-Inkl) ist sie standardmäßig Teil jeder PHP-Version und lässt sich nicht einzeln zu- oder abschalten – bitte beim Hoster-Support nachfragen bzw. prüfen, ob in den Hosting-Einstellungen eine andere PHP-Version ausgewählt werden muss.'}),e.jsx("button",{onClick:R,disabled:B||d===!1,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:B?"Komprimiert…":"Bestehende Bilder optimieren"}),z&&e.jsx("p",{className:"mt-3 text-sm text-red-600",children:z}),c&&e.jsxs("p",{className:"mt-3 text-sm text-green-600 dark:text-green-400",children:[c.processed," Bild(er) verkleinert: ",(c.before_bytes/1024/1024).toFixed(1)," MB"," → ",(c.after_bytes/1024/1024).toFixed(1)," MB."]})]})]})}export{q as default};