aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-10-07 00:11:10 +0900
committerGitHub <noreply@github.com>2017-10-07 00:11:10 +0900
commit24b1b63fb2af68cd23362965e947f4dbf76d087e (patch)
tree5c743e2772e3e5ade02e4c89d691bd4e69e3f59b
parenteb23cc04e645ee72cdf833b712476f07231ea098 (diff)
parent8e4efa28702b6386dcfd20ba98fe8fa42b9682ed (diff)
downloadtrackermap-web-24b1b63fb2af68cd23362965e947f4dbf76d087e.tar.gz
trackermap-web-24b1b63fb2af68cd23362965e947f4dbf76d087e.tar.bz2
trackermap-web-24b1b63fb2af68cd23362965e947f4dbf76d087e.zip
Merge pull request #599 from Abyss777/quick_period
Add quick period selector to Report Config dialog
-rw-r--r--web/app/Application.js1
-rw-r--r--web/app/store/ReportPeriods.js45
-rw-r--r--web/app/view/ReportController.js3
-rw-r--r--web/app/view/dialog/ReportConfig.js16
-rw-r--r--web/app/view/dialog/ReportConfigController.js49
-rw-r--r--web/l10n/en.json8
6 files changed, 122 insertions, 0 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index ed9a4b60..6338506c 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -76,6 +76,7 @@ Ext.define('Traccar.Application', {
'ReportTypes',
'ReportEventTypes',
'ReportChartTypes',
+ 'ReportPeriods',
'Statistics',
'DeviceImages',
'Calendars',
diff --git a/web/app/store/ReportPeriods.js b/web/app/store/ReportPeriods.js
new file mode 100644
index 00000000..542fdce9
--- /dev/null
+++ b/web/app/store/ReportPeriods.js
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.store.ReportPeriods', {
+ extend: 'Ext.data.Store',
+ fields: ['key', 'name'],
+
+ data: [{
+ key: 'custom',
+ name: Strings.reportCustom
+ }, {
+ key: 'today',
+ name: Strings.reportToday
+ }, {
+ key: 'yesterday',
+ name: Strings.reportYesterday
+ }, {
+ 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 836b6050..35cc95b4 100644
--- a/web/app/view/dialog/ReportConfig.js
+++ b/web/app/view/dialog/ReportConfig.js
@@ -73,8 +73,22 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
uncheckedValue: false,
value: false
}, {
+ fieldLabel: Strings.reportPeriod,
+ reference: 'periodField',
+ xtype: 'combobox',
+ store: 'ReportPeriods',
+ editable: false,
+ valueField: 'key',
+ displayField: 'name',
+ queryMode: 'local',
+ listeners: {
+ change: 'onPeriodChange'
+ }
+ }, {
xtype: 'fieldcontainer',
layout: 'vbox',
+ reference: 'fromContainer',
+ hidden: true,
fieldLabel: Strings.reportFrom,
items: [{
xtype: 'datefield',
@@ -90,6 +104,8 @@ Ext.define('Traccar.view.dialog.ReportConfig', {
}, {
xtype: 'fieldcontainer',
layout: 'vbox',
+ reference: 'toContainer',
+ hidden: true,
fieldLabel: Strings.reportTo,
items: [{
xtype: 'datefield',
diff --git a/web/app/view/dialog/ReportConfigController.js b/web/app/view/dialog/ReportConfigController.js
index ce66371b..6d029428 100644
--- a/web/app/view/dialog/ReportConfigController.js
+++ b/web/app/view/dialog/ReportConfigController.js
@@ -44,7 +44,56 @@ 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();
+ },
+
+ onPeriodChange: function (combobox, newValue) {
+ var day, first, from, to, custom = newValue === 'custom';
+ this.lookupReference('fromContainer').setHidden(!custom);
+ this.lookupReference('toContainer').setHidden(!custom);
+ if (!custom) {
+ 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 '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:
+ break;
+ }
+ 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);
+ }
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index c5acc496..4ef0d423 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -358,6 +358,14 @@
"reportChartType": "Chart Type",
"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",