HifiPlanet-Website/hifi/assets/Downloads-TSRdWSGM.js
Maaxxs c6214637e8 Collapse overlong package card bullets instead of stretching the row
Since all cards in a row share one height, a single card with long
paragraphs in its description (e.g. Limitless) made every card as tall
as that one, leaving a lot of empty space in the others. Collapsed
bullets are now clamped to three lines; normal bullets fit, long
paragraphs end with an ellipsis and the card offers "Mehr anzeigen" to
show the full text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 00:18:09 +02:00

1 line
9.8 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 n,j as e,k as B,A as P,a as m,m as L}from"./index-CZwY_OSZ.js";import{E as W,a as F}from"./eye-B3LSTnOL.js";const g="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900",S={title:"",description:"",sort_order:0};function D(o,h,l){return new Promise((i,c)=>{const r=new XMLHttpRequest;r.open("POST",`${L}${o}`),r.withCredentials=!0,r.upload.onprogress=s=>{s.lengthComputable&&l(s.loaded/s.total)},r.onload=()=>{let s=null;try{s=JSON.parse(r.responseText)}catch{}r.status>=200&&r.status<300?i(s):c(new Error((s==null?void 0:s.error)||(r.status===413?"Die Datei ist zu groß für diesen Server.":`Fehler ${r.status}`)))},r.onerror=()=>c(new Error("Netzwerkfehler beim Hochladen")),r.send(h)})}function I(){const[o,h]=n.useState(void 0),[l,i]=n.useState(""),[c,r]=n.useState(!1),[s,x]=n.useState(null);n.useEffect(()=>{m.get("/settings/downloads").then(d=>{h(d.password),i(d.password||"")}).catch(d=>x({kind:"error",text:d.message}))},[]);const b=async d=>{d.preventDefault(),r(!0),x(null);try{const u=await m.put("/settings/downloads",{password:l});h(u.password),i(u.password||""),x({kind:"ok",text:u.password?"Gespeichert – der Bereich ist jetzt geschützt.":"Gespeichert – der Bereich ist jetzt öffentlich."})}catch(u){x({kind:"error",text:u.message})}finally{r(!1)}};return e.jsxs("form",{onSubmit:b,className:"space-y-3 rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsx("h2",{className:"font-bold text-neutral-900 dark:text-white",children:"Zugriffsschutz"}),e.jsxs("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:[o===void 0&&"Lädt…",o===null&&"Öffentlich – jeder, der die Seite aufruft, sieht die Dateien.",typeof o=="string"&&"Geschützt – Besucher müssen zuerst das Passwort eingeben."]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Zugangspasswort (leer = öffentlich)"}),e.jsx("input",{value:l,maxLength:100,autoComplete:"off",onChange:d=>i(d.target.value),className:g}),e.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:"Das Passwort an die Kunden weitergeben – es bleibt hier jederzeit einsehbar. Direkte Links zu einzelnen Dateien funktionieren auch ohne Passwort; wer freigeschaltet hat, könnte sie also weitergeben."})]}),s&&e.jsx("p",{className:`text-sm ${s.kind==="error"?"text-red-600":"text-brand-600 dark:text-brand-400"}`,children:s.text}),e.jsx("button",{type:"submit",disabled:c||o===void 0,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:"Speichern"})]})}function T(){const[o,h]=n.useState([]),[l,i]=n.useState(S),[c,r]=n.useState(null),[s,x]=n.useState(null),[b,d]=n.useState(null),[u,N]=n.useState(!1),[y,p]=n.useState(""),[_,v]=n.useState(null),w=n.useRef(null),k=()=>m.get("/downloads/manage").then(h);n.useEffect(()=>{k()},[]);const f=()=>{x(null),i(S),r(null),p(""),w.current&&(w.current.value="")},z=t=>{f(),x(t.id),i({title:t.title,description:t.description||"",sort_order:t.sort_order}),window.scrollTo({top:0,behavior:"smooth"})},E=async t=>{if(t.preventDefault(),!s&&!c){p("Bitte eine Datei auswählen.");return}N(!0),p("");try{if(s){if(await m.put(`/downloads/${s}`,l),c){const a=new FormData;a.append("file",c),d(0),await D(`/downloads/${s}/file`,a,d)}}else{const a=new FormData;a.append("file",c),a.append("title",l.title),a.append("description",l.description),d(0),await D("/downloads",a,d)}f(),k()}catch(a){p(a.message)}finally{N(!1),d(null)}},A=async t=>{v(t.id);try{const a=await m.patch(`/downloads/${t.id}/visibility`,{is_hidden:!t.is_hidden});h(C=>C.map(j=>j.id===t.id?{...j,is_hidden:a.is_hidden}:j))}catch(a){alert(`Sichtbarkeit konnte nicht geändert werden: ${a.message}`)}finally{v(null)}},$=async t=>{confirm(`"${t.title}" inkl. Datei wirklich löschen?`)&&(await m.delete(`/downloads/${t.id}`),s===t.id&&f(),k())};return e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx("h1",{className:"mb-4 text-xl font-bold text-neutral-900 dark:text-white",children:"Downloads"}),e.jsxs("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:["Dateien, die Kunden auf der Seite"," ",e.jsx("a",{href:"/downloads",target:"_blank",rel:"noopener noreferrer",className:"text-brand-600 hover:underline",children:"/downloads"})," ","anhören bzw. herunterladen können, z. B. Songs oder Anleitungen. Der Menüpunkt „Downloads“ erscheint auf der Website automatisch, sobald mindestens eine Datei sichtbar ist. Ohne Zugangspasswort (siehe „Zugriffsschutz“) ist die Seite öffentlich."]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-800",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-neutral-50 text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2",children:"Titel / Datei"}),e.jsx("th",{className:"px-4 py-2",children:"Größe"}),e.jsx("th",{className:"px-4 py-2",children:"Website"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Aktionen"})]})}),e.jsxs("tbody",{className:"divide-y divide-neutral-100 dark:divide-neutral-800",children:[o.map(t=>e.jsxs("tr",{className:"bg-white dark:bg-neutral-950",children:[e.jsxs("td",{className:`px-4 py-2 ${t.is_hidden?"opacity-60":""}`,children:[e.jsx("p",{className:"font-medium text-neutral-800 dark:text-neutral-100",children:t.title}),e.jsx("a",{href:t.file_path,target:"_blank",rel:"noopener noreferrer",className:"break-all text-xs text-neutral-500 hover:text-brand-600 dark:text-neutral-400",children:t.file_name})]}),e.jsx("td",{className:"whitespace-nowrap px-4 py-2 text-neutral-500 dark:text-neutral-400",children:B(t.file_size)}),e.jsx("td",{className:"px-4 py-2",children:e.jsxs("button",{type:"button",onClick:()=>A(t),disabled:_===t.id,title:t.is_hidden?"Wieder auf der Website anzeigen":"Auf der Website ausblenden",className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold transition disabled:opacity-50 ${t.is_hidden?"border-amber-300 bg-amber-50 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:bg-amber-900/30 dark:text-amber-300":"border-neutral-300 text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800"}`,children:[t.is_hidden?e.jsx(W,{className:"h-3.5 w-3.5"}):e.jsx(F,{className:"h-3.5 w-3.5"}),t.is_hidden?"Ausgeblendet":"Sichtbar"]})}),e.jsxs("td",{className:"whitespace-nowrap px-4 py-2 text-right",children:[e.jsx("button",{onClick:()=>z(t),className:"mr-3 text-brand-600 hover:underline",children:"Bearbeiten"}),e.jsx("button",{onClick:()=>$(t),className:"text-red-600 hover:underline",children:"Löschen"})]})]},t.id)),o.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-6 text-center text-neutral-400",children:"Noch keine Dateien hochgeladen."})})]})]})})]}),e.jsxs("div",{className:"h-fit space-y-6",children:[e.jsxs("form",{onSubmit:E,className:"space-y-4 rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsx("h2",{className:"font-bold text-neutral-900 dark:text-white",children:s?"Download bearbeiten":"Neue Datei hochladen"}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:s?"Datei ersetzen (optional)":"Datei *"}),e.jsx("input",{ref:w,type:"file",accept:P.map(t=>`.${t}`).join(","),onChange:t=>{var a;return r(((a=t.target.files)==null?void 0:a[0])||null)},className:"block w-full text-sm text-neutral-600 file:mr-3 file:rounded-md file:border-0 file:bg-brand-500 file:px-3 file:py-2 file:text-sm file:font-semibold file:text-white hover:file:bg-brand-600 dark:text-neutral-300"}),e.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:"Musik (MP3, WAV, FLAC, …), Videos, PDFs, Bilder, Office-Dokumente oder ZIP-Archive. Andere Dateitypen bitte als ZIP hochladen."})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Titel ",s?"*":"(optional)"]}),e.jsx("input",{required:!!s,value:l.title,maxLength:150,onChange:t=>i({...l,title:t.target.value}),placeholder:s?"":"Leer lassen = Dateiname",className:g})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Beschreibung (optional)"}),e.jsx("textarea",{rows:3,value:l.description,onChange:t=>i({...l,description:t.target.value}),className:g})]}),s&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Sortierung"}),e.jsx("input",{type:"number",value:l.sort_order,onChange:t=>i({...l,sort_order:Number(t.target.value)}),className:g})]}),b!==null&&e.jsxs("div",{children:[e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-800",children:e.jsx("div",{className:"h-full rounded-full bg-brand-500 transition-[width]",style:{width:`${Math.round(b*100)}%`}})}),e.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:b<1?`Wird hochgeladen … ${Math.round(b*100)} %`:"Wird gespeichert …"})]}),y&&e.jsx("p",{className:"text-sm text-red-600",children:y}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:u,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:s?"Speichern":"Hochladen"}),s&&e.jsx("button",{type:"button",onClick:f,disabled:u,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),e.jsx(I,{})]})]})}export{T as default};