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

2 lines
14 KiB
JavaScript
Raw Normal View History

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