HifiPlanet-Website/hifi/assets/Downloads-BTBjkGUX.js
max.olchov 6bde1b0205
Besucher: eigene Live-Karte mit Seitenliste und Minutenverlauf
Die Echtzeit-Besucher stehen jetzt in einer eigenen Karte: Anzahl, Balken je
Minute der letzten 30 Minuten, Geräte und eine Liste der gerade angesehenen
Seiten (bis 10, mit Balken, ohne "| HifiPlanet"-Anhang). Die Karte holt sich
über GET /analytics/realtime jede Minute neue Werte (nur bei sichtbarem Tab).
Build neu.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TFDXmUdWg4Ai8x5ehhJvva
2026-10-22 09:57:55 +00:00

1 line
6.6 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{t as S,r as h,j as t,P as $,B as g,x as P,U as D,y as C,F as b,_ as E,w as _,W as B,c as j,C as F,$ as A}from"./index-Cchdg7uG.js";import{b as v,f as I,A as L}from"./downloads-B9pqFegV.js";import{u as O,E as W,R as M}from"./EntityList-yLA8e096.js";import"./SortableList-CrHaqHVB.js";import"./sortable.esm-OL8GYB2e.js";import"./grip-vertical-DcKEhQdg.js";const T={title:"",description:"",sort_order:0},R={audio:"play",video:"play",image:"image"};function N(m,n,c){return new Promise((r,l)=>{const i=new XMLHttpRequest;i.open("POST",`${A}${m}`),i.withCredentials=!0,i.upload.onprogress=a=>{a.lengthComputable&&c(a.loaded/a.total)},i.onload=()=>{let a=null;try{a=JSON.parse(i.responseText)}catch{}i.status>=200&&i.status<300?r(a):l(new Error((a==null?void 0:a.error)||(i.status===413?"Die Datei ist zu groß für diesen Server.":`Fehler ${i.status}`)))},i.onerror=()=>l(new Error("Netzwerkfehler beim Hochladen")),i.send(n)})}function K(){const m=S(),[n,c]=h.useState(void 0),[r,l]=h.useState(""),[i,a]=h.useState(!1),[s,f]=h.useState("");h.useEffect(()=>{j.get("/settings/downloads").then(o=>{c(o.password),l(o.password||"")}).catch(o=>f(o.message))},[]);const x=async o=>{o.preventDefault(),a(!0),f("");try{const p=await j.put("/settings/downloads",{password:r});c(p.password),l(p.password||""),m.success(p.password?"Gespeichert – der Bereich ist jetzt geschützt.":"Gespeichert – der Bereich ist jetzt öffentlich.")}catch(p){f(p.message)}finally{a(!1)}},w=(n||"")===r.trim();return t.jsx(F,{title:"Zugriffsschutz",description:"Mit Passwort sehen nur Kunden die Dateien, denen ihr den Code gebt.",actions:n===void 0?null:n?t.jsx(D,{tone:"brand",children:"Geschützt"}):t.jsx(D,{tone:"amber",children:"Öffentlich"}),children:t.jsxs("form",{onSubmit:x,children:[t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[t.jsx(b,{label:"Zugangspasswort",error:s,className:"flex-1",children:t.jsx(_,{value:r,maxLength:100,autoComplete:"off",onChange:o=>l(o.target.value),placeholder:"Leer lassen = öffentlich"})}),t.jsx(g,{type:"submit",disabled:i||n===void 0||w,children:"Speichern"})]}),t.jsx("p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-400",children:"Das Passwort bleibt hier jederzeit einsehbar. Direkte Links zu einzelnen Dateien funktionieren auch ohne Passwort."})]})})}function J(){const m=S(),[n,c]=h.useState(null),[r,l]=h.useState(null),[i,a]=h.useState(null),s=O({endpoint:"/downloads",listEndpoint:"/downloads/manage",reorderKey:"downloads",source:"downloads",emptyForm:T,toForm:e=>({title:e.title,description:e.description||"",sort_order:e.sort_order}),labels:{created:"Datei hochgeladen.",saved:"Download gespeichert.",deleted:"Download gelöscht."},save:async({editing:e,form:u})=>{try{if(e!=="new"){if(await j.put(`/downloads/${e}`,u),n){const d=new FormData;d.append("file",n),l(0),await N(`/downloads/${e}/file`,d,l)}}else{const d=new FormData;d.append("file",n),d.append("title",u.title),d.append("description",u.description),l(0),await N("/downloads",d,l)}c(null)}finally{l(null)}}}),{form:f,change:x}=s,w=s.isNew?null:(s.items||[]).find(e=>e.id===s.editing),o=e=>{c(null),s.openPanel(e)},p=e=>{c(e),s.setExtraDirty(!0)},k=e=>{if(e.preventDefault(),s.isNew&&!n){s.setError("Bitte eine Datei auswählen.");return}s.submit()},z=async e=>{a(e.id);try{const u=await j.patch(`/downloads/${e.id}/visibility`,{is_hidden:!e.is_hidden});s.setItems(d=>d.map(y=>y.id===e.id?{...y,is_hidden:u.is_hidden}:y)),m.success(u.is_hidden?`„${e.title}“ ist jetzt ausgeblendet.`:`„${e.title}“ ist wieder sichtbar.`)}catch(u){m.error(`Sichtbarkeit konnte nicht geändert werden: ${u.message}`)}finally{a(null)}};return t.jsxs("div",{className:"space-y-6",children:[t.jsx($,{title:"Downloads",description:"Songs, Anleitungen und andere Dateien für eure Kunden. Der Menüpunkt erscheint auf der Website, sobald eine Datei sichtbar ist. Reihenfolge am Griff links ziehen.",className:"!mb-0",actions:t.jsxs(t.Fragment,{children:[t.jsx(g,{variant:"secondary",icon:"eye",href:"/downloads",target:"_blank",rel:"noopener noreferrer",children:"Ansehen"}),t.jsx(g,{icon:"plus",onClick:()=>o(null),children:"Datei hochladen"})]})}),t.jsx(W,{items:s.items,editingId:s.editing,onReorder:s.reorder,onOpen:o,onDelete:e=>s.remove(e,`„${e.title}“ inkl. Datei wirklich löschen?`),searchText:e=>`${e.title} ${e.file_name}`,searchPlaceholder:"Datei suchen …",empty:{icon:"download",title:"Noch keine Dateien",description:"Lade z. B. Demo-Songs oder Bedienungsanleitungen hoch.",actions:t.jsx(g,{icon:"plus",onClick:()=>o(null),children:"Datei hochladen"})},renderRow:e=>({media:t.jsx(M,{icon:R[I(e.file_name)]||"file"}),title:e.title,subtitle:t.jsxs(t.Fragment,{children:[!!e.is_hidden&&t.jsx(D,{tone:"amber",className:"mr-2",children:"Ausgeblendet"}),e.file_name," · ",v(e.file_size)]}),muted:!!e.is_hidden,actions:t.jsx(P,{icon:e.is_hidden?"eyeOff":"eye",label:e.is_hidden?"Wieder auf der Website anzeigen":"Auf der Website ausblenden",disabled:i===e.id,onClick:()=>z(e)})})}),t.jsx(K,{}),t.jsxs(C,{as:"form",onSubmit:k,open:s.editing!==null,onClose:s.closePanel,size:"lg",title:s.isNew?"Datei hochladen":"Download bearbeiten",footer:t.jsxs(t.Fragment,{children:[t.jsx(g,{variant:"secondary",onClick:s.closePanel,disabled:s.saving,children:"Abbrechen"}),t.jsx(g,{type:"submit",disabled:s.saving||!s.isNew&&!s.dirty,children:s.saving?r!==null&&r<1?`Lädt hoch … ${Math.round(r*100)} %`:"Speichere…":s.isNew?"Hochladen":"Speichern"})]}),children:[s.error&&t.jsx("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300",children:s.error}),t.jsx(b,{label:s.isNew?"Datei":"Datei ersetzen (optional)",required:s.isNew,children:t.jsx(E,{file:n,onChange:p,disabled:s.saving,accept:L.map(e=>`.${e}`).join(","),current:w?`${w.file_name} (${v(w.file_size)})`:null,hint:"Musik, Videos, PDFs, Bilder, Office-Dateien oder ZIP. Andere Typen bitte als ZIP."})}),r!==null&&t.jsxs("div",{children:[t.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-800",children:t.jsx("div",{className:"h-full rounded-full bg-brand-500 transition-[width]",style:{width:`${Math.round(r*100)}%`}})}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:r<1?`Wird hochgeladen … ${Math.round(r*100)} %`:"Wird gespeichert …"})]}),t.jsx(b,{label:"Titel",required:!s.isNew,hint:s.isNew?"Leer lassen = Dateiname":null,children:t.jsx(_,{required:!s.isNew,maxLength:150,value:f.title,onChange:e=>x({title:e.target.value}),placeholder:s.isNew&&(n==null?void 0:n.name)||""})}),t.jsx(b,{label:"Beschreibung (optional)",children:t.jsx(B,{rows:3,value:f.description,onChange:e=>x({description:e.target.value})})})]})]})}export{J as default};