Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{"version":3,"sources":["webpack:///./src/pages/EditEventNotificationPage.jsx","webpack:///./src/components/event-notifications/event-notification-form/EventNotificationForm.jsx","webpack:///./src/components/event-notifications/event-notification-form/EventNotificationFormContainer.jsx","webpack:///./src/components/event-notifications/event-notification-details/EventNotificationActionLinks.jsx"],"names":["EventNotificationsActions","CombinedProvider","get","CurrentUserStore","isPermitted","PermissionsMixin","EditEventDefinitionPage","props","state","notification","undefined","this","params","currentUser","permissions","notificationId","then","setState","error","status","history","push","Routes","ALERTS","NOTIFICATIONS","LIST","NOTFOUND","title","subactions","id","page","DocsHelper","PAGES","text","to","bsStyle","DEFINITIONS","className","md","action","React","Component","PropTypes","object","isRequired","connect","withParams","EventNotificationForm","event","onSubmit","preventDefault","name","target","onChange","getValueFromInput","nextConfig","type","PluginStore","exports","find","n","nextType","defaultConfig","getNotificationPlugin","handleConfigChange","onTest","map","label","displayName","value","embedded","formId","onCancel","validation","testResult","notificationPlugin","config","notificationFormComponent","formComponent","createElement","testButtonText","isLoading","handleSubmit","errors","help","lodash","handleChange","required","description","rows","controlId","validationState","options","formattedEventNotificationTypes","handleTypeChange","clearable","Static","bsSize","disabled","onClick","handleTestTrigger","message","oneOf","shape","bool","string","func","initialValidation","initialTestResult","EventNotificationFormContainer","key","nextNotification","cloneDeep","isDirty","promise","create","errorResponse","body","additional","failed","update","clone","testPromise","test","response","responseMessage","cancel","question","handleCancel","handleTest","EventNotificationActionLinks","show","edit","propTypes"],"mappings":"glDAiCQA,EAA8BC,IAAiBC,IAAI,sBAAnDF,0BACAG,EAAqBF,IAAiBC,IAAI,eAA1CC,iBAEAC,EAAgBC,IAAhBD,YAEFE,E,sQAMJ,WAAYC,GAAO,a,4FAAA,UACjB,cAAMA,IAEDC,MAAQ,CACXC,kBAAcC,GAJC,E,8CAQnB,WAAoB,aACcC,KAAKJ,MAA7BK,EADU,EACVA,O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IAClD,gBAAC,IAAD,CAAQoB,QAAQ,WAAhB,kBAGJ,gBAAC,IAAD,CAAarB,YAAW,kCAA6BC,IACnD,gBAAC,IAAD,CAAemB,GAAIZ,IAAOC,OAAOC,cAAc4G,KAAKrH,IAClD,gBAAC,IAAD,CAAQoB,QAAQ,WAAhB,yBAMR+F,EAA6BG,UAAY,CACvCtH,eAAgB2B,IAAU+D,OAAO7D,YAGpBsF","file":"57e33c6c-61.11b9f72925818240e61d.js","sourcesContent":["/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { LinkContainer } from 'components/graylog/router';\nimport { ButtonToolbar, Col, Row, Button } from 'components/graylog';\nimport { DocumentTitle, IfPermitted, PageHeader, Spinner } from 'components/common';\nimport DocumentationLink from 'components/support/DocumentationLink';\nimport Routes from 'routing/Routes';\nimport DocsHelper from 'util/DocsHelper';\nimport CombinedProvider from 'injection/CombinedProvider';\nimport connect from 'stores/connect';\nimport PermissionsMixin from 'util/PermissionsMixin';\nimport history from 'util/History';\nimport EventNotificationFormContainer from 'components/event-notifications/event-notification-form/EventNotificationFormContainer';\nimport EventNotificationActionLinks from 'components/event-notifications/event-notification-details/EventNotificationActionLinks';\nimport withParams from 'routing/withParams';\n\nconst { EventNotificationsActions } = CombinedProvider.get('EventNotifications');\nconst { CurrentUserStore } = CombinedProvider.get('CurrentUser');\n\nconst { isPermitted } = PermissionsMixin;\n\nclass EditEventDefinitionPage extends React.Component {\n static propTypes = {\n params: PropTypes.object.isRequired,\n currentUser: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n notification: undefined,\n };\n }\n\n componentDidMount() {\n const { params, currentUser } = this.props;\n\n if (isPermitted(currentUser.permissions, `eventnotifications:edit:${params.notificationId}`)) {\n EventNotificationsActions.get(params.notificationId)\n .then(\n (notification) => this.setState({ notification: notification }),\n (error) => {\n if (error.status === 404) {\n history.push(Routes.ALERTS.NOTIFICATIONS.LIST);\n }\n },\n );\n }\n }\n\n render() {\n const { notification } = this.state;\n const { params, currentUser } = this.props;\n\n if (!isPermitted(currentUser.permissions, `eventnotifications:edit:${params.notificationId}`)) {\n history.push(Routes.NOTFOUND);\n }\n\n if (!notification) {\n return (\n \n \n \n \n \n \n \n );\n }\n\n return (\n \n \n }>\n \n Notifications alert you of any configured Event when they occur. Graylog can send Notifications directly\n to you or to other systems you use for that purpose.\n \n\n \n Graylog's new Alerting system let you define more flexible and powerful rules. Learn more in the{' '}\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n
\n \n \n \n \n \n );\n }\n}\n\nexport default connect(withParams(EditEventDefinitionPage), {\n currentUser: CurrentUserStore,\n},\n({ currentUser }) => ({ currentUser: currentUser.currentUser }));\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport lodash from 'lodash';\nimport { PluginStore } from 'graylog-web-plugin/plugin';\n\nimport { Alert, Button, ButtonToolbar, Col, ControlLabel, FormControl, FormGroup, HelpBlock, Row } from 'components/graylog';\nimport { Select, Spinner } from 'components/common';\nimport { Input } from 'components/bootstrap';\nimport { getValueFromInput } from 'util/FormsUtils';\n\nclass EventNotificationForm extends React.Component {\n static propTypes = {\n action: PropTypes.oneOf(['create', 'edit']),\n notification: PropTypes.object.isRequired,\n validation: PropTypes.object.isRequired,\n testResult: PropTypes.shape({\n isLoading: PropTypes.bool,\n error: PropTypes.bool,\n message: PropTypes.string,\n }).isRequired,\n formId: PropTypes.string,\n embedded: PropTypes.bool.isRequired,\n onChange: PropTypes.func.isRequired,\n onCancel: PropTypes.func.isRequired,\n onSubmit: PropTypes.func.isRequired,\n onTest: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n action: 'edit',\n formId: undefined,\n };\n\n handleSubmit = (event) => {\n const { notification, onSubmit } = this.props;\n\n event.preventDefault();\n\n onSubmit(notification);\n };\n\n handleChange = (event) => {\n const { name } = event.target;\n const { onChange } = this.props;\n\n onChange(name, getValueFromInput(event.target));\n };\n\n handleConfigChange = (nextConfig) => {\n const { onChange } = this.props;\n\n onChange('config', nextConfig);\n };\n\n getNotificationPlugin = (type) => {\n if (type === undefined) {\n return {};\n }\n\n return PluginStore.exports('eventNotificationTypes').find((n) => n.type === type) || {};\n };\n\n handleTypeChange = (nextType) => {\n const notificationPlugin = this.getNotificationPlugin(nextType);\n const defaultConfig = notificationPlugin.defaultConfig || {};\n\n this.handleConfigChange({ ...defaultConfig, type: nextType });\n };\n\n handleTestTrigger = () => {\n const { notification, onTest } = this.props;\n\n onTest(notification);\n };\n\n formattedEventNotificationTypes = () => {\n return PluginStore.exports('eventNotificationTypes')\n .map((type) => ({ label: type.displayName, value: type.type }));\n };\n\n render() {\n const { action, embedded, formId, notification, onCancel, validation, testResult } = this.props;\n\n const notificationPlugin = this.getNotificationPlugin(notification.config.type);\n const notificationFormComponent = notificationPlugin.formComponent\n ? React.createElement(notificationPlugin.formComponent, {\n config: notification.config,\n onChange: this.handleConfigChange,\n validation: validation,\n })\n : null;\n\n const testButtonText = testResult.isLoading ? : 'Execute Test Notification';\n\n return (\n \n
\n \n \n \n );\n }\n}\n\nexport default EventNotificationForm;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport lodash from 'lodash';\n\nimport { ConfirmLeaveDialog } from 'components/common';\nimport history from 'util/History';\nimport Routes from 'routing/Routes';\nimport CombinedProvider from 'injection/CombinedProvider';\n\nimport EventNotificationForm from './EventNotificationForm';\n\n// Import built-in Event Notification Types\nimport {} from '../event-notification-types';\n\nconst { EventNotificationsActions } = CombinedProvider.get('EventNotifications');\n\nconst initialValidation = {\n errors: {},\n};\n\nconst initialTestResult = {\n isLoading: false,\n};\n\nclass EventNotificationFormContainer extends React.Component {\n static propTypes = {\n action: PropTypes.oneOf(['create', 'edit']),\n notification: PropTypes.object,\n /** Controls whether the form should be embedded into another one, and submitted/cancel externally */\n embedded: PropTypes.bool,\n /** Controls the ID of the form, so it can be controlled externally */\n formId: PropTypes.string,\n onSubmit: PropTypes.func,\n };\n\n static defaultProps = {\n action: 'edit',\n notification: {\n title: '',\n description: '',\n config: {},\n },\n embedded: false,\n formId: undefined,\n onSubmit: () => {},\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n notification: props.notification,\n validation: initialValidation,\n testResult: initialTestResult,\n isDirty: false,\n };\n }\n\n componentWillUnmount() {\n // Test request may take a while to return a result, cancel the promise before leaving the page.\n if (this.testPromise) {\n this.testPromise.cancel();\n }\n }\n\n handleChange = (key, value) => {\n const { notification } = this.state;\n const nextNotification = lodash.cloneDeep(notification);\n\n nextNotification[key] = value;\n this.setState({ notification: nextNotification, isDirty: true, testResult: initialTestResult });\n };\n\n handleCancel = () => {\n history.push(Routes.ALERTS.NOTIFICATIONS.LIST);\n };\n\n handleSubmit = () => {\n const { action, embedded, onSubmit } = this.props;\n const { notification } = this.state;\n\n let promise;\n\n if (action === 'create') {\n promise = EventNotificationsActions.create(notification);\n\n promise.then(\n () => {\n this.setState({ isDirty: false }, () => {\n if (!embedded) {\n history.push(Routes.ALERTS.NOTIFICATIONS.LIST);\n }\n });\n },\n (errorResponse) => {\n const { body } = errorResponse.additional;\n\n if (errorResponse.status === 400 && body && body.failed) {\n this.setState({ validation: body });\n }\n },\n );\n } else {\n promise = EventNotificationsActions.update(notification.id, notification);\n\n promise.then(\n () => {\n this.setState({ isDirty: false }, () => {\n if (!embedded) {\n history.push(Routes.ALERTS.NOTIFICATIONS.LIST);\n }\n });\n },\n (errorResponse) => {\n const { body } = errorResponse.additional;\n\n if (errorResponse.status === 400 && body && body.failed) {\n this.setState({ validation: body });\n }\n },\n );\n }\n\n onSubmit(promise);\n };\n\n handleTest = () => {\n const { notification } = this.state;\n\n this.setState({ testResult: { isLoading: true }, validation: initialValidation });\n const testResult = lodash.clone(initialTestResult);\n\n this.testPromise = EventNotificationsActions.test(notification);\n\n this.testPromise\n .then(\n (response) => {\n testResult.error = false;\n testResult.message = 'Notification was executed successfully.';\n\n return response;\n },\n (errorResponse) => {\n testResult.error = true;\n const { body } = errorResponse.additional;\n\n if (errorResponse.status === 400 && body && body.failed) {\n testResult.message = 'Validation failed, please correct any errors in the form before continuing.';\n this.setState({ validation: body });\n } else {\n testResult.message = errorResponse.responseMessage || 'Unknown error, please check your Graylog server logs.';\n }\n },\n )\n .finally(() => {\n this.setState({ testResult: testResult });\n this.testPromise = undefined;\n });\n };\n\n render() {\n const { action, embedded, formId } = this.props;\n const { notification, validation, testResult, isDirty } = this.state;\n\n return (\n <>\n {!embedded && isDirty && (\n \n )}\n \n >\n );\n }\n}\n\nexport default EventNotificationFormContainer;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { LinkContainer } from 'components/graylog/router';\nimport { IfPermitted } from 'components/common';\nimport { Button, ButtonToolbar } from 'components/graylog';\nimport Routes from 'routing/Routes';\n\nconst EventNotificationActionLinks = ({ notificationId }) => (\n \n \n \n \n \n \n \n \n \n \n \n \n);\n\nEventNotificationActionLinks.propTypes = {\n notificationId: PropTypes.string.isRequired,\n};\n\nexport default EventNotificationActionLinks;\n"],"sourceRoot":""}