import{f as M,o as i,i as S,j as b,b as s,h as l,a as u,M as N,an as T,z as I,ac as L,Q as Y,B as x,c as _,d as v,aS as z,S as U,r as n,e as h}from"./vendor-0kGcmQpG.js";import{u as j,a as y,s as d,S as q}from"./index-Bn9WoKhP.js";const O={class:"flex flex-col gap-4 p-2"},P={class:"flex flex-col gap-2"},Q={class:"flex gap-2"},R={key:0,class:"mt-1 text-orange-600"},F={class:"flex flex-col gap-2"},G={key:0,class:"bg-gray-50 rounded-lg p-3 text-sm"},J={class:"list-disc list-inside space-y-1 text-gray-600"},K={key:1,class:"bg-orange-50 border border-orange-200 rounded-lg p-3 text-sm text-orange-800"},ee={__name:"sauvegardeAuto",setup(W){const{showError:D,showSuccess:k}=j(),c=n(!0),g=n(!1),p=n(!1),o=n(null),r=n({Dossier_Sauvgarde:"",Heure_sauvegarde:0}),C=h(()=>{const a=(r.value.Dossier_Sauvgarde||"").toLowerCase();return a.includes("onedrive")||a.includes("dropbox")||a.includes("google drive")});M(async()=>{try{const a=await y.get(`${d.lienApi}/sauvegarde-auto/config/${d.state.dbCommun6}`);r.value={Dossier_Sauvgarde:a.data.Dossier_Sauvgarde||"",Heure_sauvegarde:a.data.Heure_sauvegarde||0}}catch{D("Erreur lors du chargement de la configuration")}});const w=async()=>{if(!r.value.Dossier_Sauvgarde){o.value={success:!1,error:"Veuillez saisir un dossier"};return}p.value=!0,o.value=null;try{const a=await y.post(`${d.lienApi}/sauvegarde-auto/tester-dossier`,{dossier:r.value.Dossier_Sauvgarde});o.value=a.data}catch(a){o.value={success:!1,error:a.message}}finally{p.value=!1}},V=async()=>{g.value=!0;try{await y.post(`${d.lienApi}/sauvegarde-auto/config/${d.state.dbCommun6}`,r.value),k("Configuration enregistrée"),m()}catch(a){D("Erreur lors de l'enregistrement : "+(a.response?.data?.error||a.message))}finally{g.value=!1}},m=()=>{c.value=!1,q("sauvegardeAuto")};return(a,e)=>{const H=N,f=I,$=Y,B=z,E=U,A=L;return i(),S(E,{visible:c.value,"onUpdate:visible":e[2]||(e[2]=t=>c.value=t),modal:"",header:"Configuration de la sauvegarde automatique",style:{width:"500px"},closable:!0,onHide:m},{footer:b(()=>[u(f,{label:"Annuler",severity:"secondary",onClick:m}),u(f,{label:"Enregistrer",icon:"pi pi-save",onClick:V,loading:g.value},null,8,["loading"])]),default:b(()=>[s("div",O,[e[13]||(e[13]=s("div",{class:"bg-blue-50 border border-blue-200 rounded-lg p-3 text-sm text-blue-800"},[s("i",{class:"pi pi-info-circle mr-2"}),l(" La sauvegarde automatique se lance en arrière-plan lors de la connexion si l'intervalle configuré est dépassé. ")],-1)),s("div",P,[e[4]||(e[4]=s("label",{class:"font-medium"},"Dossier de sauvegarde",-1)),s("div",Q,[u(H,{modelValue:r.value.Dossier_Sauvgarde,"onUpdate:modelValue":e[0]||(e[0]=t=>r.value.Dossier_Sauvgarde=t),placeholder:"Ex: D:\\Sauvegardes",class:"flex-1"},null,8,["modelValue"]),T(u(f,{icon:"pi pi-check",severity:"secondary",onClick:w,loading:p.value},null,8,["loading"]),[[A,"Tester le dossier"]])]),e[5]||(e[5]=s("small",{class:"text-gray-500"}," Chemin absolu du dossier où stocker les fichiers .bak ",-1)),o.value?(i(),S($,{key:0,severity:o.value.success?"success":"error",closable:!1},{default:b(()=>[l(x(o.value.message||o.value.error)+" ",1),o.value.warning?(i(),_("div",R,[e[3]||(e[3]=s("i",{class:"pi pi-exclamation-triangle mr-1"},null,-1)),l(x(o.value.warning),1)])):v("",!0)]),_:1},8,["severity"])):v("",!0)]),s("div",F,[e[6]||(e[6]=s("label",{class:"font-medium"},"Intervalle de sauvegarde (heures)",-1)),u(B,{modelValue:r.value.Heure_sauvegarde,"onUpdate:modelValue":e[1]||(e[1]=t=>r.value.Heure_sauvegarde=t),min:0,max:168,placeholder:"0",class:"w-32"},null,8,["modelValue"]),e[7]||(e[7]=s("small",{class:"text-gray-500"}," 0 = sauvegarde auto désactivée. Ex: 24 = une sauvegarde par jour ",-1))]),r.value.Heure_sauvegarde>0?(i(),_("div",G,[e[11]||(e[11]=s("p",{class:"font-medium mb-2"},"Récapitulatif :",-1)),s("ul",J,[s("li",null,[e[8]||(e[8]=l("Sauvegarde toutes les ",-1)),s("strong",null,x(r.value.Heure_sauvegarde)+"h",1)]),e[9]||(e[9]=s("li",null,[l("Fichiers : "),s("code",null,"nomBase_YYYY-MM-DD_HHhMM.bak")],-1)),e[10]||(e[10]=s("li",null,"Bases sauvegardées : base de prod + commun6",-1))])])):v("",!0),C.value?(i(),_("div",K,[...e[12]||(e[12]=[s("i",{class:"pi pi-exclamation-triangle mr-2"},null,-1),s("strong",null,"Attention :",-1),l(" Les dossiers OneDrive/Dropbox peuvent poser des problèmes de permissions avec SQL Server. Préférez un dossier local comme ",-1),s("code",null,"C:\\Sauvegardes",-1),l(". ",-1)])])):v("",!0)])]),_:1},8,["visible"])}}};export{ee as default};
