web-interface.assets.bb8c8232-4340.29fb40742a3b1b1fb546.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-4340"],{FBcshu83:(x,v,t)=>{t.d(v,{A:()=>A});var e=t("ii0bleBb"),a=t.n(e),n=t("Z7aTuO5B"),u=t("r3NKmxcf"),E=t("JOCOSU54");const s="",p=(l,c)=>{if(c.type===u.A.MATCH_INPUT){const m=l.find(({id:f})=>f===c.value);return m?`${m.title} (${m.name}: ${m.id})`:`: ${c.value})`}return c.type!==u.A.FIELD_PRESENCE?c.value?c.value:s:null},O=l=>l.field?l.field:l.type===u.A.MATCH_INPUT?"gl_source_input":s,h=({streamRule:l,inputs:c=[]})=>{const{data:m}=(0,E.A)(),f=m==null?void 0:m.find(({id:L})=>L===l.type),S=l.inverted?"not ":null,C=f?f.long_desc:null;return l.type===u.A.ALWAYS_MATCHES?n.createElement("span",null,"Rule always matches"):n.createElement("span",null,n.createElement("em",null,O(l))," ",n.createElement("strong",null,"must ",S),C," ",n.createElement("em",null,p(c,l)))};h.propTypes={streamRule:a().object.isRequired,inputs:a().array.isRequired};const A=h},RfX2tXzp:(x,v,t)=>{t.d(v,{A:()=>Y});var e=t("ii0bleBb"),a=t.n(e),n=t("Z7aTuO5B"),u=t("oc9db6Tt"),E=t.n(u),s=t("J6y4/h8P"),p=t("FBcshu83"),O=t("8fnsnG21"),h=t("IOI9nV80"),A=t("rIl5IEuP"),l=t("yGRmSjYM"),c=t("0CyR/E1C"),m=t("jAGDuYSC"),f=t("W/ejv//U"),S=t("apKKh8n6"),C=t("q2j1bVbz");const L=s.default.span`
margin-right: 6px;
`,d=({matchData:_,stream:M,streamRule:R,onSubmit:g,onDelete:K})=>{const{permissions:W}=(0,C.A)(),[H,P]=(0,n.useState)(!1),{inputs:B}=(0,O.P)(f.s);(0,n.useEffect)(()=>{f.M.list()},[]);const j=D=>{D.preventDefault(),P(!0)},$=D=>{D.preventDefault(),window.confirm("Do you really want to delete this stream rule?")&&S.D.remove(M.id,R.id,()=>{K&&K(R.id),m.A.success("Stream rule has been successfully deleted.","Success")})},I=(D,G)=>S.D.update(M.id,D,G,()=>{g&&g(D,G),m.A.success("Stream rule has been successfully updated.","Success")}),r=()=>n.createElement(L,null,n.createElement(A.Button,{bsStyle:"link",bsSize:"xsmall",onClick:$,title:"Delete stream rule"},n.createElement(h.In,{name:"delete",type:"regular"})),n.createElement(A.Button,{bsStyle:"link",bsSize:"xsmall",onClick:j,title:"Edit stream rule"},n.createElement(h.In,{name:"edit_square"}))),o=()=>_.rules[R.id]?"success":"danger",i=(0,l.Nn)(W,[`streams:edit:${M.id}`])?r():null,T=R.description?n.createElement("small",null," ","(",R.description,")"):null,U=E()(_)?null:o();return n.createElement(A.ListGroupItem,{bsStyle:U},i,n.createElement(p.A,{streamRule:R,inputs:B}),H&&n.createElement(c.A,{initialValues:R,onClose:()=>P(!1),title:"Edit Stream Rule",submitButtonText:"Update Rule",submitLoadingText:"Updating Rule...",onSubmit:I}),T)};d.propTypes={matchData:a().shape({matches:a().bool,rules:a().object}),onDelete:a().func,onSubmit:a().func,stream:a().object.isRequired,streamRule:a().object.isRequired},d.defaultProps={matchData:{},onSubmit:()=>{},onDelete:()=>{}};const y=d,N=({matchData:_,onDelete:M,onSubmit:R,stream:g})=>{if(!g)return n.createElement(h.y$,null);const K=!!g.rules.length;return n.createElement(A.ListGroup,{componentClass:"ul"},K&&g.rules.map(W=>n.createElement(y,{key:W.id,matchData:_,onSubmit:R,onDelete:M,stream:g,streamRule:W})),!K&&n.createElement(A.ListGroupItem,null,"No rules defined."))};N.propTypes={matchData:a().shape({matches:a().bool,rules:a().object}),onSubmit:a().func,onDelete:a().func,stream:a().object.isRequired},N.defaultProps={matchData:{},onSubmit:()=>{},onDelete:()=>{}};const Y=N},"0CyR/E1C":(x,v,t)=>{t.d(v,{A:()=>L});var e=t("Z7aTuO5B"),a=t("UiXZqrDE"),n=t("kbGtT3aS"),u=t("IOI9nV80"),E=t("FBcshu83"),s=t("rIl5IEuP"),p=t("fVisTAey"),O=t("E+CaPsQD"),h=t("8fnsnG21"),A=t("W/ejv//U"),l=t("r3NKmxcf"),c=t("JOCOSU54");const m=d=>d!==l.A.FIELD_PRESENCE&&d!==l.A.ALWAYS_MATCHES,f=d=>d!==l.A.ALWAYS_MATCHES&&d!==l.A.MATCH_INPUT,S=d=>{let y={};return d.type||(y={...y,type:"Type is required"}),m(d.type)&&!d.value&&(y={...y,value:"Value is required"}),f(d.type)&&!d.field&&(y={...y,field:"Field is required"}),y},C=({title:d,onClose:y,submitButtonText:N,submitLoadingText:Y,onSubmit:_,initialValues:M})=>{const{inputs:R}=(0,h.P)(A.s),{data:g}=(0,c.A)();(0,e.useEffect)(()=>{A.M.list()},[]);const K=(0,e.useCallback)(P=>_(M==null?void 0:M.id,P).then(()=>y()),[_,M==null?void 0:M.id,y]),W=(0,e.useMemo)(()=>g==null?void 0:g.map(({id:P,short_desc:B})=>({value:P,label:B})),[g]),H=(0,e.useMemo)(()=>R==null?void 0:R.map(({id:P,title:B,name:j})=>({label:`${B} (${j})`,value:P})),[R]);return e.createElement(s.Modal,{title:d,onHide:y,show:!0},e.createElement(a.Formik,{initialValues:M,onSubmit:K,validate:S},({values:P,setFieldValue:B,isSubmitting:j,isValidating:$})=>e.createElement(a.Form,null,e.createElement(s.Modal.Header,{closeButton:!0},e.createElement(s.Modal.Title,null,d)),e.createElement(s.Modal.Body,null,g!=null&&g.length?e.createElement(s.Row,null,e.createElement(s.Col,{md:8},f(P.type)&&e.createElement(a.Field,{name:"field"},({field:{name:I,value:r,onChange:o,onBlur:i},meta:{error:T,touched:U}})=>e.createElement(u.ci,{id:I,onBlur:i,type:"text",label:"Field",name:I,error:T&&U?T:void 0,defaultValue:r,onChange:o})),e.createElement(a.Field,{name:"type"},({field:{name:I,value:r,onChange:o,onBlur:i},meta:{error:T,touched:U}})=>e.createElement(s.Input,{label:"Type",id:"type",error:T&&U?T:void 0},e.createElement(u.l6,{onBlur:i,onChange:D=>((D===l.A.MATCH_INPUT||D===l.A.ALWAYS_MATCHES)&&(B("value",""),B("field","")),o({target:{value:D,name:I}})),options:W,inputId:I,placeholder:"Select a type",inputProps:{"aria-label":"Select a type"},value:r}))),m(P.type)&&(P.type===l.A.MATCH_INPUT?e.createElement(a.Field,{name:"value"},({field:{name:I,value:r,onChange:o,onBlur:i},meta:{error:T,touched:U}})=>e.createElement(s.Input,{id:"value",label:"Input",error:T&&U?T:void 0},e.createElement(u.l6,{onBlur:i,onChange:D=>{o({target:{value:D,name:I}})},options:H,inputId:I,placeholder:"Select an input",inputProps:{"aria-label":"Select an input"},value:r}))):e.createElement(u.jF,{id:"value",label:"Value",name:"value"})),e.createElement(u.jF,{id:"inverted",label:"Inverted",name:"inverted",type:"checkbox"}),e.createElement(u.jF,{id:"description",label:e.createElement(e.Fragment,null,"Description ",e.createElement(u.Bt,null)),name:"description",type:"textarea"}),e.createElement("p",null,e.createElement("strong",null,"Result:")," ",e.createElement(E.A,{streamRule:P,inputs:R}))),e.createElement(s.Col,{md:4},e.createElement(s.Well,{bsSize:"small",className:"matcher-github"},"The server will try to convert to strings or numbers based on the matcher type as well as it can.",e.createElement("br",null),e.createElement("br",null),e.createElement(u.rK,{name:"github"}),"\xA0",e.createElement("a",{href:`https://github.com/Graylog2/graylog2-server/tree/${n.Ay.getMajorAndMinorVersion()}/graylog2-server/src/main/java/org/graylog2/streams/matchers`,target:"_blank",rel:"noopener noreferrer"}," Take a look at the matcher code on GitHub"),e.createElement("br",null),e.createElement("br",null),"Regular expressions use Java syntax. ",e.createElement(p.$,{page:O.A.PAGES.STREAMS,title:"More information",text:e.createElement(u.In,{name:"lightbulb_circle",type:"regular"})})))):e.createElement(u.y$,null)),e.createElement(s.Modal.Footer,null,e.createElement(u.E6,{submitButtonText:N,submitLoadingText:Y,onCancel:y,disabledSubmit:$,isSubmitting:j})))))};C.defaultProps={initialValues:{field:"",type:1,value:"",inverted:!1,description:""}};const L=C},JOCOSU54:(x,v,t)=>{t.d(v,{A:()=>E});var e=t("DUKaTDO2"),a=t("apKKh8n6"),n=t("jAGDuYSC");const E=()=>{const{data:s}=(0,e.useQuery)(["streams","rule-types"],()=>a.D.types(),{onError:p=>{n.A.error(`Loading stream rule types failed with status: ${p}`,"Could not load stream rule types")},keepPreviousData:!0,staleTime:36e5});return{data:s}}},r3NKmxcf:(x,v,t)=>{t.d(v,{A:()=>a});const a={FIELD_PRESENCE:5,ALWAYS_MATCHES:7,MATCH_INPUT:8}},VBBnYA0D:(x,v,t)=>{t.r(v),t.d(v,{default:()=>I});var e=t("Z7aTuO5B"),a=t("yAXMqwrl"),n=t("rIl5IEuP"),u=t("ii0bleBb"),E=t.n(u),s=t("J6y4/h8P"),p=t("ty2gyrHp"),O=t("d4kzUuQm"),h=t("IOI9nV80"),A=t("mihjYJ2+"),l=t("jAGDuYSC"),c=t("pUKP3+Pg"),m=Object.defineProperty,f=(r,o,i)=>o in r?m(r,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[o]=i,S=(r,o,i)=>(f(r,typeof o!="symbol"?o+"":o,i),i);const C=s.default.div(({theme:r})=>(0,s.css)`
margin-top: 10px;
margin-bottom: 13px;
label {
font-size: ${r.fonts.size.small};
}
.form-group {
margin-bottom: 5px;
}
.radio {
margin-top: 0;
margin-bottom: 0;
}
input[type='radio'] {
margin-top: 2px;
margin-bottom: 2px;
}
`);class L extends e.Component{constructor(){super(...arguments),S(this,"handleTypeChangeToAnd",()=>{this.handleTypeChange("AND")}),S(this,"handleTypeChangeToOr",()=>{this.handleTypeChange("OR")}),S(this,"handleTypeChange",o=>{const{onChange:i,stream:T}=this.props;window.confirm("You are about to change how rules are applied to this stream, do you want to continue? Changes will take effect immediately.")&&c.Ay.update(T.id,{matching_type:o},U=>(i(),l.A.success(`Messages will now be routed into the stream when ${o==="AND"?"all":"any"} rules are matched`,"Success"),U))})}render(){const{stream:o}=this.props;return e.createElement(C,null,e.createElement("div",null,e.createElement(n.Input,{id:"streamrule-and-connector",type:"radio",label:"A message must match all of the following rules",checked:o.matching_type==="AND",onChange:this.handleTypeChangeToAnd}),e.createElement(n.Input,{id:"streamrule-or-connector",type:"radio",label:"A message must match at least one of the following rules",checked:o.matching_type==="OR",onChange:this.handleTypeChangeToOr})))}}S(L,"propTypes",{stream:E().object.isRequired,onChange:E().func.isRequired});const d=L;var y=t("RfX2tXzp"),N=t("0CyR/E1C"),Y=t("dsvqAVKU"),_=t("apKKh8n6"),M=t("yzCFXWYn");const R=(0,s.default)(n.Panel.Heading)`
font-weight: bold;
`,g=(0,s.default)(h.In)(({theme:r,$empty:o,$matches:i})=>{const T=i?r.colors.variant.success:r.colors.variant.danger;return(0,s.css)`
color: ${o?r.colors.variant.info:T};
margin-right: 3px;
`}),K=(0,s.default)(Y.A)`
margin-left: 10px;
`,W=r=>r.matches?"success":"danger",H=({streamId:r,messageId:o,index:i})=>{const[T,U]=(0,e.useState)(!1),[D,G]=(0,e.useState)(),[F,Q]=(0,e.useState)(),{data:X,refetch:z}=(0,M.A)(r);(0,e.useEffect)(()=>{const b=()=>z();return c.Ay.onChange(b),_.D.onChange(b),()=>{c.Ay.unregister(b),_.D.unregister(b)}},[z]);const V=b=>{G(b),D!==void 0?c.Ay.testMatch(r,{message:D.fields},J=>{Q(J)}):Q(void 0)},Z=(b,J)=>_.D.create(r,J,()=>{}),w=b=>{b.preventDefault(),U(!0)},k=F?W(F):"info";return X?e.createElement(n.Row,{className:"content"},e.createElement(n.Col,{md:12,className:"streamrule-sample-message"},e.createElement("h2",null,"1. Load a message to test rules"),e.createElement("div",{className:"stream-loader"},e.createElement(A.A,{messageId:o,index:i,onMessageLoaded:V})),e.createElement("hr",null),e.createElement("div",{className:"buttons pull-right"},e.createElement(n.Button,{bsStyle:"success",className:"show-stream-rule",onClick:w},"Add stream rule"),T&&e.createElement(N.A,{title:"New Stream Rule",onClose:()=>U(!1),submitButtonText:"Create Rule",submitLoadingText:"Creating Rule...",onSubmit:Z})),e.createElement("h2",null,"2. Manage stream rules"),e.createElement(d,{stream:X,onChange:z}),e.createElement(n.Panel,{bsStyle:k},e.createElement(R,null,(F==null?void 0:F.matches)&&e.createElement(e.Fragment,null,e.createElement(g,{$matches:!0,name:"check"})," This message would be routed to this stream!"),F&&!F.matches&&e.createElement(e.Fragment,null,e.createElement(g,{name:"close"})," This message would not be routed to this stream."),!F&&e.createElement(e.Fragment,null,e.createElement(g,{$empty:!0,name:"error"})," Please load a message in Step 1 above to check if it would match against these rules.")),e.createElement(y.A,{stream:X,matchData:F})),e.createElement("p",null,e.createElement(p.m,{to:O.Ay.STREAMS},e.createElement(n.Button,{bsStyle:"success"},"I'm done!"))))):e.createElement(n.Row,{className:"content"},e.createElement(K,null))};H.propTypes={streamId:E().string.isRequired,messageId:E().string,index:E().string},H.defaultProps={messageId:"",index:""};const P=H;var B=t("brbjQOmY"),j=t("E+CaPsQD");const I=()=>{const r=(0,a.useParams)(),o=(0,B.A)(),{data:i}=(0,M.A)(r.streamId);return i?e.createElement(h.Qc,{title:`Rules of Stream ${i.title}`},e.createElement("div",null,e.createElement(h.zY,{title:e.createElement("span",null,'Rules of Stream "',i.title,'"'),documentationLink:{title:"Streams documentation",path:j.A.PAGES.STREAMS}},e.createElement("span",null,"This screen is dedicated to an easy and comfortable creation and manipulation of stream rules. You can"," ","see the effect configured stream rules have on message matching here.")),!i.is_default&&e.createElement(P,{streamId:r.streamId,messageId:o.message_id,index:o.index}),i.is_default&&e.createElement("div",{className:"row content"},e.createElement("div",{className:"col-md-12"},e.createElement(n.Alert,{bsStyle:"danger"},"The default stream cannot be edited."))))):e.createElement(h.y$,null)}},"W/ejv//U":(x,v,t)=>{t.d(v,{M:()=>p,s:()=>O});var e=t("JnTtTRmZ"),a=t.n(e),n=t("jAGDuYSC"),u=t("MdYBRjRJ"),E=t("eFxcQyPT"),s=t("IA3Ku5lS");const p=(0,s.rN)("core.StreamRulesInputs",()=>a().createActions({list:{asyncResult:!0}})),O=(0,s.Bv)("core.StreamRulesInputs",()=>a().createStore({listenables:[p],sourceUrl:"/streams/rules/inputs",inputs:void 0,init(){this.list()},_state(){return{inputs:this.inputs}},getInitialState(){return this._state()},list(){const h=(0,E.Ay)("GET",(0,u.H3)(this.sourceUrl));h.then(A=>(this.inputs=A.inputs,this.trigger(this._state()),this.inputs),A=>{n.A.error(`Fetching Stream Rule Inputs List failed with status: ${A}`,"Could not retrieve Stream Rule Inputs")}),p.list.promise(h)}}))},apKKh8n6:(x,v,t)=>{t.d(v,{D:()=>A});var e=t("JnTtTRmZ"),a=t.n(e),n=t("XYSsaeV4"),u=t.n(n),E=t("eFxcQyPT"),s=t("U1Iufsob"),p=t("MdYBRjRJ"),O=t("jAGDuYSC"),h=t("IA3Ku5lS");const A=(0,h.Bv)("core.StreamRules",()=>a().createStore({callbacks:[],types(){return(0,E.Ay)("GET",p.H3("/streams/null/rules/types"))},update(l,c,m,f){const S=d=>{O.A.error(`Updating Stream Rule failed with status: ${d}`,"Could not update Stream Rule")},C=p.H3(s.A.StreamRulesApiController.update(l,c).url),L={field:m.field,type:m.type,value:m.value,inverted:m.inverted,description:m.description};return(0,E.Ay)("PUT",C,L).then(f,S).then(this._emitChange.bind(this))},remove(l,c,m){const f=C=>{O.A.error(`Deleting Stream Rule failed with status: ${C}`,"Could not delete Stream Rule")},S=p.H3(s.A.StreamRulesApiController.delete(l,c).url);(0,E.Ay)("DELETE",S).then(m,f).then(this._emitChange.bind(this))},create(l,c,m){const f=C=>{O.A.error(`Creating Stream Rule failed with status: ${C}`,"Could not create Stream Rule")},S=p.H3(s.A.StreamRulesApiController.create(l).url);return(0,E.Ay)("POST",S,c).then(m,f).then(this._emitChange.bind(this))},onChange(l){this.callbacks.push(l)},_emitChange(){this.callbacks.forEach(l=>l())},unregister(l){u()(this.callbacks,l)}}))}}]);})();
//# sourceMappingURL=bb8c8232-4340.29fb40742a3b1b1fb546.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy