-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a two-step configuration wizard, modified navbar to change co…
…nfiguration Also modified the splunk-local target in Makefile to depend on the venv and disable caching locally. Created a Rest API handler to be able to call the Flare SDK endpoints from Javascript Created a Home page with Lorem Ipsum Formatted javascript files
- Loading branch information
Marc-Antoine Hinse
committed
Oct 25, 2024
1 parent
ebddaba
commit f4098e2
Showing
17 changed files
with
449 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// The number of spaces a tab is equal to. This setting is overridden | ||
// based on the file contents when `editor.detectIndentation` is true. | ||
"editor.tabSize": 4, | ||
|
||
// Insert spaces when pressing Tab. This setting is overriden | ||
// based on the file contents when `editor.detectIndentation` is true. | ||
"editor.insertSpaces": true, | ||
|
||
// When opening a file, `editor.tabSize` and `editor.insertSpaces` | ||
// will be detected based on the file contents. Set to false to keep | ||
// the values you've explicitly set, above. | ||
"editor.detectIndentation": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 102 additions & 39 deletions
141
flare_splunk_integration/appserver/static/javascript/views/app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,113 @@ | ||
import * as Setup from "./setupConfiguration.js"; | ||
|
||
define(["react", "splunkjs/splunk"], function(react, splunkSdk){ | ||
const e = react.createElement; | ||
define(["react", "splunkjs/splunk"], function (react, splunkSdk) { | ||
const e = react.createElement; | ||
|
||
class SetupPage extends react.Component { | ||
constructor(props) { | ||
super(props); | ||
class SetupPage extends react.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
serverKey: '', | ||
tenantId: '', | ||
}; | ||
this.state = { | ||
serverKey: '', | ||
tenantId: '', | ||
tenants: [], | ||
errorMessage: '', | ||
isLoading: false, | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
} | ||
this.handleChangeServerKey = this.handleChangeServerKey.bind(this); | ||
this.handleChangeTenantId = this.handleChangeTenantId.bind(this); | ||
this.handleSubmitServerKey = this.handleSubmitServerKey.bind(this); | ||
this.handleSubmitTenant = this.handleSubmitTenant.bind(this); | ||
} | ||
|
||
handleChange(event) { | ||
this.setState({ ...this.state, [event.target.name]: event.target.value}); | ||
} | ||
handleChangeServerKey(event) { | ||
this.setState({ ...this.state, ["serverKey"]: event.target.value }); | ||
} | ||
|
||
async handleSubmit(event) { | ||
event.preventDefault(); | ||
handleChangeTenantId(event) { | ||
this.setState({ ...this.state, ["tenantId"]: event.target.value }); | ||
} | ||
|
||
async handleSubmitServerKey(event) { | ||
event.preventDefault(); | ||
this.setState({ ...this.state, ["isLoading"]: true }); | ||
Setup.retrieveUserTenants(splunkSdk, this.state.serverKey, (user_tenants) => { | ||
if (this.state.tenantId === '' && user_tenants.tenants.length > 0) { | ||
this.state.tenantId = user_tenants.tenants[0].id; | ||
} | ||
this.state.errorMessage = ''; | ||
this.setState({ ...this.state, ["tenants"]: user_tenants.tenants }); | ||
this.setState({ ...this.state, ["isLoading"]: false }); | ||
}, (error) => { | ||
this.setState({ ...this.state, ["errorMessage"]: error }); | ||
this.setState({ ...this.state, ["isLoading"]: false }); | ||
}); | ||
} | ||
|
||
async handleSubmitTenant(event) { | ||
event.preventDefault(); | ||
this.setState({ ...this.state, ["isLoading"]: true }); | ||
await Setup.saveConfiguration(splunkSdk, this.state.serverKey, this.state.tenantId); | ||
} | ||
|
||
componentDidMount() { | ||
this.setState({ ...this.state, ["isLoading"]: true }); | ||
Setup.retrieveServerKey(splunkSdk).then((serverKey) => { | ||
this.setState({ ...this.state, ["serverKey"]: serverKey }); | ||
Setup.retrieveTenantId(splunkSdk).then((tenantId) => { | ||
this.setState({ ...this.state, ["tenantId"]: tenantId }); | ||
this.setState({ ...this.state, ["isLoading"]: false }); | ||
}); | ||
}); | ||
} | ||
|
||
render() { | ||
if (this.state.isLoading) { | ||
return e('div', null, 'Loading...'); | ||
} | ||
|
||
if (this.state.tenants.length == 0 || this.state.serverKey == '') { | ||
return e("div", null, [ | ||
e("h2", null, "Enter your API Key"), | ||
e("p", null, "A new API Key can be generated by going on your profile page in Flare"), | ||
e("p", { class: "error" }, this.state.errorMessage), | ||
e("div", null, [ | ||
e("form", { onSubmit: this.handleSubmitServerKey }, [ | ||
e("label", null, [ | ||
"Server API Key ", | ||
e("input", { type: "password", name: "serverKey", value: this.state.serverKey, onChange: this.handleChangeServerKey }) | ||
]), | ||
e("input", { type: "submit", value: "Next Step" }) | ||
]) | ||
]) | ||
]); | ||
} else { | ||
const tenantOptions = []; | ||
for (let i = 0; i < this.state.tenants.length; i++) { | ||
tenantOptions.push( | ||
e('option', { key: i, value: this.state.tenants[i].id }, this.state.tenants[i].name) | ||
); | ||
} | ||
return e("div", null, [ | ||
e("h2", null, "Please select the Tenant you want to ingest events from"), | ||
e("p", { class: "error" }, this.state.errorMessage), | ||
e("div", null, [ | ||
e("form", { onSubmit: this.handleSubmitTenant }, [ | ||
e( | ||
'select', | ||
{ name: 'tenantsDropdown', value: this.state.tenantId, onChange: this.handleChangeTenantId }, | ||
...tenantOptions | ||
), | ||
e("br"), | ||
e("input", { type: "submit", value: "Submit" }) | ||
]) | ||
]) | ||
]); | ||
} | ||
} | ||
|
||
await Setup.saveConfiguration(splunkSdk, this.state.serverKey, this.state.tenantId); | ||
} | ||
render() { | ||
return e("div", null, [ | ||
e("h2", null, "Add a server key and tenant ID to complete app setup."), | ||
e("div", null, [ | ||
e("form", { onSubmit: this.handleSubmit }, [ | ||
e("label", null, [ | ||
"Server API Key ", | ||
e("input", { type: "password", name: "serverKey", value: this.state.serverKey, onChange: this.handleChange }) | ||
]), | ||
e("label", null, [ | ||
"Tenant ID ", | ||
e("input", { type: "number", name: "tenantId", value: this.state.tenantId, onChange: this.handleChange }) | ||
]), | ||
e("input", { type: "submit", value: "Submit" }) | ||
]) | ||
]) | ||
]); | ||
} | ||
|
||
} | ||
|
||
return e(SetupPage); | ||
return e(SetupPage); | ||
}); |
Oops, something went wrong.