Skip to content
This repository was archived by the owner on Nov 14, 2020. It is now read-only.

Commit 9927152

Browse files
authored
Merge pull request #4 from MarquezProject/feat/add-job-row-details
Display job / job run details in a dialog
2 parents 501b805 + b1ccb1c commit 9927152

File tree

2 files changed

+162
-31
lines changed

2 files changed

+162
-31
lines changed

src/components/JobDetailsDialog.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { withStyles } from '@material-ui/core/styles';
4+
5+
import Dialog from '@material-ui/core/Dialog';
6+
import DialogActions from '@material-ui/core/DialogActions';
7+
import DialogContent from '@material-ui/core/DialogContent';
8+
import DialogTitle from '@material-ui/core/DialogTitle';
9+
import Button from '@material-ui/core/Button';
10+
11+
import Table from '@material-ui/core/Table';
12+
import TableBody from '@material-ui/core/TableBody';
13+
import TableCell from '@material-ui/core/TableCell';
14+
import TableHead from '@material-ui/core/TableHead';
15+
import TableRow from '@material-ui/core/TableRow';
16+
17+
const styles = theme => ({
18+
root: {
19+
width: '100%',
20+
marginTop: theme.spacing.unit * 3,
21+
overflowX: 'auto',
22+
},
23+
table: {
24+
minWidth: 700,
25+
},
26+
});
27+
28+
function JobRunsTable(props) {
29+
const { classes } = props;
30+
return (
31+
<Table>
32+
<TableHead>
33+
<TableRow>
34+
<TableCell>RUN ARGUMENTS</TableCell>
35+
<TableCell align="right">FINAL STATE</TableCell>
36+
</TableRow>
37+
</TableHead>
38+
<TableBody>
39+
{
40+
props.runs.map(row => (
41+
<TableRow key={row.runId}>
42+
<TableCell component="th" scope="row">
43+
{row.runArgs}
44+
</TableCell>
45+
<TableCell align="right">{row.runState}</TableCell>
46+
</TableRow>
47+
))
48+
}
49+
</TableBody>
50+
</Table>
51+
)
52+
}
53+
54+
function JobDetailsDialog(props) {
55+
return (
56+
<Dialog
57+
fullWidth="sm"
58+
maxWidth="sm"
59+
open={props.open}
60+
onClose={props.onClose}
61+
aria-labelledby="max-width-dialog-title"
62+
>
63+
<DialogTitle id="max-width-dialog-title">Job Details</DialogTitle>
64+
<DialogContent>
65+
<JobRunsTable runs={props.jobDetails.runs} />
66+
</DialogContent>
67+
<DialogActions>
68+
<Button onClick={props.onClose} color="primary">
69+
Close
70+
</Button>
71+
</DialogActions>
72+
</Dialog>
73+
);
74+
}
75+
76+
JobDetailsDialog.propTypes = {
77+
open: PropTypes.bool.isRequired,
78+
onClose: PropTypes.func.isRequired,
79+
jobDetails: PropTypes.object.isRequired
80+
}
81+
82+
JobDetailsDialog.defaultProps = {
83+
open: false,
84+
onClose: function(){},
85+
jobDetails: null
86+
}
87+
88+
export default withStyles(styles)(JobDetailsDialog);

src/components/Tabs.js

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ import Tabs from '@material-ui/core/Tabs';
66
import Tab from '@material-ui/core/Tab';
77
import Typography from '@material-ui/core/Typography';
88
import MUIDataTable from "mui-datatables";
9+
import TableRow from "@material-ui/core/TableRow";
10+
import TableCell from "@material-ui/core/TableCell";
911
import axios from 'axios'
1012

