Skip to content

Commit 72c15d6

Browse files
committed
Refactor Models tab components into presentational and container components
1 parent f66c14b commit 72c15d6

File tree

10 files changed

+323
-283
lines changed

10 files changed

+323
-283
lines changed

static/js/components/Main.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import ProjectSelector from '../containers/ProjectSelector';
1717
import ProjectTab from '../containers/ProjectTab';
1818
import DatasetsTab from './DatasetsTab';
1919
import FeaturesTab from '../containers/FeaturesTab';
20-
import ModelsTab from './Models';
20+
import ModelsTab from './ModelsTab';
2121
import PredictTab from './Predictions';
2222
import colorScheme from './colorscheme';
2323
import Progress from './Progress';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
5+
const ModelInfo = props => (
6+
<table className="table">
7+
<thead>
8+
<tr>
9+
<th>Model Type</th>
10+
<th>Hyperparameters</th>
11+
<th>Training Data Score</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
<tr>
16+
<td>
17+
{props.model.type}
18+
</td>
19+
<td>
20+
<table>
21+
<tbody>
22+
{
23+
Object.keys(props.model.params).map((param, idx) => (
24+
<tr key={idx}>
25+
<td>{param}</td>
26+
<td style={{ paddingLeft: "5px" }}>{JSON.stringify(props.model.params[param])}</td>
27+
</tr>
28+
))
29+
}
30+
</tbody>
31+
</table>
32+
</td>
33+
<td>
34+
{props.model.train_score}
35+
</td>
36+
</tr>
37+
</tbody>
38+
</table>
39+
);
40+
ModelInfo.propTypes = {
41+
model: PropTypes.object.isRequired
42+
};
43+
44+
export default ModelInfo;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import { TextInput, CheckBoxInput } from '../Form';
5+
6+
7+
const ModelParamsForm = (props) => {
8+
const style = {
9+
};
10+
11+
const { model } = { ...props };
12+
13+
return (
14+
<div style={style}>
15+
<h3>{model.name}</h3>
16+
{model.params.map((param, idx) => {
17+
const pProps = props[param.name];
18+
if (param.type === 'bool') {
19+
return <CheckBoxInput key={idx} label={param.name} {...(pProps)} />;
20+
} else {
21+
return <TextInput key={idx} label={param.name} {...(pProps)} />;
22+
}
23+
})}
24+
</div>
25+
);
26+
};
27+
28+
export default ModelParamsForm;

static/js/components/Models.jsx

Lines changed: 0 additions & 282 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import Expand from '../Expand';
5+
import ModelsTable from '../../containers/ModelsTable';
6+
import NewModelForm from '../../containers/NewModelForm';
7+
8+
9+
const ModelsTab = props => (
10+
<div>
11+
<Expand label="Create New Model" id="newModelExpander">
12+
<NewModelForm selectedProject={props.selectedProject} />
13+
</Expand>
14+
15+
<ModelsTable selectedProject={props.selectedProject} />
16+
</div>
17+
);
18+
ModelsTab.propTypes = {
19+
selectedProject: PropTypes.object
20+
};
21+
ModelsTab.defaultProps = {
22+
selectedProject: null
23+
};
24+
25+
export default ModelsTab;

0 commit comments

Comments
 (0)