aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/store/ReportPeriods.js9
-rw-r--r--web/app/view/ReportController.js3
-rw-r--r--web/app/view/dialog/ReportConfig.js5
-rw-r--r--web/app/view/dialog/ReportConfigController.js18
-rw-r--r--web/l10n/en.json3
5 files changed, 38 insertions, 0 deletions
diff --git a/web/app/store/ReportPeriods.js b/web/app/store/ReportPeriods.js
index b9c19f93..542fdce9 100644
--- a/web/app/store/ReportPeriods.js
+++ b/web/app/store/ReportPeriods.js
@@ -21,6 +21,9 @@ Ext.define('Traccar.store.ReportPeriods', {
fields: ['key', 'name'],
data: [{
+ key: 'custom',
+ name: Strings.reportCustom
+ }, {
key: 'today',
name: Strings.reportToday
}, {
@@ -30,7 +33,13 @@ Ext.define('Traccar.store.ReportPeriods', {
key: 'thisWeek',
name: Strings.reportThisWeek
}, {
+ key: 'previousWeek',
+ name: Strings.reportPreviousWeek
+ }, {
key: 'thisMonth',
name: Strings.reportThisMonth
+ }, {
+ key: 'previousMonth',
+ name: Strings.reportPreviousMonth
}]
});
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 6d984de7..80e56ba4 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -128,6 +128,9 @@ Ext.define('Traccar.view.ReportController', {
if (this.toTime !== undefined) {
dialog.lookupReference('toTimeField').setValue(this.toTime);
}
+ if (this.period !== undefined) {
+ dialog.lookupReference('periodField').setValue(this.period);
+ }
dialog.show();
},
diff --git a/web/app/view/dialog/ReportConfig.js b/web/app/view/dialog/ReportConfig.js
index cdf11e1c..67080bf5 100644
--- a/web/app/view/dialog/ReportConfig.js
+++ b/web/app/view/dialog/ReportConfig.js
@@ -75,6 +75,8 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
}, {
xtype: 'fieldcontainer',
layout: 'vbox',
+ reference: 'fromContainer',
+ hidden: true,
fieldLabel: Strings.reportFrom,
items: [{
xtype: 'datefield',
@@ -90,6 +92,8 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
}, {
xtype: 'fieldcontainer',
layout: 'vbox',
+ reference: 'toContainer',
+ hidden: true,
fieldLabel: Strings.reportTo,
items: [{
xtype: 'datefield',
@@ -104,6 +108,7 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
}]
}, {
fieldLabel: Strings.reportPeriod,
+ reference: 'periodField',
xtype: 'combobox',
store: 'ReportPeriods',
editable: false,
diff --git a/web/app/view/dialog/ReportConfigController.js b/web/app/view/dialog/ReportConfigController.js
index 2958515e..17699b98 100644
--- a/web/app/view/dialog/ReportConfigController.js
+++ b/web/app/view/dialog/ReportConfigController.js
@@ -44,6 +44,7 @@ Ext.define('Traccar.view.dialog.ReportConfigController', {
callingPanel.fromTime = this.lookupReference('fromTimeField').getValue();
callingPanel.toDate = this.lookupReference('toDateField').getValue();
callingPanel.toTime = this.lookupReference('toTimeField').getValue();
+ callingPanel.period = this.lookupReference('periodField').getValue();
callingPanel.updateButtons();
button.up('window').close();
},
@@ -51,6 +52,10 @@ Ext.define('Traccar.view.dialog.ReportConfigController', {
onPeriodChange: function (combobox, newValue) {
var day, first, from = new Date(), to = new Date();
switch (newValue) {
+ case 'custom':
+ this.lookupReference('fromContainer').setHidden(false);
+ this.lookupReference('toContainer').setHidden(false);
+ return;
case 'today':
to.setDate(to.getDate() + 1);
break;
@@ -63,11 +68,22 @@ Ext.define('Traccar.view.dialog.ReportConfigController', {
from.setDate(first);
to.setDate(first + 7);
break;
+ case 'previousWeek':
+ day = from.getDay();
+ first = from.getDate() - day + (day === 0 ? -6 : 1);
+ from.setDate(first - 7);
+ to.setDate(first);
+ break;
case 'thisMonth':
from.setDate(1);
to.setDate(1);
to.setMonth(from.getMonth() + 1);
break;
+ case 'previousMonth':
+ from.setDate(1);
+ from.setMonth(from.getMonth() - 1);
+ to.setDate(1);
+ break;
default:
}
from.setHours(0, 0, 0, 0);
@@ -76,5 +92,7 @@ Ext.define('Traccar.view.dialog.ReportConfigController', {
this.lookupReference('fromTimeField').setValue(from);
this.lookupReference('toDateField').setValue(to);
this.lookupReference('toTimeField').setValue(to);
+ this.lookupReference('fromContainer').setHidden(true);
+ this.lookupReference('toContainer').setHidden(true);
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index c215a9b9..4ef0d423 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -359,10 +359,13 @@
"reportShowMarkers": "Show Markers",
"reportExport": "Export",
"reportPeriod": "Period",
+ "reportCustom": "Custom",
"reportToday": "Today",
"reportYesterday": "Yesterday",
"reportThisWeek": "This Week",
+ "reportPreviousWeek": "Previous Week",
"reportThisMonth": "This Month",
+ "reportPreviousMonth": "Previous Month",
"reportDeviceName": "Device Name",
"reportAverageSpeed": "Average Speed",
"reportMaximumSpeed": "Maximum Speed",