This repository has been archived by the owner on May 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stats page with application status summary
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import axios from 'axios' | ||
|
||
class statApi { | ||
static getApplicationSummary() { | ||
return axios.get('/stat/applicationSummary') | ||
.then((response) => { | ||
return response.data | ||
}) | ||
} | ||
} | ||
|
||
export default statApi |
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,34 @@ | ||
import React, { PropTypes } from 'react' | ||
import { Glyphicon } from 'react-bootstrap' | ||
|
||
function displayApplicationCount(count) { | ||
return count ? count : 0 | ||
} | ||
|
||
function getApplicationTotal() { | ||
let applicationTotal = 0 | ||
for (let index = 0; index < arguments.length; index++) { | ||
if (typeof arguments[index] === 'number') { | ||
applicationTotal += arguments[index] | ||
} | ||
} | ||
return applicationTotal | ||
} | ||
|
||
const ApplicationSummaryRow = ({ applicationSummary }) => { | ||
return ( | ||
<tr> | ||
<td>{ applicationSummary.name }</td> | ||
<td>{ displayApplicationCount(applicationSummary.sent) }</td> | ||
<td>{ displayApplicationCount(applicationSummary.accepted) }</td> | ||
<td>{ displayApplicationCount(applicationSummary.refused) }</td> | ||
<td>{ getApplicationTotal(applicationSummary.accepted, applicationSummary.refused, applicationSummary.sent) }</td> | ||
</tr> | ||
) | ||
} | ||
|
||
ApplicationSummaryRow.propTypes = { | ||
applicationSummary: PropTypes.object.isRequired | ||
} | ||
|
||
export default ApplicationSummaryRow |
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,28 @@ | ||
import React, { PropTypes } from 'react' | ||
import { Glyphicon } from 'react-bootstrap' | ||
import ApplicationSummaryRow from './ApplicationSummaryRow' | ||
|
||
const ApplicationSummaryTable = ({ applicationSummaryList }) => { | ||
return ( | ||
<table className="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Pepite</th> | ||
<th>En attente</th> | ||
<th>Acceptées</th> | ||
<th>Refusées</th> | ||
<th>Total</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{applicationSummaryList.map((applicationSummary, i) => { return (<ApplicationSummaryRow key={i} applicationSummary={applicationSummary} />) })} | ||
</tbody> | ||
</table> | ||
) | ||
} | ||
|
||
ApplicationSummaryTable.propTypes = { | ||
applicationSummaryList: PropTypes.array.isRequired | ||
} | ||
|
||
export default ApplicationSummaryTable |
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,35 @@ | ||
import React, { PropTypes } from 'react' | ||
import { Panel } from 'react-bootstrap' | ||
|
||
import statApi from '../../api/statApi' | ||
import ApplicationSummaryTable from './ApplicationSummaryTable' | ||
|
||
class StatPage extends React.Component { | ||
constructor(props, context) { | ||
super(props, context) | ||
this.state = { | ||
applicationSummary: [] | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
statApi.getApplicationSummary().then(((applicationSummary) => { | ||
this.setState({ applicationSummary }) | ||
})) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="container"> | ||
<div className="page-header"> | ||
<h1>Métriques du service</h1> | ||
<Panel header="Candidatures par PEPITE"> | ||
<ApplicationSummaryTable applicationSummaryList={this.state.applicationSummary} /> | ||
</Panel> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default StatPage |
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