HifiPlanet-Website/hifi/assets/Downloads-DTmW1Yx6.js
Claude 6523206d22
Fahrzeug-Vorlage: neue Marken/Modelle bekommen die Standard-Schrift
Import uebernimmt die haeufigste Schrift-Einstellung (text_styles) der vorhandenen
Marken- und Modellnamen fuer alle Eintraege ohne eigene Einstellung. Im Vorlagen-Fenster
gleicht 'Jetzt angleichen' frueher importierte Eintraege an (POST /vehicle-catalog/align-styles).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019bUXMMTn84UnoT7ps5aXCs
2026-10-20 14:45:03 +00:00

1 line
11 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,q as P,s as W,j as e,c as f,A as I}from"./index-BM2n23kL.js";import{b as V,A as M}from"./downloads-B9pqFegV.js";import{S as Z,s as T}from"./SortableList-CdKMXDz1.js";import{V as G}from"./ViewOnSite-yEPGvejb.js";import{E as q,a as H}from"./eye-Z2HAQifv.js";import"./sortable.esm-x3iLDoEI.js";import"./grip-vertical-DZAT6CJD.js";const v="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={title:"",description:"",sort_order:0};function A(d,o,i){return new Promise((c,u)=>{const a=new XMLHttpRequest;a.open("POST",`${I}${d}`),a.withCredentials=!0,a.upload.onprogress=s=>{s.lengthComputable&&i(s.loaded/s.total)},a.onload=()=>{let s=null;try{s=JSON.parse(a.responseText)}catch{}a.status>=200&&a.status<300?c(s):u(new Error((s==null?void 0:s.error)||(a.status===413?"Die Datei ist zu groß für diesen Server.":`Fehler ${a.status}`)))},a.onerror=()=>u(new Error("Netzwerkfehler beim Hochladen")),a.send(o)})}function J(){const[d,o]=n.useState(void 0),[i,c]=n.useState(""),[u,a]=n.useState(!1),[s,x]=n.useState(null);n.useEffect(()=>{f.get("/settings/downloads").then(l=>{o(l.password),c(l.password||"")}).catch(l=>x({kind:"error",text:l.message}))},[]);const m=async l=>{l.preventDefault(),a(!0),x(null);try{const h=await f.put("/settings/downloads",{password:i});o(h.password),c(h.password||""),x({kind:"ok",text:h.password?"Gespeichert – der Bereich ist jetzt geschützt.":"Gespeichert – der Bereich ist jetzt öffentlich."})}catch(h){x({kind:"error",text:h.message})}finally{a(!1)}};return e.jsxs("form",{onSubmit:m,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:[d===void 0&&"Lädt…",d===null&&"Öffentlich – jeder, der die Seite aufruft, sieht die Dateien.",typeof d=="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:i,maxLength:100,autoComplete:"off",onChange:l=>c(l.target.value),className:v}),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:u||d===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 se(){const[d,o]=n.useState([]),[i,c]=n.useState(j),[u,a]=n.useState(null),[s,x]=n.useState(null),[m,l]=n.useState(null),[h,S]=n.useState(!1),[D,g]=n.useState(""),[E,_]=n.useState(null),[C,z]=n.useState(j),k=n.useRef(null),$=n.useRef(null),b=P();W(!!u||JSON.stringify(i)!==JSON.stringify(C),"downloads");const y=()=>f.get("/downloads/manage").then(o);n.useEffect(()=>{y()},[]);const w=()=>{x(null),c(j),z(j),a(null),g(""),k.current&&(k.current.value="")},B=t=>{var p;w(),x(t.id);const r={title:t.title,description:t.description||"",sort_order:t.sort_order};c(r),z(r),(p=$.current)==null||p.scrollIntoView({behavior:"smooth",block:"start"})},F=async t=>{if(t.preventDefault(),!s&&!u){g("Bitte eine Datei auswählen.");return}S(!0),g("");try{if(s){if(await f.put(`/downloads/${s}`,i),u){const r=new FormData;r.append("file",u),l(0),await A(`/downloads/${s}/file`,r,l)}}else{const r=new FormData;r.append("file",u),r.append("title",i.title),r.append("description",i.description),l(0),await A("/downloads",r,l)}b.success(s?"Download gespeichert.":"Datei hochgeladen."),w(),y()}catch(r){g(r.message)}finally{S(!1),l(null)}},L=async t=>{_(t.id);try{const r=await f.patch(`/downloads/${t.id}/visibility`,{is_hidden:!t.is_hidden});o(p=>p.map(N=>N.id===t.id?{...N,is_hidden:r.is_hidden}:N)),b.success(r.is_hidden?`„${t.title}“ ist jetzt ausgeblendet.`:`„${t.title}“ ist wieder sichtbar.`)}catch(r){b.error(`Sichtbarkeit konnte nicht geändert werden: ${r.message}`)}finally{_(null)}},R=async t=>{if(confirm(`"${t.title}" inkl. Datei wirklich löschen?`))try{await f.delete(`/downloads/${t.id}`),s===t.id&&w(),b.success("Download gelöscht."),y()}catch(r){b.error(`Löschen fehlgeschlagen: ${r.message}`)}},O=async t=>{const r=d;o(t);try{o(await T("downloads",t)),b.success("Reihenfolge gespeichert.")}catch(p){o(r),b.error(`Reihenfolge konnte nicht gespeichert werden: ${p.message}`)}};return e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h1",{className:"text-xl font-bold text-neutral-900 dark:text-white",children:"Downloads"}),e.jsx(G,{to:"/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. Reihenfolge am Griff links per Ziehen ändern."]}),e.jsxs("div",{className:"overflow-x-auto 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:"w-10 px-2 py-2",children:e.jsx("span",{className:"sr-only",children:"Reihenfolge"})}),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.jsx(Z,{items:d,onReorder:O,as:"tbody",className:"divide-y divide-neutral-100 bg-white dark:divide-neutral-800 dark:bg-neutral-950",children:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-2 py-2",children:r}),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:V(t.file_size)}),e.jsx("td",{className:"px-4 py-2",children:e.jsxs("button",{type:"button",onClick:()=>L(t),disabled:E===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(q,{className:"h-3.5 w-3.5"}):e.jsx(H,{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:()=>B(t),className:"mr-3 text-brand-600 hover:underline",children:"Bearbeiten"}),e.jsx("button",{onClick:()=>R(t),className:"text-red-600 hover:underline",children:"Löschen"})]})]})})]}),d.length===0&&e.jsx("p",{className:"px-4 py-6 text-center text-sm text-neutral-400",children:"Noch keine Dateien hochgeladen."})]})]}),e.jsxs("div",{className:"h-fit space-y-6",children:[e.jsxs("form",{ref:$,onSubmit:F,className:"scroll-mt-20 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:k,type:"file",accept:M.map(t=>`.${t}`).join(","),onChange:t=>{var r;return a(((r=t.target.files)==null?void 0:r[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:i.title,maxLength:150,onChange:t=>c({...i,title:t.target.value}),placeholder:s?"":"Leer lassen = Dateiname",className:v})]}),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:i.description,onChange:t=>c({...i,description:t.target.value}),className:v})]}),m!==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(m*100)}%`}})}),e.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:m<1?`Wird hochgeladen … ${Math.round(m*100)} %`:"Wird gespeichert …"})]}),D&&e.jsx("p",{className:"text-sm text-red-600",children:D}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:h,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:w,disabled:h,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),e.jsx(J,{})]})]})}export{se as default};