2 lines
9.8 KiB
JavaScript
2 lines
9.8 KiB
JavaScript
import{d as Q,y as X,o as Y,c as o,a as e,D as s,E as a,f,G as m,F as V,P as j,n as Z,h as z,i as L,U as ee,T as te,j as w,r as c,B as _,J as se,b as ae,q as n}from"./index-DnbYEqLr.js";const le={class:"pb-6"},oe={class:"mb-6"},ne={class:"text-3xl font-bold text-white mb-2"},de={class:"text-white/70"},ce={class:"glass-card p-6 mb-6"},ie={class:"text-lg font-semibold text-white mb-4"},ue={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},re={class:"p-4 bg-white/5 rounded-lg"},pe={class:"text-xs text-white/60 mb-1"},me={class:"text-xl font-bold text-white"},he={class:"p-4 bg-white/5 rounded-lg"},ve={class:"text-xs text-white/60 mb-1"},ye={class:"text-sm font-medium text-white"},_e={class:"p-4 bg-white/5 rounded-lg"},ge={class:"text-xs text-white/60 mb-1"},be={class:"flex items-center gap-2"},xe={key:1,class:"glass-card p-6 mb-6 border border-orange-400/30"},fe={class:"flex items-start justify-between mb-4"},we={class:"text-lg font-semibold text-white"},ke={class:"text-sm text-white/60"},Ue={class:"px-3 py-1 bg-orange-500/20 text-orange-400 text-xs font-medium rounded-full"},Ce={key:0,class:"mb-4"},Se={class:"text-sm font-medium text-white/80 mb-2"},Te={class:"space-y-1"},De={key:1,class:"mb-4 p-3 bg-white/5 rounded-lg"},Fe={class:"text-xs text-white/60"},Me={class:"flex gap-3"},Ae={key:2,class:"glass-card p-6 mb-6"},Be={class:"flex items-center gap-3 mb-4"},Ie={class:"text-lg font-semibold text-white"},Ve={class:"text-sm text-white/60"},je={key:3,class:"glass-card p-6 mb-6"},ze={class:"text-lg font-semibold text-white mb-4"},Le={class:"w-full h-3 bg-white/10 rounded-full overflow-hidden mb-2"},Ne={class:"text-xs text-white/60"},Pe={key:4,class:"glass-card p-6 mb-6"},qe={class:"text-lg font-semibold text-white mb-4"},Ee={class:"flex items-center gap-3"},Oe={class:"text-sm text-white/70"},Re={class:"glass-card p-6 mb-6"},$e={class:"text-lg font-semibold text-white mb-2"},Ge={class:"text-sm text-white/60 mb-4"},Je={class:"space-y-3"},We=["value","checked","onChange"],He={class:"text-sm font-medium text-white"},Ke={class:"text-xs text-white/50"},Qe={class:"glass-card p-6"},Xe={class:"text-lg font-semibold text-white mb-4"},Ye={class:"flex flex-wrap gap-3"},Ze=["disabled"],et={class:"glass-card p-6 max-w-sm w-full mx-4"},tt={class:"text-lg font-semibold text-white mb-3"},st={class:"text-sm text-white/70 mb-6"},at={class:"flex gap-3 justify-end"},nt=Q({__name:"SystemUpdate",setup(lt){const{t}=X(),F=w(()=>[{value:"manual",label:t("systemUpdate.manualOnly"),description:t("systemUpdate.manualOnlyDesc")},{value:"daily_check",label:t("systemUpdate.dailyCheck"),description:t("systemUpdate.dailyCheckDesc")},{value:"auto_apply",label:t("systemUpdate.autoApply"),description:t("systemUpdate.autoApplyDesc")}]),k=c("daily_check"),b=c(!1),v=c(!1),U=c(!1),h=c(!1),i=c(null),T=c("0.0.0"),x=c(null),u=c(null),C=c(!1),S=c(!1),y=c(""),M=c(!1),g=c(0),N=w(()=>{if(!x.value)return t("common.never");try{return new Date(x.value).toLocaleString()}catch{return x.value}}),P=w(()=>h.value?t("systemUpdate.applying"):v.value?t("systemUpdate.downloading"):S.value?t("systemUpdate.applying"):u.value?t("systemUpdate.updateAvailable"):C.value?t("systemUpdate.rollback"):t("systemUpdate.upToDate")),q=w(()=>h.value||v.value?"bg-orange-400 animate-pulse":u.value||S.value?"bg-orange-400":"bg-green-400"),E=w(()=>h.value||v.value||u.value||S.value?"text-orange-400":"text-green-400");function p(l,d=!1){y.value=l,M.value=d,setTimeout(()=>{y.value=""},8e3)}async function D(){try{const l=await _.call({method:"update.status"});T.value=l.current_version,x.value=l.last_check,S.value=l.update_in_progress,C.value=l.rollback_available,l.update_in_progress&&(U.value=!0)}catch{}}async function A(){b.value=!0,y.value="";try{const l=await _.call({method:"update.check"});T.value=l.current_version,x.value=l.last_check,u.value=l.update,l.update_available||p(t("systemUpdate.upToDateMessage"))}catch{p(t("systemUpdate.checkFailed"),!0)}finally{b.value=!1}}async function O(){v.value=!0,g.value=0,y.value="";const l=setInterval(()=>{g.value<90&&(g.value+=Math.random()*15)},500);try{const d=await _.call({method:"update.download"});g.value=100,U.value=!0;const r=(d.downloaded_bytes/1048576).toFixed(1);p(t("systemUpdate.downloadSuccess",{count:d.components_downloaded,size:r}))}catch{p(t("systemUpdate.downloadFailed"),!0)}finally{clearInterval(l),v.value=!1}}function R(){i.value="apply"}function $(){i.value="rollback"}function B(){i.value=null}async function G(){i.value==="apply"?(i.value=null,await J()):i.value==="rollback"&&(i.value=null,await W())}async function J(){h.value=!0,y.value="";try{await _.call({method:"update.apply"}),p(t("systemUpdate.applySuccess")),u.value=null,U.value=!1,await D()}catch{p(t("systemUpdate.applyFailed"),!0)}finally{h.value=!1}}async function W(){try{await _.call({method:"update.rollback"}),p(t("systemUpdate.rollbackSuccess")),C.value=!1,await D()}catch{p(t("systemUpdate.rollbackFailed"),!0)}}async function H(){try{const l=await _.call({method:"update.get-schedule"});k.value=l.schedule}catch{}}async function K(l){k.value=l;try{await _.call({method:"update.set-schedule",params:{schedule:l}}),p(`Schedule set to ${F.value.find(d=>d.value===l)?.label}`)}catch{p("Failed to save schedule",!0)}}return Y(()=>{Promise.all([D(),H(),A()])}),(l,d)=>(n(),o("div",le,[e("div",oe,[e("h1",ne,s(a(t)("systemUpdate.title")),1),e("p",de,s(a(t)("systemUpdate.subtitle")),1)]),y.value?(n(),o("div",{key:0,class:f(["mb-4 p-3 rounded-lg text-sm",M.value?"bg-red-500/20 text-red-300":"bg-green-500/20 text-green-300"])},s(y.value),3)):m("",!0),e("div",ce,[e("h2",ie,s(a(t)("systemUpdate.currentSystem")),1),e("div",ue,[e("div",re,[e("p",pe,s(a(t)("common.version")),1),e("p",me,"v"+s(T.value),1)]),e("div",he,[e("p",ve,s(a(t)("systemUpdate.lastChecked")),1),e("p",ye,s(N.value),1)]),e("div",_e,[e("p",ge,s(a(t)("common.status")),1),e("div",be,[e("div",{class:f(["w-2 h-2 rounded-full",q.value])},null,2),e("p",{class:f(["text-sm font-medium",E.value])},s(P.value),3)])])])]),u.value?(n(),o("div",xe,[e("div",fe,[e("div",null,[e("h2",we,s(a(t)("systemUpdate.updateAvailable")),1),e("p",ke,"Version "+s(u.value.version)+" — "+s(u.value.release_date),1)]),e("span",Ue,s(a(t)("systemUpdate.new")),1)]),u.value.changelog.length?(n(),o("div",Ce,[e("h3",Se,s(a(t)("systemUpdate.changelog")),1),e("ul",Te,[(n(!0),o(V,null,j(u.value.changelog,(r,I)=>(n(),o("li",{key:I,class:"text-sm text-white/60 flex gap-2"},[d[0]||(d[0]=e("span",{class:"text-orange-400 shrink-0"},"•",-1)),e("span",null,s(r),1)]))),128))])])):m("",!0),u.value.components>0?(n(),o("div",De,[e("p",Fe,s(a(t)("systemUpdate.componentsToUpdate",{count:u.value.components})),1)])):m("",!0),e("div",Me,[!v.value&&!h.value?(n(),o("button",{key:0,onClick:O,class:"glass-button rounded-lg px-6 py-2 text-sm font-medium"},s(a(t)("systemUpdate.downloadUpdate")),1)):m("",!0),U.value&&!h.value?(n(),o("button",{key:1,onClick:R,class:"glass-button rounded-lg px-6 py-2 text-sm font-medium bg-orange-500/20 border-orange-400/30"},s(a(t)("systemUpdate.applyUpdate")),1)):m("",!0)])])):b.value?m("",!0):(n(),o("div",Ae,[e("div",Be,[d[1]||(d[1]=e("svg",{class:"w-6 h-6 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1)),e("h2",Ie,s(a(t)("systemUpdate.upToDate")),1)]),e("p",Ve,s(a(t)("systemUpdate.upToDateMessage")),1)])),v.value?(n(),o("div",je,[e("h2",ze,s(a(t)("systemUpdate.downloading")),1),e("div",Le,[e("div",{class:"h-full bg-orange-400 rounded-full transition-all duration-500",style:Z({width:g.value+"%"})},null,4)]),e("p",Ne,s(a(t)("systemUpdate.percentComplete",{percent:g.value})),1)])):m("",!0),h.value?(n(),o("div",Pe,[e("h2",qe,s(a(t)("systemUpdate.applying")),1),e("div",Ee,[d[2]||(d[2]=e("div",{class:"w-5 h-5 border-2 border-orange-400 border-t-transparent rounded-full animate-spin"},null,-1)),e("p",Oe,s(a(t)("systemUpdate.applyWarning")),1)])])):m("",!0),e("div",Re,[e("h2",$e,s(a(t)("systemUpdate.updateSchedule")),1),e("p",Ge,s(a(t)("systemUpdate.subtitle")),1),e("div",Je,[(n(!0),o(V,null,j(F.value,r=>(n(),o("label",{key:r.value,class:f(["flex items-start gap-3 p-3 bg-white/5 rounded-lg cursor-pointer hover:bg-white/10 transition-colors",{"ring-1 ring-orange-400/50 bg-orange-500/10":k.value===r.value}])},[e("input",{type:"radio",name:"update-schedule",value:r.value,checked:k.value===r.value,onChange:I=>K(r.value),class:"mt-1 accent-orange-400"},null,40,We),e("div",null,[e("p",He,s(r.label),1),e("p",Ke,s(r.description),1)])],2))),128))])]),e("div",Qe,[e("h2",Xe,s(a(t)("systemUpdate.actions")),1),e("div",Ye,[e("button",{onClick:A,disabled:b.value,class:"glass-button rounded-lg px-5 py-2 text-sm font-medium disabled:opacity-40"},s(b.value?a(t)("systemUpdate.checking"):a(t)("systemUpdate.checkForUpdates")),9,Ze),C.value?(n(),o("button",{key:0,onClick:$,class:"glass-button rounded-lg px-5 py-2 text-sm font-medium bg-red-500/10 border-red-400/20"},s(a(t)("systemUpdate.rollback")),1)):m("",!0),z(a(ee),{to:"/dashboard/settings",class:"glass-button rounded-lg px-5 py-2 text-sm font-medium text-center"},{default:L(()=>[se(s(a(t)("systemUpdate.backToSettings")),1)]),_:1})])]),z(te,{name:"fade"},{default:L(()=>[i.value?(n(),o("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/10 backdrop-blur-md",onClick:ae(B,["self"])},[e("div",et,[e("h3",tt,s(i.value==="apply"?a(t)("systemUpdate.applyTitle"):a(t)("systemUpdate.rollbackTitle")),1),e("p",st,s(i.value==="apply"?a(t)("systemUpdate.applyMessage"):a(t)("systemUpdate.rollbackMessage")),1),e("div",at,[e("button",{onClick:B,class:"glass-button rounded-lg px-4 py-2 text-sm font-medium"},s(a(t)("common.cancel")),1),e("button",{onClick:G,class:f(["glass-button rounded-lg px-4 py-2 text-sm font-medium",i.value==="rollback"?"bg-red-500/20 border-red-400/30":"bg-orange-500/20 border-orange-400/30"])},s(i.value==="apply"?a(t)("systemUpdate.applyNow"):a(t)("systemUpdate.rollbackButton")),3)])])])):m("",!0)]),_:1})]))}});export{nt as default};
|