You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
React
64 lines
1.2 KiB
React
4 years ago
|
import React from 'react';
|
||
|
|
||
|
export default class Env extends React.Component {
|
||
|
constructor(props) {
|
||
|
super(props);
|
||
|
this.state = {
|
||
|
commandLine: [],
|
||
|
env: {}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
loadState() {
|
||
|
fetch(this.props.apiPath)
|
||
|
.then(response => response.json())
|
||
|
.then(response => this.setState(response));
|
||
|
}
|
||
|
|
||
|
componentDidMount() {
|
||
|
this.loadState()
|
||
|
}
|
||
|
|
||
|
|
||
|
render () {
|
||
|
let args = [];
|
||
|
for (let [idx, arg] of this.state.commandLine.entries()) {
|
||
|
args.push(<code key={idx}>{arg}</code>)
|
||
|
args.push(" ")
|
||
|
}
|
||
|
|
||
|
let rows = [];
|
||
|
for (let k in this.state.env) {
|
||
|
rows.push(
|
||
|
<tr key={k}>
|
||
|
<td><samp>{k}</samp></td>
|
||
|
<td><samp>{this.state.env[k]}</samp></td>
|
||
|
</tr>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div>
|
||
|
<dl>
|
||
|
<dt>Command Line</dt>
|
||
|
<dd>{args}</dd>
|
||
|
</dl>
|
||
|
<table className="table table-condensed table-bordered">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Key</th><th>Value</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
{rows}
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Env.propTypes = {
|
||
|
apiPath: React.PropTypes.string.isRequired,
|
||
|
}
|