2025-02-12 20:07:37 +08:00
|
|
|
|
import{O,r as x,I as E,D as z,o as J,a as c,c as v,b as e,d as i,n as $,m as B,x as R,A as K,i as S,z as W,g as M,_ as I,u as Q,p as X,w as T,e as N,T as Y,t as D,f as V,F as H,h as F,k as G,E as j,W as q,H as Z,j as ee,a4 as te,q as P,C as se,a5 as ne,N as ae,v as ie}from"./index-Dtibxnfz.js";import{L as l}from"./localeText-GaOVxp1i.js";import{d as le}from"./dayjs.min-DPqi2oRr.js";const oe={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},re={class:"container d-flex h-100 w-100"},de={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},ue={class:"card rounded-3 shadow flex-grow-1 bg-danger-subtle border-danger-subtle",id:"deleteConfigurationContainer"},ce={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},fe={class:"mb-0"},ge={class:"card-body px-4 text-muted"},me={class:"mb-0"},be={key:0},ve={key:1},pe={key:2,class:"d-flex align-items-center gap-2"},he=["placeholder"],ye=["disabled"],xe={__name:"deleteConfiguration",emits:["backup","close"],setup(o,{emit:r}){const p=O().params.id,n=x(""),g=E(),u=z(),h=x(!1),f=()=>{clearInterval(u.Peers.RefreshInterval),h.value=!0,W("/api/deleteWireguardConfiguration",{Name:p},_=>{_.status?(g.push("/"),u.newMessage("Server","Configuration deleted","success")):h.value=!1})},b=x(!0),y=x([]),w=()=>{b.value=!0,M("/api/getWireguardConfigurationBackup",{configurationName:p},_=>{y.value=_.data,b.value=!1})};J(()=>{w()});const k=r;return(_,d)=>(c(),v("div",oe,[e("div",re,[e("div",de,[e("div",ue,[e("div",ce,[e("h5",fe,[i(l,{t:"Are you sure to delete this configuration?"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:d[0]||(d[0]=s=>k("close"))})]),e("div",ge,[e("p",me,[i(l,{t:"Once you deleted this configuration:"})]),e("ul",null,[e("li",null,[i(l,{t:"All connected peers will get disconnected"})]),e("li",null,[i(l,{t:"Both configuration file (.conf) and database table related to this configuration will get deleted"})])]),e("div",{class:$(["alert",[b.value?"alert-secondary":y.value.length>0?"alert-success":"alert-danger"]])},[b.value?(c(),v("div",be,[d[5]||(d[5]=e("i",{class:"bi bi-search me-2"},null,-1)),i(l,{t:"Checking backups..."})])):y.value.length>0?(c(),v("div",ve,[d[6]||(d[6]=e("i",{class:"bi bi-check-circle-fill me-2"},null,-1)),i(l,{t:"This configuration have "+y.value.length+" backups"},null,8,["t"])])):(c(),v("div",pe,[d[9]||(d[9]=e("i",{class:"bi bi-x-circle-fill me-2"},null,-1)),i(l,{t:"This configuration have no backup"}),e("a",{role:"button",onClick:d[1]||(d[1]=s=>k("backup")),class:"ms-auto btn btn-sm btn-primary rounded-3"},[d[7]||(d[7]=e("i",{class:"bi bi-clock-history me-2"},null,-1)),i(l,{t:"Backup"})]),e("a",{role:"button",onClick:d[2]||(d[2]=s=>w()),class:"btn btn-sm btn-primary rounded-3"},d[8]||(d[8]=[e("i",{class:"bi bi-arrow-clockwise"},null,-1)]))]))],2),d[11]||(d[11]=e("hr",null,null,-1)),e("p",null,[i(l,{t:"If you're sure, please type in the configuration name below and click Delete"})]),B(e("input",{class:"form-control rounded-3 mb-3",placeholder:K(p),"onUpdate:modelValue":d[3]||(d[3]=s=>n.value=s),type:"text"},null,8,he),[[R,n.value]]),e("button",{class:"btn btn-danger w-100",onClick:d[4]||(d[4]=s=>f()),disabled:n.value!==K(p)||h.value},[d[10]||(d[10]=e("i",{class:"bi bi-trash-fill me-2 rounded-3"},null,-1)),h.value?(c(),S(l,{key:1,t:"Deleting..."})):(c(),S(l,{key:0,t:"Delete"}))],8,ye)])])])])]))}},we={class:"card my-0 rounded-3"},ke={class:"card-body position-relative"},Ce={key:0,class:"position-absolute w-100 h-100 confirmationContainer start-0 top-0 rounded-3 d-flex p-2"},_e={class:"m-auto"},Ne={class:"d-flex gap-2 align-items-center justify-content-center"},Se=["disabled"],$e=["disabled"],Be={key:0,class:"position-absolute w-100 h-100 confirmationContainer start-0 top-0 rounded-3 d-flex p-2"},Pe={class:"m-auto"},Re={class:"d-flex gap-2 align-items-center justify-content-center"},De=["disabled"],We=["disabled"],Le={class:"d-flex gap-3"},Ve={class:"d-flex flex-column"},He={class:"text-muted"},Me={class:"d-flex flex-column"},ze={class:"text-muted"
|
2025-01-26 23:07:32 +08:00
|
|
|
|
`:this.modelValue+`
|
|
|
|
|
`},scroll(){return this.height!="auto"}},methods:{updateValue(o){this.modelValue==null?this.content=o.target.value:this.$emit("update:modelValue",o.target.value)},changeLang(o){this.languageTitle=o[1]?o[1]:o[0],this.languageClass="language-"+o[0],this.$emit("lang",o[0])},tab(){if(document.execCommand("insertText"))document.execCommand("insertText",!1,this.tabWidth);else{const o=this.$refs.textarea.selectionStart;this.content=this.content.substring(0,o)+this.tabWidth+this.content.substring(o),this.cursorPosition=o+this.tabWidth.length,this.insertTab=!0}},calcScrollDistance(o){this.$refs.code.scrolling=!0,this.scrolling=!0,this.top=-o.target.scrollTop,this.left=-o.target.scrollLeft},resizer(){new ResizeObserver(t=>{this.scrollBarWidth=t[0].target.offsetWidth-t[0].target.clientWidth,this.scrollBarHeight=t[0].target.offsetHeight-t[0].target.clientHeight,this.textareaHeight=t[0].target.offsetHeight}).observe(this.$refs.textarea);const r=new ResizeObserver(t=>{this.lineNumsWidth=t[0].target.offsetWidth});this.$refs.lineNums&&r.observe(this.$refs.lineNums)},copy(){document.execCommand("copy")?(this.$refs.textarea.select(),document.execCommand("copy"),window.getSelection().removeAllRanges()):navigator.clipboard.writeText(this.$refs.textarea.value)},getLineNum(){const o=this.$refs.textarea.value;let r=0,t=o.indexOf(`
|
|
|
|
|
`);for(;t!==-1;)r++,t=o.indexOf(`
|
|
|
|
|
`,t+1);const p=this.$refs.lineNums.firstChild.offsetHeight,n=parseInt(this.textareaHeight/p)-1;this.lineNum=this.height=="auto"||r>n?r:n}},mounted(){this.$emit("lang",this.languages[0][0]),this.$emit("content",this.content),this.$emit("textarea",this.$refs.textarea),this.resizer()},updated(){this.insertTab&&(this.$refs.textarea.setSelectionRange(this.cursorPosition,this.cursorPosition),this.insertTab=!1),this.lineNums&&(this.scrolling?this.scrolling=!1:this.getLineNum())}},ht=["theme"],yt=["readOnly","autofocus","value"];function xt(o,r,t,p,n,g){const u=ee("Dropdown"),h=te("highlight");return c(),v("div",{theme:t.theme,class:$(["code-editor",{"hide-header":!t.header,scroll:g.scroll,"read-only":t.readOnly,wrap:t.wrap}]),style:P({width:t.width,height:t.height,zIndex:t.zIndex,maxWidth:t.maxWidth,minWidth:t.minWidth,maxHeight:t.maxHeight,minHeight:t.minHeight})},[e("div",{class:"hljs",style:P({borderRadius:t.borderRadius})},[t.header?(c(),v("div",{key:0,class:$(["header",{border:n.showLineNums}]),style:P({borderRadius:t.borderRadius+" "+t.borderRadius+" 0 0"})},[t.displayLanguage?(c(),S(u,{key:0,width:t.langListWidth,title:n.languageTitle,disabled:t.languages.length<=1,defaultDisplay:t.langListDisplay},null,8,["width","title","disabled","defaultDisplay"])):N("",!0)],6)):N("",!0),e("div",{class:"code-area",style:P({borderRadius:t.header?"0 0 "+t.borderRadius+" "+t.borderRadius:t.borderRadius})},[n.showLineNums?(c(),v("div",{key:0,ref:"lineNums",class:"line-nums hljs",style:P({fontSize:t.fontSize,paddingTop:t.header?"10px":t.padding,paddingBottom:t.padding,top:n.top+"px"})},[r[3]||(r[3]=e("div",null,"1",-1)),(c(!0),v(H,null,F(n.lineNum,f=>(c(),v("div",null,D(f+1),1))),256)),r[4]||(r[4]=e("div",null," ",-1))],4)):N("",!0),e("textarea",{title:"textarea",readOnly:t.readOnly,style:P({fontSize:t.fontSize,padding:t.header?t.lineNums?"10px "+t.padding+" "+t.padding:"0 "+t.padding+" "+t.padding:t.padding,marginLeft:n.showLineNums?n.lineNumsWidth+"px":"0",width:n.showLineNums?"calc(100% - "+n.lineNumsWidth+"px)":"100%"}),ref:"textarea",autofocus:t.autofocus,spellcheck:"false",onKeydown:r[0]||(r[0]=se(ne((...f)=>g.tab&&g.tab(...f),["prevent","stop"]),["tab"])),onScroll:r[1]||(r[1]=(...f)=>g.calcScrollDistance&&g.calcScrollDistance(...f)),value:t.modelValue==null?n.content:t.modelValue,onInput:r[2]||(r[2]=(...f)=>g.updateValue&&g.updateValue(...f))},null,44,yt),e("pre",{style:P({paddingRight:n.scrollBarWidth+"px",paddingBottom:n.scrollBarHeight+"px",marginLeft:n.showLineNums?n.lineNumsWidth+"px":"0",width:n.showLineNums?"calc(100% - "+n.lineNumsWidth+"px)":"100%"})},[r[6]||(r[6]=V(" ")),B((c(),v("code",{ref:"code",class:$(n.languageClass),style:P({top:n.top+"px",left:n.left+"px",fontSize:t.fontSize,padding:t.header?t.lineNums?"10px "+t.padding+" "+t.padding:"0 "+t.padding+" "+t.padding:t.padding})},r[5]||(r[5]=[V(`
|
|
|
|
|
`)]),6)),[[h,g.contentValue]]),r[7]||(r[7]=V(`
|
|
|
|
|
`))],4)],4)],4)],14,ht)}const wt=I(pt,[["render",xt]]),kt={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Ct={class:"container d-flex h-100 w-100"},_t={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"1000px"}},Nt={class:"card rounded-3 shadow flex-grow-1",id:"deleteConfigurationContainer"},St={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},$t={class:"mb-0"},Bt={class:"card-body px-4 d-flex flex-column gap-3"},Pt={class:"alert alert-warning rounded-3 mb-0"},Rt={key:0,class:"alert alert-danger rounded-3 mb-0"},Dt={class:"mb-2"},Wt={class:"bg-body w-100 p-2 rounded-3"},Lt={class:"d-flex gap-2"},Vt=["disabled"],Ht=["disabled"],Mt={__name:"editRawConfigurationFile",emits:["close"],async setup(o,{emit:r}){let t,p;const n=r,g=O(),u=x(""),h=x(""),f=x(!1),b=x(""),y=async()=>{await M("/api/getWireguardConfigurationRawFile",{configurationName:g.params.id},d=>{u.value=d.data.content,h.value=d.data.path})};[t,p]=ae(()=>y()),await t,p();const w=z(),k=x(!1),_=async()=>{k.value=!0,await W("/api/updateWireguardConfigurationRawFile",{configurationName:g.params.id,rawConfiguration:u.value},d=>{d.status?(f.value=!1,w.newMessage("Server","Configuration saved","success")):(f.value=!0,b.value=d.message),k.value=!1})};return(d,s)=>(c(),v("div",kt,[e("div",Ct,[e("div",_t,[e("div",Nt,[e("div",St,[e("h5",$t,[i(l,{t:"Edit Raw Configuration File"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:s[0]||(s[0]=C=>n("close"))})]),e("div",Bt,[e("div",Pt,[s[4]||(s[4]=e("i",{class:"bi-exclamation-triangle-fill me-2"},null,-1)),i(l,{t:"Please be careful when editing the raw file"})]),f.value?(c(),v("div",Rt,[e("div",Dt,[e("strong",null,[i(l,{t:"Failed to save configuration. Please see the following error message:"})])]),e("div",Wt,[e("pre",null,D(b.value),1)])])):N("",!0),i(wt,{disabled:!0,"read-only":k.value,modelValue:u.value,"onUpdate:modelValue":s[1]||(s[1]=C=>u.value=C),theme:K(w).Configuration.Server.dashboard_theme==="dark"?"github-dark":"github",languages:[["ini",h.value]],width:"100%",height:"600px"},null,8,["read-only","modelValue","theme","languages"]),e("div",Lt,[e("button",{class:"btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto px-3 py-2",disabled:k.value,onClick:s[2]||(s[2]=C=>y())},[s[5]||(s[5]=e("i",{class:"bi bi-arrow-clockwise me-2"},null,-1)),i(l,{t:"Reset"})],8,Vt),e("button",{onClick:s[3]||(s[3]=C=>_()),disabled:k.value,class:"btn bg-danger-subtle border-danger-subtle text-danger-emphasis rounded-3 px-3 py-2 shadow"},[s[6]||(s[6]=e("i",{class:"bi bi-save-fill me-2"},null,-1)),k.value?(c(),S(l,{key:1,t:"Saving..."})):(c(),S(l,{key:0,t:"Save"}))],8,Ht)])])])])])]))}},zt={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll",ref:"editConfigurationContainer"},It={class:"container d-flex h-100 w-100"},Kt={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},Tt={class:"card rounded-3 shadow flex-grow-1"},Ft={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},Ot={class:"mb-0"},Ut={class:"card-body px-4 pb-4"},At={class:"d-flex gap-2 flex-column"},jt={key:0,class:"d-flex align-items-center gap-3"},Jt={class:"text-muted"},Yt={class:"d-flex align-items-center gap-3"},Et={class:"text-muted",style:{"word-break":"keep-all"}},Gt={class:"ms-auto",style:{"word-break":"break-all"}},qt={class:"d-flex"},Zt={for:"configuration_private_key",class:"form-label"},Qt={class:"text-muted d-block"},Xt={class:"form-check form-switch ms-auto"},es=["disabled"],ts={for:"configuration_ipaddress_cidr",class:"form-label"},ss={class:"text-muted"},ns=["disabled"],as={for:"configuration_listen_port",class:"form-label"},is={class:"text-muted"},ls=["disabled"],os=["for"],rs={class:"text-muted"},ds=["disabled","onUpdate:modelValue","id"],us=["for"],cs={class:"text-muted"},fs=["disabled","onUpdate:modelValue","id"],gs={class:"d-flex align-items-center gap-2 mt-4"},ms=["disabled"],bs=["disabled"],vs={class:"d-flex gap-2 fl
|