HifiPlanet-Website/hifi/assets/UpdateSettings-BgbTqUeI.js
Maaxxs 29f15d0133 Package editor: products, upgrades and prices for a model on one page
Tested locally on a separate branch before merging.

- Selected model (and package to open) live in the URL (?model=…&paket=…),
  so going back or reloading returns to the same vehicle.
- Packages are compact rows (price, product/upgrade count, badge,
  visibility); a click expands one package with its texts on the left and
  markup, live price calculation, products and upgrades on the right.
- Products and upgrades are edited inline and saved immediately. Several
  audio4cars links can be pasted at once, and products/upgrades are
  reordered by drag & drop (@dnd-kit). The separate product/upgrade pages
  are gone; old links redirect to the package in the editor.
- New GET /models/{id}/package-items loads all products and upgrades of a
  model in one request.
- "Pakete kopieren" can include upgrades (include_upgrades).

No database changes.

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

1 line
5.2 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 l,j as e,a as u}from"./index-D6g8QQLx.js";const D={download:"Herunterladen",extract:"Entpacken",backup:"Sichern",apply:"Installieren"};function w(a){return a?a.slice(0,7):"–"}function L(a){return a?new Date(a).toLocaleString("de-DE"):"–"}function H(){const[a,v]=l.useState(null),[n,_]=l.useState(null),[E,g]=l.useState(!0),[h,j]=l.useState(""),[c,f]=l.useState(!1),[d,i]=l.useState({download:null,extract:null,backup:null,apply:null}),[p,k]=l.useState(""),[x,N]=l.useState(null),m=()=>{g(!0),j(""),Promise.all([u.get("/settings/update-status"),u.get("/settings/update-check")]).then(([t,s])=>{v(t),_(s)}).catch(t=>j(t.message)).finally(()=>g(!1))};l.useEffect(m,[]);const P=async()=>{f(!0),k(""),N(null),i({download:"busy",extract:null,backup:null,apply:null});try{const s=(await u.post("/settings/update-download",{})).run_id;i(r=>({...r,download:"done",extract:"busy"})),await u.post("/settings/update-extract",{run_id:s}),i(r=>({...r,extract:"done",backup:"busy"})),await u.post("/settings/update-backup",{}),i(r=>({...r,backup:"done",apply:"busy"}));const o=await u.post("/settings/update-apply",{run_id:s});i(r=>({...r,apply:"done"})),N(o.log||[]),m()}catch(t){i(s=>{const o=Object.keys(s).find(r=>s[r]==="busy");return o?{...s,[o]:"error"}:s}),k(t.message)}finally{f(!1)}};if(E)return e.jsx("p",{className:"text-sm text-neutral-400",children:"Lädt…"});const b=(a==null?void 0:a.capabilities)||{},y=b.zip?b.http_client?b.writable?null:"Das Website-Verzeichnis ist für PHP nicht beschreibbar - bitte Dateiberechtigungen prüfen.":"Diese Funktion benötigt ausgehende HTTPS-Verbindungen (curl oder allow_url_fopen), die auf diesem Server aktuell nicht verfügbar sind.":'Diese Funktion benötigt die PHP-Erweiterung "zip", die auf diesem Server aktuell nicht aktiviert ist. Bitte beim Hoster aktivieren lassen.',S=n==null?void 0:n.update_available;return e.jsx("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:"Updates aus Git"}),e.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:'Zieht den aktuellen Stand direkt vom Code-Repository und installiert ihn hier - ohne manuellen FTP-Upload. Passiert nur, wenn du unten aktiv auf "Update installieren" klickst, nie automatisch im Hintergrund.'}),h&&e.jsx("p",{className:"mb-3 text-sm text-red-600",children:h}),y?e.jsx("p",{className:"rounded-md bg-amber-50 p-3 text-sm text-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:y}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"rounded-md bg-neutral-50 p-3 dark:bg-neutral-800/50",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-neutral-400",children:"Installiert"}),e.jsx("p",{className:"font-mono text-neutral-800 dark:text-neutral-100",children:w(a==null?void 0:a.deployed_sha)}),e.jsx("p",{className:"text-xs text-neutral-400",children:L(a==null?void 0:a.deployed_at)})]}),e.jsxs("div",{className:"rounded-md bg-neutral-50 p-3 dark:bg-neutral-800/50",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-neutral-400",children:"Neuester Stand"}),e.jsx("p",{className:"font-mono text-neutral-800 dark:text-neutral-100",children:w(n==null?void 0:n.latest_sha)}),(n==null?void 0:n.latest_message)&&e.jsx("p",{className:"truncate text-xs text-neutral-400",title:n.latest_message,children:n.latest_message})]})]}),S?e.jsx("p",{className:"mb-3 text-sm font-medium text-brand-600 dark:text-brand-400",children:"Update verfügbar."}):e.jsx("p",{className:"mb-3 text-sm text-neutral-500 dark:text-neutral-400",children:"Bereits auf dem neuesten Stand."}),e.jsxs("div",{className:"mb-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:m,disabled:c,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:"Nach Updates suchen"}),e.jsx("button",{type:"button",onClick:P,disabled:c||!S,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:c?"Installiere…":"Update installieren"})]}),(c||p)&&e.jsx("ul",{className:"mb-3 space-y-1 text-sm",children:Object.entries(D).map(([t,s])=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:d[t]==="done"?"text-green-600 dark:text-green-400":d[t]==="error"?"text-red-600":d[t]==="busy"?"text-brand-600 dark:text-brand-400":"text-neutral-300 dark:text-neutral-600",children:d[t]==="done"?"✓":d[t]==="error"?"✕":d[t]==="busy"?"…":"○"}),s]},t))}),p&&e.jsx("p",{className:"text-sm text-red-600",children:p}),x&&e.jsxs("div",{className:"mt-3 rounded-md bg-green-50 p-3 text-sm text-green-800 dark:bg-green-900/20 dark:text-green-300",children:[e.jsx("p",{className:"mb-1 font-semibold",children:"Update installiert."}),x.length>0&&e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer text-xs",children:"Details anzeigen"}),e.jsx("ul",{className:"mt-2 list-disc pl-5 text-xs",children:x.map((t,s)=>e.jsx("li",{children:t},s))})]})]})]})]})})}export{H as default};