aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-10-06 09:34:00 +0500
committerAbyss777 <abyss@fox5.ru>2017-10-06 09:34:00 +0500
commitdf9b799cbfd51c24158bb16ca5b37105a390a5d3 (patch)
tree72a60fd7892bfe89a43763d5af939600166225b4 /web/app/view
parenteb23cc04e645ee72cdf833b712476f07231ea098 (diff)
downloadtrackermap-web-df9b799cbfd51c24158bb16ca5b37105a390a5d3.tar.gz
trackermap-web-df9b799cbfd51c24158bb16ca5b37105a390a5d3.tar.bz2
trackermap-web-df9b799cbfd51c24158bb16ca5b37105a390a5d3.zip
Add quick period selector to Report Config dialog
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/dialog/ReportConfig.js11
-rw-r--r--web/app/view/dialog/ReportConfigController.js30
2 files changed, 41 insertions, 0 deletions
diff --git a/web/app/view/dialog/ReportConfig.js b/web/app/view/dialog/ReportConfig.js
index 836b6050..cdf11e1c 100644
--- a/web/app/view/dialog/ReportConfig.js
+++ b/web/app/view/dialog/ReportConfig.js
@@ -102,6 +102,17 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
reference: 'toTimeField',
value: new Date()
}]
+ }, {
+ fieldLabel: Strings.reportPeriod,
+ xtype: 'combobox',
+ store: 'ReportPeriods',
+ editable: false,
+ valueField: 'key',
+ displayField: 'name',
+ queryMode: 'local',
+ listeners: {
+ change: 'onPeriodChange'
+ }
}],
buttons: [{
diff --git a/web/app/view/dialog/ReportConfigController.js b/web/app/view/dialog/ReportConfigController.js
index ce66371b..2958515e 100644
--- a/web/app/view/dialog/ReportConfigController.js
+++ b/web/app/view/dialog/ReportConfigController.js
@@ -46,5 +46,35 @@ Ext.define('Traccar.view.dialog.ReportConfigController', {
callingPanel.toTime = this.lookupReference('toTimeField').getValue();
callingPanel.updateButtons();
button.up('window').close();
+ },
+
+ onPeriodChange: function (combobox, newValue) {
+ var day, first, from = new Date(), to = new Date();
+ switch (newValue) {
+ case 'today':
+ to.setDate(to.getDate() + 1);
+ break;
+ case 'yesterday':
+ from.setDate(to.getDate() - 1);
+ break;
+ case 'thisWeek':
+ day = from.getDay();
+ first = from.getDate() - day + (day === 0 ? -6 : 1);
+ from.setDate(first);
+ to.setDate(first + 7);
+ break;
+ case 'thisMonth':
+ from.setDate(1);
+ to.setDate(1);
+ to.setMonth(from.getMonth() + 1);
+ break;
+ default:
+ }
+ from.setHours(0, 0, 0, 0);
+ to.setHours(0, 0, 0, 0);
+ this.lookupReference('fromDateField').setValue(from);
+ this.lookupReference('fromTimeField').setValue(from);
+ this.lookupReference('toDateField').setValue(to);
+ this.lookupReference('toTimeField').setValue(to);
}
});