-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin screen for viewing the list of stored runs. This also generates the server side run query that will be used by the MAV system as requested in #9
- Loading branch information
1 parent
2b93d55
commit 3a5c92a
Showing
9 changed files
with
157 additions
and
8 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
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,19 @@ | ||
import React, { Fragment } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
function Admin() { | ||
const links = [ | ||
{ path: '/admin/runs', label: 'Runs' }, | ||
]; | ||
return ( | ||
<Fragment> | ||
<div>Admin page</div> | ||
<ul>{links.map(link => ( | ||
<li><Link to={link.path}>{link.label}</Link></li> | ||
))} | ||
</ul> | ||
</Fragment> | ||
); | ||
} | ||
|
||
export default Admin; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.wordwrap { | ||
white-space: pre-line !important; | ||
word-wrap: break-word; | ||
} |
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,85 @@ | ||
import { Query } from 'react-apollo'; | ||
import gql from 'graphql-tag'; | ||
import React from 'react'; | ||
import ReactTable from 'react-table'; | ||
import moment from 'moment'; | ||
import 'react-table/react-table.css'; | ||
import './Runs.css'; | ||
|
||
const GET_RUNS = gql` | ||
query runs($lastX: Int!) { | ||
runs(lastX: $lastX){ | ||
id | ||
start | ||
end | ||
} | ||
} | ||
`; | ||
|
||
function Runs() { | ||
const dateFormat = 'dddd, MMMM Do YYYY, h:mm:ss a'; | ||
return ( | ||
<Query | ||
query={GET_RUNS} | ||
variables={{ lastX: parseInt(10) }} | ||
> | ||
{({ loading, error, data }) => { | ||
if (loading) return 'Loading...'; | ||
if (error) return `Error! ${error.message}`; | ||
return ( | ||
<ReactTable | ||
data={data.runs} | ||
columns={[ | ||
{ | ||
Header: 'Run ID', | ||
accessor: 'id', | ||
}, | ||
{ | ||
Header: 'Start', | ||
accessor: 'start', | ||
className: 'wordwrap', | ||
Cell: row => ( | ||
<div>{moment(row.row.start).format(dateFormat)}</div> | ||
), | ||
}, | ||
{ | ||
Header: 'End', | ||
accessor: 'end', | ||
className: 'wordwrap', | ||
Cell: row => ( | ||
<div> | ||
{ | ||
row.row.end | ||
? moment(row.row.end).format(dateFormat) | ||
: '-' | ||
} | ||
</div> | ||
), | ||
}, | ||
{ | ||
Header: 'Duration', | ||
accessor: 'duration', | ||
Cell: (row) => { | ||
const completed = !!(row.row.start && row.row.end); | ||
const startDate = moment(row.row.start).valueOf(); | ||
const endDate = moment(row.row.end).valueOf(); | ||
const runDuration = endDate - startDate; | ||
return ( | ||
<div> | ||
{completed | ||
? <div>{runDuration}</div> | ||
: <div>-</div> | ||
} | ||
</div>); | ||
}, | ||
}, | ||
]} | ||
/> | ||
); | ||
}} | ||
</Query> | ||
); | ||
} | ||
|
||
export default Runs; | ||
|
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