import{w as T,O as b,L as s,J as l,G as r,P as E,V as I,W as L,R as f,F as k,S as x,N as p,r as u,T as P,I as a,U as R,a1 as z,K as n,$ as F,M as y,Q as w,e as M}from"./index-iCRehgtD.js";import{u as U,Q as D}from"./useSetupWs-P74ozpSr.js";import{u as W}from"./setup-B2WhYkmc.js";const j={key:0,class:"text-caption text-grey q-mt-sm q-mb-none"},G={class:"row justify-between"},H={class:"row q-gutter-sm"},A={__name:"DbConfigPage",setup(J){const C=P(),t=W(),{send:S,messages:q,clearMessages:B}=U(),o=u(!1),i=u(!1),v=u(!1),d=u(0),c=u([]),m=u(null);T(q,_=>{const e=_[_.length-1];!e||!o.value||(e.type==="output"?(c.value.push({text:e.line,cls:e.stream==="stderr"?"output-line-err":"output-line-out"}),M(()=>{m.value&&(m.value.scrollTop=m.value.scrollHeight)})):e.type==="error"?(o.value=!1,i.value=!0,d.value=1,c.value.push({text:e.message,cls:"output-line-err"})):e.type==="done"&&(o.value=!1,i.value=!0,d.value=e.exit_code,e.exit_code===0&&(v.value=!0)))},{deep:!0});function Q(){B(),c.value=[],i.value=!1,v.value=!1,o.value=!0,S({action:"run_step",id:"setup_db",sudo:!0})}function h(){t.prevStep(),C.push("/tape")}function V(){t.nextStep(),C.push("/passwords")}return(_,e)=>(a(),b("div",null,[e[3]||(e[3]=s("div",{class:"step-header"},"Database Configuration",-1)),e[4]||(e[4]=s("p",{class:"text-body2 q-mb-md"}," Bareos requires a PostgreSQL catalog database. Configure it below. ",-1)),l(E,{flat:"",bordered:"",class:"q-mb-md"},{default:r(()=>[l(R,null,{default:r(()=>[l(z,{modelValue:p(t).dbConfig.createDb,"onUpdate:modelValue":e[0]||(e[0]=g=>p(t).dbConfig.createDb=g),label:"Initialize Bareos catalog database"},null,8,["modelValue"]),p(t).dbConfig.createDb?(a(),b("p",j,[...e[1]||(e[1]=[n(" Runs ",-1),s("code",null,"create_bareos_database",-1),n(", ",-1),s("code",null,"make_bareos_tables",-1),n(" and ",-1),s("code",null,"grant_bareos_privileges",-1),n(" as root. ",-1)])])):f("",!0)]),_:1})]),_:1}),c.value.length?(a(),b("div",{key:0,class:"output-console q-mb-md",ref_key:"consoleEl",ref:m},[(a(!0),b(I,null,L(c.value,(g,N)=>(a(),b("div",{key:N,class:F(g.cls)},y(g.text),3))),128))],512)):f("",!0),i.value&&d.value!==0?(a(),k(D,{key:1,class:"bg-negative text-white q-mb-md",rounded:""},{avatar:r(()=>[l(w,{name:"error"})]),default:r(()=>[n(" Database setup failed (exit code "+y(d.value)+"). ",1)]),_:1})):f("",!0),i.value&&d.value===0?(a(),k(D,{key:2,class:"bg-positive text-white q-mb-md",rounded:""},{avatar:r(()=>[l(w,{name:"check_circle"})]),default:r(()=>[e[2]||(e[2]=n(" Database configured successfully. ",-1))]),_:1})):f("",!0),s("div",G,[l(x,{flat:"",label:"Back",icon:"arrow_back",disable:o.value,onClick:h},null,8,["disable"]),s("div",H,[p(t).dbConfig.createDb&&!v.value?(a(),k(x,{key:0,label:"Set up Database",color:"secondary",icon:"storage",loading:o.value,onClick:Q},null,8,["loading"])):f("",!0),l(x,{label:"Continue",color:"primary","icon-right":"arrow_forward",disable:p(t).dbConfig.createDb&&!v.value,onClick:V},null,8,["disable"])])])]))}};export{A as default};
