aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/app/Application.js2
-rw-r--r--web/app/model/ReportStop.js50
-rw-r--r--web/app/store/ReportStops.js30
-rw-r--r--web/app/store/ReportTypes.js3
-rw-r--r--web/app/view/ReportController.js74
-rw-r--r--web/l10n/en.json1
6 files changed, 142 insertions, 18 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index 3f09a0a7..0d41fc87 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -38,6 +38,7 @@ Ext.define('Traccar.Application', {
'AttributeAlias',
'ReportSummary',
'ReportTrip',
+ 'ReportStop',
'Calendar',
'KnownAttribute'
],
@@ -68,6 +69,7 @@ Ext.define('Traccar.Application', {
'ReportRoute',
'ReportEvents',
'ReportTrips',
+ 'ReportStops',
'ReportSummary',
'ReportTypes',
'ReportEventTypes',
diff --git a/web/app/model/ReportStop.js b/web/app/model/ReportStop.js
new file mode 100644
index 00000000..c0ca4004
--- /dev/null
+++ b/web/app/model/ReportStop.js
@@ -0,0 +1,50 @@
+/*
+ * 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.model.ReportStop', {
+ extend: 'Ext.data.Model',
+ identifier: 'negative',
+
+ fields: [{
+ name: 'deviceId',
+ type: 'int'
+ }, {
+ name: 'deviceName',
+ type: 'string'
+ }, {
+ name: 'duration',
+ type: 'int'
+ }, {
+ name: 'startTime',
+ type: 'date',
+ dateFormat: 'c'
+ }, {
+ name: 'address',
+ type: 'string'
+ }, {
+ name: 'endTime',
+ type: 'date',
+ dateFormat: 'c'
+ }, {
+ name: 'engineHours',
+ type: 'int'
+ }, {
+ name: 'positionId',
+ type: 'int'
+ }]
+});
diff --git a/web/app/store/ReportStops.js b/web/app/store/ReportStops.js
new file mode 100644
index 00000000..60826b76
--- /dev/null
+++ b/web/app/store/ReportStops.js
@@ -0,0 +1,30 @@
+/*
+ * 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.ReportStops', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.ReportStop',
+
+ proxy: {
+ type: 'rest',
+ url: 'api/reports/stops',
+ headers: {
+ 'Accept': 'application/json'
+ }
+ }
+});
diff --git a/web/app/store/ReportTypes.js b/web/app/store/ReportTypes.js
index 26a36279..48400b88 100644
--- a/web/app/store/ReportTypes.js
+++ b/web/app/store/ReportTypes.js
@@ -29,6 +29,9 @@ Ext.define('Traccar.store.ReportTypes', {
key: 'trips',
name: Strings.reportTrips
}, {
+ key: 'stops',
+ name: Strings.reportStops
+ }, {
key: 'summary',
name: Strings.reportSummary
}, {
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 3daa2957..36eceb0f 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -42,11 +42,14 @@ Ext.define('Traccar.view.ReportController', {
},
store: {
'#ReportEvents': {
- add: 'loadEvents',
- load: 'loadEvents'
+ add: 'loadRelatedPositions',
+ load: 'loadRelatedPositions'
},
'#ReportRoute': {
load: 'loadRoute'
+ },
+ '#ReportStops': {
+ load: 'loadRelatedPositions'
}
}
}
@@ -173,7 +176,7 @@ Ext.define('Traccar.view.ReportController', {
clearReport: function (reportType) {
this.getGrid().getStore().removeAll();
- if (reportType === 'trips' || reportType === 'events') {
+ if (reportType === 'trips' || reportType === 'events' || reportType === 'stops') {
Ext.getStore('ReportRoute').removeAll();
}
if (reportType === 'chart') {
@@ -189,8 +192,8 @@ Ext.define('Traccar.view.ReportController', {
if (report instanceof Traccar.model.ReportTrip) {
this.selectTrip(report);
}
- if (report instanceof Traccar.model.Event) {
- this.selectEvent(report);
+ if (report instanceof Traccar.model.Event || report instanceof Traccar.model.ReportStop) {
+ this.selectPositionRelated(report);
}
}
},
@@ -202,15 +205,15 @@ Ext.define('Traccar.view.ReportController', {
},
selectReport: function (object, center) {
- var positionEvent, reportType = this.lookupReference('reportTypeField').getValue();
+ var positionRelated, reportType = this.lookupReference('reportTypeField').getValue();
if (object instanceof Traccar.model.Position) {
if (reportType === 'route') {
this.getGrid().getSelectionModel().select([object], false, true);
this.getGrid().getView().focusRow(object);
- } else if (reportType === 'events') {
- positionEvent = this.getGrid().getStore().findRecord('positionId', object.get('id'), 0, false, true, true);
- this.getGrid().getSelectionModel().select([positionEvent], false, true);
- this.getGrid().getView().focusRow(positionEvent);
+ } else if (reportType === 'events' || reportType === 'stops') {
+ positionRelated = this.getGrid().getStore().findRecord('positionId', object.get('id'), 0, false, true, true);
+ this.getGrid().getSelectionModel().select([positionRelated], false, true);
+ this.getGrid().getView().focusRow(positionRelated);
}
}
},
@@ -236,23 +239,23 @@ Ext.define('Traccar.view.ReportController', {
});
},
- selectEvent: function (event) {
+ selectPositionRelated: function (report) {
var position;
- if (event.get('positionId')) {
- position = Ext.getStore('ReportRoute').getById(event.get('positionId'));
+ if (report.get('positionId')) {
+ position = Ext.getStore('ReportRoute').getById(report.get('positionId'));
if (position) {
this.fireEvent('selectreport', position, true);
}
}
},
- loadEvents: function (store, data) {
- var i, eventObject, positionIds = [];
+ loadRelatedPositions: function (store, data) {
+ var i, reportObject, positionIds = [];
Ext.getStore('ReportRoute').removeAll();
for (i = 0; i < data.length; i++) {
- eventObject = data[i];
- if (eventObject.get('positionId')) {
- positionIds.push(eventObject.get('positionId'));
+ reportObject = data[i];
+ if (reportObject.get('positionId')) {
+ positionIds.push(reportObject.get('positionId'));
}
}
if (positionIds.length > 0) {
@@ -390,6 +393,9 @@ Ext.define('Traccar.view.ReportController', {
} else if (newValue === 'trips') {
this.getGrid().reconfigure('ReportTrips', this.tripsColumns);
this.getView().getLayout().setActiveItem('grid');
+ } else if (newValue === 'stops') {
+ this.getGrid().reconfigure('ReportStops', this.stopsColumns);
+ this.getView().getLayout().setActiveItem('grid');
} else if (newValue === 'chart') {
this.getView().getLayout().setActiveItem('chart');
}
@@ -525,5 +531,37 @@ Ext.define('Traccar.view.ReportController', {
text: Strings.reportSpentFuel,
dataIndex: 'spentFuel',
renderer: Traccar.AttributeFormatter.getFormatter('spentFuel')
+ }],
+
+ stopsColumns: [{
+ text: Strings.reportDeviceName,
+ dataIndex: 'deviceId',
+ renderer: Traccar.AttributeFormatter.getFormatter('deviceId')
+ }, {
+ text: Strings.reportStartTime,
+ dataIndex: 'startTime',
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.getFormatter('startTime')
+ }, {
+ text: Strings.positionAddress,
+ dataIndex: 'address',
+ renderer: Traccar.AttributeFormatter.getFormatter('address')
+ }, {
+ text: Strings.reportEndTime,
+ dataIndex: 'endTime',
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.getFormatter('endTime')
+ }, {
+ text: Strings.reportDuration,
+ dataIndex: 'duration',
+ renderer: Traccar.AttributeFormatter.getFormatter('duration')
+ }, {
+ text: Strings.reportEngineHours,
+ dataIndex: 'engineHours',
+ renderer: Traccar.AttributeFormatter.getFormatter('duration')
+ }, {
+ text: Strings.reportSpentFuel,
+ dataIndex: 'spentFuel',
+ renderer: Traccar.AttributeFormatter.getFormatter('spentFuel')
}]
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 30f66ba9..90dddd0e 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -306,6 +306,7 @@
"reportRoute": "Route",
"reportEvents": "Events",
"reportTrips": "Trips",
+ "reportStops": "Stops",
"reportSummary": "Summary",
"reportChart": "Chart",
"reportConfigure": "Configure",