mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-07-15 01:26:59 +00:00
2 lines
9.9 KiB
JavaScript
2 lines
9.9 KiB
JavaScript
import{_ as L,r as y,O as H,H as T,a as i,c,b as e,t as B,e as x,n as w,A as P,g as U,D as N,E as A,k,d as r,m as _,y as C,u as $,G as D,v as V,w as E,s as R,i as g,S as W}from"./index-DZliHkQD.js";import{d as M}from"./dayjs.min-PaIL06iQ.js";import{V as j}from"./vue-datepicker-4ltJE5cT.js";import{L as p}from"./localeText-DG9SnJT8.js";const O={class:"card rounded-0 border-start-0 border-bottom-0 bg-body-secondary",style:{height:"400px",overflow:"scroll"}},J={class:"card-body"},q={key:0,class:"alert alert-danger rounded-3"},G={class:"font-monospace"},z=["innerText"],F={__name:"peerShareWithEmailBodyPreview",props:["body","selectedPeer"],async setup(s){let t,f;const m=s,b=y(""),h=y(!1),n=y(""),l=async()=>{m.body&&(h.value=!1,b.value="",await P("/api/email/previewBody",{Body:m.body,ConfigurationName:m.selectedPeer.configuration.Name,Peer:m.selectedPeer.id},o=>{o.status?b.value=o.data:n.value=o.message,h.value=!o.status}))};[t,f]=H(()=>l()),await t,f();let d;return T(()=>m.body,async()=>{d===void 0?d=setTimeout(async()=>{await l()},500):(clearTimeout(d),d=setTimeout(async()=>{await l()},500))}),(o,S)=>(i(),c("div",O,[e("div",J,[h.value&&s.body?(i(),c("div",q,[S[0]||(S[0]=e("i",{class:"bi bi-exclamation-triangle-fill me-2"},null,-1)),e("span",G,B(n.value),1)])):x("",!0),s.body?(i(),c("div",{key:1,class:w({"opacity-50":h.value}),innerText:b.value},null,10,z)):x("",!0)])]))}},K=L(F,[["__scopeId","data-v-8cfb4d4d"]]),Q={key:0},X={class:"mb-3"},Z={class:"position-relative"},ee=["disabled","placeholder"],te={class:"position-relative"},se=["placeholder","disabled"],ae={class:"row g-0"},oe=["disabled","placeholder"],ie={key:0,class:"col-6"},le={class:"card border-top-0 rounded-top-0 rounded-bottom-3 bg-body-tertiary",style:{border:"var(--bs-border-width) solid var(--bs-border-color)"}},re={class:"card-body d-flex flex-column gap-2"},ne={class:"form-check form-switch ms-auto"},de={class:"form-check-label",for:"livePreview"},ce={class:"form-check form-switch"},ue={class:"form-check-label",for:"includeAttachment"},me=["disabled"],he={key:0},pe={key:1},be={key:1},fe={__name:"peerShareWithEmail",props:["dataCopy","selectedPeer"],emits:["fullscreen"],async setup(s,{emit:t}){let f,m;const b=s,h=y(!1);[f,m]=H(()=>U("/api/email/ready",{},v=>{h.value=v.status})),await f,m();const n=N(),l=A({Receiver:"",Body:n.Configuration.Email.email_template,Subject:"",IncludeAttachment:!1,ConfigurationName:b.selectedPeer.configuration.Name,Peer:b.selectedPeer.id}),d=y(!1),o=y(!1),S=async()=>{o.value=!0,await P("/api/email/send",l,v=>{v.status?n.newMessage("Server","Email sent successfully!","success"):n.newMessage("Server",`Email sent failed! Reason: ${v.message}`,"danger"),o.value=!1})},Y=t;return T(d,()=>{Y("fullscreen",d.value)}),(v,a)=>{const I=k("RouterLink");return h.value?(i(),c("div",Q,[e("h6",X,[r(p,{t:"Share with Email"})]),e("form",{class:"d-flex gap-3 flex-column",onSubmit:a[5]||(a[5]=u=>{u.preventDefault(),S()})},[e("div",null,[e("div",Z,[a[6]||(a[6]=e("i",{class:"bi bi-person-circle",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),_(e("input",{type:"email",class:"form-control rounded-top-3 rounded-bottom-0",style:{"padding-left":"calc( 0.75rem + 24px )"},"onUpdate:modelValue":a[0]||(a[0]=u=>l.Receiver=u),disabled:o.value,placeholder:$(D)("Who are you sending to?"),required:"",id:"email_receiver","aria-describedby":"emailHelp"},null,8,ee),[[C,l.Receiver]])]),e("div",te,[a[7]||(a[7]=e("i",{class:"bi bi-hash",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),_(e("input",{type:"text",class:"form-control rounded-0 border-top-0 border-bottom-0",style:{"padding-left":"calc( 0.75rem + 24px )"},placeholder:$(D)("What's the subject?"),disabled:o.value,"onUpdate:modelValue":a[1]||(a[1]=u=>l.Subject=u),id:"email_subject","aria-describedby":"emailHelp"},null,8,se),[[C,l.Subject]])]),e("div",ae,[e("div",{class:w([d.value?"col-6":"col-12"])},[_(e("textarea",{class:"form-control rounded-top-0 rounded-bottom-0 font-monospace border-bottom-0","onUpdate:modelValue":a[2]||(a[2]=u=>l.Body=u),disabled:o.value,placeholder:$(D)("What's the body?"),style:{height:"400px","max-height":"400px"}},null,8,oe),[[C,l.Body]])],2),d.value?(i(),c("div",ie,[r(K,{body:l.Body,selectedPeer:s.selectedPeer},null,8,["body","selectedPeer"])])):x("",!0)]),e("div",le,[e("div",re,[e("div",ne,[_(e("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":a[3]||(a[3]=u=>d.value=u),role:"switch",id:"livePreview"},null,512),[[V,d.value]]),e("label",de,[r(p,{t:"Live Preview"})])])])])]),e("div",ce,[_(e("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":a[4]||(a[4]=u=>l.IncludeAttachment=u),role:"switch",id:"includeAttachment"},null,512),[[V,l.IncludeAttachment]]),e("label",ue,[r(p,{t:"Include configuration file as an attachment"})])]),e("button",{disabled:o.value,class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-3"},[o.value?(i(),c("span",pe,[a[9]||(a[9]=e("span",{class:"spinner-border spinner-border-sm me-2"},null,-1)),r(p,{t:"Sending..."})])):(i(),c("span",he,[a[8]||(a[8]=e("i",{class:"bi bi-send me-2"},null,-1)),r(p,{t:"Send"})]))],8,me)],32)])):(i(),c("div",be,[e("small",null,[r(p,{t:"SMTP is not configured, please navigate to "}),r(I,{to:"/settings"},{default:E(()=>[r(p,{t:"Settings"})]),_:1}),r(p,{t:" to finish setup"})])]))}}},ye=L(fe,[["__scopeId","data-v-6e705c87"]]),ve={name:"peerShareLinkModal",props:{selectedPeer:Object},components:{PeerShareWithEmail:ye,LocaleText:p,VueDatePicker:j},data(){return{dataCopy:void 0,loading:!1,fullscreen:!1}},setup(){return{store:N()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.selectedPeer.ShareLink)).at(0)},watch:{"selectedPeer.ShareLink":{deep:!0,handler(s,t){t.length!==s.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.selectedPeer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,P("/api/sharePeer/create",{Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,ExpireDate:M().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},s=>{s.status?(this.selectedPeer.ShareLink=s.data,this.dataCopy=s.data.at(0)):this.store.newMessage("Server","Share link failed to create. Reason: "+s.message,"danger"),this.loading=!1})},updateLinkExpireDate(){P("/api/sharePeer/update",this.dataCopy,s=>{s.status?(this.dataCopy=s.data.at(0),this.selectedPeer.ShareLink=s.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+s.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=M().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(s){s?this.dataCopy.ExpireDate=M(s).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const s=this.store.getActiveCrossServer();return s?`${s.host}/${this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}`:window.location.origin+window.location.pathname+this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}}},_e={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},ge={class:"container d-flex h-100 w-100"},Se={class:"card rounded-3 shadow flex-grow-1"},ke={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},xe={class:"mb-0"},we={key:0,class:"card-body px-4 pb-4"},Pe={key:0},Ce={class:"mb-3 text-muted"},$e=["disabled"],De={key:1},Me={class:"d-flex gap-2 mb-4"},Ee=["href"],Le={class:"d-flex flex-column gap-2 mb-3"},Ve=["disabled"],He={class:"text-muted"};function Te(s,t,f,m,b,h){const n=k("LocaleText"),l=k("VueDatePicker"),d=k("PeerShareWithEmail");return i(),c("div",_e,[e("div",ge,[e("div",{class:"m-auto modal-dialog-centered dashboardModal",style:R([this.fullscreen?"width: 100%":"width: 700px"])},[e("div",Se,[e("div",ke,[e("h4",xe,[r(n,{t:"Share Peer"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=o=>this.$emit("close"))})]),this.selectedPeer.ShareLink?(i(),c("div",we,[this.dataCopy?(i(),c("div",De,[e("div",Me,[t[5]||(t[5]=e("i",{class:"bi bi-link-45deg"},null,-1)),e("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},B(h.getUrl),9,Ee)]),e("div",Le,[e("small",null,[t[6]||(t[6]=e("i",{class:"bi bi-calendar me-2"},null,-1)),r(n,{t:"Expire At"})]),r(l,{is24:!0,"min-date":new Date,"model-value":this.dataCopy.ExpireDate,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","dark"])]),e("button",{onClick:t[2]||(t[2]=o=>this.stopSharing()),disabled:this.loading,class:"w-100 btn bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle rounded-3 shadow-sm"},[e("span",{class:w({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[7]||(t[7]=[e("i",{class:"bi bi-send-slash-fill me-2"},null,-1)]),2),this.loading?(i(),g(n,{key:0,t:"Stop Sharing..."})):(i(),g(n,{key:1,t:"Stop Sharing"}))],8,Ve),t[9]||(t[9]=e("hr",null,null,-1)),(i(),g(W,null,{fallback:E(()=>[e("h6",He,[t[8]||(t[8]=e("span",{class:"spinner-border me-2 spinner-border-sm",role:"status"},null,-1)),r(n,{t:"Checking SMTP Configuration..."})])]),default:E(()=>[r(d,{onFullscreen:t[3]||(t[3]=o=>{this.fullscreen=o}),selectedPeer:f.selectedPeer,dataCopy:b.dataCopy},null,8,["selectedPeer","dataCopy"])]),_:1}))])):(i(),c("div",Pe,[e("h6",Ce,[r(n,{t:"Currently the peer is not sharing"})]),e("button",{onClick:t[1]||(t[1]=o=>this.startSharing()),disabled:this.loading,class:"w-100 btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm"},[e("span",{class:w({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[4]||(t[4]=[e("i",{class:"bi bi-send-fill me-2"},null,-1)]),2),this.loading?(i(),g(n,{key:0,t:"Sharing..."})):(i(),g(n,{key:1,t:"Start Sharing"}))],8,$e)]))])):x("",!0)])],4)])])}const Ue=L(ve,[["render",Te]]);export{Ue as default};
|