aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/Application.js3
-rw-r--r--web/app/Style.js3
-rw-r--r--web/app/store/ReportEventTypes.js26
-rw-r--r--web/app/view/Report.js41
-rw-r--r--web/app/view/ReportConfigController.js59
-rw-r--r--web/app/view/ReportConfigDialog.js97
-rw-r--r--web/app/view/ReportController.js60
-rw-r--r--web/l10n/en.json4
8 files changed, 233 insertions, 60 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index da28070e6..2d806534e 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -63,7 +63,8 @@ Ext.define('Traccar.Application', {
'ReportEvents',
'ReportTrips',
'ReportSummary',
- 'ReportTypes'
+ 'ReportTypes',
+ 'ReportEventTypes'
],
controllers: [
diff --git a/web/app/Style.js b/web/app/Style.js
index d047fd96b..6ca93c18c 100644
--- a/web/app/Style.js
+++ b/web/app/Style.js
@@ -71,6 +71,5 @@ Ext.define('Traccar.Style', {
coordinatePrecision: 6,
numberPrecision: 2,
- maxTagfieldWidth: 200,
- maxTagfieldGrow: 1
+ reportTagfieldWidth: 375
});
diff --git a/web/app/store/ReportEventTypes.js b/web/app/store/ReportEventTypes.js
new file mode 100644
index 000000000..4c2f69bb4
--- /dev/null
+++ b/web/app/store/ReportEventTypes.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.store.ReportEventTypes', {
+ extend: 'Ext.data.Store',
+ fields: ['type', 'name'],
+
+ data: [{
+ type: '%',
+ name: Strings.eventAll
+ }]
+});
diff --git a/web/app/view/Report.js b/web/app/view/Report.js
index 2ce9137ee..161ac4c64 100644
--- a/web/app/view/Report.js
+++ b/web/app/view/Report.js
@@ -41,45 +41,8 @@ Ext.define('Traccar.view.Report', {
change: 'onTypeChange'
}
}, '-', {
- xtype: 'tbtext',
- html: Strings.reportDevice
- }, {
- xtype: 'tagfield',
- maxWidth: Traccar.Style.maxTagfieldWidth,
- growMax: Traccar.Style.maxTagfieldGrow,
- reference: 'deviceField',
- store: 'Devices',
- valueField: 'id',
- displayField: 'name',
- queryMode: 'local'
- }, '-', {
- xtype: 'tbtext',
- html: Strings.reportFrom
- }, {
- xtype: 'datefield',
- reference: 'fromDateField',
- startDay: Traccar.Style.weekStartDay,
- format: Traccar.Style.dateFormat,
- value: new Date(new Date().getTime() - 30 * 60 * 1000)
- }, {
- xtype: 'customTimeField',
- reference: 'fromTimeField',
- maxWidth: Traccar.Style.reportTime,
- value: new Date(new Date().getTime() - 30 * 60 * 1000)
- }, '-', {
- xtype: 'tbtext',
- html: Strings.reportTo
- }, {
- xtype: 'datefield',
- reference: 'toDateField',
- startDay: Traccar.Style.weekStartDay,
- format: Traccar.Style.dateFormat,
- value: new Date()
- }, {
- xtype: 'customTimeField',
- reference: 'toTimeField',
- maxWidth: Traccar.Style.reportTime,
- value: new Date()
+ text: Strings.reportConfigure,
+ handler: 'onConfigureClick'
}, '-', {
text: Strings.reportShow,
reference: 'showButton',
diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js
new file mode 100644
index 000000000..2ee68ea9f
--- /dev/null
+++ b/web/app/view/ReportConfigController.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.view.ReportConfigController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.reportConfigDialog',
+
+ init: function () {
+ var store = this.lookupReference('eventTypeField').getStore();
+ if (store.getCount() === 1) {
+ Ext.create('Traccar.store.AllNotifications').load({
+ scope: this,
+ callback: function (records, operation, success) {
+ var i, value, name, typeKey;
+ if (success) {
+ for (i = 0; i < records.length; i++) {
+ value = records[i].get('type');
+ typeKey = 'event' + value.charAt(0).toUpperCase() + value.slice(1);
+ name = Strings[typeKey];
+ store.add({type: value, name: name});
+ }
+ }
+ }
+ });
+ }
+ },
+
+ onSaveClick: function (button) {
+ var eventType;
+ this.getView().callingPanel.deviceId = this.lookupReference('deviceField').getValue();
+ this.getView().callingPanel.groupId = this.lookupReference('groupField').getValue();
+ eventType = this.lookupReference('eventTypeField').getValue();
+ if (eventType.indexOf('%') > -1) {
+ eventType = ['%'];
+ } else if (eventType.length === this.lookupReference('eventTypeField').getStore().getCount() - 1) {
+ eventType = ['%'];
+ }
+ this.getView().callingPanel.eventType = eventType;
+ this.getView().callingPanel.fromDate = this.lookupReference('fromDateField').getValue();
+ this.getView().callingPanel.fromTime = this.lookupReference('fromTimeField').getValue();
+ this.getView().callingPanel.toDate = this.lookupReference('toDateField').getValue();
+ this.getView().callingPanel.toTime = this.lookupReference('toTimeField').getValue();
+ button.up('window').close();
+ }
+});
diff --git a/web/app/view/ReportConfigDialog.js b/web/app/view/ReportConfigDialog.js
new file mode 100644
index 000000000..70effdaa0
--- /dev/null
+++ b/web/app/view/ReportConfigDialog.js
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.view.ReportConfigDialog', {
+ extend: 'Traccar.view.BaseDialog',
+
+ requires: [
+ 'Traccar.view.ReportConfigController'
+ ],
+
+ controller: 'reportConfigDialog',
+ title: Strings.reportConfigure,
+
+ items: [{
+ fieldLabel: Strings.reportDevice,
+ xtype: 'tagfield',
+ width: Traccar.Style.reportTagfieldWidth,
+ reference: 'deviceField',
+ store: 'Devices',
+ valueField: 'id',
+ displayField: 'name',
+ queryMode: 'local'
+ }, {
+ fieldLabel: Strings.reportGroup,
+ xtype: 'tagfield',
+ width: Traccar.Style.reportTagfieldWidth,
+ reference: 'groupField',
+ store: 'Groups',
+ valueField: 'id',
+ displayField: 'name',
+ queryMode: 'local'
+ }, {
+ fieldLabel: Strings.reportEventTypes,
+ xtype: 'tagfield',
+ width: Traccar.Style.reportTagfieldWidth,
+ reference: 'eventTypeField',
+ store: 'ReportEventTypes',
+ hidden: true,
+ valueField: 'type',
+ displayField: 'name',
+ queryMode: 'local'
+ }, {
+ xtype: 'fieldcontainer',
+ layout: 'hbox',
+ items: [{
+ xtype: 'datefield',
+ fieldLabel: Strings.reportFrom,
+ reference: 'fromDateField',
+ startDay: Traccar.Style.weekStartDay,
+ format: Traccar.Style.dateFormat,
+ value: new Date(new Date().getTime() - 30 * 60 * 1000)
+ }, {
+ xtype: 'customTimeField',
+ reference: 'fromTimeField',
+ maxWidth: Traccar.Style.reportTime,
+ value: new Date(new Date().getTime() - 30 * 60 * 1000)
+ }]
+ }, {
+ xtype: 'fieldcontainer',
+ layout: 'hbox',
+ items: [{
+ xtype: 'datefield',
+ fieldLabel: Strings.reportTo,
+ reference: 'toDateField',
+ startDay: Traccar.Style.weekStartDay,
+ format: Traccar.Style.dateFormat,
+ value: new Date()
+ }, {
+ xtype: 'customTimeField',
+ reference: 'toTimeField',
+ maxWidth: Traccar.Style.reportTime,
+ value: new Date()
+ }]
+ }],
+
+ buttons: [{
+ text: Strings.sharedSave,
+ handler: 'onSaveClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index aeaa1849e..0247c96a9 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -19,6 +19,10 @@ Ext.define('Traccar.view.ReportController', {
extend: 'Ext.app.ViewController',
alias: 'controller.report',
+ requires: [
+ 'Traccar.view.ReportConfigDialog'
+ ],
+
config: {
listen: {
controller: {
@@ -30,34 +34,53 @@ Ext.define('Traccar.view.ReportController', {
}
},
+ onConfigureClick: function () {
+ var dialog = Ext.create('Traccar.view.ReportConfigDialog');
+ dialog.lookupReference('eventTypeField').setHidden(this.lookupReference('reportTypeField').getValue() !== 'events');
+ dialog.callingPanel = this;
+ dialog.lookupReference('deviceField').setValue(this.deviceId);
+ dialog.lookupReference('groupField').setValue(this.groupId);
+ if (this.eventType !== undefined) {
+ dialog.lookupReference('eventTypeField').setValue(this.eventType);
+ } else {
+ dialog.lookupReference('eventTypeField').setValue(['%']);
+ }
+ if (this.fromDate !== undefined) {
+ dialog.lookupReference('fromDateField').setValue(this.fromDate);
+ }
+ if (this.fromTime !== undefined) {
+ dialog.lookupReference('fromTimeField').setValue(this.fromTime);
+ }
+ if (this.toDate !== undefined) {
+ dialog.lookupReference('toDateField').setValue(this.toDate);
+ }
+ if (this.toTime !== undefined) {
+ dialog.lookupReference('toTimeField').setValue(this.toTime);
+ }
+ dialog.show();
+ },
+
onReportClick: function (button) {
- var reportType, deviceId, fromDate, fromTime, from, toDate, toTime, to, store, url;
+ var reportType, from, to, store, url;
reportType = this.lookupReference('reportTypeField').getValue();
- deviceId = this.lookupReference('deviceField').getValue();
-
- fromDate = this.lookupReference('fromDateField').getValue();
- fromTime = this.lookupReference('fromTimeField').getValue();
-
- if (reportType && deviceId) {
+ if (reportType && (this.deviceId || this.groupId)) {
from = new Date(
- fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
- fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
-
- toDate = this.lookupReference('toDateField').getValue();
- toTime = this.lookupReference('toTimeField').getValue();
+ this.fromDate.getFullYear(), this.fromDate.getMonth(), this.fromDate.getDate(),
+ this.fromTime.getHours(), this.fromTime.getMinutes(), this.fromTime.getSeconds(), this.fromTime.getMilliseconds());
to = new Date(
- toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
- toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
+ this.toDate.getFullYear(), this.toDate.getMonth(), this.toDate.getDate(),
+ this.toTime.getHours(), this.toTime.getMinutes(), this.toTime.getSeconds(), this.toTime.getMilliseconds());
if (button.reference === "showButton") {
store = this.getView().getStore();
store.load({
params: {
- deviceId: deviceId,
- type: '%',
+ deviceId: this.deviceId,
+ groupId: this.groupId,
+ type: this.eventType,
from: from.toISOString(),
to: to.toISOString()
}
@@ -65,8 +88,9 @@ Ext.define('Traccar.view.ReportController', {
} else if (button.reference === "csvButton") {
url = this.getView().getStore().getProxy().url;
this.downloadCsv(url, {
- deviceId: deviceId,
- type: '%',
+ deviceId: this.deviceId,
+ groupId: this.groupId,
+ type: this.eventType,
from: from.toISOString(),
to: to.toISOString()
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index c662cd47c..c4a130cf0 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -61,6 +61,7 @@
"settingsTwelveHourFormat": "12-hour Format",
"reportTitle": "Reports",
"reportDevice": "Device",
+ "reportGroup": "Group",
"reportFrom": "From",
"reportTo": "To",
"reportShow": "Show",
@@ -119,6 +120,7 @@
"commandData": "Data",
"commandPhoneNumber": "Phone Number",
"commandMessage": "Message",
+ "eventAll": "All Events",
"eventDeviceOnline": "Device is online",
"eventDeviceOffline": "Device is offline",
"eventDeviceMoving": "Device is moving",
@@ -145,6 +147,8 @@
"reportEvents": "Events",
"reportTrips": "Trips",
"reportSummary": "Summary",
+ "reportConfigure": "Configure",
+ "reportEventTypes": "Event Types",
"reportCsv": "CSV",
"reportDeviceName": "Device Name",
"reportAverageSpeed": "Average Speed",