2026-11-12 18:49:40 +03:00
import { r as v , a as F , p as N , D as ze , o as qe , C as We , c as Ye , d as n , e as t , q as B , g as c , m as u , F as b , i as _ , t as o , w as g , x , y as Ge , s as C , v as X , A as q , h as ee , z as ge , j as Je , k as l } from "./index-CH6sppUl.js" ; import { u as Ze } from "./useFormatters-CKGG-YVI.js" ; import { _ as ye , a as te } from "./ConfirmModal-XwuF5iM0.js" ; import "./vendor-ui-Dumif2LN.js" ; const Qe = { class : "backup-page" }, Xe = { class : "config-card backup-card" }, et = { class : "d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2" }, tt = [ "disabled" ], st = { class : "table-responsive" }, at = { class : "table table-hover mb-0" }, nt = { key : 0 }, lt = { key : 1 }, ot = { class : "align-top" }, it = { class : "fw-semibold" , style : { color : "var(--text-heading)" }}, rt = { class : "text-muted small" }, dt = { key : 0 , class : "small mt-1" }, ct = [ "title" ], ut = { key : 1 , class : "status-badge status-warning" }, pt = { key : 1 , class : "small mt-1" }, mt = { class : "align-top" }, bt = { class : "status-badge status-client" }, ft = { class : "align-top" }, gt = { class : "align-top" }, yt = [ "title" ], vt = { key : 1 , class : "text-muted small" }, kt = { key : 2 , class : "text-muted small" }, ht = { class : "align-top" }, _t = [ "onClick" , "disabled" ], wt = { key : 0 , class : "fas fa-spinner fa-spin" }, xt = { key : 1 , class : "fas fa-plug" }, St = [ "onClick" , "disabled" ], Ct = [ "onClick" , "disabled" ], $t = { class : "config-card backup-card" }, Tt = { class : "d-flex justify-content-between align-items-center flex-wrap gap-2 mb-2" }, Pt = { key : 0 , class : "status-badge status-valid" }, Nt = { key : 1 , class : "status-badge status-warning" }, Vt = [ "disabled" ], It = { class : "text-muted small mb-3" }, Dt = { class : "config-input-group" }, Ut = [ "disabled" ], At = [ "disabled" ], Et = { class : "text-muted small mt-2 mb-0" }, Rt = { class : "text-main" }, Ft = { key : 0 }, Bt = { key : 1 }, Mt = { key : 0 , class : "text-muted small mb-3" }, jt = { key : 1 , class : "mb-3" }, Lt = [ "id" , "value" , "disabled" ], Ot = [ "for" ], Ht = { class : "text-muted small" }, Kt = { key : 0 , class : "text-muted small" }, zt = { class : "btn-action-group justify-content-center mt-3" }, qt = [ "disabled" ], Wt = { key : 0 , class : "fas fa-spinner fa-spin" }, Yt = { key : 1 , class : "fas fa-box-archive" }, Gt = { key : 2 , class : "nested-box fade-in mt-4" }, Jt = { class : "nested-label d-flex justify-content-between" }, Zt = { class : "backup-steps" }, Qt = { key : 0 , class : "fas fa-spinner fa-spin me-1" }, Xt = { class : "fw-semibold ms-2" , style : { color : "var(--text-heading)" }}, es = { key : 0 , class : "text-muted small ms-1 mt-1" }, ts = { key : 0 , class : "text-muted small mt-2" }, ss = { key : 3 , class : "mt-4" }, as = { class : "table-responsive" }, ns = { class : "table table-hover mb-0" }, ls = { class : "text-capitalize" }, os = { class : "small text-muted" }, is = { class : "config-card backup-card" }, rs = { class : "config-row" }, ds = { class : "config-col" }, cs = { class : "select-container" }, us = [ "disabled" ], ps = [ "value" ], ms = { key : 0 , class : "text-muted small mt-2" }, bs = { key : 1 , class : "mt-2" }, fs = { class : "text-muted small mt-1" }, gs = { key : 2 , class : "mt-2" }, ys = { class : "text-muted small ms-2" }, vs = { class : "config-row" }, ks = { class : "config-col" }, hs = { class : "select-container" }, _s = [ "disabled" ], ws = { value : "" , disabled : "" }, xs = [ "value" ], Ss = { key : 0 , class : "config-row" }, Cs = { class : "config-col" }, $s = { class : "btn-action-group justify-content-center" }, Ts = [ "disabled" ], Ps = { key : 0 , class : "fas fa-spinner fa-spin" }, Ns = { key : 1 , class : "fas fa-rotate-left" }, Vs = { key : 1 , class : "nested-box fade-in mt-4" }, Is = { class : "nested-label d-flex justify-content-between" }, Ds = { class : "backup-steps" }, Us = { class : "status-badge status-warning" }, As = { key : 1 , class : "mt-3" }, Es = { class : "mb-3" }, Rs = { class : "mb-3" }, Fs = { class : "select-container" }, Bs = [ "value" ], Ms = { key : 0 , class : "form-text mt-2 small text-warning" }, js = { class : "form-label small fw-bold text-muted text-uppercase d-block" }, Ls = { class : "toggle-wrapper" }, Os = { class : "toggle-switch" }, Hs = [ "onUpdate:modelValue" ], Ks = { class : "form-label small fw-bold text-muted text-uppercase" }, zs = [ "onUpdate:modelValue" , "placeholder" ], qs = { key : 0 , class : "form-text mt-1 text-muted small" }, Ws = { class : "form-label small fw-bold text-muted text-uppercase" }, Ys = [ "onUpdate:modelValue" , "placeholder" ], Gs = { class : "form-label small fw-bold text-muted text-uppercase" }, Js = [ "onUpdate:modelValue" ], Zs = { class : "form-label small fw-bold text-muted text-uppercase" }, Qs = [ "onUpdate:modelValue" , "placeholder" ], Xs = { key : 0 , class : "form-text mt-1 text-muted small" }, ea = { key : 5 , class : "form-text mt-2 small text-warning" }
2026-10-07 14:10:31 +03:00
`:` The server of "${a.name}" showed this host key . Compare it with the fingerprint you know ( ssh - keygen - lf on the server ) before you trust it .
`)+` Type : $ { e . key_type }
SHA - 256 : $ { e . fingerprint }
Packages are sent only to a server with exactly this key . `,confirmText:e.key_changed?"Trust the new key":"Trust",confirmBtnClass:e.key_changed?"btn-action-danger":"btn-action-primary",data:{id:a.id,name:a.name,fingerprint:e.fingerprint}})},Ee=async a=>{try{await y.post(` / backup / destinations / $ { a . id } / trust - host - key `,{fingerprint:a.fingerprint}),m.show(` Host key of $ { a . name } trusted . Press Test to check the connection . `,"success"),await T()}catch(e){m.show(w(e),"error")}},Re=a=>{ae.value.open({title:"Delete Destination?",message:` Delete "${a.name}" ? Packages already stored there are not deleted . `,confirmText:"Yes, Delete",data:a})},Fe=async a=>{try{await y.delete(` / backup / destinations / $ { a . id } `),m.show(` $ { a . name } deleted . `,"success"),d.sourceId===a.id&&(d.sourceId=null),await T()}catch(e){m.show(w(e),"error")}},Be=()=>{S.value="",S.confirm="",L.value.show()},Me=async()=>{if(S.value!==S.confirm){m.show("Passphrases do not match.","error");return}await be({passphrase:S.value},"Passphrase saved.")},je=async()=>{await be({clear_passphrase:!0},"Passphrase removed. New packages are not encrypted.")},me=async()=>{const a=P.value.trim();if(a!==(p.server_name||"")){k.value=!0;try{const e=await y.put("/backup/settings",{server_name:a});Object.assign(p,e.data),P.value=p.server_name||"",m.show(a?"Server name saved.":"Server name cleared.","success")}catch(e){m.show(w(e),"error")}finally{k.value=!1}}},be=async(a,e)=>{k.value=!0;try{const s=await y.put("/backup/settings",a);Object.assign(p,s.data),m.show(e,"success"),L.value.hide(),await T()}catch(s){m.show(w(s),"error")}finally{k.value=!1}},Le=async()=>{try{await y.post("/backup/run",{destination_ids:$.value}),j.value=!1,i.kind="backup",i.state="running",await R(),Z()}catch(a){a.response?.status===409&&await R(),m.show(w(a),"error")}},fe=async()=>{if(d.packages=[],d.packageName="",d.passphrase="",d.sourceError="",d.sourceId!==null){d.checking=!0;try{const a=await y.get(` / backup / destinations / $ { d . sourceId } / packages `);d.packages=a.data.packages}catch(a){d.sourceError=w(a)}finally{d.checking=!1}}};ze(()=>d.sourceId,fe);const Oe=()=>{const a=E.value;ne.value.open({title:"Restore from Backup?",message:` Package : $ { a . server_name }, $ { oe ( a . created_at )} ( $ { z ( a . created_at )} local )
This replaces :
- the monitoring database ( statistics , administrator accounts , 2 FA ),
- the profiler database and the server settings ,
- the PKI ( CA , keys , certificates ) and the client profiles .
OpenVPN is stopped and started again ; connected clients are disconnected . The current state is saved to a local safety copy first . You will have to log in again . `,confirmText:"Yes, Restore",confirmBtnClass:"btn-action-danger",data:a})},He=async a=>{try{await y.post("/backup/restore",{destination_id:d.sourceId,package:a.name,passphrase:a.encrypted?d.passphrase:null}),j.value=!1,d.passphrase="",i.kind="restore",i.state="running",await R(),Z()}catch(e){m.show(w(e),"error")}},Ke=()=>{localStorage.removeItem("ovpmon_token"),localStorage.removeItem("ovpmon_user"),window.location.href="/login"};return qe(async()=>{try{await Te(),await T(),ce(),await Promise.all([de(),R()])}catch(a){m.show(` Failed to load backup settings : $ { w ( a )} `,"error")}finally{se.value=!1}}),Ye(ue),(a,e)=>(l(),n("div",Qe,[t("div",Xe,[e[23]||(e[23]=t("div",{class:"config-header"},[t("h1",null,"Backup Destinations")],-1)),t("div",et,[e[14]||(e[14]=t("span",{class:"text-muted small"},"Where backup packages are stored. A backup goes to every selected destination.",-1)),t("button",{type:"button",class:"btn-action btn-action-save btn-sm",onClick:Ne,disabled:!p.types.length},[...e[13]||(e[13]=[t("i",{class:"fas fa-plus"},null,-1),c(" Add destination ",-1)])],8,tt)]),t("div",st,[t("table",at,[e[22]||(e[22]=t("thead",null,[t("tr",null,[t("th",null,"Name"),t("th",null,"Type"),t("th",null,"Status"),t("th",null,"Last result"),t("th",null,"Actions")])],-1)),t("tbody",null,[se.value?(l(),n("tr",nt,[...e[15]||(e[15]=[t("td",{colspan:"5",class:"text-center py-4"},[t("div",{class:"spinner-border spinner-border-sm text-primary",role:"status"},[t("span",{class:"visually-hidden"},"Loading...")])],-1)])])):V.value.length===0?(l(),n("tr",lt,[...e[16]||(e[16]=[t("td",{colspan:"5",class:"empty-state text-center py-4"},[t("i",{class:"fas fa-box-archive fa-2x mb-3 text-muted"}),t("p",{class:"text-muted mb-0"},"No destinations yet. Add one to start making backups.")],-1)])])):u("",!0),(l(!0),n(b,null,_(V.value,s=>(l(),n("tr",{key:s.id},[t("td",ot,[t("div",it,o(s.name),1),t("div",rt,o(we(s)),1),U(s.type)?.pins_host_key?(l(),n("div",dt,[s.params.host_key?(l(),n("span",{key:0,class:"status-badge status-valid",title:s.params.host_key},[...e[17]||(e[17]=[t("i",{class:"fas fa-fingerprint me-1"},null,-1),c("Host key trusted ",-1)])],8,ct)):(l(),n("span",ut,[...e[18]||(e[18]=[t("i",{class:"fas fa-triangle-exclamation me-1"},null,-1),c("Host key not trusted: press Test and confirm it ",-1)])]))])):u("",!0),xe(s)?(l(),n("div",pt,[...e[19]||(e[19]=[t("span",{class:"status-badge status-warning"},[t("i",{class:"fas fa-triangle-exclamation me-1"}),c("No TLS: clear text")],-1)])])):u("",!0)]),t("td",mt,[t("span",bt,o(Y(s.type)),1)]),t("td",ft,[t("span",{class:C(["status-badge",s.enabled?"status-valid":"status-secondary"])},o(s.enabled?"Enabled":"Disabled"),3)]),t("td",gt,[s.last_status?(l(),n("span",{key:0,class:C(["status-badge",s.last_status==="ok"?"status-valid":"status-expired"]),title:s.last_message},o(s.last_status==="ok"?"OK":"Failed"),11,yt)):(l(),n("span",vt,"never used")),s.last_at?(l(),n("div",kt,o(z(s.last_at)),1)):u("",!0)]),t("td",ht,[t("button",{class:"btn btn-sm btn-link text-primary p-0 me-2",title:"Test connection",onClick:f=>Ue(s),disabled:M.value===s.id},[M.value===s.id?(l(),n("i",wt)):(l(),n("i",xt))],8,_t),t("button",{class:"btn btn-sm btn-link text-warning p-0 me-2",title:"Edit",onClick:f=>Ve(s),disabled:h.value},[...e[20]||(e[20]=[t("i",{class:"fas fa-pen"},null,-1)])],8,St),t("button",{class:"btn btn-sm btn-link text-danger p-0",title:"Delete",onClick:f=>Re(s),disabled:h.value},[...e[21]||(e[21]=[t("i",{class:"fas fa-trash"},null,-1)])],8,Ct)])]))),128))])])])]),t("div",$t,[e[34]||(e[34]=t("div",{class:"config-header"},[t("h1",null,"Backup")],-1)),t("div",Tt,[t("div",null,[p.encryption_enabled?(l(),n("span",Pt,[...e[24]||(e[24]=[t("i",{class:"fas fa-lock me-1"},null,-1),c("Packages are encrypted ",-1)])])):(l(),n("span",Nt,[...e[25]||(e[25]=[t("i",{class:"fas fa-triangle-exclamation me-1"},null,-1),c("Packages are NOT encrypted ",-1)])]))]),t("button",{type:"button",class:"