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