web-interface.assets.1255d548-8905.ec28249651141b909d18.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["1255d548-8905"],{VPjWgPqM:(U,I,i)=>{i.d(I,{Z:()=>S});var C=i("pmX897Fv"),e=i.n(C),x=i("DjJvgDaP"),s=i.n(x),f=s()(e());f.push([U.id,`.z6LAsSk67C9Z9TP6Sw_Z .panel-title {
font-size: 1rem; /* theme.fonts.size.body */
}
.z6LAsSk67C9Z9TP6Sw_Z .panel-title > a {
cursor: pointer;
display: block;
}
.z6LAsSk67C9Z9TP6Sw_Z .panel-body {
padding: 10px;
}
.z6LAsSk67C9Z9TP6Sw_Z ul {
padding-left: 0;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/common/HelpPanel.css"],names:[],mappings:"AAAA;IACI,eAAe,EAAE,0BAA0B;AAC/C;;AAEA;IACI,eAAe;IACf,cAAc;AAClB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,eAAe;AACnB",sourcesContent:[`:local(.helpPanel) .panel-title {
font-size: 1rem; /* theme.fonts.size.body */
}
:local(.helpPanel) .panel-title > a {
cursor: pointer;
display: block;
}
:local(.helpPanel) .panel-body {
padding: 10px;
}
:local(.helpPanel) ul {
padding-left: 0;
}
`],sourceRoot:""}]),f.locals={helpPanel:"z6LAsSk67C9Z9TP6Sw_Z"};const S=f},FvcXAh9q:(U,I,i)=>{i.d(I,{Z:()=>S});var C=i("pmX897Fv"),e=i.n(C),x=i("DjJvgDaP"),s=i.n(x),f=s()(e());f.push([U.id,`.Rm5RJaCv9xhyX2lY9jI3 {
margin-top: 25px;
height: 34px;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-types/AggregationConditionExpression.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,YAAY;AAChB",sourcesContent:[`:local(.formControlNoLabel) {
margin-top: 25px;
height: 34px;
}
`],sourceRoot:""}]),f.locals={formControlNoLabel:"Rm5RJaCv9xhyX2lY9jI3"};const S=f},"0dxeJt3g":(U,I,i)=>{i.d(I,{Z:()=>S});var C=i("pmX897Fv"),e=i.n(C),x=i("DjJvgDaP"),s=i.n(x),f=s()(e());f.push([U.id,`.wp9nUw71uYu2kck_XycC span:not(:last-child)::after {
content: ', ';
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-types/FilterAggregationSummary.css"],names:[],mappings:"AAAA;IACI,aAAa;AACjB",sourcesContent:[`:local(.streamList) span:not(:last-child)::after {
content: ', ';
}
`],sourceRoot:""}]),f.locals={streamList:"wp9nUw71uYu2kck_XycC"};const S=f},ld8xWljG:(U,I,i)=>{i.d(I,{Z:()=>S});var C=i("pmX897Fv"),e=i.n(C),x=i("DjJvgDaP"),s=i.n(x),f=s()(e());f.push([U.id,`.YV9VLhWAF0dOTkZvWqvg .panel-body {
max-height: 400px;
overflow-y: auto;
padding: 20px 10px;
}
.YV9VLhWAF0dOTkZvWqvg table {
table-layout: fixed;
word-wrap: break-word;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-types/FilterPreview.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,mBAAmB;IACnB,qBAAqB;AACzB",sourcesContent:[`:local(.filterPreview) .panel-body {
max-height: 400px;
overflow-y: auto;
padding: 20px 10px;
}
:local(.filterPreview) table {
table-layout: fixed;
word-wrap: break-word;
}
`],sourceRoot:""}]),f.locals={filterPreview:"YV9VLhWAF0dOTkZvWqvg"};const S=f},xnXzNzZh:(U,I,i)=>{i.d(I,{e:()=>T,Z:()=>v});var C=i("Z7aTuO5B"),e=i("ii0bleBb"),x=i.n(e),s=i("J6y4/h8P"),f=i("uZqmR+ju"),S=i("/GOzvPf6"),H=i("dFpwyWHg"),L=i.n(H),X=i("C2ikvoS0"),_=i.n(X),l=i("1IntWRSu"),Q=i.n(l),Y=i("8nGWeFnd"),de=i.n(Y),te=i("TeAcaicX"),ce=i.n(te),R=i("eE3+5goe"),D=i.n(R),Z=i("VPjWgPqM"),A={};A.styleTagTransform=D(),A.setAttributes=de(),A.insert=Q().bind(null,"head"),A.domAPI=_(),A.insertStyleElement=ce();var ue=L()(Z.Z,A);const p=Z.Z&&Z.Z.locals?Z.Z.locals:void 0,g=(0,s.default)(S.JO)`
margin-right: 9px;
`,m=({condition:O,wrapper:q,children:K})=>O?q(K):K,T=({bsStyle:O,children:q,className:K,collapsible:J,header:me,title:ge,defaultExpanded:ne})=>{const j=C.createElement("h3",null,C.createElement(g,{name:"info-circle"}),ge);return C.createElement(f.Panel,{defaultExpanded:ne,className:`${p.helpPanel} ${K}`,bsStyle:O},C.createElement(f.Panel.Heading,null,C.createElement(f.Panel.Title,{toggle:J},me||j)),C.createElement(m,{condition:J,wrapper:pe=>C.createElement(f.Panel.Collapse,null,pe)},C.createElement(f.Panel.Body,null,q)))};T.propTypes={bsStyle:x().oneOf(["success","warning","danger","info","default","primary"]),children:x().node,className:x().string,collapsible:x().bool,header:x().node,title:x().string,defaultExpanded:x().bool},T.defaultProps={bsStyle:"info",children:void 0,className:"",collapsible:!1,header:void 0,title:"",defaultExpanded:!1};const v=T},"+BJjAwAf":(U,I,i)=>{var C=i("QL8i6bcz"),e=i("Z7aTuO5B"),x=i("ii0bleBb"),s=i.n(x),f=i("/yh+QgO6"),S=i.n(f),H=i("oc9db6Tt"),L=i.n(H),X=i("IW7priiX"),_=i.n(X),l=i("uZqmR+ju"),Q=i("S6FuRS7B"),Y=i("/sQQYQjH"),de=i("Mx+G+HdB"),te=i.n(de),ce=i("+KM7MH1U"),R=i.n(ce),D=i("CHWvwBKE"),Z=i("/coHI+Jz"),A=i("8fnsnG21"),ue=i("0TVxnHwi"),p=i("J1ga+jW6"),g=i("JnTtTRmZ"),m=i.n(g),T=i("oCSEoDew"),v=i.n(T),O=i("u1Q00LVl"),q=i.n(O),K=i("MdYBRjRJ"),J=i("eFxcQyPT"),me=i("jAGDuYSC"),ge=i("53I4yQGE"),ne=i("IA3Ku5lS");const j=(0,ne.ei)("core.FilterPreview",()=>m().createActions({create:{asyncResult:!0},execute:{asyncResult:!0},search:{asyncResult:!0}})),pe=r=>new Promise(t=>{setTimeout(t,r)}),pt=(0,ne.dS)("core.FilterPreview",()=>m().createStore({listenables:[j],sourceUrl:"/views/search",searchJob:void 0,result:void 0,getInitialState(){return this.getState()},propagateChanges(){this.trigger(this.getState())},getState(){return{searchJob:this.searchJob,result:this.result}},resourceUrl({segments:r=[],query:t={}}){const n=new(v())(this.sourceUrl),o=q()(n.segment(),r);return n.segmentCoded(o),n.query(t),K.DC(n.resource())},create(r){const t=r.toBuilder().newId().build(),n=(0,J.ZP)("POST",this.resourceUrl({}),JSON.stringify(t));n.then(o=>(this.searchJob=Z.Z.fromJSON(o),this.result=void 0,this.propagateChanges(),o)),j.create.promise(n)},trackJobStatus(r,t){return new Promise(n=>{r&&r.execution.done?n(new ge.Z(r)):n(pe(250).then(()=>this.jobStatus(r.id)).then(o=>this.trackJobStatus(o,t)))})},run(r,t){return(0,J.ZP)("POST",this.resourceUrl({segments:[r.id,"execute"]}),JSON.stringify(t))},jobStatus(r){return(0,J.ZP)("GET",this.resourceUrl({segments:["status",r]}))},trackJob(r,t){return this.run(r,t).then(n=>this.trackJobStatus(n,r))},execute(r){if(this.executePromise&&this.executePromise.cancel(),this.searchJob)return this.executePromise=this.trackJob(this.searchJob,r).then(t=>(this.result=t,this.executePromise=void 0,this.propagateChanges(),t),()=>me.Z.error("Could not execute search")),j.execute.promise(this.executePromise),this.executePromise;throw new Error("Unable to execute search if no search was created before!")},search(r,t){j.create(r).then(()=>j.execute(t))}}));var Ve=i("iltCXley"),M=i("/GOzvPf6"),ht=i("xnXzNzZh"),ft=i("dFpwyWHg"),Te=i.n(ft),Et=i("C2ikvoS0"),be=i.n(Et),vt=i("1IntWRSu"),De=i.n(vt),yt=i("8nGWeFnd"),Oe=i.n(yt),Ct=i("TeAcaicX"),Fe=i.n(Ct),At=i("eE3+5goe"),Ie=i.n(At),fe=i("ld8xWljG"),re={};re.styleTagTransform=Ie(),re.setAttributes=Oe(),re.insert=De().bind(null,"head"),re.domAPI=be(),re.insertStyleElement=Fe();var bn=Te()(fe.Z,re);const Pt=fe.Z&&fe.Z.locals?fe.Z.locals:void 0;var xt=Object.defineProperty,St=(r,t,n)=>t in r?xt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,Ee=(r,t,n)=>(St(r,typeof t!="symbol"?t+"":t,n),n);class _e extends e.Component{constructor(){super(...arguments),Ee(this,"renderMessages",t=>t.map(({index:n,message:o})=>e.createElement("tr",{key:`${n}-${o._id}`},e.createElement("td",null,o.timestamp),e.createElement("td",null,o.message)))),Ee(this,"renderSearchResult",(t={})=>!t.messages||t.messages.length===0?e.createElement("p",null,"Could not find any messages with the current search criteria."):e.createElement(l.Table,{striped:!0,condensed:!0,bordered:!0},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Timestamp"),e.createElement("th",null,"Message"))),e.createElement("tbody",null,this.renderMessages(t.messages))))}render(){const{isFetchingData:t,searchResult:n,errors:o,displayPreview:a}=this.props,d=t?e.createElement(M.$j,{text:"Loading filter preview..."}):this.renderSearchResult(n);return e.createElement(e.Fragment,null,e.createElement(ht.Z,{collapsible:!0,defaultExpanded:!a,title:"How many Events will Filter & Aggregation create?"},e.createElement("p",null,"The Filter & Aggregation Condition will generate different number of Events, depending on how it is configured:"),e.createElement("ul",null,e.createElement("li",null,e.createElement("b",null,"Filter:"),"\u2003One Event per message matching the filter"),e.createElement("li",null,e.createElement("b",null,"Aggregation without groups:"),"\u2003One Event every time the aggregation result satisfies the condition"),e.createElement("li",null,e.createElement("b",null,"Aggregation with groups:"),"\u2003One Event per group whose aggregation result satisfies the condition"))),a&&e.createElement(l.Panel,{className:Pt.filterPreview,bsStyle:"default"},e.createElement(l.Panel.Heading,null,e.createElement(l.Panel.Title,null,"Filter Preview")),e.createElement(l.Panel.Body,null,o.length>0?e.createElement("p",{className:"text-danger"},o[0].description):d)))}}Ee(_e,"propTypes",{searchResult:s().object,errors:s().array,isFetchingData:s().bool,displayPreview:s().bool}),Ee(_e,"defaultProps",{searchResult:{},errors:[],isFetchingData:!1,displayPreview:!1});const Rt=_e;var Tt=Object.defineProperty,bt=(r,t,n)=>t in r?Tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,ze=(r,t,n)=>(bt(r,typeof t!="symbol"?t+"":t,n),n);const He=(r,t)=>{var n;return!((n=t==null?void 0:t.streams)==null?void 0:n.some(a=>!(0,ue.rq)(r.permissions,`streams:read:${a}`)))};class Xe extends e.Component{constructor(t){super(t),ze(this,"fetchSearch",te()(n=>{var o,a;const{currentUser:d}=this.props;if(!He(d,n))return;const{queryId:u,searchTypeId:c}=this.state,h=((o=n==null?void 0:n.streams)==null?void 0:o.map(E=>({type:"stream",id:E})))||[],y=D.ZP.builder().id(u).query({type:"elasticsearch",query_string:(n==null?void 0:n.query)||"*"}).timerange({type:"relative",range:((n==null?void 0:n.search_within_ms)||0)/1e3}).filter(h.length===0?null:{type:"or",filters:h}).searchTypes([{id:c,type:"messages",limit:10,offset:0}]).build(),B=Z.Z.create().toBuilder().parameters(((a=n==null?void 0:n.query_parameters)==null?void 0:a.filter(E=>!E.embryonic))||[]).queries([y]).build();j.search(B)},250)),this.state={queryId:(0,Ve.Z)(),searchTypeId:(0,Ve.Z)()}}componentDidMount(){const{eventDefinition:t}=this.props;this.fetchSearch(t.config)}componentDidUpdate(t){const{eventDefinition:n}=this.props,{query:o,query_parameters:a,streams:d,search_within_ms:u}=t.eventDefinition.config,{query:c,query_parameters:h,streams:P,search_within_ms:y}=n.config;(c!==o||h!==a||!R()(P,d)||y!==u)&&this.fetchSearch(n.config)}render(){const{eventDefinition:t,filterPreview:n,currentUser:o}=this.props,{queryId:a,searchTypeId:d}=this.state,u=!n.result||!n.result.forId(a);let c,h;return u||(c=n.result.forId(a).searchTypes[d],h=n.result.errors),e.createElement(Rt,{eventDefinition:t,isFetchingData:u,displayPreview:He(o,t.config),searchResult:c,errors:h})}}ze(Xe,"propTypes",{eventDefinition:s().object.isRequired,filterPreview:s().object.isRequired,currentUser:s().object.isRequired});const Dt=(0,A.Z)(Xe,{filterPreview:pt,currentUser:p.D},({currentUser:r,...t})=>({...t,currentUser:r.currentUser}));var Ot=i("WgCNywL/"),Ft=i.n(Ot),Qe=i("4E3oowBb"),It=i("9kZNWwre"),Be=i("nxMFMmDQ"),_t=i("8OvTct/Z"),Bt=i("0t7Ye+61"),Lt=i("v4GbOr/o"),k=i("J6y4/h8P");const ve=()=>({expr:void 0,left:{expr:"number-ref",ref:void 0},right:{expr:"number",value:0}}),Ye=({operator:r="&&",left:t=ve(),right:n=ve()})=>({expr:r,left:t,right:n}),Mt=({operator:r="&&",child:t=ve()})=>({expr:"group",operator:r,child:t}),ye=(r,t)=>{const n={...t};return(t.expr==="&&"||t.expr==="||")&&(n.expr=r,n.left=ye(r,n.left),n.right=ye(r,n.right)),n};var Ut=i("yA/mTvIZ"),Le=i.n(Ut);const Ce=(r,t=[])=>r.message?Le()(t,[r.message]):r.left?Le()(t,Ce(r.left),Ce(r.right)):r.child?Le()(t,Ce(r.child)):t,Ae=(r,t,n={})=>{switch(r.expr){case"number":return Number.isFinite(r.value)?{}:{message:"Threshold must be a valid number"};case"number-ref":const o={message:"Function must be set"};if(!r.ref)return o;const a=t.find(d=>d.id===r.ref);return(a==null?void 0:a.type)==="percentage"&&(a==null?void 0:a.strategy)==="SUM"&&!(a!=null&&a.field)?{message:"Field must be set"}:((a==null?void 0:a.type)==="percentile"||(a==null?void 0:a.type)==="max"||(a==null?void 0:a.type)==="card")&&!(a!=null&&a.field)?{message:"Field must be set"}:a!=null&&a.type?{}:o;case"&&":case"||":case"<":case"<=":case">":case">=":case"==":return{left:Ae(r.left,t,n),right:Ae(r.right,t,n)};case"group":return{child:Ae(r.child,t,n)};default:return{message:"Condition must be set"}}},qe=(r,t)=>{const n={};return r?(n.validationTree=Ae(r,t),n.errors=Ce(n.validationTree),n.isValid=n.errors.length===0,n):(n.isValid=!0,n)},ie=s().shape({expr:s().string,left:s().object,right:s().object}),Zt=s().shape({expr:s().string,value:s().oneOfType([s().number,s().string])}),jt=s().shape({expr:s().string,ref:s().string}),Me=({expression:r,onChange:t,renderLabel:n,validation:o})=>{const a=d=>{const u=_()(r);u.value=d.target.value===""?"":Q.n6(d.target),t({conditions:u})};return e.createElement(l.Col,{md:3},e.createElement(l.Input,{id:"aggregation-threshold",name:"threshold",label:n?"Threshold":"",type:"number",value:S()(r,"value"),bsStyle:o.message?"error":null,help:o.message,onChange:a}))};Me.propTypes={expression:Zt.isRequired,onChange:s().func.isRequired,renderLabel:s().bool.isRequired,validation:s().object},Me.defaultProps={validation:{}};const Nt=Me,Wt=r=>r.sort(Qe.S).map(t=>({label:`${t.toLowerCase()}()`,value:t})),Gt=r=>{var t;return`${r.type}-${(t=r.field)!=null?t:""}`},Ue=({aggregationFunctions:r,formattedFields:t,eventDefinition:n,expression:o,onChange:a,renderLabel:d,validation:u})=>{var c,h;const P=(0,e.useCallback)(b=>{var G,$;return($=(G=n==null?void 0:n.config)==null?void 0:G.series)==null?void 0:$.find(le=>le.id===b)},[(c=n==null?void 0:n.config)==null?void 0:c.series]),y=(0,e.useCallback)(()=>({id:o.ref}),[o.ref]),B=(0,e.useCallback)(b=>P(b)||y(),[y,P]),E=(0,e.useCallback)((b,G)=>{var $;const le=_()(($=n==null?void 0:n.config)==null?void 0:$.series),z=_()(B(o.ref));G!==void 0&&(z[b]=G),b==="type"&&G!=="percentage"&&delete z.strategy,b==="type"&&G!=="percentage"&&delete z.percentile;const ut=Gt(z);z.id=ut;const mt=le.findIndex(Tn=>Tn.id===z.id);mt>=0?le[mt]=z:le.push(z);const gt=_()(o);gt.ref=ut,a({series:le,conditions:gt})},[(h=n==null?void 0:n.config)==null?void 0:h.series,o,B,a]),F=(0,e.useCallback)(b=>{E("type",b)},[E]),Re=(0,e.useCallback)(b=>{E("field",b)},[E]),W=P(o.ref)||{},ee=["percentage","percentile"].includes(W.type)?3:2;return e.createElement(l.Col,{md:6},e.createElement(l.FormGroup,{controlId:"aggregation-function",validationState:u.message?"error":null},d&&e.createElement(l.ControlLabel,null,"If"),e.createElement(l.Row,{className:"row-sm"},e.createElement(l.Col,{md:12/ee},e.createElement(M.Ph,{className:"aggregation-function",matchProp:"label",placeholder:"Select Function",onChange:F,options:Wt(r),clearable:!1,value:W.type})),W.type==="percentage"&&e.createElement(l.Col,{md:12/ee},e.createElement(M.Ph,{className:"aggregation-function-strategy",matchProp:"label",placeholder:"Select Strategy (Optional)",onChange:b=>E("strategy",b),options:Be.tY,value:W.strategy})),e.createElement(l.Col,{md:12/ee},e.createElement(M.Ph,{className:"aggregation-function-field",ignoreAccents:!1,matchProp:"label",placeholder:"Select Field (Optional)",onChange:Re,options:t,value:W.field,allowCreate:!0})),W.type==="percentile"&&e.createElement(l.Col,{md:12/ee},e.createElement(M.Ph,{className:"aggregation-function-percentile",placeholder:"Select Percentile",onChange:b=>E("percentile",b),options:Be.YN,value:W.percentile}))),u.message&&e.createElement(l.HelpBlock,null,u.message)))};Ue.propTypes={aggregationFunctions:s().array.isRequired,eventDefinition:s().object.isRequired,expression:jt.isRequired,formattedFields:s().array.isRequired,onChange:s().func.isRequired,renderLabel:s().bool.isRequired,validation:s().object},Ue.defaultProps={validation:{}};const Kt=Ue,wt=k.default.div(({theme:r})=>(0,k.css)`
margin-bottom: 15px;
font-size: ${r.fonts.size.body};
`),$t=(0,k.default)(({isFirstElement:r,...t})=>e.createElement(l.FormGroup,{...t}))`
width: 100px;
margin-left: ${r=>r.isFirstElement?"":"1em"};
margin-right: 1em;
`,Ze=({initialText:r,operator:t,onOperatorChange:n})=>e.createElement(l.Col,{md:12},e.createElement(wt,{className:"form-inline"},r&&e.createElement(l.FormGroup,null,e.createElement(l.FormControl.Static,null,r," ")),e.createElement($t,{isFirstElement:!r},e.createElement(M.Ph,{className:"boolean-operator",matchProp:"label",size:"small",onChange:n,options:[{label:"all",value:"&&"},{label:"any",value:"||"}],value:t,clearable:!1})),e.createElement(l.FormGroup,null,e.createElement(l.FormControl.Static,null," of the following rules:"))));Ze.propTypes={initialText:s().string,operator:s().string.isRequired,onOperatorChange:s().func.isRequired},Ze.defaultProps={initialText:""};const ke=Ze,je=r=>{const{expression:t,level:n,onChildChange:o,validation:a}=r;return e.createElement(e.Fragment,null,e.createElement(oe,{...r,expression:t.left,validation:a.left,parent:t,onChange:o("left"),level:n+1}),e.createElement(l.Clearfix,null),e.createElement(oe,{...r,expression:t.right,validation:a.right,parent:t,onChange:o("right"),level:n+1,renderLabel:!1}))};je.propTypes={expression:ie.isRequired,parent:ie,level:s().number.isRequired,onChange:s().func.isRequired,onChildChange:s().func.isRequired,validation:s().object},je.defaultProps={parent:void 0,validation:{}};const Jt=je,Ne=r=>{const{expression:t,level:n,onChildChange:o,onChange:a,renderLabel:d,validation:u}=r,c=h=>{const P=_()(t);P.expr=h,a({conditions:P})};return e.createElement(l.Col,{md:10},e.createElement(l.Row,{className:"row-sm"},e.createElement(oe,{...r,expression:t.left,validation:u.left,parent:t,onChange:o("left"),level:n+1}),e.createElement(l.Col,{md:3},e.createElement(l.FormGroup,{controlId:"aggregation-condition",validationState:u.message?"error":null},d&&e.createElement(l.ControlLabel,null,"Is"),e.createElement(M.Ph,{id:"aggregation-condition",matchProp:"label",placeholder:"Select Condition",onChange:c,options:[{label:"<",value:"<"},{label:"<=",value:"<="},{label:">",value:">"},{label:">=",value:">="},{label:"=",value:"=="}],value:t.expr,clearable:!1}),u.message&&e.createElement(l.HelpBlock,null,u.message))),e.createElement(oe,{...r,expression:t.right,validation:u.right,parent:t,onChange:o("right"),level:n+1})))};Ne.propTypes={expression:ie.isRequired,level:s().number.isRequired,onChange:s().func.isRequired,onChildChange:s().func.isRequired,renderLabel:s().bool.isRequired,validation:s().object},Ne.defaultProps={validation:{}};const Vt=Ne,zt=k.default.div`
padding-left: 40px;
`,We=r=>{const{expression:t,level:n,onChange:o,onChildChange:a,validation:d}=r,u=c=>{const h=_()(t);h.operator=c,h.child=ye(c,h.child),o({conditions:h})};return e.createElement(e.Fragment,null,e.createElement(ke,{operator:t.operator,onOperatorChange:u}),e.createElement(l.Clearfix,null),e.createElement(zt,null,e.createElement(oe,{...r,expression:t.child,validation:d.child,parent:t,onChange:a("child"),level:n+1})))};We.propTypes={expression:ie.isRequired,level:s().number.isRequired,onChange:s().func.isRequired,onChildChange:s().func.isRequired,validation:s().object},We.defaultProps={validation:{}};const Ht=We;var Pe=i("FvcXAh9q"),se={};se.styleTagTransform=Ie(),se.setAttributes=Oe(),se.insert=De().bind(null,"head"),se.domAPI=be(),se.insertStyleElement=Fe();var On=Te()(Pe.Z,se);const Xt=Pe.Z&&Pe.Z.locals?Pe.Z.locals:void 0;var Qt=Object.defineProperty,Yt=(r,t,n)=>t in r?Qt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,N=(r,t,n)=>(Yt(r,typeof t!="symbol"?t+"":t,n),n);class Ge extends e.Component{constructor(){super(...arguments),N(this,"state",{globalGroupOperator:void 0}),N(this,"getEffectiveGlobalGroupOperator",()=>{const{globalGroupOperator:t}=this.state;if(t)return t;const{expression:n}=this.props;return n.expr==="&&"||n.expr==="||"?n.expr:"&&"}),N(this,"getBooleanOperator",(t,n)=>{if(!t)return n;const o=t.expr==="group"?"operator":"expr";return S()(t,o,n)==="&&"?"&&":"||"}),N(this,"handleAddExpression",()=>{const{expression:t,onChange:n,parent:o}=this.props,a=this.getEffectiveGlobalGroupOperator(),d=this.getBooleanOperator(o,a),u=Ye({operator:d,left:t});n({conditions:u})}),N(this,"handleAddGroup",()=>{const{expression:t,onChange:n,parent:o}=this.props,a=this.getEffectiveGlobalGroupOperator(),d=this.getBooleanOperator(o,a),c=Mt({operator:d==="&&"?"||":"&&"}),h=Ye({operator:d,left:t,right:c});n({conditions:h})}),N(this,"handleDeleteExpression",()=>{const{onChange:t}=this.props;t({conditions:null})}),N(this,"handleChildChange",t=>n=>{const{expression:o,onChange:a}=this.props;if(!Object.keys(n).includes("conditions")){a(n);return}const d=n.conditions;let u;if(d===null)t==="child"?u=null:u=o[t==="left"?"right":"left"];else if(t==="child"&&d.expr==="group")u=d;else{const c=_()(o);c[t]=d,u=c}a({...n,conditions:u})}),N(this,"handleOperatorChange",t=>{const{expression:n,onChange:o}=this.props;this.setState({globalGroupOperator:t});const a=ye(t,n);o({conditions:a})})}render(){const{expression:t,parent:n,renderLabel:o}=this.props;let a;switch(t.expr){case"number-ref":a=e.createElement(Kt,{...this.props,parent:n});break;case"number":a=e.createElement(Nt,{...this.props,parent:n});break;case"group":a=e.createElement(Ht,{...this.props,onChildChange:this.handleChildChange,parent:n});break;case"&&":case"||":a=e.createElement(Jt,{...this.props,onChildChange:this.handleChildChange,parent:n});break;case"<":case"<=":case">":case">=":case"==":default:a=e.createElement(e.Fragment,null,e.createElement(Vt,{...this.props,onChildChange:this.handleChildChange,parent:n}),e.createElement(l.Col,{md:2},e.createElement(l.FormGroup,null,e.createElement("div",{className:o?Xt.formControlNoLabel:void 0},e.createElement(l.ButtonToolbar,null,e.createElement(l.Button,{bsSize:"sm",onClick:this.handleDeleteExpression},e.createElement(M.JO,{name:"minus",fixedWidth:!0})),e.createElement(l.Button,{bsSize:"sm",onClick:this.handleAddExpression},e.createElement(M.JO,{name:"plus",fixedWidth:!0})),e.createElement(l.Button,{bsSize:"sm",onClick:this.handleAddGroup},"Add Group"))))))}return!n&&t.expr!=="group"?e.createElement(e.Fragment,null,e.createElement(ke,{initialText:"Messages must meet",operator:this.getEffectiveGlobalGroupOperator(),onOperatorChange:this.handleOperatorChange}),e.createElement(l.Clearfix,null),a):a}}N(Ge,"propTypes",{eventDefinition:s().object.isRequired,validation:s().object,formattedFields:s().array.isRequired,aggregationFunctions:s().array.isRequired,onChange:s().func.isRequired,expression:ie.isRequired,parent:ie,level:s().number,renderLabel:s().bool}),N(Ge,"defaultProps",{level:0,parent:void 0,renderLabel:!0,validation:{}});const oe=Ge,V=({expression:r,series:t})=>{if(!r)return"No condition configured";switch(r.expr){case"number":return r.value;case"number-ref":const n=t.find(o=>o.id===r.ref);return n&&n.type?e.createElement("var",null,n.type,"(",n.strategy?`${n.strategy}, `:null,n.field,n.percentile?`, ${n.percentile}`:null,")"):e.createElement("span",null,"No series selected");case"&&":case"||":return e.createElement(e.Fragment,null,e.createElement(V,{expression:r.left,series:t})," ",e.createElement("strong",{className:"text-info"},r.expr==="&&"?"AND":"OR")," ",e.createElement(V,{expression:r.right,series:t}));case"group":return e.createElement("span",null,"[",e.createElement(V,{expression:r.child,series:t}),"]");case"<":case"<=":case">":case">=":case"==":return e.createElement(e.Fragment,null,e.createElement(V,{expression:r.left,series:t})," ",e.createElement("strong",{className:"text-primary"},r.expr," "),e.createElement(V,{expression:r.right,series:t}));default:return"No condition configured"}};V.propTypes={expression:s().object,series:s().array.isRequired},V.defaultProps={expression:null};const et=({conditions:r,series:t})=>e.createElement(V,{expression:r==null?void 0:r.expression,series:t});et.propTypes={conditions:s().object.isRequired,series:s().array.isRequired};const tt=et,qt=(0,k.default)(l.Panel)`
margin-top: 10px;
`,kt=(0,k.default)(l.Button)`
margin-left: 15px;
vertical-align: baseline;
`,Ke=r=>{const{conditions:t,series:n,expressionValidation:o,showInlineValidation:a,toggleShowValidation:d}=r;return e.createElement("div",null,e.createElement(qt,{header:"Condition summary"},o.isValid?e.createElement("p",{className:"text-success"},e.createElement(M.JO,{name:"check-square"}),"\xA0Condition is valid"):e.createElement("p",{className:"text-danger"},e.createElement(M.JO,{name:"exclamation-triangle"}),"\xA0Condition is not valid",e.createElement(kt,{bsSize:"xsmall",onClick:d},a?"Hide errors":"Show errors")),e.createElement("b",null,"Preview:")," ",e.createElement(tt,{series:n,conditions:t})))};Ke.propTypes={conditions:s().object.isRequired,series:s().array.isRequired,expressionValidation:s().object,showInlineValidation:s().bool,toggleShowValidation:s().func.isRequired},Ke.defaultProps={expressionValidation:{isValid:!0},showInlineValidation:!1};const en=Ke;var nt=i("9O66OgQd"),tn=Object.defineProperty,nn=(r,t,n)=>t in r?tn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,we=(r,t,n)=>(nn(r,typeof t!="symbol"?t+"":t,n),n);const rn=ve(),xe=(r,t=[])=>(r.expr==="number-ref"&&t.push(r.ref),r.left&&r.right?xe(r.left).concat(xe(r.right)):r.child?xe(r.child):t),sn=(0,k.default)(l.Alert)`
margin-bottom: 10px !important;
`;class rt extends e.Component{constructor(t){super(t),we(this,"toggleShowInlineValidation",()=>{const{showInlineValidation:n}=this.state;this.setState({showInlineValidation:!n})}),we(this,"handleChange",n=>{var o,a;const{eventDefinition:d,onChange:u}=this.props;if(!Object.keys(n).includes("conditions")){u(n);return}const c=n.conditions;let h;if(c){const P=xe(c);h=((a=n.series||((o=d==null?void 0:d.config)==null?void 0:o.series))==null?void 0:a.filter(y=>P.includes(y.id)))||[]}else h=[];u({...n,conditions:{expression:c},series:h})}),this.state={showInlineValidation:!1}}render(){var t,n,o,a,d;const{showInlineValidation:u}=this.state,{eventDefinition:c,validation:h}=this.props,P=((n=(t=c==null?void 0:c.config)==null?void 0:t.conditions)==null?void 0:n.expression)||rn,y=qe(P,((o=c==null?void 0:c.config)==null?void 0:o.series)||[]);return e.createElement(e.Fragment,null,e.createElement("h3",{className:nt.Z.title},"Create Events for Definition"),h.errors.conditions&&e.createElement(sn,{bsStyle:"danger",title:"Errors found"},e.createElement("p",null,S()(h,"errors.conditions[0]"))),e.createElement(l.Row,null,e.createElement(oe,{expression:P,...this.props,validation:u?y.validationTree:{},onChange:this.handleChange})),e.createElement(en,{conditions:((a=c==null?void 0:c.config)==null?void 0:a.conditions)||{},series:((d=c==null?void 0:c.config)==null?void 0:d.series)||[],expressionValidation:y,showInlineValidation:u,toggleShowValidation:this.toggleShowInlineValidation}))}}we(rt,"propTypes",{eventDefinition:s().object.isRequired,validation:s().object.isRequired,formattedFields:s().array.isRequired,aggregationFunctions:s().array.isRequired,onChange:s().func.isRequired});const on=rt,it=({aggregationFunctions:r,eventDefinition:t,validation:n,onChange:o})=>{var a,d;const{data:u}=(0,It.Z)((d=(a=t==null?void 0:t.config)==null?void 0:a.streams)!=null?d:[],Be.w_),c=(0,e.useMemo)(()=>(u!=null?u:[]).sort((E,F)=>(0,Qe.S)(E.name,F.name)).map(E=>({label:`${E.name} \u2013 ${E.value.type.type}`,value:E.name})),[u]),{pathname:h}=(0,Bt.Z)(),P=(0,_t.Z)(),y=(0,e.useCallback)(E=>{const F={...t.config,...E};o("config",F)},[t.config,o]),B=(0,e.useCallback)(E=>{const F=E===""?[]:E.split(",");P(Lt.A.EVENTDEFINITION_CONDITION.AGGREGATION_GROUP_BY_FIELD_SELECTED,{app_pathname:(0,K.av)(h),app_section:"event-definition-condition",app_action_value:"group-by-field-select",selection_count:F.length}),y({group_by:F})},[h,y,P]);return e.createElement("fieldset",null,e.createElement("h2",{className:nt.Z.title},"Aggregation"),e.createElement("p",null,"Summarize log messages matching the Filter defined above by using a function. You can optionally group the Filter results by identical field values."),e.createElement(l.Row,null,e.createElement(l.Col,{lg:7},e.createElement(l.FormGroup,{controlId:"group-by"},e.createElement(l.ControlLabel,null,"Group by Field(s) ",e.createElement("small",{className:"text-muted"},"(Optional)")),e.createElement(M.NU,{id:"group-by",matchProp:"label",onChange:B,options:c,ignoreAccents:!1,value:Ft()(t.config.group_by,[]).join(","),allowCreate:!0}),e.createElement(l.HelpBlock,null,"Select Fields that Graylog should use to group Filter results when they have identical values."," ",e.createElement("b",null,"Example:"),e.createElement("br",null),"Assuming you created a Filter with all failed log-in attempts in your network, Graylog could alert you when there are more than 5 failed log-in attempts overall. Now, add ",e.createElement("code",null,"username")," as Group by Field and Graylog will alert you ",e.createElement("em",null,"for each ",e.createElement("code",null,"username"))," with more than 5 failed log-in attempts.")))),e.createElement("hr",null),e.createElement(on,{eventDefinition:t,validation:n,formattedFields:c,aggregationFunctions:r,onChange:y}))};it.propTypes={eventDefinition:s().object.isRequired,validation:s().object.isRequired,aggregationFunctions:s().array.isRequired,onChange:s().func.isRequired};const an=it;var ln=Object.defineProperty,dn=(r,t,n)=>t in r?ln(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,he=(r,t,n)=>(dn(r,typeof t!="symbol"?t+"":t,n),n);const w={AGGREGATION:0,FILTER:1},cn={query:"",query_parameters:[],streams:[],search_within_ms:5*60*1e3,execute_every_ms:5*60*1e3,_is_scheduled:!0,event_limit:100},$e={group_by:[],series:[],conditions:{}};class Je extends e.Component{constructor(t){super(t),he(this,"handleConfigChange",c=>{const h=_()(this.props.eventDefinition.config);h[c.target.name]=Q.n6(c.target),this.propagateConfigChange(h)}),he(this,"propagateConfigChange",c=>{this.props.onChange("config",c)}),he(this,"handleTypeChange",c=>{const h={},P=Number(Q.n6(c.target));if(h[c.target.name]=P,P===w.FILTER){const{eventDefinition:y}=this.props,B={};Object.keys($e).forEach(F=>{B[F]=y.config[F]}),h.existingAggregationConfig=B;const E={...y.config,...$e};this.propagateConfigChange(E)}else{const{existingAggregationConfig:y}=this.state;if(y){const{eventDefinition:B}=this.props,E={...B.config,...y};this.propagateConfigChange(E),h.existingAggregationConfig=void 0}}this.setState(h)});const{group_by:n,series:o,conditions:a}=t.eventDefinition.config,d=S()(a,"expression",{}),u=L()(n)&&L()(o)&&L()(d)?w.FILTER:w.AGGREGATION;this.state={conditionType:u}}render(){const{conditionType:t}=this.state,{entityTypes:n,eventDefinition:o,streams:a,validation:d,currentUser:u}=this.props;return e.createElement(e.Fragment,null,e.createElement(l.Row,null,e.createElement(l.Col,{md:7,lg:6},e.createElement(Y.Z,{eventDefinition:o,validation:d,streams:a.filter(c=>c.is_editable),currentUser:u,onChange:this.props.onChange}),e.createElement(l.FormGroup,null,e.createElement(l.ControlLabel,null,"Create Events for Definition if..."),e.createElement(l.Radio,{id:"filter-type",name:"conditionType",value:w.FILTER,checked:t===w.FILTER,onChange:this.handleTypeChange},"Filter has results"),e.createElement(l.Radio,{id:"aggregation-type",name:"conditionType",value:w.AGGREGATION,checked:t===w.AGGREGATION,onChange:this.handleTypeChange},"Aggregation of results reaches a threshold")),t===w.FILTER&&e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement(l.Input,{id:"event-limit",name:"event_limit",label:"Event Limit",type:"number",bsStyle:d.errors.event_limit?"error":null,help:S()(d,"errors.event_limit","Maximum number of events to be created."),value:o.config.event_limit,onChange:this.handleConfigChange,required:!0})))),e.createElement(l.Col,{md:5,lgOffset:1},e.createElement(Dt,{eventDefinition:o}))),t===w.AGGREGATION&&e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement(an,{eventDefinition:o,validation:d,aggregationFunctions:n.aggregation_functions,onChange:this.props.onChange}))))}}he(Je,"propTypes",{eventDefinition:s().object.isRequired,validation:s().object.isRequired,entityTypes:s().object.isRequired,streams:s().array.isRequired,onChange:s().func.isRequired,currentUser:s().object.isRequired}),he(Je,"defaultConfig",{...cn,...$e});const st=Je;var un=i("pUKP3+Pg");function ot(r,t=[]){const n=r.displayName||r.name||"Component";class o extends e.Component{constructor(d){super(d),this.state={streams:void 0}}componentDidMount(){un.sH.load(d=>{let u=d.filter(c=>c.is_editable);t.length!==0&&(u=d.filter(c=>!t.includes(c.id))),this.setState({streams:u})})}render(){const{streams:d}=this.state;return d?e.createElement(r,{streams:d,...this.props}):e.createElement(M.$j,{text:"Loading Streams Information..."})}}return o.displayName=`withStreams(${n})`,o}const at=r=>e.createElement(st,{...r});at.propTypes={action:s().oneOf(["create","edit"]).isRequired,validation:s().object.isRequired,eventDefinition:s().object.isRequired,onChange:s().func.isRequired,currentUser:s().object.isRequired};const mn=ot(at);var gn=i("Dg7SLLbb"),pn=i.n(gn),hn=i("ty2gyrHp"),lt=i("ATOIS62c"),fn=i("1/PeS1Oa"),En=i("d4kzUuQm"),Se=i("0dxeJt3g"),ae={};ae.styleTagTransform=Ie(),ae.setAttributes=Oe(),ae.insert=De().bind(null,"head"),ae.domAPI=be(),ae.insertStyleElement=Fe();var Fn=Te()(Se.Z,ae);const vn=Se.Z&&Se.Z.locals?Se.Z.locals:void 0;var yn=i("dlIR0k67"),Cn=Object.defineProperty,An=(r,t,n)=>t in r?Cn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,dt=(r,t,n)=>(An(r,typeof t!="symbol"?t+"":t,n),n);const Pn=r=>typeof r=="string"?e.createElement("span",{key:r},e.createElement("em",null,r)):e.createElement("span",{key:r.id},e.createElement(hn.r,{to:En.ZP.stream_search(r.id)},r.title)),xn=r=>{const{group_by:t,series:n,conditions:o}=r;return L()(t)&&(!o||L()(o)||o.expression===null)&&L()(n)?"filter":"aggregation"},Sn=r=>{if(r.some(t=>t.embryonic)){const t=r.filter(n=>n.embryonic).map(n=>n.name).join(", ");return e.createElement(l.Alert,{bsStyle:"danger"},"There are undeclared query parameters: ",t)}return e.createElement("dd",null,r.map(t=>t.name).join(", "))};class ct extends e.Component{constructor(){super(...arguments),dt(this,"renderStreams",(t,n)=>{const{streams:o}=this.props;if((!t||t.length===0)&&n.length<=0)return"No Streams selected, searches in all Streams";const a=n.length>0?e.createElement(l.Alert,{bsStyle:"warning"},"Missing Stream Permissions for:",e.createElement("br",null),n.join(", ")):null,d=t.map(u=>o.find(c=>c.id===u)||u).sort((u,c)=>(0,fn.Q)(u.title||u,c.title||c)).map(Pn);return e.createElement(e.Fragment,null,a,d)})}render(){const{config:t,currentUser:n}=this.props,{query:o,query_parameters:a,streams:d,search_within_ms:u,execute_every_ms:c,_is_scheduled:h,event_limit:P,group_by:y,series:B,conditions:E}=t,F=xn(t),Re=(0,lt.l)(u,Y.L),W=(0,lt.l)(c,Y.L),ee=d==null?void 0:d.filter($=>(0,ue.rq)(n.permissions,`streams:read:${$}`)),b=d==null?void 0:d.filter($=>!ee.includes($)),G=qe(E.expression,B);return e.createElement("dl",null,e.createElement("dt",null,"Type"),e.createElement("dd",null,pn()(F)),e.createElement("dt",null,"Search Query"),e.createElement("dd",null,o||"*"),a.length>0&&Sn(a),e.createElement("dt",null,"Streams"),e.createElement("dd",{className:vn.streamList},this.renderStreams(ee,b)),e.createElement("dt",null,"Search within"),e.createElement("dd",null,Re.duration," ",Re.unit.toLowerCase()),e.createElement("dt",null,"Execute search every"),e.createElement("dd",null,W.duration," ",W.unit.toLowerCase()),e.createElement("dt",null,"Enable scheduling"),e.createElement("dd",null,h?"yes":"no"),F==="filter"&&e.createElement(e.Fragment,null,e.createElement("dt",null,"Event limit"),e.createElement("dd",null,P)),F==="aggregation"&&e.createElement(e.Fragment,null,e.createElement("dt",null,"Group by Field(s)"),e.createElement("dd",null,y&&y.length>0?y.join(", "):"No Group by configured"),e.createElement("dt",null,"Create Events if"),e.createElement("dd",null,G.isValid?e.createElement(tt,{series:B,conditions:E}):e.createElement(l.Alert,{bsSize:"small",bsStyle:"danger"},"Condition is not valid: ",G.errors.join(", ")))),e.createElement("dt",null,"Actions"),e.createElement("dd",null,e.createElement(yn.Z,null)))}}dt(ct,"propTypes",{config:s().object.isRequired,currentUser:s().object.isRequired,streams:s().array.isRequired});const Rn=ot(ct);C.G.register(new C.h({},{eventDefinitionTypes:[{type:"aggregation-v1",displayName:"Filter & Aggregation",sortOrder:0,description:"Create Events from log messages by filtering them and (optionally) aggregating their results to match a given condition. These Events can be used as input for a Correlation Rule.",formComponent:mn,summaryComponent:Rn,defaultConfig:st.defaultConfig}]}))},dlIR0k67:(U,I,i)=>{i.d(I,{Z:()=>S});var C=i("Z7aTuO5B"),e=i("d4kzUuQm"),x=i("hfAjrXHN"),s=i("6dLKCZdN");const f=({isEvent:H,id:L})=>{const{definitionId:X}=(0,s.Z)(),_=H?e.ZP.ALERTS.replay_search(L):e.ZP.ALERTS.DEFINITIONS.replay_search(L||X);return C.createElement(x.a,{searchLink:_},"Replay search")};f.defaultProps={id:void 0,isEvent:!1};const S=f},cd5HAK44:(U,I,i)=>{i.d(I,{B:()=>ue,y:()=>A});var C=i("JnTtTRmZ"),e=i.n(C),x=i("oCSEoDew"),s=i.n(x),f=i("IW7priiX"),S=i.n(f),H=i("u1Q00LVl"),L=i.n(H),X=i("WgCNywL/"),_=i.n(X),l=i("LF8A/8I5"),Q=i.n(l),Y=i("RjO1iR6D"),de=i.n(Y),te=i("MdYBRjRJ"),ce=i("gyRmhZSW"),R=i("jAGDuYSC"),D=i("eFxcQyPT"),Z=i("IA3Ku5lS");const A=(0,Z.ei)("core.EventDefinitions",()=>e().createActions({listAll:{asyncResult:!0},listPaginated:{asyncResult:!0},searchPaginated:{asyncResult:!0},get:{asyncResult:!0},create:{asyncResult:!0},copy:{asyncResult:!0},update:{asyncResult:!0},delete:{asyncResult:!0},enable:{asyncResult:!0},disable:{asyncResult:!0},clearNotificationQueue:{asyncResult:!0}})),ue=(0,Z.dS)("core.EventDefinitions",()=>e().createStore({listenables:[A],sourceUrl:"/events/definitions",all:void 0,eventDefinitions:void 0,context:void 0,query:void 0,pagination:{count:void 0,page:void 0,pageSize:void 0,total:void 0,grandTotal:void 0},getInitialState(){return this.getState()},propagateChanges(){this.trigger(this.getState())},getState(){return{all:this.all,eventDefinitions:this.eventDefinitions,context:this.context,query:this.query,pagination:this.pagination}},eventDefinitionsUrl({segments:p=[],query:g={}}){const m=new(s())(this.sourceUrl),T=L()(m.segment(),p);return m.segmentCoded(T),m.query(g),te.DC(m.resource())},refresh(){this.all&&this.listAll(),this.pagination.page&&this.listPaginated({query:this.query,page:this.pagination.page,pageSize:this.pagination.pageSize})},listAll(){const p=(0,D.ZP)("GET",this.eventDefinitionsUrl({query:{per_page:0}}));p.then(g=>(this.all=g.event_definitions,this.context=g.context,this.propagateChanges(),g)),A.listAll.promise(p)},listPaginated({query:p="",page:g=1,pageSize:m=10}){const T=(0,D.ZP)("GET",this.eventDefinitionsUrl({query:{query:p,page:g,per_page:m}}));T.then(v=>(this.eventDefinitions=v.event_definitions,this.context=v.context,this.query=v.query,this.pagination={count:v.count,page:v.page,pageSize:v.per_page,total:v.total,grandTotal:v.grand_total},this.propagateChanges(),v)).catch(v=>{R.Z.error(`Fetching event definitions failed with status: ${v}`,"Could not retrieve event definitions")}),A.listPaginated.promise(T)},searchPaginated(p,g,m,T){const v=(0,ce.Z)(`${this.sourceUrl}/paginated`,p,g,m,T),O=(0,D.ZP)("GET",te.DC(v)).then(q=>{const{elements:K,query:J,attributes:me,pagination:{count:ge,total:ne,page:j,per_page:pe}}=q;return{elements:K,attributes:me,pagination:{count:ge,total:ne,page:j,perPage:pe,query:J}}});return A.searchPaginated.promise(O),O},get(p){const g=(0,D.ZP)("GET",this.eventDefinitionsUrl({segments:[p,"with-context"]}));g.catch(m=>{m.status===404&&R.Z.error(`Unable to find Event Definition with id <${p}>, please ensure it wasn't deleted.`,"Could not retrieve Event Definition")}),A.get.promise(g)},setAlertFlag(p){const g=p.notifications.length>0;return{...p,alert:g}},extractSchedulerInfo(p){const g=S()(p),{_is_scheduled:m}=Q()(g.config,["_is_scheduled"]);return g.config=de()(g.config,["_is_scheduled"]),{eventDefinition:g,isScheduled:_()(m,!0)}},create(p){const{eventDefinition:g,isScheduled:m}=this.extractSchedulerInfo(p),T=(0,D.ZP)("POST",this.eventDefinitionsUrl({query:{schedule:m}}),this.setAlertFlag(g));T.then(v=>(R.Z.success("Event Definition created successfully",`Event Definition "${g.title}" was created successfully.`),this.refresh(),v),v=>{(v.status!==400||!v.additional.body||!v.additional.body.failed)&&R.Z.error(`Creating Event Definition "${g.title}" failed with status: ${v}`,"Could not save Event Definition")}),A.create.promise(T)},copy(p){const g=(0,D.ZP)("POST",this.eventDefinitionsUrl({segments:[p.id,"duplicate"]}));g.then(m=>(R.Z.success("Event Definition duplicated successfully",`Event Definition "${m.title}" was created successfully.`),this.refresh(),m),m=>{(m.status!==400||!m.additional.body||!m.additional.body.failed)&&R.Z.error(`Duplicating Event Definition "${p.title}" failed with status: ${m}`,"Could not duplicate Event Definition")}),A.copy.promise(g)},update(p,g){const{eventDefinition:m,isScheduled:T}=this.extractSchedulerInfo(g),v=(0,D.ZP)("PUT",this.eventDefinitionsUrl({segments:[p],query:{schedule:T}}),this.setAlertFlag(m));v.then(O=>(R.Z.success("Event Definition updated successfully",`Event Definition "${m.title}" was updated successfully.`),this.refresh(),O),O=>{(O.status!==400||!O.additional.body||!O.additional.body.failed)&&R.Z.error(`Updating Event Definition "${m.title}" failed with status: ${O}`,"Could not update Event Definition")}),A.update.promise(v)},delete(p){const g=(0,D.ZP)("DELETE",this.eventDefinitionsUrl({segments:[p.id]}));A.delete.promise(g)},enable(p){const g=(0,D.ZP)("PUT",this.eventDefinitionsUrl({segments:[p.id,"schedule"]}));g.then(m=>(R.Z.success("Event Definition successfully enabled",`Event Definition "${p.title}" was successfully enabled.`),this.refresh(),m),m=>{(m.status!==400||!m.additional.body||!m.additional.body.failed)&&R.Z.error(`Enabling Event Definition "${p.title}" failed with status: ${m}`,"Could not enable Event Definition")}),A.enable.promise(g)},disable(p){const g=(0,D.ZP)("PUT",this.eventDefinitionsUrl({segments:[p.id,"unschedule"]}));g.then(m=>(R.Z.success("Event Definition successfully disabled",`Event Definition "${p.title}" was successfully disabled.`),this.refresh(),m),m=>{(m.status!==400||!m.additional.body||!m.additional.body.failed)&&R.Z.error(`Disabling Event Definition "${p.title}" failed with status: ${m}`,"Could not disable Event Definition")}),A.disable.promise(g)},clearNotificationQueue(p){const g=(0,D.ZP)("PUT",this.eventDefinitionsUrl({segments:[p.id,"clear-notification-queue"]}));g.then(m=>(R.Z.success("Queued notifications cleared.","Queued notifications were successfully cleared."),this.refresh(),m),m=>{(m.status!==400||!m.additional.body||!m.additional.body.failed)&&R.Z.error(`Clearing queued notifications failed with status: ${m}`,"Could not clear queued notifications")}),A.clearNotificationQueue.promise(g)}}))}}]);})();
//# sourceMappingURL=1255d548-8905.ec28249651141b909d18.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy