HifiPlanet-Website/hifi/assets/UpdateSettings-CQNnNfsJ.js
Max Olchov de91ab0926
Self-Update: Branch im Admin auswählbar, um zwischen Branches zu wechseln
Unter Einstellungen > Updates lässt sich jetzt der Branch wählen, von dem
installiert wird (Standard main). So kann z.B. ein Test-Branch eingespielt
und danach wieder auf main zurückgewechselt werden - jeweils mit Backup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Dgc8etkq7JkjyZgD2DEbv
2026-10-19 21:53:13 +00:00

1 line
6.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,j as e,a as i}from"./index-QV-Szw5n.js";const z={download:"Herunterladen",extract:"Entpacken",backup:"Sichern",apply:"Installieren"};function C(a){return a?a.slice(0,7):"–"}function A(a){return a?new Date(a).toLocaleString("de-DE"):"–"}function O(){const[a,y]=r.useState(null),[n,S]=r.useState(null),[R,v]=r.useState(!0),[_,B]=r.useState(""),[h,E]=r.useState([]),[b,P]=r.useState(!1),[m,U]=r.useState(!1),[u,o]=r.useState({download:null,extract:null,backup:null,apply:null}),[g,p]=r.useState(""),[f,j]=r.useState(null),k=()=>{v(!0),B(""),Promise.all([i.get("/settings/update-status"),i.get("/settings/update-check")]).then(([t,s])=>{y(t),S(s)}).catch(t=>B(t.message)).finally(()=>v(!1)),i.get("/settings/update-branches").then(t=>E(t.branches||[])).catch(()=>E([]))},H=async t=>{P(!0),p(""),j(null);try{const s=await i.post("/settings/update-branch",{branch:t});S(s),y(d=>d&&{...d,branch:t})}catch(s){p(s.message)}finally{P(!1)}};r.useEffect(k,[]);const I=async()=>{U(!0),p(""),j(null),o({download:"busy",extract:null,backup:null,apply:null});try{const s=(await i.post("/settings/update-download",{})).run_id;o(l=>({...l,download:"done",extract:"busy"})),await i.post("/settings/update-extract",{run_id:s}),o(l=>({...l,extract:"done",backup:"busy"})),await i.post("/settings/update-backup",{}),o(l=>({...l,backup:"done",apply:"busy"}));const d=await i.post("/settings/update-apply",{run_id:s});o(l=>({...l,apply:"done"})),j(d.log||[]),k()}catch(t){o(s=>{const d=Object.keys(s).find(l=>s[l]==="busy");return d?{...s,[d]:"error"}:s}),p(t.message)}finally{U(!1)}};if(R)return e.jsx("p",{className:"text-sm text-neutral-400",children:"Lädt…"});const N=(a==null?void 0:a.capabilities)||{},D=N.zip?N.http_client?N.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.',w=n==null?void 0:n.update_available,c=(a==null?void 0:a.branch)||"main",x=a==null?void 0:a.deployed_branch,L=!!x&&x!==c,F=h.some(t=>t.name===c)?h:[{name:c},...h];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.'}),_&&e.jsx("p",{className:"mb-3 text-sm text-red-600",children:_}),D?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:D}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"update-branch",className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-200",children:"Branch"}),e.jsx("select",{id:"update-branch",value:c,onChange:t=>H(t.target.value),disabled:m||b,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm disabled:opacity-50 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100",children:F.map(t=>e.jsxs("option",{value:t.name,children:[t.name,t.message?` – ${t.message}`:""]},t.name))}),e.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"Von diesem Branch wird installiert. Zum Zurückwechseln einfach wieder „main“ wählen und installieren – vorher wird wie immer eine Sicherung angelegt."})]}),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.jsxs("p",{className:"font-mono text-neutral-800 dark:text-neutral-100",children:[C(a==null?void 0:a.deployed_sha),x&&e.jsxs("span",{className:"ml-2 font-sans text-xs text-neutral-400",children:["(",x,")"]})]}),e.jsx("p",{className:"text-xs text-neutral-400",children:A(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.jsxs("p",{className:"font-mono text-neutral-800 dark:text-neutral-100",children:[C(n==null?void 0:n.latest_sha),e.jsxs("span",{className:"ml-2 font-sans text-xs text-neutral-400",children:["(",c,")"]})]}),(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})]})]}),L&&w?e.jsxs("p",{className:"mb-3 text-sm font-medium text-brand-600 dark:text-brand-400",children:["Installiert ist „",x,"“ – mit „Update installieren“ wechselst du auf „",c,"“."]}):w?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:k,disabled:m||b,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:I,disabled:m||b||!w,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50",children:m?"Installiere…":L?`Auf „${c}“ wechseln`:"Update installieren"})]}),(m||g)&&e.jsx("ul",{className:"mb-3 space-y-1 text-sm",children:Object.entries(z).map(([t,s])=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:u[t]==="done"?"text-green-600 dark:text-green-400":u[t]==="error"?"text-red-600":u[t]==="busy"?"text-brand-600 dark:text-brand-400":"text-neutral-300 dark:text-neutral-600",children:u[t]==="done"?"✓":u[t]==="error"?"✕":u[t]==="busy"?"…":"○"}),s]},t))}),g&&e.jsx("p",{className:"text-sm text-red-600",children:g}),f&&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."}),f.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:f.map((t,s)=>e.jsx("li",{children:t},s))})]})]})]})]})})}export{O as default};