diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 3e6c582b..52d25748 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -44,7 +44,7 @@ class StatsChart extends React.Component { label: i18n('CHART_' + stroke.name), data: stroke.values.map((val) => val.value), fill: false, - borderWidth: 4, + borderWidth: 4, // ESTO PODRIA CAMBIAR DEPENDIENDO DEL PERIOD, MIENTRA MAS HALLA, DEBERIA SER MAS FINO borderColor: color[stroke.name], pointBorderColor: color[stroke.name], pointRadius: 0, @@ -80,7 +80,7 @@ class StatsChart extends React.Component { if (this.props.period === 7) return 20; if (this.props.period === 30) return 15; if (this.props.period === 90) return 10; - return 3; + return 1; } getChartOptions() { diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 74843f6a..f84956a2 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -45,7 +45,7 @@ class AdminPanelStats extends React.Component { }; componentDidMount() { - this.retrieve(); + this.retrieve(7); } render() { @@ -90,10 +90,15 @@ class AdminPanelStats extends React.Component {
{i18n('CHART_COMMENT')}
} - ] + ], + onChange: this.onToggleListChange.bind(this) }; } + onToggleListChange(data) { + + } + getDropDownProps() { return { items: [ @@ -113,133 +118,58 @@ class AdminPanelStats extends React.Component { content: 'Last 365 days', icon: '' } - ] + ], + onChange: this.onDropDownChange.bind(this) } } + onDropDownChange(event) { + console.log('DROP DOWN HAS CHANGED'); + let val = [7, 30, 90, 365]; + + this.retrieve(val[event.index]); + } + getStatsChartProps() { - - console.log('This is the shit'); - console.log(this.state.strokes); - return { period: this.state.period, strokes: this.state.strokes - /*strokes: [ - { - name: 'COMMENT', - show: true, - values: [ - { - date: "20160420", - value: 17 - }, - { - date: "20160421", - value: 15 - }, - { - date: "20160422", - value: 12 - }, - { - date: "20160423", - value: 9 - }, - { - date: "20160424", - value: 10 - }, - { - date: "20160425", - value: 7 - }, - { - date: "20160426", - value: 5 - } - ] - }, - { - name: 'SIGNUP', - show: true, - values: [ - { - date: "20160420", - value: 3 - }, - { - date: "20160421", - value: 5 - }, - { - date: "20160422", - value: 3 - }, - { - date: "20160423", - value: 4 - }, - { - date: "20160424", - value: 5 - }, - { - date: "20160425", - value: 5 - }, - { - date: "20160426", - value: 6 - } - ] - }, - { - name: 'CLOSE', - show: true, - values: [ - { - date: "20160420", - value: 4 - }, - { - date: "20160421", - value: 7 - }, - { - date: "20160422", - value: 4 - }, - { - date: "20160423", - value: 7 - }, - { - date: "20160424", - value: 9 - }, - { - date: "20160425", - value: 11 - }, - { - date: "20160426", - value: 13 - } - ] - } - ]*/ } } - retrieve() { + retrieve(period) { + console.log('THIS SHOULD NOT BE DISPLAYED'); + + let periodName; + switch (period) { + case 30: + periodName = 'MONTH'; + break; + case 90: + periodName = 'QUARTER'; + break; + case 365: + periodName = 'YEAR'; + break; + default: + periodName = 'WEEK'; + } + + console.log('--------------------------------------------period: ' + this.state.period); + console.log('--------------------------------------------PERIOD NAME: ' + periodName); + API.call({ path: '/system/get-stats', - data: {} - }).then(this.onRetrieveSuccess.bind(this)); + data: { + period: periodName + } + }).then(this.onRetrieveSuccess.bind(this, period)); } - onRetrieveSuccess(result) { + onRetrieveSuccess(period, result) { + + console.log('This is the shit you SHOULD look at!'); + console.log(result); let newState = { 'CLOSE': 0, @@ -287,7 +217,7 @@ class AdminPanelStats extends React.Component { }); } - this.setState({stats: newState, strokes: newStrokes, period: 7}); + this.setState({stats: newState, strokes: newStrokes, period: period}); } } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 76200c6c..06b087fd 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -160,10 +160,52 @@ module.exports = [ { path: '/system/get-stats', time: 200, - response: function() { + response: function(_data) { + let ID = { + 'WEEK': 7, + 'MONTH': 30, + 'QUARTER': 90, + 'YEAR': 365 + }; + + let k = ID[_data.period]; + let DATA = []; + + for (let i = 0; i < k; i++) { + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'COMMENT', + general: 1, + value: (4 + i + Math.floor(Math.random() * 2)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'SIGNUP', + general: 1, + value: (9 + i + Math.floor(Math.random() * (i / 15))).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CLOSE', + general: 1, + value: (8 + i + Math.floor(Math.random() * i)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CREATE_TICKET', + general: 1, + value: (10 + Math.floor(Math.random() * 4)).toString() + }); + } + + console.log('DATA:'); + console.log(DATA); + console.log(k); + return { status: "success", - data: [ + data: DATA + /*data: [ { "date": "20170112", "type": "COMMENT", @@ -332,7 +374,7 @@ module.exports = [ "general": "1", "value": "5" } - ] + ]*/ }; } },