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