Files
WGDashboard/src/static/dist/WGDashboardAdmin/assets/dashboardWebHooks-vxQTlYsj.js

2 lines
14 KiB
JavaScript
Raw Normal View History

2025-09-17 15:23:09 +08:00
import{L as a}from"./localeText-C3GiyveB.js";import{B as D,r as p,I as N,G as A,D as F,c as o,a as t,e as f,b as e,d as l,m as w,f as V,y as I,C as O,v as U,F as C,i as L,n as _,u as J,A as K,t as h,g as R,z as T,q as E,j as $,x as Y,_ as j,o as Z,w as P,S as M}from"./index-BQYwwrw6.js";const Q={class:"p-3"},X={key:0},ee={for:"PayloadURL",class:"form-label fw-bold text-muted"},se=["disabled"],te={for:"ContentType",class:"form-label fw-bold text-muted"},le=["disabled"],oe={class:"form-label fw-bold text-muted"},ne={class:"form-check form-switch mb-2"},ae=["disabled"],ie={class:"form-check-label",for:"VerifySSL"},de={key:0,class:"alert-danger alert rounded-3"},ue={class:"form-label fw-bold text-muted"},re={class:"card rounded-3"},ce={class:"card-body d-flex gap-2 flex-column"},be={class:"d-flex gap-2"},ve={class:"flex-grow-1"},me=["disabled","onUpdate:modelValue"],fe={class:"flex-grow-1"},pe=["disabled","onUpdate:modelValue"],ke=["onClick"],ye={class:"form-label fw-bold text-muted"},he={class:"form-check form-check-inline"},_e=["disabled","id","value"],xe=["for"],ge={class:"form-label fw-bold text-muted"},Se={class:"form-check form-switch mb-2"},we=["disabled"],$e={class:"form-check-label",for:"IsActive"},He={key:0,class:"alert alert-danger rounded-3"},We={class:"d-flex gap-2"},Ce={class:"d-flex align-items-center"},Le={class:"mb-0"},B=D({__name:"addWebHook",props:["webHook"],emits:["refresh","delete"],async setup(i,{emit:m}){let y,r;const s=p({ContentType:String,Headers:Object,IsActive:Boolean,Notes:String,PayloadURL:String,SubscribedActions:Array,VerifySSL:Boolean,WebHookID:String}),u=i;u.webHook?s.value={...u.webHook}:([y,r]=N(()=>R("/api/webHooks/createWebHook",{},g=>{s.value=g.data})),await y,r());const k=p({peer_created:A("Peer Created"),peer_deleted:A("Peer Deleted"),peer_updated:A("Peer Updated")}),x=m,d=F(),c=p(!1),S=p(""),v=p(!1),G=async g=>{g&&g.preventDefault(),v.value=!0,await T("/api/webHooks/updateWebHook",s.value,n=>{n.status?(x("refresh"),d.newMessage("Server","Webhook saved","success")):(c.value=!0,S.value=n.message,d.newMessage("Server","Webhook failed to save","danger")),v.value=!1})},z=async()=>{v.value=!0,await T("/api/webHooks/deleteWebHook",s.value,g=>{g.status?(x("delete"),d.newMessage("Server","Webhook deleted","success")):(c.value=!0,S.value=g.message,d.newMessage("Server","Webhook failed to delete","danger")),v.value=!1})};return(g,n)=>(t(),o("div",Q,[i.webHook?f("",!0):(t(),o("div",X,[e("h6",null,[l(a,{t:"Add Webhook"})]),e("p",null,[l(a,{t:"WGDashboard will sent a POST Request to the URL below with details of any subscribed events."})])])),e("form",{onSubmit:n[7]||(n[7]=b=>G(b)),class:"d-flex flex-column gap-2"},[e("div",null,[e("label",ee,[e("small",null,[l(a,{t:"Payload URL"}),n[8]||(n[8]=V("* ",-1))])]),w(e("input",{required:"",disabled:v.value,id:"PayloadURL","onUpdate:modelValue":n[0]||(n[0]=b=>s.value.PayloadURL=b),class:"form-control rounded-3",type:"url"},null,8,se),[[I,s.value.PayloadURL]])]),e("div",null,[e("label",te,[e("small",null,[l(a,{t:"Content Type"}),n[9]||(n[9]=V("* ",-1))])]),w(e("select",{disabled:v.value,id:"ContentType","onUpdate:modelValue":n[1]||(n[1]=b=>s.value.ContentType=b),class:"form-select rounded-3",required:""},[...n[10]||(n[10]=[e("option",{value:"application/json"}," application/json ",-1),e("option",{value:"application/x-www-form-urlencoded"}," application/x-www-form-urlencoded ",-1)])],8,le),[[O,s.value.ContentType]])]),e("div",null,[e("label",oe,[e("small",null,[l(a,{t:"Verify SSL"})])]),e("div",null,[e("div",ne,[w(e("input",{disabled:v.value,"onUpdate:modelValue":n[2]||(n[2]=b=>s.value.VerifySSL=b),class:"form-check-input",type:"checkbox",role:"switch",id:"VerifySSL"},null,8,ae),[[U,s.value.VerifySSL]]),e("label",ie,[l(a,{t:s.value.VerifySSL?"Enabled":"Disabled"},null,8,["t"])])]),s.value.VerifySSL?f("",!0):(t(),o("div",de,[n[11]||(n[11]=e("i",{class:"bi bi-exclamation-triangle-fill me-2"},null,-1)),l(a,{t:"We highly suggest to enable SSL verification"})]))])]),e("div",null,[e("label",ue,[e("small",null,[l(a,{t:"Custom Headers"})])]),e("div",re,[e("div",