13+
import JobDetailsDialog from './JobDetailsDialog';
14+
15+
1116
function TabContainer(props) {
1217
return (
1318
<Typography component="div" style={{ padding: 8 * 3 }}>
@@ -35,7 +40,8 @@ class SimpleTabs extends React.Component {
3540
value: 0,
3641
jobs: [],
3742
datasets: [],
38-
namespace: null
43+
namespace: null,
44+
jobDetails: {runs: []}
3945
};
4046
}
4147

@@ -47,7 +53,7 @@ class SimpleTabs extends React.Component {
4753
});
4854
axios.get('/api/v1/namespaces/' + namespace + '/datasets/').then((response) => {
4955
const datasetData = response.data
50-
const datasetRows = datasetData.datasets.map(dataset => [dataset.name, dataset.createdAt])
56+
const datasetRows = datasetData.datasets.map(dataset => [dataset.name, dataset.urn, dataset.createdAt])
5157
this.setState({datasets: datasetRows})
5258
});
5359
}
@@ -67,45 +73,82 @@ class SimpleTabs extends React.Component {
6773
this.setState({ value });
6874
};
6975

76+
handleJobRowClick = (rowData, rowState) => {
77+
const jobName = rowData[0]
78+
var jobRuns = []
79+
axios.get('/api/v1/namespaces/' + this.state.namespace + '/jobs/' + jobName + '/runs' ).then((response) => {
80+
jobRuns = response.data;
81+
this.setState(
82+
{
83+
jobDetails: {
84+
runs: jobRuns
85+
}
86+
})
87+
this.setState({showJobDetails: true});
88+
});
89+
}
90+
91+
handleJobDetailsClose = () => {
92+
this.setState({showJobDetails: false});
93+
}
94+
7095
render() {
7196
const { classes } = this.props;
7297
const { value } = this.state;
73-
const jobColumns = ["Name", "Description", "Created At"];
98+
const jobColumns = [
99+
"Name",
100+
"Description",
101+
"Created At"
102+
];
74103
const datasetColumns = ["URN", "Created At"];
75104

76105
const options = {
77106
filter: true,
78-
filterType: 'dropdown'
107+
filterType: 'dropdown',
108+
onRowClick: this.handleJobRowClick
79109
};
80110

81111
return (
82-
<div className={classes.root}>
83-
<AppBar position="static">
84-
<Tabs value={value} onChange={this.handleChange}>
85-
<Tab label="Jobs" />
86-
<Tab label="Datasets" />
87-
</Tabs>
88-
</AppBar>
89-
{value === 0 &&
90-
<TabContainer>
91-
<MUIDataTable
92-
title={"Jobs"}
93-
data={this.state.jobs}
94-
columns={jobColumns}
95-
options={options}
96-
/>
97-
</TabContainer>
98-
}
99-
{value === 1 &&
100-
<TabContainer>
101-
<MUIDataTable
102-
title={"Datasets"}
103-
data={this.state.datasets}
104-
columns={datasetColumns}
105-
options={options}
106-
/>
107-
</TabContainer>
108-
} </div>
112+
<React.Fragment>
113+
<div className={classes.root}>
114+
<AppBar position="static">
115+
<Tabs value={value} onChange={this.handleChange}>
116+
<Tab label="Jobs" />
117+
<Tab label="Datasets" />
118+
</Tabs>
119+
</AppBar>
120+
{value === 0 &&
121+
<TabContainer>
122+
<MUIDataTable
123+
title={"Jobs"}
124+
data={this.state.jobs}
125+
columns={jobColumns}
126+
options={options}
127+
/>
128+
</TabContainer>
129+
}
130+
{value === 1 &&
131+
<TabContainer>
132+
<MUIDataTable
133+
title={"Datasets"}
134+
data={this.state.datasets}
135+
columns={datasetColumns}
136+
options={options}
137+
/>
138+
</TabContainer>
139+
}
140+
</div>
141+
142+
{/* Job Details Dialog */}
143+
<JobDetailsDialog
144+
open={this.state.showJobDetails}
145+
onClose={this.handleJobDetailsClose}
146+
jobDetails={this.state.jobDetails}
147+
/>
148+
149+
150+
{/* Dataset Details Dialog */}
151+
</React.Fragment>
109152
);
110153
}
111154
}

0 commit comments

Comments
 (0)