partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 1b3fedbf1f5279f1e0976d3d3d143dc3e2d63401
parent 0f39e79b2bb400844ac406f14afcb60d9ea2da2c
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed,  4 Jan 2012 21:24:40 +0100

Added some checks to the statistics chart where possible JS errors could be thrown.

Diffstat:
Msrc/frontend/js/Components/Statistics/StatisticsChart.js | 18+++++++++++++++++-
Msrc/frontend/js/Components/Statistics/StatisticsChartPanel.js | 7+++++++
2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/frontend/js/Components/Statistics/StatisticsChart.js b/src/frontend/js/Components/Statistics/StatisticsChart.js @@ -113,7 +113,7 @@ Ext.define('PartKeepr.StatisticsChart', { "service": "Statistic", "call": "getSampledStatistics", "startDateTime": "2011-01-01 00:00:00", - "endDateTime": "2011-12-01 00:00:00" + "endDateTime": "2011-12-01 23:59:59" }, headers: { session :PartKeepr.getApplication().getSession() @@ -124,10 +124,26 @@ Ext.define('PartKeepr.StatisticsChart', { this.callParent(); }, + /** + * Sets the start date for the chart. Does not trigger a reload of the dataset. + * @param date A valid date object + */ setStart: function (date) { + if (!(date instanceof Date)) { return; } this.store.getProxy().extraParams.startDateTime = Ext.Date.format(date, "Y-m-d H:i:s"); }, + /** + * Sets the end date for the chart. Does not trigger a reload of the dataset. + * @param date A valid date object + */ setEnd: function (date) { + if (!(date instanceof Date)) { return; } + + // Always set the end date to the end of the day + date.setHours(23); + date.setMinutes(59); + date.setSeconds(59); + this.store.getProxy().extraParams.endDateTime = Ext.Date.format(date, "Y-m-d H:i:s"); } }); \ No newline at end of file diff --git a/src/frontend/js/Components/Statistics/StatisticsChartPanel.js b/src/frontend/js/Components/Statistics/StatisticsChartPanel.js @@ -40,6 +40,13 @@ Ext.define('PartKeepr.StatisticsChartPanel', { call.doCall(); }, onReloadDates: function (data) { + if (data.data.start === null || data.data.end === null) { + Ext.Msg.alert( + i18n("Unable to retrieve the statistic data"), + i18n("The system was unable to retrieve the statistic data. The most probable cause is that the CreateStatisticSnapshot.php cronjob is not running.")); + return; + } + var start = Ext.Date.parse(data.data.start, "Y-m-d H:i:s"); var end = Ext.Date.parse(data.data.end, "Y-m-d H:i:s");