Max Red - Create stats state, and display correct values in the toggle list [skip ci]

This commit is contained in:
ivan 2017-01-14 15:15:26 -03:00
parent 1e69e6f4f8
commit 8c50cc97c9
3 changed files with 60 additions and 8 deletions

View File

@ -29,10 +29,10 @@ class StatsChart extends React.Component {
let labels = this.getLabels();
let color = {
'CREATE_TICKET': 'rgba(150, 20, 20, 0.8)',
'CLOSE': 'rgba(20, 150, 20, 0.8)',
'CLOSE': 'rgba(150, 20, 20, 0.8)',
'CREATE_TICKET': 'rgba(20, 150, 20, 0.8)',
'SIGNUP': 'rgba(20, 20, 150, 0.8)',
'COMMENT': 'rgba(150, 150, 20, 0.8)'
'COMMENT': 'rgba(20, 200, 200, 0.8)'
};
let datasets = [];

View File

@ -1,6 +1,7 @@
import React from 'react';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
import Header from 'core-components/header';
import DropDown from 'core-components/drop-down';
@ -10,6 +11,19 @@ import StatsChart from 'app/admin/panel/dashboard/admin-panel-stats-chart';
class AdminPanelStats extends React.Component {
state = {
stats: {
'CLOSE': 0,
'CREATE_TICKET': 0,
'SIGNUP': 0,
'COMMENT': 0
}
};
componentDidMount() {
this.retrieve();
}
render() {
return (
<div>
@ -22,19 +36,36 @@ class AdminPanelStats extends React.Component {
}
getToggleListProps() {
console.log('LALA: ' + this.state.stats);
return {
items: [
{
content: <div></div>
content:
<div>
{this.state.stats['CREATE_TICKET']}
<div>{i18n('CHART_CREATE_TICKET')}</div>
</div>
},
{
content: <div></div>
content:
<div>
{this.state.stats['CLOSE']}
<div>{i18n('CHART_CLOSE')}</div>
</div>
},
{
content: <div></div>
content:
<div>
{this.state.stats['SIGNUP']}
<div>{i18n('CHART_SIGNUP')}</div>
</div>
},
{
content: <div></div>
content:
<div>
{this.state.stats['COMMENT']}
<div>{i18n('CHART_COMMENT')}</div>
</div>
}
]
};
@ -68,7 +99,7 @@ class AdminPanelStats extends React.Component {
display: 7,
strokes: [
{
name: 'CREATE_TICKET',
name: 'COMMENT',
show: true,
values: [
{
@ -172,6 +203,26 @@ class AdminPanelStats extends React.Component {
]
}
}
retrieve() {
API.call({
path: '/system/get-stats',
data: {}
}).then(this.onRetrieveSuccess.bind(this));
}
onRetrieveSuccess(result) {
let newState = {
'CLOSE': 0,
'CREATE_TICKET': 0,
'SIGNUP': 0,
'COMMENT': 0
};
for (let i = 0; i < result.data.length; i++) {
newState[result.data[i].type] += result.data[i].value * 1;
}
this.setState({stats: newState});
}
}
export default AdminPanelStats;

View File

@ -154,6 +154,7 @@ export default {
'VERIFY_FAILED': 'Could not verify',
'TICKET_ACTIVITY': 'Ticket Activity',
'CHART_CREATE_TICKET': 'Tickets created',
'CHART_CLOSE': 'Tickets closed',
'CHART_SIGNUP': 'Signups',