Files
yakpanel-core/YakPanel-server/frontend/dist/assets/SitePage-BCHU1V0e.js

2 lines
15 KiB
JavaScript
Raw Normal View History

2026-04-07 05:05:28 +05:30
import{r as l,j as e,a as Ee,c as Ae,s as He,l as G,b as De,d as ie,e as Fe,f as Ge,h as Le,i as Ie,k as qe,u as Me,m as ze,n as $e,o as Ue}from"./index-cE9w-Kq7.js";import{M as a}from"./Modal-CL3xZqxR.js";import{A as k}from"./AdminAlert-yrdXFH0e.js";import{A as ce}from"./AdminButton-ByutG8m-.js";import{A as We}from"./AdminTable-eCi7S__-.js";import{E as Ve}from"./EmptyState-CmnFWkSO.js";import{P as L}from"./PageHeader-HdM4gpcn.js";function et(){const[C,re]=l.useState([]),[oe,I]=l.useState(!0),[b,i]=l.useState(""),[de,j]=l.useState(!1),[q,M]=l.useState(!1),[z,w]=l.useState(""),[r,f]=l.useState(null),[$,B]=l.useState([]),[_,g]=l.useState(!1),[T,N]=l.useState(null),[n,c]=l.useState(null),[U,W]=l.useState(!1),[V,p]=l.useState(""),[K,J]=l.useState(null),[m,P]=l.useState(null),[O,R]=l.useState([]),[E,A]=l.useState(""),[H,D]=l.useState(""),[Q,X]=l.useState(301),[me,Y]=l.useState(!1),[x,h]=l.useState(null),[F,Z]=l.useState(""),[ee,te]=l.useState("main"),[v,o]=l.useState(null),[S,y]=l.useState(!1),u=()=>{I(!0),Ee("/site/list").then(re).catch(t=>i(t.message)).finally(()=>I(!1))};l.useEffect(()=>{u()},[]);const ue=t=>{var ae,ne;t.preventDefault();const s=t.currentTarget,d=s.elements.namedItem("name").value.trim(),le=s.elements.namedItem("domains").value.trim(),we=s.elements.namedItem("path").value.trim(),Be=s.elements.namedItem("ps").value.trim();if(!d||!le){w("Name and domain(s) are required");return}const _e=le.split(/[\s,]+/).filter(Boolean),Te=((ae=s.elements.namedItem("php_version"))==null?void 0:ae.value)||"74",Pe=((ne=s.elements.namedItem("force_https"))==null?void 0:ne.checked)||!1;M(!0),w(""),Ae({name:d,domains:_e,path:we||void 0,ps:Be||void 0,php_version:Te,force_https:Pe}).then(()=>{j(!1),s.reset(),u()}).catch(Re=>w(Re.message)).finally(()=>M(!1))},he=(t,s)=>{confirm(`Delete site "${s}"? This cannot be undone.`)&&Fe(t).then(u).catch(d=>i(d.message))},pe=t=>{f(t),B([]),ie(t).then(s=>B(s.backups)).catch(s=>i(s.message))},xe=()=>{r&&(g(!0),ze(r).then(()=>ie(r).then(t=>B(t.backups))).catch(t=>i(t.message)).finally(()=>g(!1)))},be=t=>{!r||!confirm(`Restore from ${t}? This will overwrite existing files.`)||(g(!0),Ue(r,t).then(()=>f(null)).catch(s=>i(s.message)).finally(()=>g(!1)))},je=t=>{r&&$e(r,t).catch(s=>i(s.message))},fe=t=>{N(t),p(""),De(t).then(s=>c({domains:(s.domains||[]).join(", "),path:s.path||"",ps:s.ps||"",php_version:s.php_version||"74",force_https:!!(s.force_https&&s.force_https!==0)})).catch(s=>p(s.message))},ge=t=>{if(t.preventDefault(),!T||!n)return;const s=n.domains.split(/[\s,]+/).filter(Boolean);if(s.length===0){p("At least one domain is required");return}W(!0),p(""),Me(T,{domains:s,path:n.path||void 0,ps:n.ps||void 0,php_version:n.php_version,force_https:n.force_https}).then(()=>{N(null),c(null),u()}).catch(d=>p(d.message)).finally(()=>W(!1))},se=(t,s)=>{J(t),He(t,s).then(u).catch(d=>i(d.message)).finally(()=>J(null))},Ne=t=>{P(t),A(""),D(""),X(301),G(t).then(R).catch(s=>i(s.message))},ve=t=>{t.preventDefault(),!(!m||!E.trim()||!H.trim())&&(Y(!0),Ie(m,E.trim(),H.trim(),Q).then(()=>G(m).then(R)).then(()=>{A(""),D("")}).catch(s=>i(s.message)).finally(()=>Y(!1)))},Se=t=>{m&&qe(m,t).then(()=>G(m).then(R)).catch(s=>i(s.message))},ye=t=>{t.preventDefault(),!(!x||!F.trim())&&(y(!0),Ge(x,F.trim(),ee.trim()||"main").then(()=>{h(null),o(null),u()}).catch(s=>i(s.message)).finally(()=>y(!1)))},ke=()=>{x&&(y(!0),Le(x).then(()=>{h(null),o(null),u()}).catch(t=>i(t.message)).finally(()=>y(!1)))},Ce=t=>t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/1024/1024).toFixed(1)+" MB";return oe?e.jsxs(e.Fragment,{children:[e.jsx(L,{title:"Website"}),e.jsx("div",{className:"text-center py-5 text-muted",children:"Loading…"})]}):b&&!C.length?e.jsxs(e.Fragment,{children:[e.jsx(L,{title:"Website"}),e.jsx(k,{variant:"danger",children:b})]}):e.jsxs(e.Fragment,{children:[e.jsx(L,{title:"Website",actions:e.jsxs(ce,{onClick:()=>j(!0),children:[e.jsx("i",{className:"ti ti-plus me-1"}),"Add Site"]})}),b?e.jsx(k,{variant:"warning",children:b}):null,e.jsxs(a,{show:de,onHide:()=>j(!1),centered:!0,children:[e.jsx(a.Header,{closeButton: