HifiPlanet-Website/hifi/assets/Downloads-CWcQSZ06.js
Max Olchov 1892fe5942
Pakete: einzelne Pakete kopieren, auch ins selbe Modell
Neben "Von anderem Modell kopieren" (alle Pakete) lassen sich jetzt einzelne
Pakete kopieren: "Kopieren" im Paket-Panel, in der Auswahl (Nach Modell) und
in der Liste "Alle Pakete". Ein einzelnes Paket kann dabei als andere Stufe
landen (z. B. Drive als Grundlage fuer Prime im selben Modell). Gibt es die
Stufe im Ziel schon: ersetzen oder ueberspringen.

API: POST /packages/copy {items [{id, name?, sort_order?}], target_model_id,
include_upgrades, replace_existing}; copyPackages nutzt dieselbe
Kopierfunktion (copyOne).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H18w9G2ZdEdGJ3E3goxdQE
2026-10-23 16:19:46 +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{v as S,r as h,j as s,P as $,B as g,y as P,M as D,z as C,F as b,_ as E,x as _,W as B,c as j,C as F,$ as A}from"./index-C_s9-1Hj.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-CoSiENdP.js";import"./SortableList-CLUeg4wy.js";import"./sortable.esm-6v9ZDa7m.js";import"./grip-vertical-DYdP3qiC.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),[t,f]=h.useState("");h.useEffect(()=>{j.get("/settings/downloads").then(o=>{c(o.password),l(o.password||"")}).catch(o=>f(o.message))},[]);const w=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)}},x=(n||"")===r.trim();return s.jsx(F,{title:"Zugriffsschutz",description:"Mit Passwort sehen nur Kunden die Dateien, denen ihr den Code gebt.",actions:n===void 0?null:n?s.jsx(D,{tone:"brand",children:"Geschützt"}):s.jsx(D,{tone:"amber",children:"Öffentlich"}),children:s.jsxs("form",{onSubmit:w,children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[s.jsx(b,{label:"Zugangspasswort",error:t,className:"flex-1",children:s.jsx(_,{value:r,maxLength:100,autoComplete:"off",onChange:o=>l(o.target.value),placeholder:"Leer lassen = öffentlich"})}),s.jsx(g,{type:"submit",disabled:i||n===void 0||x,children:"Speichern"})]}),s.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),t=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:w}=t,x=t.isNew?null:(t.items||[]).find(e=>e.id===t.editing),o=e=>{c(null),t.openPanel(e)},p=e=>{c(e),t.setExtraDirty(!0)},k=e=>{if(e.preventDefault(),t.isNew&&!n){t.setError("Bitte eine Datei auswählen.");return}t.submit()},z=async e=>{a(e.id);try{const u=await j.patch(`/downloads/${e.id}/visibility`,{is_hidden:!e.is_hidden});t.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 s.jsxs("div",{className:"space-y-6",children:[s.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:s.jsxs(s.Fragment,{children:[s.jsx(g,{variant:"secondary",icon:"eye",href:"/downloads",target:"_blank",rel:"noopener noreferrer",children:"Ansehen"}),s.jsx(g,{icon:"plus",onClick:()=>o(null),children:"Datei hochladen"})]})}),s.jsx(W,{items:t.items,editingId:t.editing,onReorder:t.reorder,onOpen:o,onDelete:e=>t.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:s.jsx(g,{icon:"plus",onClick:()=>o(null),children:"Datei hochladen"})},renderRow:e=>({media:s.jsx(M,{icon:R[I(e.file_name)]||"file"}),title:e.title,subtitle:s.jsxs(s.Fragment,{children:[!!e.is_hidden&&s.jsx(D,{tone:"amber",className:"mr-2",children:"Ausgeblendet"}),e.file_name," · ",v(e.file_size)]}),muted:!!e.is_hidden,actions:s.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)})})}),s.jsx(K,{}),s.jsxs(C,{as:"form",onSubmit:k,open:t.editing!==null,onClose:t.closePanel,size:"lg",title:t.isNew?"Datei hochladen":"Download bearbeiten",footer:s.jsxs(s.Fragment,{children:[s.jsx(g,{variant:"secondary",onClick:t.closePanel,disabled:t.saving,children:"Abbrechen"}),s.jsx(g,{type:"submit",disabled:t.saving||!t.isNew&&!t.dirty,children:t.saving?r!==null&&r<1?`Lädt hoch … ${Math.round(r*100)} %`:"Speichere…":t.isNew?"Hochladen":"Speichern"})]}),children:[t.error&&s.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:t.error}),s.jsx(b,{label:t.isNew?"Datei":"Datei ersetzen (optional)",required:t.isNew,children:s.jsx(E,{file:n,onChange:p,disabled:t.saving,accept:L.map(e=>`.${e}`).join(","),current:x?`${x.file_name} (${v(x.file_size)})`:null,hint:"Musik, Videos, PDFs, Bilder, Office-Dateien oder ZIP. Andere Typen bitte als ZIP."})}),r!==null&&s.jsxs("div",{children:[s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-800",children:s.jsx("div",{className:"h-full rounded-full bg-brand-500 transition-[width]",style:{width:`${Math.round(r*100)}%`}})}),s.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 …"})]}),s.jsx(b,{label:"Titel",required:!t.isNew,hint:t.isNew?"Leer lassen = Dateiname":null,children:s.jsx(_,{required:!t.isNew,maxLength:150,value:f.title,onChange:e=>w({title:e.target.value}),placeholder:t.isNew&&(n==null?void 0:n.name)||""})}),s.jsx(b,{label:"Beschreibung (optional)",children:s.jsx(B,{rows:3,value:f.description,onChange:e=>w({description:e.target.value})})})]})]})}export{J as default};