WGDashboard/src/static/app/dist/assets/peerShareLinkModal-7GPnxpds.js

2 lines
7.7 KiB
JavaScript
Raw Normal View History

2025-01-13 16:47:15 +08:00
import{r as C,Y as $,g as M,E,D as P,j as g,a as o,c as p,b as e,d as i,m as f,x as S,v as L,w as k,z as x,_ as V,n as w,i as m,t as Y,S as H,e as N}from"./index-Cdy--wcE.js";import{d as v}from"./dayjs.min-B_4C5ugr.js";import{V as I}from"./vue-datepicker-BjpxqJk-.js";import{L as u}from"./localeText-DwvvmbTS.js";const R={key:0},U={class:"mb-3"},j={class:"position-relative"},A=["disabled"],B={class:"position-relative"},T=["disabled"],O=["disabled"],J={class:"form-check form-switch"},W={class:"form-check-label",for:"includeAttachment"},q=["disabled"],z={key:0},G={key:1},F={key:1},K={__name:"peerShareWithEmail",props:["dataCopy","selectedPeer"],async setup(s){let t,h;const _=s,b=C(!1);[t,h]=$(()=>M("/api/email/ready",{},c=>{b.value=c.status})),await t,h();const n=E({Receiver:"",Body:"",Subject:"",IncludeAttachment:!1,ConfigurationName:_.selectedPeer.configuration.Name,Peer:_.selectedPeer.id}),r=P(),l=C(!1),y=async()=>{l.value=!0,await x("/api/email/send",n,c=>{c.status?r.newMessage("Server","Email sent successfully!","success"):r.newMessage("Server",`Email sent failed! Reason: ${c.message}`,"danger"),l.value=!1})};return(c,a)=>{const D=g("RouterLink");return b.value?(o(),p("div",R,[e("h6",U,[i(u,{t:"Share with Email"})]),e("form",{class:"d-flex gap-3 flex-column",onSubmit:a[4]||(a[4]=d=>{d.preventDefault(),y()})},[e("div",null,[e("div",j,[a[5]||(a[5]=e("i",{class:"bi bi-person-circle",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),f(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]=d=>n.Receiver=d),disabled:l.value,placeholder:"Send to who?",required:"",id:"email_receiver","aria-describedby":"emailHelp"},null,8,A),[[S,n.Receiver]])]),e("div",B,[a[6]||(a[6]=e("i",{class:"bi bi-hash",style:{position:"absolute",top:"0.4rem",left:"0.75rem"}},null,-1)),f(e("input",{type:"text",class:"form-control rounded-0 border-top-0 border-bottom-0",style:{"padding-left":"calc( 0.75rem + 24px )"},placeholder:"Subject",disabled:l.value,"onUpdate:modelValue":a[1]||(a[1]=d=>n.Subject=d),id:"email_subject","aria-describedby":"emailHelp"},null,8,T),[[S,n.Subject]])]),f(e("textarea",{class:"form-control rounded-bottom-3 rounded-top-0","onUpdate:modelValue":a[2]||(a[2]=d=>n.Body=d),disabled:l.value,placeholder:"Body",style:{"min-height":"300px"}},null,8,O),[[S,n.Body]])]),e("div",J,[f(e("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":a[3]||(a[3]=d=>n.IncludeAttachment=d),role:"switch",id:"includeAttachment",checked:""},null,512),[[L,n.IncludeAttachment]]),e("label",W,[i(u,{t:"Include configuration file as an attachment"})])]),e("button",{disabled:l.value,class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-3"},[l.value?(o(),p("span",G,[a[8]||(a[8]=e("span",{class:"spinner-border spinner-border-sm me-2"},null,-1)),i(u,{t:"Sending..."})])):(o(),p("span",z,[a[7]||(a[7]=e("i",{class:"bi bi-send me-2"},null,-1)),i(u,{t:"Send"})]))],8,q)],32)])):(o(),p("div",F,[e("small",null,[i(u,{t:"SMTP is not configured, please navigate to "}),i(D,{to:"/settings"},{default:k(()=>[i(u,{t:"Settings"})]),_:1}),i(u,{t:" to finish setup"})])]))}}},Q={name:"peerShareLinkModal",props:{selectedPeer:Object},components:{PeerShareWithEmail:K,LocaleText:u,VueDatePicker:I},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:P()}},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,x("/api/sharePeer/create",{Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,ExpireDate:v().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(){x("/api/sharePeer/upd