Viewing File: /usr/local/cpanel/base/frontend/jupiter/koality/_nuxt/D6psN8rT.js

import{J as Z,N as se,Q as he,P as _e,d as ne,aw as we,T as Se,U as I,ax as pe,Z as Ae,h as re,j as le,o as g,c as x,Y as ke,k as e,w as s,e as te,F as ie,a as l,p as H,b as V,l as N,t as E,m as q,u as J,_ as Y,n as f,q as oe,D as de,s as L,A as G,y as Ce,z as ce,ab as xe,ac as Ue,a4 as Te,a5 as $e,f as Ee,r as Ve,av as Pe}from"./EJiqiqZX.js";import{_ as ze}from"./CMk4p11g.js";import{_ as me}from"./D7qtAg9b.js";import{_ as Ne}from"./DPX3lXZf.js";import{_ as De}from"./BBOQFEVZ.js";import{_ as Re}from"./nktVwxwq.js";import{_ as je}from"./ByTKohwH.js";import{_ as Ie}from"./8R23gm1P.js";import{_ as ue}from"./COaTHx-9.js";import{_ as He}from"./DMYOpUVc.js";import{_ as fe}from"./BfhOLfqp.js";import{_ as Fe}from"./Bd9WPADb.js";import{_ as Ke}from"./gjzm6RoO.js";import{_ as Me}from"./EjhM9UWu.js";import"./88opOQSr.js";import"./iik6CYzq.js";import"./lBS7YjNH.js";import"./BdHYZYxo.js";import"./CC92fphK.js";import"./Cqd5VgjX.js";import"./NwK2Pm4d.js";import"./C4BmrwDT.js";import"./DbaqFYix.js";import"./CB5_IlOE.js";import"./CSwwpV8A.js";import"./B3XbUJXz.js";import"./b6minSIt.js";import"./qv9l9arW.js";import"./CASzI7RK.js";const ge=()=>{const{t:v}=Z(),{kapi:P}=se(),a=he(),{tracker:t}=_e();return{removeAlert:async(p,b)=>{try{await P("AlertingChannel").then(u=>u.delete(b,p)),a.add({title:v("alertingActions.deleted.title"),description:v("alertingActions.deleted.description"),color:"success"}),t("alerting_channel","click",`Deleted alerting channel ${p}`)}catch(u){return u}}}},Oe={class:"flex items-center gap-1"},Be={class:"flex items-center gap-1"},qe={class:"flex flex-row gap-2 items-center"},Le={class:"flex flex-row gap-2 items-center"},Ge={class:"flex items-center gap-1"},We={key:3,class:"flex o_gap-2 justify-end o_mt-4"},Je=ne({__name:"AlertComponentForm",props:{channel:{default:void 0},type:{default:void 0}},emits:["updateChannel","addedChannel","close"],setup(v,{emit:P}){const a=v,{t,locale:m}=Z(),{languageItems:p}=we(),b=he(),u=L(()=>a.channel),w=L(()=>a.type?a.type:a.channel?a.channel.sender:"email"),o=L(()=>w.value==="email"),k=Se({email:o.value?I().min(6,t("formErrors.min",{min:6})).email(t("formErrors.invalidEmail")):I().optional(),highSeverity:o.value?I():pe(),lowSeverity:o.value?I():pe(),lang:I(),url:o.value?I().optional():I().min(5,t("formErrors.min",{min:5})).refine(n=>!n.includes(" "),{message:t("formErrors.invalid")}).refine(n=>n.startsWith("http://")||n.startsWith("https://"),{message:t("formErrors.invalidProtocol")}),name:o.value?I().optional():I().min(3,t("formErrors.min",{min:3}))}),U=L(()=>[{label:t("None"),value:"none"},{label:t("immediately"),value:"immediately"},{label:t("Hourly"),value:"1h"},{label:t("Daily"),value:"24h"}]);function j(){const n=u.value&&a.channel?a.channel.language:m.value;return u.value&&a.channel?o.value?{lang:n,email:a.channel.options.emailaddresses??"",highSeverity:a.channel.severities.high||"none",lowSeverity:a.channel.severities.low||"none"}:{lang:n,highSeverity:!!a.channel.severities.high,lowSeverity:!!a.channel.severities.low,name:a.channel.name,url:a.channel.options.webhookUrl??""}:o.value?{lang:n,email:"",highSeverity:"none",lowSeverity:"none"}:{lang:n,highSeverity:!1,lowSeverity:!1,name:"",url:""}}const i=Ae(j()),{kapi:D}=se(),C=P,{pid:S}=re().params;if(!S)throw new Error("Project ID not found");const r=G(null),T=G(!1),{tracker:z}=_e(),W=async n=>{T.value=!0;const c=await D("AlertingChannel"),h=await D("AlertingPolicy"),d=o.value?{emailaddresses:n.data.email}:{webhookUrl:n.data.url},y=o.value?n.data.email:n.data.name||`${w.value.charAt(0).toUpperCase()+w.value.slice(1)} Notification`,X=A=>o.value?A!=="none":A,ee=A=>o.value?A:A?"immediately":"none";try{if(u.value){if(!a.channel)throw new Error("Channel not found");await c.update(Number(S),a.channel.id,{name:y,language:n.data.lang,type:w.value,options:d});const A=($,O,ae,B)=>{const _=async()=>await h.update(Number(S),ae,{name:y,severities:[B],interval:$}),ve=async()=>{if(!a.channel)throw new Error("Channel not found");return await h.create(Number(S),{name:y,channels:[a.channel.id],severities:[B],interval:$})},be=async()=>await h.delete(Number(S),ae);if($!=="none"){if(O&&$!==O)return _();if($!==O)return ve()}else if(O)return be()},{severitiesId:R,severities:M}=a.channel;if(!R||!M)throw new Error("Severities not found");await Promise.all([A(ee(n.data.lowSeverity),M.low,R.low,"low"),A(ee(n.data.highSeverity),M.high,R.high,"high")]),b.add({title:t("alertingActions.updated.title"),description:t("alertingActions.updated.description"),color:"success"}),C("updateChannel"),z("alerting_channel","click",`Updated alerting channel ${y}`)}else{const{channel:A}=await c.create(Number(S),{name:y,type:w.value,language:n.data.lang,options:d}),R=[],M=($,O)=>({name:y,channels:[A.id],severities:$==="high"?["high"]:["low","medium"],interval:ee(O)});X(n.data.highSeverity)&&R.push(h.create(Number(S),M("high",n.data.highSeverity))),X(n.data.lowSeverity)&&R.push(h.create(Number(S),M("low",n.data.lowSeverity))),R.length>0&&await Promise.all(R),b.add({title:t("alertingActions.created.title"),description:t("alertingActions.created.description"),color:"success"}),z("alerting_channel","click",`Created alerting channel ${y}`),setTimeout(()=>{i.lang=m.value,o.value?(i.email="",i.highSeverity="none",i.lowSeverity="none",document.querySelector('input[name="email"]')?.focus()):(i.name="",i.url="",i.highSeverity=!1,i.lowSeverity=!1,document.querySelector('input[name="name"]')?.focus()),n.submitter?.getAttribute("data-action")==="saveAndClose"&&C("close")},2e3),C("addedChannel")}}catch(A){r.value=A}finally{T.value=!1}},F=G(!1),{removeAlert:Q}=ge(),K=async()=>{if(!a.channel||a.channel===void 0)throw new Error("Channel not found");const n=a.channel.id,c=await Q(n,Number(S));if(c){r.value=c;return}C("updateChannel")};return(n,c)=>{const h=Ne,d=De,y=Y,X=Re,ee=me,A=je,R=Ie,M=ue,$=oe,O=He,ae=ke,B=le("tippy");return g(),x(ae,{class:"flex flex-col gap-2",schema:e(k),state:e(i),"validate-on-input-delay":500,onSubmit:W},{default:s(()=>[e(o)?(g(),te(ie,{key:0},[l(d,{label:e(t)("Email"),name:"email",required:"",class:"o_mb-2"},{default:s(()=>[l(h,{modelValue:e(i).email,"onUpdate:modelValue":c[0]||(c[0]=_=>e(i).email=_),modelModifiers:{trim:!0},class:"w-full",size:"lg","data-1p-ignore":"",autocomplete:"off",placeholder:e(t)("emailPlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{name:"highSeverity",class:"o_mb-2"},{label:s(()=>[V("span",Oe,[N(E(e(t)("notificationCriticalErrors"))+" ",1),q(l(y,{name:e(f).icoHelp,class:"size-5"},null,8,["name"]),[[B,{content:e(t)("alerting.tooltips.critical"),theme:("useUiStore"in n?n.useUiStore:e(J))().tippyTheme}]])])]),default:s(()=>[typeof e(i).highSeverity=="string"?(g(),x(X,{key:0,modelValue:e(i).highSeverity,"onUpdate:modelValue":c[1]||(c[1]=_=>e(i).highSeverity=_),portal:!1,"search-input":!1,items:e(U),"label-key":"label","value-key":"value",class:"w-full",ui:{content:"z-20"}},null,8,["modelValue","items"])):H("",!0)]),_:1}),l(d,{name:"lowSeverity",class:"o_mb-2"},{label:s(()=>[V("span",Be,[N(E(e(t)("notificationNonCriticalErrors"))+" ",1),q(l(y,{name:e(f).icoHelp,class:"size-5"},null,8,["name"]),[[B,{content:e(t)("alerting.tooltips.nonCritical"),theme:("useUiStore"in n?n.useUiStore:e(J))().tippyTheme}]])])]),default:s(()=>[typeof e(i).lowSeverity=="string"?(g(),x(X,{key:0,modelValue:e(i).lowSeverity,"onUpdate:modelValue":c[2]||(c[2]=_=>e(i).lowSeverity=_),portal:!1,"search-input":!1,class:"w-full",items:e(U),"label-key":"label","value-key":"value",ui:{content:"z-20"}},null,8,["modelValue","items"])):H("",!0)]),_:1})],64)):(g(),te(ie,{key:1},[l(d,{label:e(t)("notificationName"),name:"name",required:"",class:"o_mb-2"},{default:s(()=>[l(h,{modelValue:e(i).name,"onUpdate:modelValue":c[3]||(c[3]=_=>e(i).name=_),modelModifiers:{trim:!0},class:"w-full",size:"lg","data-1p-ignore":"",autocomplete:"off",placeholder:e(t)("notificationNamePlaceholder")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(d,{label:e(t)("webHookUrl"),class:"o_mb-2",name:"url",required:""},{default:s(()=>[l(h,{modelValue:e(i).url,"onUpdate:modelValue":c[4]||(c[4]=_=>e(i).url=_),modelModifiers:{trim:!0},class:"w-full",size:"lg","data-1p-ignore":"",autocomplete:"off",placeholder:e(t)("webHookUrlPlaceholder")},null,8,["modelValue","placeholder"]),l(ee,{text:n.$t(`plugin.alerting.${e(w)}.webhookHelp`),class:"text-xs o_px-1 pt-0.5 text-uiText-muted"},null,8,["text"])]),_:1},8,["label"]),l(d,{label:e(t)("Notification"),name:"highSeverity"},{default:s(()=>[V("div",qe,[l(A,{modelValue:e(i).highSeverity,"onUpdate:modelValue":c[5]||(c[5]=_=>e(i).highSeverity=_),label:e(t)("responseTimeCriticalError")},null,8,["modelValue","label"]),q(l(y,{name:e(f).icoHelp,class:"size-5"},null,8,["name"]),[[B,{content:e(t)("alerting.tooltips.critical"),theme:("useUiStore"in n?n.useUiStore:e(J))().tippyTheme}]])])]),_:1},8,["label"]),l(d,{name:"highSeverity"},{default:s(()=>[V("div",Le,[l(A,{modelValue:e(i).lowSeverity,"onUpdate:modelValue":c[6]||(c[6]=_=>e(i).lowSeverity=_),label:e(t)("responseTimeNonCriticalError")},null,8,["modelValue","label"]),q(l(y,{name:e(f).icoHelp,class:"size-5"},null,8,["name"]),[[B,{content:e(t)("alerting.tooltips.nonCritical"),theme:("useUiStore"in n?n.useUiStore:e(J))().tippyTheme}]])])]),_:1})],64)),l(d,null,{label:s(()=>[V("div",Ge,[N(E(e(t)("Language"))+" ",1),q(l(y,{name:e(f).icoHelp,class:"size-5"},null,8,["name"]),[[B,{content:e(t)("alertLanguageTooltip")}]])])]),default:s(()=>[l(R,{modelValue:e(i).lang,"onUpdate:modelValue":c[7]||(c[7]=_=>e(i).lang=_),portal:!1,items:e(p),"leading-icon":e(p).find(_=>_.value===e(i).lang)?.icon,class:"w-full font-normal",color:"neutral",variant:"outline",ui:{content:"z-20"}},null,8,["modelValue","items","leading-icon"])]),_:1}),e(r)?(g(),x(M,{key:2,error:e(r),refresh:()=>{},"with-refresh":!1},null,8,["error"])):H("",!0),e(F)?(g(),x(O,{key:4,class:"justify-end o_mt-4",size:"md",onCancel:c[9]||(c[9]=_=>F.value=!1),onAction:K})):(g(),te("div",We,[e(u)?(g(),x($,{key:0,variant:"subtle",icon:e(f).icoTrash,color:"error",disabled:e(T),onClick:c[8]||(c[8]=_=>F.value=!0)},{default:s(()=>[N(E(n.$t("delete")),1)]),_:1},8,["icon","disabled"])):H("",!0),e(u)?H("",!0):(g(),x($,{key:1,type:"submit",disabled:e(T),"data-action":"saveAndClose"},{leading:s(()=>[l(y,{name:e(f).icoSave,class:de(["size-5",[{"animate-spin":e(T)}]])},null,8,["name","class"])]),default:s(()=>[N(" "+E(n.$t("saveAndClose")),1)]),_:1},8,["disabled"])),l($,{type:"submit",disabled:e(T)},{leading:s(()=>[l(y,{name:e(f).icoSave,class:de(["size-5",[{"animate-spin":e(T)}]])},null,8,["name","class"])]),default:s(()=>[N(" "+E(e(u)?n.$t("update"):n.$t("save")),1)]),_:1},8,["disabled"])]))]),_:1},8,["schema","state"])}}}),ye=Object.assign(Je,{__name:"AlertComponentForm"}),Qe=Object.freeze(Object.defineProperty({__proto__:null,default:ye},Symbol.toStringTag,{value:"Module"})),Ye={class:"text-uiText-toned flex items-center font-medium o_gap-1"},Ze=ne({__name:"AlertConfiguration",props:{type:{default:"email"}},emits:["refresh"],setup(v,{emit:P}){const a=v,{t}=Z(),m=L(()=>({email:{title:t("emailSettings"),subtitle:t("emailSettingsSubline"),icon:f.icoEmail,accessKey:"alert.email"},slack:{title:t("plugin.alerting.slack.headline"),subtitle:t("plugin.alerting.slack.subline"),icon:f.icoSlack,accessKey:"alert.slack"},teams:{title:t("plugin.alerting.teams.headline"),subtitle:t("plugin.alerting.teams.subline"),icon:f.icoTeams,accessKey:"alert.teams"}})[a.type]),p=G(!1),b=G(0),u=P;return Ce(()=>{!p.value&&b.value>0&&(u("refresh"),b.value=0)}),(w,o)=>{const k=Y,U=oe,j=me,i=ye,D=fe;return e(m)?(g(),x(D,{key:0,open:e(p),"onUpdate:open":o[2]||(o[2]=C=>ce(p)?p.value=C:null)},{header:s(()=>[V("h3",Ye,[l(k,{name:e(m).icon,class:"size-5"},null,8,["name"]),N(" "+E(e(m).title),1)])]),body:s(()=>[V("div",null,[l(j,{class:"o_mb-6"},{default:s(()=>[N(E(e(m).subtitle),1)]),_:1}),l(i,{type:v.type,onClose:o[0]||(o[0]=C=>p.value=!1),onAddedChannel:o[1]||(o[1]=C=>b.value++)},null,8,["type"])])]),default:s(()=>[l(U,{label:e(m).title,icon:e(m).icon},null,8,["label","icon"])]),_:1},8,["open"])):H("",!0)}}}),Xe=Object.assign(Ze,{__name:"AlertConfiguration"}),et=xe(()=>Ue(()=>Promise.resolve().then(()=>Qe),void 0,import.meta.url).then(v=>v.default||v)),tt={class:"text-uiText-toned flex items-center font-medium o_gap-2"},nt=ne({__name:"EditAlerts",props:{channel:{}},emits:["refresh"],setup(v,{emit:P}){const{t:a}=Z(),t=v,m=L(()=>t.channel.sender||"email"),p=G(!1),b=P,u=L(()=>({email:{title:a("alertSetup.email.title"),subtitle:a("alertSetup.email.subtitle"),icon:f.icoEmail},slack:{title:a("alertSetup.slack.title"),subtitle:a("alertSetup.slack.subtitle"),icon:f.icoSlack},teams:{title:a("alertSetup.teams.title"),subtitle:a("alertSetup.teams.subtitle"),icon:f.icoTeams}})),w=()=>{p.value=!1,b("refresh")};return(o,k)=>{const U=Y,j=oe,i=me,D=et,C=fe,S=le("tippy");return g(),x(C,{open:e(p),"onUpdate:open":k[0]||(k[0]=r=>ce(p)?p.value=r:null)},{header:s(()=>[V("h3",tt,[l(U,{name:e(u)[e(m)]?.icon||"",class:"size-5 text-uiText-muted"},null,8,["name"]),N(" "+E(e(u)[e(m)]?.title||""),1)])]),body:s(()=>[l(i,{class:"o_mb-6"},{default:s(()=>[N(E(e(u)[e(m)]?.subtitle||""),1)]),_:1}),l(D,{"edit-mode":!0,channel:t.channel,onUpdateChannel:w},null,8,["channel"])]),default:s(()=>[l(j,{variant:"subtle",color:"neutral",size:"sm"},{trailing:s(()=>[q(l(U,{name:e(f).icoEdit,class:"size-4"},null,8,["name"]),[[S,{content:e(a)("EditAlertSetting"),theme:("useUiStore"in o?o.useUiStore:e(J))().tippyTheme}]])]),_:1})]),_:1},8,["open"])}}}),at=Object.assign(nt,{__name:"EditAlerts"}),lt={class:"o_p-3 text-sm max-w-[40ch]"},ot={class:"text-uiText-toned font-medium o_mb-2"},it={class:"text-uiText-toned o_mb-2"},st=ne({__name:"DeleteAlertsAction",props:{channel:{}},emits:["refresh"],setup(v,{emit:P}){const{t:a}=Z(),t=v,m=G(!1),p=G(null),{removeAlert:b}=ge(),{pid:u}=re().params;if(!u)throw new Error("Project id not found");const w=P,o=async()=>{const k=await b(t.channel.id,Number(u));if(k){p.value=k;return}w("refresh"),m.value=!1};return(k,U)=>{const j=Y,i=oe,D=ue,C=Fe,S=le("tippy");return g(),x(C,{open:e(m),"onUpdate:open":U[0]||(U[0]=r=>ce(m)?m.value=r:null),arrow:"",content:{align:"end",side:"bottom"}},{content:s(()=>[V("div",lt,[V("h3",ot,E(e(a)("alertSetup.deleteAlert")),1),V("p",it,E(e(a)("alertSetup.deleteAlertDescription")),1),e(p)?(g(),x(D,{key:0,error:e(p),refresh:()=>{},"with-refresh":!1},null,8,["error"])):H("",!0),l(i,{variant:"solid",color:"error",icon:e(f).icoTrash,size:"sm",onClick:o},{default:s(()=>[N(E(e(a)("DeleteAlert")),1)]),_:1},8,["icon"])])]),default:s(()=>[l(i,{variant:"subtle",color:"neutral","active-color":"error",active:e(m),size:"sm"},{trailing:s(()=>[q(l(j,{name:e(f).icoTrash,class:"size-4"},null,8,["name"]),[[S,{content:e(a)("delete"),theme:("useUiStore"in k?k.useUiStore:e(J))().tippyTheme}]])]),_:1},8,["active"])]),_:1},8,["open"])}}}),rt=Object.assign(st,{__name:"DeleteAlertsAction"}),ct={class:"flex gap-2 flex-wrap"},mt={class:"flex gap-2 justify-end"},Ft=ne({__name:"alerts-[pid]-[sid]",setup(v){const{kapi:P}=se(),{addTimeToProcessedData:a,setCachedData:t}=Te(),{pid:m}=re().params;if(!m)throw new Error("Project ID is required");const{data:p,status:b,refresh:u,error:w}=$e(`alert-settings-${m}`,async()=>{const r=await P("AlertingChannel"),T=await P("AlertingPolicy"),[z,W]=await Promise.all([r.list(Number(m)),T.list(Number(m))]);return{channels:z.channels,policies:W.policies}},{transform:r=>{const T=Object.entries(r.channels).map(([z,W])=>{const F={},Q={},K=Object.values(r.policies).filter(n=>n.channels[+z]);if(K){const n=K.map(h=>h.interval),c=K.map(h=>h.id);K.map((h,d)=>h.severities.flat().map(y=>({...y,interval:n[d],id:c[d]}))).flat().forEach(h=>{F[h.name]=h.interval,Q[h.name]=h.id})}return{...W,severities:F,severitiesId:Q}});return a({alerts:T})},getCachedData:(r,T,z)=>{if(!(z.cause==="refresh:manual"||z.cause==="refresh:hook"))return t(r)}}),{t:o}=Z(),k=Y,U={email:f.icoEmail,slack:f.icoSlack,teams:f.icoTeams},j=[{header:()=>"",accessorKey:"sender",meta:{class:{th:"w-[30px]"}},cell:({row:r})=>Pe(Y,{name:U[r.original.sender]})},{accessorKey:"name",header:()=>o("alertName")},{header:()=>o("Language"),meta:{class:{th:"min-w-[100px]"}},accessorKey:"language",cell:({row:r})=>o(`language.${r.original.language}`)},{accessorKey:"severities.high",header:()=>o("criticalErrors"),meta:{class:{th:"min-w-[140px]"}},cell:({row:r})=>r.original.sender==="email"?o(`${r.original.severities.high||"-"}`):o(`${r.original.severities.high||"-"}`)},{accessorKey:"severities.low",header:()=>o("nonCriticalErrors"),meta:{class:{th:"min-w-[160px]"}},cell:({row:r})=>r.original.sender==="email"?o(`${r.original.severities.low||"-"}`):o(`${r.original.severities.low||"-"}`)},{id:"actions",meta:{class:{td:"text-right"}}}],{policyGuard:i}=Ee(),D=[{type:"email",accessKey:"alerting.with.email"},{type:"slack",accessKey:"alerting.with.slack"},{type:"teams",accessKey:"alerting.with.teams"}],C=L(()=>D.filter(r=>i(r.accessKey,{trackingContext:{components:"AlertsPage"}}))),S=J();return(r,T)=>{const z=ze,W=Xe,F=at,Q=rt,K=Ke,n=Me,c=ue,h=le("tippy");return g(),te("div",null,[l(z,{"page-key":"pProjectSettingsAlerts"}),V("div",ct,[(g(!0),te(ie,null,Ve(e(C),d=>(g(),x(W,{key:d.type,type:d.type,onRefresh:e(u)},null,8,["type","onRefresh"]))),128))]),e(p)?.alerts.length?(g(),x(n,{key:0,class:"o_overflow-hidden max-w-screen-2xl o_my-8",variant:"subtle",ui:{header:"border-b-0",body:"border-b-0"}},{default:s(()=>[l(K,{data:e(p).alerts,columns:j,loading:e(b)==="pending","loading-color":"success","loading-animation":"carousel","loading-text":e(o)("loadingAlerts"),empty:e(o)("noAlertsFound")},{"sender-cell":s(({row:d})=>[q(l(e(k),{name:U[d.original.sender],class:"size-5 block text-uiText-muted"},null,8,["name"]),[[h,{content:e(o)("alertSender",{sender:d.original.sender}),theme:e(S).tippyTheme}]])]),"actions-cell":s(({row:d})=>[V("div",mt,[l(F,{channel:d.original,onRefresh:e(u)},null,8,["channel","onRefresh"]),l(Q,{channel:d.original,onRefresh:e(u)},null,8,["channel","onRefresh"])])]),_:1},8,["data","loading","loading-text","empty"])]),_:1})):H("",!0),e(w)?(g(),x(c,{key:1,status:e(b),error:e(w),refresh:e(u)},null,8,["status","error","refresh"])):H("",!0)])}}});export{Ft as default};
Back to Directory File Manager