var h=Object.defineProperty;var S=(r,l,e)=>l in r?h(r,l,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[l]=e;var n=(r,l,e)=>(S(r,typeof l!="symbol"?l+"":l,e),e);import{d as g,r as v,i as y,S as p,o as P,c as U,a as s,e as u,k as a,p as _,n as i,D as d}from"../index.js";import"../vendor.js";class w{constructor(){n(this,"smtpServer","");n(this,"smtpPort",0);n(this,"smtpUsername","");n(this,"smtpPassword","");n(this,"smtpFromName","");n(this,"smtpFromAddress","");n(this,"alertDefaultEmail","")}}const x={class:"row"},E={class:"col-sm-12"},F={class:"card"},T={class:"card-header"},k=["disabled"],V=s("span",{class:"fa fa-sync"},null,-1),A=s("h3",null,"Mail server settings",-1),D={class:"card-body col-md-6 offset-md-6"},M=s("i",{class:"fa-3x fas fa-circle-notch fa-spin"},null,-1),N=[M],B={class:"card-body"},C={class:"form-group"},H=s("label",{for:"smtpHost",class:"control-label"},"SMTP Server",-1),$={class:"form-group"},j=s("label",{for:"smtpPort",class:"control-label"},"SMTP Port",-1),z={class:"form-group"},J=s("label",{for:"smtpUser",class:"control-label"},"SMTP Username",-1),O={class:"form-group"},R=s("label",{for:"smtpPass",class:"control-label"},"SMTP Password",-1),q=s("h4",null,"Email settings",-1),G={class:"form-group"},I=s("label",{for:"smtpFromName",class:"control-label"},"Sender name",-1),K={class:"form-group"},L=s("label",{for:"smtpFromAddress",class:"control-label"},"Sender address",-1),Q={class:"form-group"},W=s("label",{for:"alertDefaultEmail",class:"control-label"},"Email alert recipient(s)",-1),X=s("small",{id:"alertDefaultEmailHelp",class:"form-text text-muted"}," A semicolon-separated list of email addresses to receive alert emails ",-1),Y={class:"float-right"},Z=s("i",{class:"fa fa-envelope"},null,-1),ss=s("i",{class:"fa fa-save"},null,-1),ls=g({__name:"Smtp",setup(r){const l=v(!1),e=v(new w);y(async()=>{await m()});async function m(){l.value=!0;try{const t=await(await fetch(p.settingsBaseUrl)).json();e.value=t.result}finally{l.value=!1}}async function f(){(await fetch(p.settingsBaseUrl,{method:"PUT",body:JSON.stringify(e.value)})).ok?d({type:"success",text:"Settings saved."}):d({type:"error",text:"Settings could not be saved."}),await m()}async function b(){await f(),(await fetch(p.settingsBaseUrl+"/send-test-email",{method:"PUT"})).ok?d({type:"success",text:"An email has been sent."}):d({type:"error",text:"Send test email failed."})}return(c,t)=>(P(),U("div",x,[s("div",E,[s("div",F,[s("div",T,[s("button",{class:"btn btn-sm btn-link float-right",disabled:l.value,onClick:t[0]||(t[0]=o=>m())},[V,u(" Refresh ")],8,k),A]),a(s("div",D,N,512),[[_,l.value]]),a(s("div",B,[s("div",C,[H,a(s("input",{class:"form-control",id:"smtpHost","onUpdate:modelValue":t[1]||(t[1]=o=>e.value.smtpServer=o),placeholder:"mail.domain.name"},null,512),[[i,e.value.smtpServer]])]),s("div",$,[j,a(s("input",{type:"number",class:"form-control",id:"smtpPort","onUpdate:modelValue":t[2]||(t[2]=o=>e.value.smtpPort=o),placeholder:"25"},null,512),[[i,e.value.smtpPort]])]),s("div",z,[J,a(s("input",{class:"form-control",id:"smtpUser","onUpdate:modelValue":t[3]||(t[3]=o=>e.value.smtpUsername=o),placeholder:""},null,512),[[i,e.value.smtpUsername]])]),s("div",O,[R,a(s("input",{type:"password",class:"form-control",id:"smtpPass","onUpdate:modelValue":t[4]||(t[4]=o=>e.value.smtpPassword=o),placeholder:""},null,512),[[i,e.value.smtpPassword]])]),q,s("div",G,[I,a(s("input",{class:"form-control",id:"smtpFromName","onUpdate:modelValue":t[5]||(t[5]=o=>e.value.smtpFromName=o),placeholder:"EzeScan Authority Server"},null,512),[[i,e.value.smtpFromName]])]),s("div",K,[L,a(s("input",{type:"email",class:"form-control",id:"smtpFromAddress","onUpdate:modelValue":t[6]||(t[6]=o=>e.value.smtpFromAddress=o),placeholder:""},null,512),[[i,e.value.smtpFromAddress]])]),s("div",Q,[W,a(s("input",{class:"form-control",id:"alertDefaultEmail","onUpdate:modelValue":t[7]||(t[7]=o=>e.value.alertDefaultEmail=o),placeholder:""},null,512),[[i,e.value.alertDefaultEmail]]),X]),s("div",Y,[s("button",{type:"button",onClick:t[8]||(t[8]=o=>b()),class:"btn btn-info mr-1"},[Z,u(" Save and send a test message")]),s("button",{type:"button",onClick:t[9]||(t[9]=o=>f()),class:"btn btn-success"},[ss,u(" Save")])])],512),[[_,!l.value]])])])]))}});export{ls as default};
