Files
WGDashboard/src/static/app/dist/assets/settings-2zQgrBXq.js
Donald Zou 1dfa1d62e1 Build
2025-08-20 15:10:55 +08:00

2 lines
36 KiB
JavaScript

import{_ as k,z as v,D as y,A as I,c as l,a as t,m as b,d as _,b as i,h as m,y as f,n as $,t as D,f as n,W as M,e as S,v as L,j as x,F as P,g as E,w as F,T as j,k as U,i as K,r as T,q as z,o as O,u as w,B as q}from"./index-B-jc5mKC.js";import{L as p}from"./localeText-DmTH4uVF.js";import{d as A}from"./dayjs.min-CrcZDfUc.js";import{Q}from"./vue-datepicker-DTo5rWZa.js";const J={components:{LocaleText:p},props:{targetData:String,title:String,warning:!1,warningText:""},setup(){const s=y(),e=`input_${I()}`;return{store:s,uuid:e}},data(){return{value:"",invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0,changed:!1,updating:!1}},mounted(){this.value=this.store.Configuration.Peers[this.targetData]},methods:{async useValidation(){this.changed&&await v("/api/updateDashboardConfigurationItem",{section:"Peers",key:this.targetData,value:this.value},s=>{s.status?(this.isValid=!0,this.showInvalidFeedback=!1,this.store.Configuration.Peers[this.targetData]=this.value,clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.isValid=!1,5e3)):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=s.message),this.changed=!1,this.updating=!1})}}},X={class:"form-group mb-2"},Z=["for"],tt=["id","disabled"],et={class:"invalid-feedback"},st={key:0,class:"px-2 py-1 text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 d-inline-block mt-1"};function at(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",X,[t("label",{for:this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:this.title},null,8,["t"])])])],8,Z),b(t("input",{type:"text",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),id:this.uuid,"onUpdate:modelValue":e[0]||(e[0]=a=>this.value=a),onKeydown:e[1]||(e[1]=a=>this.changed=!0),onBlur:e[2]||(e[2]=a=>g.useValidation()),disabled:this.updating},null,42,tt),[[f,this.value]]),t("div",et,D(this.invalidFeedback),1),c.warning?(n(),l("div",st,[t("small",null,[e[3]||(e[3]=t("i",{class:"bi bi-exclamation-triangle-fill me-2"},null,-1)),i(o,{t:c.warningText},null,8,["t"])])])):_("",!0)])}const it=k(J,[["render",at]]),ot={name:"accountSettingsInputUsername",components:{LocaleText:p},props:{targetData:String,title:String},setup(){const s=y(),e=`input_${I()}`;return{store:s,uuid:e}},data(){return{value:"",invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0,changed:!1,updating:!1}},mounted(){this.value=this.store.Configuration.Account[this.targetData]},methods:{async useValidation(s){this.changed&&(this.updating=!0,await v("/api/updateDashboardConfigurationItem",{section:"Account",key:this.targetData,value:this.value},e=>{e.status?(this.isValid=!0,this.showInvalidFeedback=!1,this.store.Configuration.Account[this.targetData]=this.value,clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.isValid=!1,5e3)):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=e.message),this.changed=!1,this.updating=!1}))}}},nt={class:"form-group mb-2"},lt=["for"],dt=["id","disabled"],rt={class:"invalid-feedback"};function ut(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",nt,[t("label",{for:this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:this.title},null,8,["t"])])])],8,lt),b(t("input",{type:"text",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),id:this.uuid,"onUpdate:modelValue":e[0]||(e[0]=a=>this.value=a),onKeydown:e[1]||(e[1]=a=>this.changed=!0),onBlur:e[2]||(e[2]=a=>g.useValidation()),disabled:this.updating},null,42,dt),[[f,this.value]]),t("div",rt,D(this.invalidFeedback),1)])}const ct=k(ot,[["render",ut]]),ht={name:"accountSettingsInputPassword",components:{LocaleText:p},props:{targetData:String,warning:!1,warningText:""},setup(){const s=y(),e=`input_${I()}`;return{store:s,uuid:e}},data(){return{value:{currentPassword:"",newPassword:"",repeatNewPassword:""},invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0}},methods:{async useValidation(){Object.values(this.value).find(s=>s.length===0)===void 0?this.value.newPassword===this.value.repeatNewPassword?await v("/api/updateDashboardConfigurationItem",{section:"Account",key:this.targetData,value:this.value},s=>{s.status?(this.isValid=!0,this.showInvalidFeedback=!1,this.store.Configuration.Account[this.targetData]=this.value,clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.isValid=!1,this.value={currentPassword:"",newPassword:"",repeatNewPassword:""}},5e3)):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=s.message)}):(this.showInvalidFeedback=!0,this.invalidFeedback="New passwords does not match"):(this.showInvalidFeedback=!0,this.invalidFeedback="Please fill in all required fields.")}},computed:{passwordValid(){return Object.values(this.value).find(s=>s.length===0)===void 0&&this.value.newPassword===this.value.repeatNewPassword}}},mt={class:"d-flex flex-column gap-2"},pt={class:"row g-2"},gt={class:"col-sm"},bt={class:"form-group"},_t=["for"],ft=["id"],vt={key:0,class:"invalid-feedback d-block"},yt={class:"col-sm"},wt={class:"form-group"},$t=["for"],kt=["id"],xt={class:"col-sm"},Dt={class:"form-group"},St=["for"],It=["id"],Pt=["disabled"];function Ct(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("form",mt,[t("div",pt,[t("div",gt,[t("div",bt,[t("label",{for:"currentPassword_"+this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:"Current Password"})])])],8,_t),b(t("input",{type:"password",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),autocomplete:"current-password","onUpdate:modelValue":e[0]||(e[0]=a=>this.value.currentPassword=a),id:"currentPassword_"+this.uuid},null,10,ft),[[f,this.value.currentPassword]]),u.showInvalidFeedback?(n(),l("div",vt,D(this.invalidFeedback),1)):_("",!0)])]),t("div",yt,[t("div",wt,[t("label",{for:"newPassword_"+this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:"New Password"})])])],8,$t),b(t("input",{type:"password",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),autocomplete:"new-password","onUpdate:modelValue":e[1]||(e[1]=a=>this.value.newPassword=a),id:"newPassword_"+this.uuid},null,10,kt),[[f,this.value.newPassword]])])]),t("div",xt,[t("div",Dt,[t("label",{for:"repeatNewPassword_"+this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:"Repeat New Password"})])])],8,St),b(t("input",{type:"password",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),autocomplete:"new-password","onUpdate:modelValue":e[2]||(e[2]=a=>this.value.repeatNewPassword=a),id:"repeatNewPassword_"+this.uuid},null,10,It),[[f,this.value.repeatNewPassword]])])])]),t("button",{disabled:!this.passwordValid,class:"ms-auto btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm",onClick:e[3]||(e[3]=a=>this.useValidation())},[e[4]||(e[4]=t("i",{class:"bi bi-save2-fill me-2"},null,-1)),i(o,{t:"Update Password"})],8,Pt)])}const At=k(ht,[["render",Ct]]),Tt={name:"dashboardSettingsInputWireguardConfigurationPath",components:{LocaleText:p},props:{targetData:String,title:String,warning:!1,warningText:""},setup(){const s=y(),e=M(),c=`input_${I()}`;return{store:s,uuid:c,WireguardConfigurationStore:e}},data(){return{value:"",invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0,changed:!1,updating:!1}},mounted(){this.value=this.store.Configuration.Server[this.targetData]},methods:{async useValidation(){this.changed&&(this.updating=!0,await v("/api/updateDashboardConfigurationItem",{section:"Server",key:this.targetData,value:this.value},s=>{s.status?(this.isValid=!0,this.showInvalidFeedback=!1,this.store.Configuration.Account[this.targetData]=this.value,clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.isValid=!1,5e3),this.WireguardConfigurationStore.getConfigurations(),this.store.newMessage("Server","WireGuard configuration path saved","success")):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=s.message),this.changed=!1,this.updating=!1}))}}},Kt={class:"card"},Vt={class:"card-header"},Ft={class:"my-2"},Lt={class:"card-body"},Et={class:"form-group"},Mt=["for"],Ut={class:"d-flex gap-2 align-items-start"},Nt={class:"flex-grow-1"},Wt=["id","disabled"],Gt={class:"invalid-feedback fw-bold"},Yt=["disabled"],Rt={key:0,class:"bi bi-save2-fill"},Ht={key:1,class:"spinner-border spinner-border-sm"},Bt={key:0,class:"px-2 py-1 text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 d-inline-block mt-1 mb-2"};function jt(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",Kt,[t("div",Vt,[t("h6",Ft,[i(o,{t:"Path"})])]),t("div",Lt,[t("div",Et,[t("label",{for:this.uuid,class:"text-muted mb-1"},[t("strong",null,[t("small",null,[i(o,{t:this.title},null,8,["t"])])])],8,Mt),t("div",Ut,[t("div",Nt,[b(t("input",{type:"text",class:$(["form-control rounded-3",{"is-invalid":this.showInvalidFeedback,"is-valid":this.isValid}]),id:this.uuid,"onUpdate:modelValue":e[0]||(e[0]=a=>this.value=a),onKeydown:e[1]||(e[1]=a=>this.changed=!0),disabled:this.updating},null,42,Wt),[[f,this.value]]),t("div",Gt,D(this.invalidFeedback),1)]),t("button",{onClick:e[2]||(e[2]=a=>this.useValidation()),disabled:!this.changed,class:"ms-auto btn rounded-3 border-success-subtle bg-success-subtle text-success-emphasis"},[this.updating?(n(),l("span",Ht)):(n(),l("i",Rt))],8,Yt)]),c.warning?(n(),l("div",Bt,[t("small",null,[e[3]||(e[3]=t("i",{class:"bi bi-exclamation-triangle-fill me-2"},null,-1)),i(o,{t:c.warningText},null,8,["t"])])])):_("",!0)])])])}const zt=k(Tt,[["render",jt]]),Ot={name:"dashboardTheme",components:{LocaleText:p},setup(){return{dashboardConfigurationStore:y()}},methods:{async switchTheme(s){await v("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_theme",value:s},e=>{e.status&&(this.dashboardConfigurationStore.Configuration.Server.dashboard_theme=s)})}}},qt={class:"text-muted mb-1 d-block"},Qt={class:"d-flex gap-1"};function Jt(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",null,[t("small",qt,[t("strong",null,[i(o,{t:"Theme"})])]),t("div",Qt,[t("button",{class:$(["btn bg-primary-subtle text-primary-emphasis flex-grow-1",{active:this.dashboardConfigurationStore.Configuration.Server.dashboard_theme==="light"}]),onClick:e[0]||(e[0]=a=>this.switchTheme("light"))},[e[2]||(e[2]=t("i",{class:"bi bi-sun-fill me-2"},null,-1)),i(o,{t:"Light"})],2),t("button",{class:$(["btn bg-primary-subtle text-primary-emphasis flex-grow-1",{active:this.dashboardConfigurationStore.Configuration.Server.dashboard_theme==="dark"}]),onClick:e[1]||(e[1]=a=>this.switchTheme("dark"))},[e[3]||(e[3]=t("i",{class:"bi bi-moon-fill me-2"},null,-1)),i(o,{t:"Dark"})],2)])])}const Xt=k(Ot,[["render",Jt]]),Zt={name:"dashboardSettingsInputIPAddressAndPort",props:{},setup(){const s=y(),e=`input_${I()}`;return{store:s,uuid:e}},data(){return{app_ip:"",app_port:"",invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0,changed:!1,updating:!1}},mounted(){this.app_ip=this.store.Configuration.Server.app_ip,this.app_port=this.store.Configuration.Server.app_port},methods:{async useValidation(){this.changed&&await v("/api/updateDashboardConfigurationItem",{section:"Server",key:this.targetData,value:this.value},s=>{s.status?(this.isValid=!0,this.showInvalidFeedback=!1,this.store.Configuration.Account[this.targetData]=this.value,clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.isValid=!1,5e3)):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=s.message)})}}},te={class:"invalid-feedback d-block mt-0"},ee={class:"row"},se={class:"form-group mb-2 col-sm"},ae=["for"],ie=["id"],oe={class:"form-group col-sm"},ne=["for"],le=["id"];function de(s,e,c,h,u,g){return n(),l("div",null,[t("div",te,D(this.invalidFeedback),1),t("div",ee,[t("div",se,[t("label",{for:"app_ip_"+this.uuid,class:"text-muted mb-1"},e[2]||(e[2]=[t("strong",null,[t("small",null,"Dashboard IP Address")],-1)]),8,ae),b(t("input",{type:"text",class:"form-control mb-2",id:"app_ip_"+this.uuid,"onUpdate:modelValue":e[0]||(e[0]=o=>this.app_ip=o)},null,8,ie),[[f,this.app_ip]]),e[3]||(e[3]=t("div",{class:"px-2 py-1 text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 d-inline-block"},[t("small",null,[t("i",{class:"bi bi-exclamation-triangle-fill me-2"}),t("code",null,"0.0.0.0"),S(" means it can be access by anyone with your server IP Address.")])],-1))]),t("div",oe,[t("label",{for:"app_port_"+this.uuid,class:"text-muted mb-1"},e[4]||(e[4]=[t("strong",null,[t("small",null,"Dashboard Port")],-1)]),8,ne),b(t("input",{type:"text",class:"form-control mb-2",id:"app_port_"+this.uuid,"onUpdate:modelValue":e[1]||(e[1]=o=>this.app_port=o)},null,8,le),[[f,this.app_port]])])]),e[5]||(e[5]=t("button",{class:"btn btn-success btn-sm fw-bold rounded-3"},[t("i",{class:"bi bi-floppy-fill me-2"}),S("Update Dashboard Settings & Restart ")],-1))])}const re=k(Zt,[["render",de]]),ue={name:"newDashboardAPIKey",components:{LocaleText:p,VueDatePicker:Q},data(){return{newKeyData:{ExpiredAt:A().add(7,"d").format("YYYY-MM-DD HH:mm:ss"),NeverExpire:!1},submitting:!1}},setup(){return{store:y()}},mounted(){console.log(this.newKeyData.ExpiredAt)},methods:{submitNewAPIKey(){this.submitting=!0,v("/api/newDashboardAPIKey",this.newKeyData,s=>{s.status?(this.$emit("created",s.data),this.store.newMessage("Server","API Key created","success"),this.$emit("close")):this.store.newMessage("Server",s.message,"danger"),this.submitting=!1})},fixDate(s){return console.log(A(s).format("YYYY-MM-DDTHH:mm:ss")),A(s).format("YYYY-MM-DDTHH:mm:ss")},parseTime(s){s?this.newKeyData.ExpiredAt=A(s).format("YYYY-MM-DD HH:mm:ss"):this.newKeyData.ExpiredAt=void 0}}},ce={class:"position-absolute w-100 h-100 top-0 start-0 rounded-bottom-3 p-3 d-flex",style:{"background-color":"#00000060","backdrop-filter":"blur(3px)"}},he={class:"card m-auto rounded-3 mt-5"},me={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},pe={class:"mb-0"},ge={class:"card-body d-flex gap-2 p-4 flex-column"},be={class:"text-muted"},_e={class:"d-flex align-items-center gap-2"},fe={class:"form-check"},ve=["disabled"],ye={class:"form-check-label",for:"neverExpire"},we={key:0,class:"bi bi-check-lg me-2"};function $e(s,e,c,h,u,g){const o=m("LocaleText"),a=m("VueDatePicker");return n(),l("div",ce,[t("div",he,[t("div",me,[t("h6",pe,[i(o,{t:"Create API Key"})]),t("button",{type:"button",class:"btn-close ms-auto",onClick:e[0]||(e[0]=r=>this.$emit("close"))})]),t("div",ge,[t("small",be,[i(o,{t:"When should this API Key expire?"})]),t("div",_e,[i(a,{is24:!0,"min-date":new Date,"model-value":this.newKeyData.ExpiredAt,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",clearable:!1,disabled:this.newKeyData.NeverExpire||this.submitting,dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","disabled","dark"])]),t("div",fe,[b(t("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":e[1]||(e[1]=r=>this.newKeyData.NeverExpire=r),id:"neverExpire",disabled:this.submitting},null,8,ve),[[L,this.newKeyData.NeverExpire]]),t("label",ye,[i(o,{t:"Never Expire"}),e[3]||(e[3]=S(" (")),e[4]||(e[4]=t("i",{class:"bi bi-emoji-grimace-fill me-2"},null,-1)),i(o,{t:"Don't think that's a good idea"}),e[5]||(e[5]=S(") "))])]),t("button",{class:$(["ms-auto btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm",{disabled:this.submitting}]),onClick:e[2]||(e[2]=r=>this.submitNewAPIKey())},[this.submitting?_("",!0):(n(),l("i",we)),this.submitting?(n(),x(o,{key:1,t:"Creating..."})):(n(),x(o,{key:2,t:"Create"}))],2)])])])}const ke=k(ue,[["render",$e]]),xe={name:"dashboardAPIKey",components:{LocaleText:p},props:{apiKey:Object},setup(){return{store:y()}},data(){return{confirmDelete:!1}},methods:{deleteAPIKey(){v("/api/deleteDashboardAPIKey",{Key:this.apiKey.Key},s=>{s.status?(this.$emit("deleted",s.data),this.store.newMessage("Server","API Key deleted","success")):this.store.newMessage("Server",s.message,"danger")})}}},De={class:"card rounded-3 shadow-sm"},Se={key:0,class:"card-body d-flex gap-3 align-items-center apiKey-card-body"},Ie={class:"d-flex align-items-center gap-2"},Pe={class:"text-muted"},Ce={style:{"word-break":"break-all"}},Ae={class:"d-flex align-items-center gap-2 ms-auto"},Te={class:"text-muted"},Ke={key:0,class:"card-body d-flex gap-3 align-items-center justify-content-end"};function Ve(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",De,[this.confirmDelete?(n(),l(P,{key:1},[this.store.getActiveCrossServer()?_("",!0):(n(),l("div",Ke,[i(o,{t:"Are you sure to delete this API key?"}),t("a",{role:"button",class:"btn btn-sm bg-success-subtle text-success-emphasis rounded-3",onClick:e[1]||(e[1]=a=>this.deleteAPIKey())},e[4]||(e[4]=[t("i",{class:"bi bi-check-lg"},null,-1)])),t("a",{role:"button",class:"btn btn-sm bg-secondary-subtle text-secondary-emphasis rounded-3",onClick:e[2]||(e[2]=a=>this.confirmDelete=!1)},e[5]||(e[5]=[t("i",{class:"bi bi-x-lg"},null,-1)]))]))],64)):(n(),l("div",Se,[t("div",Ie,[t("small",Pe,[i(o,{t:"Key"})]),t("span",Ce,D(this.apiKey.Key),1)]),t("div",Ae,[t("small",Te,[i(o,{t:"Expire At"})]),this.apiKey.ExpiredAt?_("",!0):(n(),x(o,{key:0,t:"Never Expire"})),t("span",null,D(this.apiKey.ExpiredAt),1)]),this.store.getActiveCrossServer()?_("",!0):(n(),l("a",{key:0,role:"button",class:"btn btn-sm bg-danger-subtle text-danger-emphasis rounded-3",onClick:e[0]||(e[0]=a=>this.confirmDelete=!0)},e[3]||(e[3]=[t("i",{class:"bi bi-trash-fill"},null,-1)])))]))])}const Fe=k(xe,[["render",Ve],["__scopeId","data-v-a76253c8"]]),Le={name:"dashboardAPIKeys",components:{LocaleText:p,DashboardAPIKey:Fe,NewDashboardAPIKey:ke},setup(){return{store:y()}},data(){return{value:this.store.Configuration.Server.dashboard_api_key,apiKeys:[],newDashboardAPIKey:!1}},methods:{async toggleDashboardAPIKeys(){await v("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_api_key",value:this.value},s=>{s.status?(this.store.Configuration.Peers[this.targetData]=this.value,this.store.newMessage("Server",`API Keys function is successfully ${this.value?"enabled":"disabled"}`,"success")):(this.value=this.store.Configuration.Peers[this.targetData],this.store.newMessage("Server",`API Keys function is failed to ${this.value?"enabled":"disabled"}`,"danger"))})}},watch:{value:{immediate:!0,handler(s){s?E("/api/getDashboardAPIKeys",{},e=>{e.status?this.apiKeys=e.data:(this.apiKeys=[],this.store.newMessage("Server",e.message,"danger"))}):this.apiKeys=[]}}}},Ee={class:"card rounded-3"},Me={class:"my-2"},Ue={key:0,class:"form-check form-switch ms-auto"},Ne={class:"form-check-label",for:"allowAPIKeysSwitch"},We={key:0,class:"card-body position-relative d-flex flex-column gap-2"},Ge={key:1,class:"card",style:{height:"300px"}},Ye={class:"card-body d-flex text-muted"},Re={class:"m-auto"},He={key:2,class:"d-flex flex-column gap-2 position-relative",style:{"min-height":"300px"}};function Be(s,e,c,h,u,g){const o=m("LocaleText"),a=m("DashboardAPIKey"),r=m("NewDashboardAPIKey");return n(),l("div",Ee,[t("div",{class:$(["card-header d-flex align-items-center",{"border-bottom-0 rounded-3":!this.value}])},[t("h6",Me,[i(o,{t:"API Keys"})]),this.store.getActiveCrossServer()?_("",!0):(n(),l("div",Ue,[b(t("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":e[0]||(e[0]=d=>this.value=d),onChange:e[1]||(e[1]=d=>this.toggleDashboardAPIKeys()),role:"switch",id:"allowAPIKeysSwitch"},null,544),[[L,this.value]]),t("label",Ne,[this.value?(n(),x(o,{key:0,t:"Enabled"})):(n(),x(o,{key:1,t:"Disabled"}))])]))],2),this.value?(n(),l("div",We,[this.store.getActiveCrossServer()?_("",!0):(n(),l("button",{key:0,class:"btn bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle rounded-3 shadow-sm",onClick:e[2]||(e[2]=d=>this.newDashboardAPIKey=!0)},[e[6]||(e[6]=t("i",{class:"bi bi-plus-circle-fill me-2"},null,-1)),i(o,{t:"API Key"})])),this.apiKeys.length===0?(n(),l("div",Ge,[t("div",Ye,[t("span",Re,[i(o,{t:"No WGDashboard API Key"})])])])):(n(),l("div",He,[i(j,{name:"apiKey"},{default:F(()=>[(n(!0),l(P,null,K(this.apiKeys,d=>(n(),x(a,{apiKey:d,key:d.Key,onDeleted:e[3]||(e[3]=C=>this.apiKeys=C)},null,8,["apiKey"]))),128))]),_:1})])),i(U,{name:"zoomReversed"},{default:F(()=>[this.newDashboardAPIKey?(n(),x(r,{key:0,onCreated:e[4]||(e[4]=d=>this.apiKeys=d),onClose:e[5]||(e[5]=d=>this.newDashboardAPIKey=!1)})):_("",!0)]),_:1})])):_("",!0)])}const je=k(Le,[["render",Be],["__scopeId","data-v-100ee9f9"]]),ze={name:"accountSettingsMFA",components:{LocaleText:p},setup(){const s=y(),e=`input_${I()}`;return{store:s,uuid:e}},data(){return{status:!1}},mounted(){this.status=this.store.Configuration.Account.enable_totp},methods:{async resetMFA(){await v("/api/updateDashboardConfigurationItem",{section:"Account",key:"totp_verified",value:"false"},async s=>{await v("/api/updateDashboardConfigurationItem",{section:"Account",key:"enable_totp",value:"false"},e=>{e.status&&this.$router.push("/2FASetup")})})}}},Oe={class:"d-flex align-items-center"},qe={class:"form-check form-switch"},Qe={for:"allowMFAKeysSwitch"};function Je(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",null,[t("div",Oe,[t("div",qe,[b(t("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":e[0]||(e[0]=a=>this.status=a),role:"switch",id:"allowMFAKeysSwitch"},null,512),[[L,this.status]]),t("label",Qe,[this.status?(n(),x(o,{key:0,t:"Enabled"})):(n(),x(o,{key:1,t:"Disabled"}))])]),this.status?(n(),l("button",{key:0,class:"btn bg-warning-subtle text-warning-emphasis border-1 border-warning-subtle ms-auto rounded-3 shadow-sm",onClick:e[1]||(e[1]=a=>this.resetMFA())},[e[2]||(e[2]=t("i",{class:"bi bi-shield-lock-fill me-2"},null,-1)),this.store.Configuration.Account.totp_verified?(n(),x(o,{key:0,t:"Reset"})):(n(),x(o,{key:1,t:"Setup"})),e[3]||(e[3]=S(" MFA "))])):_("",!0)])])}const Xe=k(ze,[["render",Je]]),Ze={name:"dashboardLanguage",components:{LocaleText:p},setup(){return{store:y()}},data(){return{languages:void 0}},mounted(){E("/api/locale/available",{},s=>{this.languages=s.data})},methods:{changeLanguage(s){v("/api/locale/update",{lang_id:s},e=>{e.status?(this.store.Configuration.Server.dashboard_language=s,this.store.Locale=e.data):this.store.newMessage("Server","WGDashboard language update failed","danger")})}},computed:{currentLanguage(){let s=this.store.Configuration.Server.dashboard_language;return this.languages.find(e=>e.lang_id===s)}}},ts={class:"text-muted d-block mb-1"},es={class:"d-flex gap-2"},ss={class:"dropdown w-100"},as=["disabled"],is={key:1},os={class:"dropdown-menu rounded-3 shadow",style:{"max-height":"500px","overflow-y":"scroll"}},ns=["onClick"],ls={class:"me-auto mb-0"},ds={class:"d-block",style:{"font-size":"0.8rem"}},rs={key:0,class:"bi bi-check text-primary fs-5"};function us(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",null,[t("small",ts,[t("strong",null,[i(o,{t:"Language"})])]),t("div",es,[t("div",ss,[t("button",{class:"btn bg-primary-subtle text-primary-emphasis dropdown-toggle w-100 rounded-3",disabled:!this.languages,type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[this.languages?(n(),l("span",is,D(g.currentLanguage?.lang_name_localized),1)):(n(),x(o,{key:0,t:"Loading..."}))],8,as),t("ul",os,[(n(!0),l(P,null,K(this.languages,a=>(n(),l("li",null,[t("a",{class:"dropdown-item d-flex align-items-center",role:"button",onClick:r=>this.changeLanguage(a.lang_id)},[t("p",ls,[S(D(a.lang_name_localized)+" ",1),t("small",ds,D(a.lang_name),1)]),g.currentLanguage?.lang_id===a.lang_id?(n(),l("i",rs)):_("",!0)],8,ns)]))),256))])])])])}const cs=k(Ze,[["render",us],["__scopeId","data-v-4e34593e"]]),hs={name:"dashboardIPPortInput",components:{LocaleText:p},setup(){return{store:y()}},data(){return{ipAddress:"",port:0,invalidFeedback:"",showInvalidFeedback:!1,isValid:!1,timeout:void 0,changed:!1,updating:!1}},mounted(){this.ipAddress=this.store.Configuration.Server.app_ip,this.port=this.store.Configuration.Server.app_port},methods:{async useValidation(s,e,c){this.changed&&(this.updating=!0,await v("/api/updateDashboardConfigurationItem",{section:"Server",key:e,value:c},h=>{h.status?(s.target.classList.add("is-valid"),this.showInvalidFeedback=!1,this.store.Configuration.Server[e]=c,clearTimeout(this.timeout),this.timeout=setTimeout(()=>{s.target.classList.remove("is-valid")},5e3)):(this.isValid=!1,this.showInvalidFeedback=!0,this.invalidFeedback=h.message),this.changed=!1,this.updating=!1}))}}},ms={class:"row g-2"},ps={class:"col-sm"},gs={class:"form-group"},bs={for:"input_dashboard_ip",class:"text-muted mb-1"},_s=["disabled"],fs={class:"invalid-feedback"},vs={class:"col-sm"},ys={class:"form-group"},ws={for:"input_dashboard_ip",class:"text-muted mb-1"},$s=["disabled"],ks={class:"invalid-feedback"},xs={class:"px-2 py-1 text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 d-inline-block mb-2 mt-2"};function Ds(s,e,c,h,u,g){const o=m("LocaleText");return n(),l("div",null,[t("div",ms,[t("div",ps,[t("div",gs,[t("label",bs,[t("strong",null,[t("small",null,[i(o,{t:"IP Address / Hostname"})])])]),b(t("input",{type:"text",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),id:"input_dashboard_ip","onUpdate:modelValue":e[0]||(e[0]=a=>this.ipAddress=a),onKeydown:e[1]||(e[1]=a=>this.changed=!0),onBlur:e[2]||(e[2]=a=>g.useValidation(a,"app_ip",this.ipAddress)),disabled:this.updating},null,42,_s),[[f,this.ipAddress]]),t("div",fs,D(this.invalidFeedback),1)])]),t("div",vs,[t("div",ys,[t("label",ws,[t("strong",null,[t("small",null,[i(o,{t:"Listen Port"})])])]),b(t("input",{type:"number",class:$(["form-control",{"is-invalid":u.showInvalidFeedback,"is-valid":u.isValid}]),id:"input_dashboard_ip","onUpdate:modelValue":e[3]||(e[3]=a=>this.port=a),onKeydown:e[4]||(e[4]=a=>this.changed=!0),onBlur:e[5]||(e[5]=a=>g.useValidation(a,"app_port",this.port)),disabled:this.updating},null,42,$s),[[f,this.port]]),t("div",ks,D(this.invalidFeedback),1)])])]),t("div",xs,[t("small",null,[e[6]||(e[6]=t("i",{class:"bi bi-exclamation-triangle-fill me-2"},null,-1)),i(o,{t:"Manual restart of WGDashboard is needed to apply changes on IP Address and Listen Port"})])])])}const Ss=k(hs,[["render",Ds]]),Is={class:"card rounded-3"},Ps={class:"card-header"},Cs={class:"my-2"},As={class:"card-body d-flex gap-2"},Ts={class:"list-group w-100"},Ks=["onClick"],Vs={__name:"dashboardSettingsWireguardConfigurationAutostart",setup(s){const e=y(),c=M(),h=T(e.Configuration.WireGuardConfiguration.autostart),u=z(()=>c.Configurations.map(a=>a.Name)),g=async()=>{await v("/api/updateDashboardConfigurationItem",{section:"WireGuardConfiguration",key:"autostart",value:h.value},async a=>{a.status?(e.newMessage("Server","Start up configurations saved","success"),h.value=a.data):e.newMessage("Server","Start up configurations failed to save","danger")})},o=a=>{h.value.includes(a)?h.value=h.value.filter(r=>r!==a):h.value.push(a),g()};return(a,r)=>(n(),l("div",Is,[t("div",Ps,[t("h6",Cs,[i(p,{t:"Toggle When Start Up"})])]),t("div",As,[t("div",Ts,[(n(!0),l(P,null,K(u.value,d=>(n(),l("button",{type:"button",key:d,onClick:C=>o(d),class:"list-group-item list-group-item-action py-2 w-100 d-flex align-items-center"},[t("samp",null,D(d),1),t("i",{class:$(["ms-auto",[h.value.includes(d)?"bi-check-circle-fill":"bi-circle"]])},null,2)],8,Ks))),128))])])]))}},Fs=k(Vs,[["__scopeId","data-v-4aa2aed9"]]),Ls={class:"card"},Es={class:"card-header"},Ms={class:"my-2 d-flex"},Us={key:0,class:"text-success ms-auto"},Ns={class:"card-body d-flex flex-column gap-3"},Ws={class:"row gx-2 gy-2"},Gs={class:"col-12 col-lg-4"},Ys={class:"form-group"},Rs={for:"server",class:"text-muted mb-1"},Hs={class:"col-12 col-lg-4"},Bs={class:"form-group"},js={for:"port",class:"text-muted mb-1"},zs={class:"col-12 col-lg-4"},Os={class:"form-group"},qs={for:"encryption",class:"text-muted mb-1"},Qs={value:"NOTLS"},Js={class:"col-12 col-lg-4"},Xs={class:"form-group"},Zs={for:"username",class:"text-muted mb-1"},ta={class:"col-12 col-lg-4"},ea={class:"form-group"},sa={for:"email_password",class:"text-muted mb-1"},aa={class:"col-12 col-lg-4"},ia={class:"form-group"},oa={for:"send_from",class:"text-muted mb-1"},na={key:0},la={key:1},da={class:"text-muted mb-1",for:"test_email"},ra={class:"fw-bold"},ua=["disabled"],ca=["disabled"],ha={key:0,class:"bi bi-send me-2"},ma={key:1,class:"spinner-border spinner-border-sm me-2"},pa={class:"text-muted mb-1",for:"email_template"},ga={class:"fw-bold"},ba={__name:"dashboardEmailSettings",setup(s){const e=y();O(()=>{g(),document.querySelectorAll("#emailAccount input, #emailAccount select, #email_template").forEach(a=>{a.addEventListener("change",async()=>{let r=a.attributes.getNamedItem("id").value;await v("/api/updateDashboardConfigurationItem",{section:"Email",key:r,value:a.value},d=>{d.status?(a.classList.remove("is-invalid"),a.classList.add("is-valid")):(a.classList.remove("is-valid"),a.classList.add("is-invalid")),g()})})})});const c=T(!1),h=T(""),u=T(!1),g=async()=>{await E("/api/email/ready",{},a=>{c.value=a.status})},o=async()=>{u.value=!0,await v("/api/email/send",{Receiver:h.value,Subject:"WGDashboard Testing Email",Body:"Test 1, 2, 3! Hello World :)"},a=>{a.status?e.newMessage("Server","Test email sent successfully!","success"):e.newMessage("Server",`Test email sent failed! Reason: ${a.message}`,"danger"),u.value=!1})};return(a,r)=>(n(),l("div",Ls,[t("div",Es,[t("h6",Ms,[i(p,{t:"Email Account"}),c.value?(n(),l("span",Us,[r[10]||(r[10]=t("i",{class:"bi bi-check-circle-fill me-2"},null,-1)),i(p,{t:"Ready"})])):_("",!0)])]),t("div",Ns,[t("form",{onSubmit:r[6]||(r[6]=d=>d.preventDefault(d)),id:"emailAccount"},[t("div",Ws,[t("div",Gs,[t("div",Ys,[t("label",Rs,[t("strong",null,[t("small",null,[i(p,{t:"Server"})])])]),b(t("input",{id:"server","onUpdate:modelValue":r[0]||(r[0]=d=>w(e).Configuration.Email.server=d),type:"text",class:"form-control"},null,512),[[f,w(e).Configuration.Email.server]])])]),t("div",Hs,[t("div",Bs,[t("label",js,[t("strong",null,[t("small",null,[i(p,{t:"Port"})])])]),b(t("input",{id:"port","onUpdate:modelValue":r[1]||(r[1]=d=>w(e).Configuration.Email.port=d),type:"text",class:"form-control"},null,512),[[f,w(e).Configuration.Email.port]])])]),t("div",zs,[t("div",Os,[t("label",qs,[t("strong",null,[t("small",null,[i(p,{t:"Encryption"})])])]),b(t("select",{class:"form-select","onUpdate:modelValue":r[2]||(r[2]=d=>w(e).Configuration.Email.encryption=d),id:"encryption"},[r[11]||(r[11]=t("option",{value:"STARTTLS"}," STARTTLS ",-1)),t("option",Qs,[i(p,{t:"No Encryption"})])],512),[[q,w(e).Configuration.Email.encryption]])])]),t("div",Js,[t("div",Xs,[t("label",Zs,[t("strong",null,[t("small",null,[i(p,{t:"Username"})])])]),b(t("input",{id:"username","onUpdate:modelValue":r[3]||(r[3]=d=>w(e).Configuration.Email.username=d),type:"text",class:"form-control"},null,512),[[f,w(e).Configuration.Email.username]])])]),t("div",ta,[t("div",ea,[t("label",sa,[t("strong",null,[t("small",null,[i(p,{t:"Password"})])])]),b(t("input",{id:"email_password","onUpdate:modelValue":r[4]||(r[4]=d=>w(e).Configuration.Email.email_password=d),type:"password",class:"form-control"},null,512),[[f,w(e).Configuration.Email.email_password]])])]),t("div",aa,[t("div",ia,[t("label",oa,[t("strong",null,[t("small",null,[i(p,{t:"Send From"})])])]),b(t("input",{id:"send_from","onUpdate:modelValue":r[5]||(r[5]=d=>w(e).Configuration.Email.send_from=d),type:"text",class:"form-control"},null,512),[[f,w(e).Configuration.Email.send_from]])])])])],32),c.value?(n(),l("hr",na)):_("",!0),c.value?(n(),l("div",la,[t("label",da,[t("small",ra,[i(p,{t:"Send Test Email"})])]),t("form",{onSubmit:r[8]||(r[8]=d=>{d.preventDefault(),o()}),class:"input-group"},[b(t("input",{type:"email",class:"form-control rounded-start-3",id:"test_email",placeholder:"john@example.com","onUpdate:modelValue":r[7]||(r[7]=d=>h.value=d),disabled:u.value},null,8,ua),[[f,h.value]]),t("button",{class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-end-3",type:"submit",value:"Submit",disabled:h.value.length===0||u.value,id:"button-addon2"},[u.value?(n(),l("span",ma)):(n(),l("i",ha)),i(p,{t:u.value?"Sending...":"Send"},null,8,["t"])],8,ca)],32)])):_("",!0),r[12]||(r[12]=t("hr",null,null,-1)),t("div",null,[t("label",pa,[t("small",ga,[i(p,{t:"Email Body Template"})])]),b(t("textarea",{class:"form-control rounded-3 font-monospace","onUpdate:modelValue":r[9]||(r[9]=d=>w(e).Configuration.Email.email_template=d),id:"email_template",style:{"min-height":"400px"}},null,512),[[f,w(e).Configuration.Email.email_template]])])])]))}},_a={name:"settings",components:{DashboardEmailSettings:ba,DashboardSettingsWireguardConfigurationAutostart:Fs,DashboardIPPortInput:Ss,DashboardLanguage:cs,LocaleText:p,AccountSettingsMFA:Xe,DashboardAPIKeys:je,DashboardSettingsInputIPAddressAndPort:re,DashboardTheme:Xt,DashboardSettingsInputWireguardConfigurationPath:zt,AccountSettingsInputPassword:At,AccountSettingsInputUsername:ct,PeersDefaultSettingsInput:it},setup(){return{dashboardConfigurationStore:y()}},data(){return{activeTab:"WGDashboard",tabs:[{id:"WGDashboard",title:"WGDashboard Settings"},{id:"Peers",title:"Peers Settings"},{id:"WireGuardConfiguration",title:"WireGuard Configuration Settings"}]}}},fa={class:"mt-md-5 mt-3 text-body mb-3"},va={class:"container-md d-flex flex-column gap-4"},ya={class:"nav nav-pills nav-justified align-items-center gap-2"},wa={class:"nav-item"},$a=["onClick"],ka={class:"my-2"},xa={key:0,class:"d-flex gap-3 flex-column"},Da={key:1,class:"d-flex gap-3 flex-column"},Sa={class:"card rounded-3"},Ia={class:"card-header"},Pa={class:"my-2"},Ca={class:"card-body"},Aa={key:2,class:"d-flex gap-3 flex-column"},Ta={class:"card rounded-3"},Ka={class:"card-header"},Va={class:"my-2"},Fa={class:"card-body"},La={class:"row g-2"},Ea={class:"col-sm"},Ma={class:"col-sm"},Ua={class:"card"},Na={class:"card-header"},Wa={class:"my-2"},Ga={class:"card-body"},Ya={class:"card"},Ra={class:"card-header"},Ha={class:"my-2"},Ba={class:"card-body d-flex flex-column gap-3"},ja={class:"card"},za={class:"card-header"},Oa={class:"my-2"},qa={class:"card-body"};function Qa(s,e,c,h,u,g){const o=m("LocaleText"),a=m("DashboardSettingsInputWireguardConfigurationPath"),r=m("DashboardSettingsWireguardConfigurationAutostart"),d=m("PeersDefaultSettingsInput"),C=m("DashboardTheme"),N=m("DashboardLanguage"),W=m("DashboardIPPortInput"),G=m("AccountSettingsInputUsername"),Y=m("AccountSettingsInputPassword"),R=m("AccountSettingsMFA"),H=m("DashboardAPIKeys"),B=m("DashboardEmailSettings");return n(),l("div",fa,[t("div",va,[t("div",null,[t("ul",ya,[(n(!0),l(P,null,K(this.tabs,V=>(n(),l("li",wa,[t("a",{class:$(["nav-link rounded-3",{active:this.activeTab===V.id}]),onClick:Ja=>this.activeTab=V.id,role:"button"},[t("h6",ka,[i(o,{t:V.title},null,8,["t"])])],10,$a)]))),256))]),e[1]||(e[1]=t("hr",null,null,-1)),t("div",null,[i(U,{name:"fade2",mode:"out-in"},{default:F(()=>[u.activeTab==="WireGuardConfiguration"?(n(),l("div",xa,[i(a,{targetData:"wg_conf_path",title:"Configurations Directory",warning:!0,"warning-text":"Remember to remove / at the end of your path. e.g /etc/wireguard"}),i(r)])):u.activeTab==="Peers"?(n(),l("div",Da,[t("div",Sa,[t("div",Ia,[t("h6",Pa,[i(o,{t:"Peer Default Settings"})])]),t("div",Ca,[t("div",null,[i(d,{targetData:"peer_global_dns",title:"DNS"}),i(d,{targetData:"peer_endpoint_allowed_ip",title:"Endpoint Allowed IPs"}),i(d,{targetData:"peer_mtu",title:"MTU"}),i(d,{targetData:"peer_keep_alive",title:"Persistent Keepalive"}),i(d,{targetData:"remote_endpoint",title:"Peer Remote Endpoint",warning:!0,warningText:"This will be changed globally, and will be apply to all peer's QR code and configuration file."})])])])])):u.activeTab==="WGDashboard"?(n(),l("div",Aa,[t("div",Ta,[t("div",Ka,[t("h6",Va,[i(o,{t:"Appearance"})])]),t("div",Fa,[t("div",La,[t("div",Ea,[i(C)]),t("div",Ma,[i(N)])])])]),t("div",Ua,[t("div",Na,[t("h6",Wa,[i(o,{t:"Dashboard IP Address & Listen Port"})])]),t("div",Ga,[i(W)])]),t("div",Ya,[t("div",Ra,[t("h6",Ha,[i(o,{t:"Account Settings"})])]),t("div",Ba,[t("div",null,[i(G,{targetData:"username",title:"Username"})]),e[0]||(e[0]=t("hr",null,null,-1)),t("div",null,[i(Y,{targetData:"password"})])])]),t("div",ja,[t("div",za,[t("h6",Oa,[i(o,{t:"Multi-Factor Authentication (MFA)"})])]),t("div",qa,[this.dashboardConfigurationStore.getActiveCrossServer()?_("",!0):(n(),x(R,{key:0}))])]),i(H),i(B)])):_("",!0)]),_:1})])])])])}const si=k(_a,[["render",Qa]]);export{si as default};