import React from 'react'; import Form from "react-jsonschema-form"; import fetchError from './fetcherror'; const schema = { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "enable": { "title": "Enabled?", "type": "boolean" }, "exitOnComplete": { "title": "Exit server on completion?", "type": "boolean" }, "exitCode": { "title": "Exit code when exiting. 0 is success.", "type": "integer" }, "numToGen": { "title": "Number of keys to generate. 0 is infinite.", "type": "integer" }, "timeToRun": { "title": "Time to run, in seconds. 0 is infinite.", "type": "integer" }, "memQServer": { "title": "Base URL of the MemQ server to draw from. Can be http://localhost:8080/memq/server.", "type": "string" }, "memQQueue": { "title": "The Queue to pull work items from.", "type": "string" } } }; const uiSchema = { enable: { classNames: "foo" } } export default class KeyGen extends React.Component { constructor(props) { super(props); this.state = { config: { enable: false, numToGen: 0, timeToRun: 0, exitOnComplete: false, exitCode: 0 }, history: [] }; this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } loadState(initial) { fetch(this.props.serverPath) .then(fetchError) .then(response => response.json()) .then(response => { if(initial) { this.setState(response); } else { this.setState(state => { state.history = response.history return state }) } }) .catch(err => this.context.reportConnError()); } componentDidMount() { this.loadState(true) this.timer = setInterval(this.loadState.bind(this, false), 1000); } componentWillUnmount() { clearInterval(this.timer); } handleSubmit(event) { let payload = JSON.stringify(this.state.config); fetch(this.props.serverPath, { method: "PUT", body: payload }) .then(fetchError) .then(response => response.json()) .then(response => this.setState(previousState => { previousState = response return previousState })) .catch(err => this.context.reportConnError()); } handleChange({formData}) { this.setState(state => { state.config = formData; return state }) } render () { let history =

No recorded workload history

if (this.state.history.length > 0) { let historyItems = []; for (let h of this.state.history) { historyItems.push({h.data}{"\n"}) } historyItems.reverse() history = (
{historyItems}
) } return (
KeyGen Synthetic Workload
This controls a synthetic workload on the server: creating 4096 bit RSA key pairs. These parameters control how many to create and, optionally, cause the server to exit with a specific exit code.
{history}
) } } KeyGen.propTypes = { serverPath: React.PropTypes.string.isRequired, } KeyGen.contextTypes = { reportConnError: React.PropTypes.func };