All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web-interface.assets.325e2d4b-9241.3392b02049eebcaaa089.js Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
"use strict";(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["325e2d4b-9241"],{x85XLEUc:(e,t,i)=>{i.d(t,{Z:()=>N});var n=i("Z7aTuO5B"),o=i("ii0bleBb"),s=i.n(o),a=i("nHcjWeCO"),r=i.n(a),l=i("0zTRKSqx"),c=i("BSHS2nUH"),d=i("DeVaSktS"),u=i("5GvVt6f3"),h=i("AztyBNMT"),m=i("F9olzlTR"),f=i("YyiN4DLW");function p(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const b=e=>void 0===e?{}:h.PluginStore.exports("eventNotificationTypes").find((t=>t.type===e))||{};class g extends n.Component{constructor(e){super(e),p(this,"setIsSubmitEnabled",(e=>{this.setState({isSubmitEnabled:e})})),p(this,"handleSubmit",(e=>{const{notification:t,onSubmit:i}=this.props;e.preventDefault(),i(t)})),p(this,"handleChange",(e=>{const{name:t}=e.target,{onChange:i}=this.props;i(t,(0,f.n6)(e.target))})),p(this,"handleConfigChange",(e=>{const{onChange:t}=this.props;t("config",e)})),p(this,"handleTypeChange",(e=>{const t=b(e).defaultConfig||{};this.handleConfigChange({...t,type:e})})),p(this,"handleTestTrigger",(()=>{const{notification:e,onTest:t}=this.props;t(e)})),this.state={isSubmitEnabled:!0}}render(){const{action:e,embedded:t,formId:i,notification:o,onCancel:s,validation:a,testResult:c}=this.props,{isSubmitEnabled:d}=this.state,u=b(o.config.type),f=u.formComponent?n.createElement(u.formComponent,{config:o.config,onChange:this.handleConfigChange,validation:a,setIsSubmitEnabled:this.setIsSubmitEnabled}):null,p=c.isLoading?n.createElement(l.$j,{text:"Testing..."}):"Execute Test Notification";return n.createElement(m.X2,null,n.createElement(m.JX,{lg:8},n.createElement("form",{onSubmit:this.handleSubmit,id:i},n.createElement(m.II,{id:"notification-title",name:"title",label:"Title",type:"text",bsStyle:a.errors.title?"error":null,help:r().get(a,"errors.title[0]","Title to identify this Notification."),value:o.title,onChange:this.handleChange,required:!0,autoFocus:!0}),n.createElement(m.II,{id:"notification-description",name:"description",label:n.createElement("span",null,"Description ",n.createElement("small",{className:"text-muted"},"(Optional)")),type:"textarea",help:"Longer description for this Notification.",value:o.description,onChange:this.handleChange,rows:2}),n.createElement(m.cw,{controlId:"notification-type",validationState:a.errors.config?"error":null},n.createElement(m.J$,null,"Notification Type"),n.createElement(l.Ph,{id:"notification-type",options:h.PluginStore.exports("eventNotificationTypes").map((e=>({label:e.displayName,value:e.type}))),value:o.config.type,onChange:this.handleTypeChange,clearable:!1,required:!0}),n.createElement(m.Qb,null,r().get(a,"errors.config[0]","Choose the type of Notification to create."))),f,f&&n.createElement(m.cw,null,n.createElement(m.J$,null,"Test Notification ",n.createElement("small",{className:"text-muted"},"(Optional)")),n.createElement(m.NI.Static,null,n.createElement(m.zx,{bsStyle:"info",bsSize:"small",disabled:c.isLoading,onClick:this.handleTestTrigger},p)),c.message&&n.createElement(m.bZ,{bsStyle:c.error?"danger":"success"},n.createElement("b",null,c.error?"Error: ":"Success: "),c.message),n.createElement(m.Qb,null,"Execute this Notification with a test Alert.")),!t&&n.createElement(l.Ow,{disabledSubmit:!d,submitButtonText:("create"===e?"Create":"Update")+" notification",onCancel:s}))))}}p(g,"propTypes",{action:s().oneOf(["create","edit"]),notification:s().object.isRequired,validation:s().object.isRequired,testResult:s().shape({isLoading:s().bool,error:s().bool,message:s().string}).isRequired,formId:s().string,embedded:s().bool.isRequired,onChange:s().func.isRequired,onCancel:s().func.isRequired,onSubmit:s().func.isRequired,onTest:s().func.isRequired}),p(g,"defaultProps",{action:"edit",formId:void 0});const S=g;i("BXP2KjIr");function y(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const E={errors:{}},T={isLoading:!1};class C extends n.Component{static scrollToFirstError(){void 0!==document.getElementsByClassName("has-error")[0]&&document.getElementsByClassName("has-error")[0].scrollIntoView(!0)}constructor(e){super(e),y(this,"handleChange",((e,t)=>{const{notification:i}=this.state,n=r().cloneDeep(i);n[e]=t,this.setState({notification:n,isDirty:!0,testResult:T})})),y(this,"handleCancel",(()=>{c.Z.push(d.ZP.ALERTS.NOTIFICATIONS.LIST)})),y(this,"handleSubmit",(()=>{const{action:e,embedded:t,onSubmit:i}=this.props,{notification:n}=this.state;let o;"create"===e?(o=u.e.create(n),o.then((()=>{this.setState({isDirty:!1},(()=>{t||c.Z.push(d.ZP.ALERTS.NOTIFICATIONS.LIST)}))}),(e=>{const{body:t}=e.additional;400===e.status&&t&&t.failed&&(this.setState({validation:t}),C.scrollToFirstError())}))):(o=u.e.update(n.id,n),o.then((()=>{this.setState({isDirty:!1},(()=>{t||c.Z.push(d.ZP.ALERTS.NOTIFICATIONS.LIST)}))}),(e=>{const{body:t}=e.additional;400===e.status&&t&&t.failed&&(this.setState({validation:t}),C.scrollToFirstError())}))),i(o)})),y(this,"handleTest",(()=>{const{notification:e}=this.state;this.setState({testResult:{isLoading:!0},validation:E});const t=r().clone(T);this.testPromise=u.e.test(e),this.testPromise.then((e=>(t.error=!1,t.message="Notification was executed successfully.",e)),(e=>{t.error=!0;const{body:i}=e.additional;400===e.status&&i&&i.failed?(t.message="Validation failed, please correct any errors in the form before continuing.",this.setState({validation:i})):t.message=e.responseMessage||"Unknown error, please check your Graylog server logs."})).finally((()=>{this.setState({testResult:t}),this.testPromise=void 0}))})),this.state={notification:e.notification,validation:E,testResult:T,isDirty:!1}}componentWillUnmount(){this.testPromise&&this.testPromise.cancel()}render(){const{action:e,embedded:t,formId:i}=this.props,{notification:o,validation:s,testResult:a,isDirty:r}=this.state;return n.createElement(n.Fragment,null,!t&&r&&n.createElement(l.oU,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),n.createElement(S,{action:e,notification:o,validation:s,testResult:a,formId:i,embedded:t,onChange:this.handleChange,onCancel:this.handleCancel,onSubmit:this.handleSubmit,onTest:this.handleTest}))}}y(C,"propTypes",{action:s().oneOf(["create","edit"]),notification:s().object,embedded:s().bool,formId:s().string,onSubmit:s().func}),y(C,"defaultProps",{action:"edit",notification:{title:"",description:"",config:{}},embedded:!1,formId:void 0,onSubmit:()=>{}});const N=C},"7yh3vaEI":(e,t,i)=>{i.r(t),i.d(t,{default:()=>g});var n=i("Z7aTuO5B"),o=i("ii0bleBb"),s=i.n(o),a=i("F9olzlTR"),r=i("0zTRKSqx"),l=i("DeVaSktS"),c=i("4Js8dUPg"),d=i("b/6pmtOr"),u=i("EUJYvlA3"),h=i("BSHS2nUH"),m=i("x85XLEUc"),f=i("6WrsI6bg"),p=i("GdY2o7iN");const b=e=>{let{currentUser:t}=e;return(0,u.rq)(t.permissions,"eventnotifications:create")||h.Z.push(l.ZP.NOTFOUND),n.createElement(r.$4,{title:"New Notification"},n.createElement(p.Z,null),n.createElement(r.mr,{title:"New Notification",documentationLink:{title:"Alerts documentation",path:c.Z.PAGES.ALERTS}},n.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.")),n.createElement(a.X2,{className:"content"},n.createElement(a.JX,{md:12},n.createElement(m.Z,{action:"create"}))))};b.propTypes={currentUser:s().object.isRequired};const g=(0,d.Z)(b,{currentUser:f.D},(e=>{let{currentUser:t}=e;return{currentUser:t.currentUser}}))}}]);
//# sourceMappingURL=325e2d4b-9241.3392b02049eebcaaa089.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy