diff options
author | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
commit | 1c7437d6de01fffbe3f69853717808b1790413fd (patch) | |
tree | ae6fa7144b30321e754773af4a2d464c9e52c624 /web/app | |
parent | 3826a93f1009942e22ec80c1e13be71e8e917b01 (diff) | |
download | trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.gz trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.bz2 trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.zip |
- Added trips report
- Refactored reports models
- Added tests for ReportUtils
- Added speed to test-generator.py
- Other changes
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Application.js | 4 | ||||
-rw-r--r-- | web/app/AttributeFormatter.js | 9 | ||||
-rw-r--r-- | web/app/model/ReportSummary.js | 1 | ||||
-rw-r--r-- | web/app/model/ReportTrip.js | 55 | ||||
-rw-r--r-- | web/app/store/ReportSummary.js | 1 | ||||
-rw-r--r-- | web/app/store/ReportTrips.js | 29 | ||||
-rw-r--r-- | web/app/store/ReportTypes.js | 3 | ||||
-rw-r--r-- | web/app/view/ReportController.js | 63 |
8 files changed, 162 insertions, 3 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index 22102f74b..da28070e6 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -34,7 +34,8 @@ Ext.define('Traccar.Application', { 'Event', 'Geofence', 'Notification', - 'ReportSummary' + 'ReportSummary', + 'ReportTrip' ], stores: [ @@ -60,6 +61,7 @@ Ext.define('Traccar.Application', { 'GeofenceTypes', 'ReportRoute', 'ReportEvents', + 'ReportTrips', 'ReportSummary', 'ReportTypes' ], diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index dcf50c580..1fff07bcf 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -39,6 +39,13 @@ Ext.define('Traccar.AttributeFormatter', { return (hours + ' ' + Strings.sharedHourAbbreviation); }, + durationFormatter: function (value) { + var hours, minutes; + hours = Math.floor(value / 3600000); + minutes = Math.round((value % 3600000) / 60000); + return (hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation); + }, + defaultFormatter: function (value) { if (typeof value === 'number') { return Number(value.toFixed(Traccar.Style.numberPrecision)); @@ -65,6 +72,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.distanceFormatter; } else if (key === 'hours') { return this.hoursFormatter; + } else if (key === 'duration') { + return this.durationFormatter; } else { return this.defaultFormatter; } diff --git a/web/app/model/ReportSummary.js b/web/app/model/ReportSummary.js index 39f0c498c..430d00b9b 100644 --- a/web/app/model/ReportSummary.js +++ b/web/app/model/ReportSummary.js @@ -1,5 +1,6 @@ /* * 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. diff --git a/web/app/model/ReportTrip.js b/web/app/model/ReportTrip.js new file mode 100644 index 000000000..cbd03d77a --- /dev/null +++ b/web/app/model/ReportTrip.js @@ -0,0 +1,55 @@ +/* + * 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.model.ReportTrip', { + extend: 'Ext.data.Model', + identifier: 'negative', + + fields: [{ + name: 'deviceId', + type: 'int' + }, { + name: 'deviceName', + type: 'string' + }, { + name: 'maxSpeed', + type: 'float' + }, { + name: 'averageSpeed', + type: 'float' + }, { + name: 'distance', + type: 'float' + }, { + name: 'duration', + type: 'int' + }, { + name: 'startTime', + type: 'date', + dateFormat: 'c' + }, { + name: 'startAddress', + type: 'string' + }, { + name: 'endTime', + type: 'date', + dateFormat: 'c' + }, { + name: 'endAddress', + type: 'string' + }] +}); diff --git a/web/app/store/ReportSummary.js b/web/app/store/ReportSummary.js index 35dad736b..7c9a4fca2 100644 --- a/web/app/store/ReportSummary.js +++ b/web/app/store/ReportSummary.js @@ -1,5 +1,6 @@ /* * 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. diff --git a/web/app/store/ReportTrips.js b/web/app/store/ReportTrips.js new file mode 100644 index 000000000..e0d86aa48 --- /dev/null +++ b/web/app/store/ReportTrips.js @@ -0,0 +1,29 @@ +/* + * 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.store.ReportTrips', { + extend: 'Ext.data.Store', + model: 'Traccar.model.ReportTrip', + + proxy: { + type: 'rest', + url: 'api/reports/trips', + headers: { + 'Accept': 'application/json' + } + } +}); diff --git a/web/app/store/ReportTypes.js b/web/app/store/ReportTypes.js index d544a2fda..09ef61db6 100644 --- a/web/app/store/ReportTypes.js +++ b/web/app/store/ReportTypes.js @@ -25,6 +25,9 @@ Ext.define('Traccar.store.ReportTypes', { key: 'events', name: Strings.reportEvents }, { + key: 'trips', + name: Strings.reportTrips + }, { key: 'summary', name: Strings.reportSummary }] diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 61e278993..aeaa1849e 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -1,5 +1,6 @@ /* * Copyright 2015 - 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. @@ -114,7 +115,7 @@ Ext.define('Traccar.view.ReportController', { window.navigator.msSaveBlob(blob, filename); } else { url = window.URL || window.webkitURL; - downloadUrl = URL.createObjectURL(blob); + downloadUrl = url.createObjectURL(blob); if (filename) { elementA = document.createElement("a"); elementA.href = downloadUrl; @@ -131,7 +132,7 @@ Ext.define('Traccar.view.ReportController', { }, onTypeChange: function (combobox, newValue, oldValue) { - var routeColumns, eventsColumns, summaryColumns; + var routeColumns, eventsColumns, summaryColumns, tripsColumns; if (oldValue !== null) { this.onClearClick(); } @@ -234,12 +235,70 @@ Ext.define('Traccar.view.ReportController', { renderer: Traccar.AttributeFormatter.getFormatter('hours') }]; + tripsColumns = [{ + text: Strings.reportDeviceName, + dataIndex: 'deviceId', + flex: 1, + renderer: function (value) { + return Ext.getStore('Devices').findRecord('id', value).get('name'); + } + }, { + text: Strings.reportStartTime, + dataIndex: 'startTime', + flex: 1, + xtype: 'datecolumn', + renderer: Traccar.AttributeFormatter.getFormatter('startTime') + }, { + text: Strings.reportStartAddress, + dataIndex: 'startAddress', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('address') + }, { + text: Strings.reportEndTime, + dataIndex: 'endTime', + flex: 1, + xtype: 'datecolumn', + renderer: Traccar.AttributeFormatter.getFormatter('endTime') + }, { + text: Strings.reportEndAddress, + dataIndex: 'endAddress', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('address') + }, { + text: Strings.sharedDistance, + dataIndex: 'distance', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('distance') + }, { + text: Strings.reportAverageSpeed, + dataIndex: 'averageSpeed', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('speed') + }, { + text: Strings.reportMaximumSpeed, + dataIndex: 'maxSpeed', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('speed') + }, { + text: Strings.reportDuration, + dataIndex: 'duration', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('duration') + }, { + text: Strings.reportSpentFuel, + dataIndex: 'spentFuel', + flex: 1, + renderer: Traccar.AttributeFormatter.getFormatter('spentFuel') + }]; + if (newValue === 'route') { this.getView().reconfigure('ReportRoute', routeColumns); } else if (newValue === 'events') { this.getView().reconfigure('ReportEvents', eventsColumns); } else if (newValue === 'summary') { this.getView().reconfigure('ReportSummary', summaryColumns); + } else if (newValue === 'trips') { + this.getView().reconfigure('ReportTrips', tripsColumns); } } |