web-interface.assets.1255d548-5226.894068cf0729ec9c720d.js Maven / Gradle / Ivy
(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["1255d548-5226"],{"42lc8BRs":(I,E,t)=>{"use strict";t.d(E,{Z:()=>Y});var e=t("Z7aTuO5B"),f=t("ii0bleBb"),o=t.n(f),p=t("VZ0CjfW1"),T=t.n(p),y=t("IW7priiX"),N=t.n(y),C=t("/GOzvPf6"),O=t("d4kzUuQm"),P=t("J7MaobQD"),U=t("N6x7vnl1"),R=t("/yh+QgO6"),S=t.n(R),b=t("QL8i6bcz"),m=t("uZqmR+ju"),W=t("S6FuRS7B"),G=t("BqxuktKK"),L=t("MdYBRjRJ"),D=t("v4GbOr/o"),j=t("HCsT5Gmk"),H=Object.defineProperty,V=(r,i,n)=>i in r?H(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,h=(r,i,n)=>(V(r,typeof i!="symbol"?i+"":i,n),n);const Z=r=>r===void 0?{}:b.G.exports("eventNotificationTypes").find(i=>i.type===r)||{},_=()=>b.G.exports("eventNotificationTypes").map(r=>({label:r.displayName,value:r.type}));class A extends e.Component{constructor(i){super(i),h(this,"setIsSubmitEnabled",n=>{this.setState({isSubmitEnabled:n})}),h(this,"handleSubmit",n=>{const{notification:a,onSubmit:s,sendTelemetry:l,action:c,location:d}=this.props;l(c==="create"?D.A.NOTIFICATIONS.CREATE_CLICKED:D.A.NOTIFICATIONS.EDIT_CLICKED,{app_pathname:(0,L.av)(d.pathname),app_section:"event-notification",app_action_value:`${c}-button`}),n.preventDefault(),s(a)}),h(this,"handleChange",n=>{const{name:a}=n.target,{onChange:s}=this.props;s(a,(0,W.n6)(n.target))}),h(this,"handleConfigChange",n=>{const{onChange:a}=this.props;a("config",n)}),h(this,"handleTypeChange",n=>{const{sendTelemetry:a,location:s}=this.props;a(D.A.EVENTDEFINITION_NOTIFICATIONS.NOTIFICATION_TYPE_SELECTED,{app_pathname:(0,L.av)(s.pathname),app_section:"event-definition-notifications",app_action_value:"notification-type-select",notification_type:n});const c=Z(n).defaultConfig||{};this.handleConfigChange({...c,type:n})}),h(this,"handleTestTrigger",()=>{const{notification:n,onTest:a,sendTelemetry:s,location:l}=this.props;s(D.A.NOTIFICATIONS.EXECUTE_TEST_CLICKED,{app_pathname:(0,L.av)(l.pathname),app_section:"event-notification",app_action_value:"execute-test-button"}),a(n)}),this.state={isSubmitEnabled:!0}}render(){const{action:i,embedded:n,formId:a,notification:s,onCancel:l,validation:c,testResult:d}=this.props,{isSubmitEnabled:v}=this.state,u=Z(s.config.type),K=u.formComponent?e.createElement(u.formComponent,{config:s.config,onChange:this.handleConfigChange,validation:c,setIsSubmitEnabled:this.setIsSubmitEnabled}):null,J=d.isLoading?e.createElement(C.$j,{text:"Testing..."}):"Execute Test Notification";return e.createElement(m.Row,null,e.createElement(m.Col,{lg:8},e.createElement("form",{onSubmit:this.handleSubmit,id:a},e.createElement(m.Input,{id:"notification-title",name:"title",label:"Title",type:"text",bsStyle:c.errors.title?"error":null,help:S()(c,"errors.title[0]","Title to identify this Notification."),value:s.title,onChange:this.handleChange,required:!0,autoFocus:!0}),e.createElement(m.Input,{id:"notification-description",name:"description",label:e.createElement("span",null,"Description ",e.createElement("small",{className:"text-muted"},"(Optional)")),type:"textarea",help:"Longer description for this Notification.",value:s.description,onChange:this.handleChange,rows:2}),e.createElement(m.FormGroup,{controlId:"notification-type",validationState:c.errors.config?"error":null},e.createElement(m.ControlLabel,null,"Notification Type"),e.createElement(C.Ph,{id:"notification-type",options:_(),value:s.config.type,onChange:this.handleTypeChange,clearable:!1,required:!0}),e.createElement(m.HelpBlock,null,S()(c,"errors.config[0]","Choose the type of Notification to create."))),K,K&&e.createElement(m.FormGroup,null,e.createElement(m.ControlLabel,null,"Test Notification ",e.createElement("small",{className:"text-muted"},"(Optional)")),e.createElement(m.FormControl.Static,null,e.createElement(m.Button,{bsStyle:"info",bsSize:"small",disabled:d.isLoading,onClick:this.handleTestTrigger},J)),d.message&&e.createElement(m.Alert,{bsStyle:d.error?"danger":"success",title:d.error?"Error: ":"Success: "},d.message),e.createElement(m.HelpBlock,null,"Execute this Notification with a test Alert.")),!n&&e.createElement(C.Ow,{disabledSubmit:!v,submitButtonText:`${i==="create"?"Create":"Update"} notification`,onCancel:l}))))}}h(A,"propTypes",{action:o().oneOf(["create","edit"]),notification:o().object.isRequired,validation:o().object.isRequired,testResult:o().shape({isLoading:o().bool,error:o().bool,message:o().string}).isRequired,formId:o().string,embedded:o().bool.isRequired,onChange:o().func.isRequired,onCancel:o().func.isRequired,onSubmit:o().func.isRequired,onTest:o().func.isRequired,sendTelemetry:o().func.isRequired,location:o().object.isRequired}),h(A,"defaultProps",{action:"edit",formId:void 0});const z=(0,j.Z)((0,G.Z)(A));var w=t("ava0cCRK"),Q=Object.defineProperty,X=(r,i,n)=>i in r?Q(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,g=(r,i,n)=>(X(r,typeof i!="symbol"?i+"":i,n),n);const x={errors:{}},F={isLoading:!1},B=class M extends e.Component{constructor(i){super(i),g(this,"handleChange",(n,a)=>{const{notification:s}=this.state,l=N()(s);l[n]=a,this.setState({notification:l,isDirty:!0,testResult:F})}),g(this,"handleCancel",()=>{const{history:n}=this.props;n.push(O.ZP.ALERTS.NOTIFICATIONS.LIST)}),g(this,"handleSubmit",()=>{const{action:n,embedded:a,onSubmit:s,history:l}=this.props,{notification:c}=this.state;let d;n==="create"?(d=P.e.create(c),d.then(()=>{this.setState({isDirty:!1},()=>{a||l.push(O.ZP.ALERTS.NOTIFICATIONS.LIST)})},v=>{const{body:u}=v.additional;v.status===400&&u&&u.failed&&(this.setState({validation:u}),M.scrollToFirstError())})):(d=P.e.update(c.id,c),d.then(()=>{this.setState({isDirty:!1},()=>{a||l.push(O.ZP.ALERTS.NOTIFICATIONS.LIST)})},v=>{const{body:u}=v.additional;v.status===400&&u&&u.failed&&(this.setState({validation:u}),M.scrollToFirstError())})),s(d)}),g(this,"handleTest",()=>{const{notification:n}=this.state;this.setState({testResult:{isLoading:!0},validation:x});const a=T()(F);this.testPromise=P.e.test(n),this.testPromise.then(s=>(a.error=!1,a.message="Notification was executed successfully.",s),s=>{a.error=!0;const{body:l}=s.additional;s.status===400&&l&&l.failed?(a.message="Validation failed, please correct any errors in the form before continuing.",this.setState({validation:l})):a.message=s.responseMessage||"Unknown error, please check your Graylog server logs."}).finally(()=>{this.setState({testResult:a}),this.testPromise=void 0})}),this.state={notification:i.notification,validation:x,testResult:F,isDirty:!1}}static scrollToFirstError(){document.getElementsByClassName("has-error")[0]!==void 0&&document.getElementsByClassName("has-error")[0].scrollIntoView(!0)}componentWillUnmount(){this.testPromise&&this.testPromise.cancel()}render(){const{action:i,embedded:n,formId:a}=this.props,{notification:s,validation:l,testResult:c,isDirty:d}=this.state;return e.createElement(e.Fragment,null,!n&&d&&e.createElement(C.oU,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(z,{action:i,notification:s,validation:l,testResult:c,formId:a,embedded:n,onChange:this.handleChange,onCancel:this.handleCancel,onSubmit:this.handleSubmit,onTest:this.handleTest}))}};g(B,"propTypes",{action:o().oneOf(["create","edit"]),notification:o().object,embedded:o().bool,formId:o().string,onSubmit:o().func,history:o().object.isRequired}),g(B,"defaultProps",{action:"edit",notification:{title:"",description:"",config:{}},embedded:!1,formId:void 0,onSubmit:()=>{}});let $=B;const Y=(0,U.Z)($)},ipCdamDE:(I,E,t)=>{"use strict";t.r(E),t.d(E,{default:()=>R});var e=t("Z7aTuO5B"),f=t("uZqmR+ju"),o=t("/GOzvPf6"),p=t("d4kzUuQm"),T=t("E+CaPsQD"),y=t("0TVxnHwi"),N=t("42lc8BRs"),C=t("jvpdvVQ7"),O=t("q2j1bVbz"),P=t("/7OuCFNo");const R=()=>{const S=(0,O.Z)(),b=(0,P.Z)();return(0,y.rq)(S.permissions,"eventnotifications:create")||b.push(p.ZP.NOTFOUND),e.createElement(o.$4,{title:"New Notification"},e.createElement(C.Z,null),e.createElement(o.mr,{title:"New Notification",documentationLink:{title:"Alerts documentation",path:T.Z.PAGES.ALERTS}},e.createElement("span",null,"Notifications alert you of any configured Event when they occur. Graylog can send Notifications directly to you or to other systems you use for that purpose.")),e.createElement(f.Row,{className:"content"},e.createElement(f.Col,{md:12},e.createElement(N.Z,{action:"create"}))))}},N6x7vnl1:(I,E,t)=>{"use strict";t.d(E,{Z:()=>p});var e=t("Z7aTuO5B"),f=t("/7OuCFNo");const p=T=>y=>{const N=(0,f.Z)();return e.createElement(T,{...y,history:N})}},VZ0CjfW1:(I,E,t)=>{var e=t("8U3oBBH1"),f=4;function o(p){return e(p,f)}I.exports=o}}]);})();
//# sourceMappingURL=1255d548-5226.894068cf0729ec9c720d.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy