diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-15 16:14:28 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 16:14:28 +1200 |
commit | cdce6e8dd567acf01f2d477b6c1bb0ecba9efd23 (patch) | |
tree | e143f40a1a974648f1eb1a2c7ec67de01411cab8 /web/app | |
parent | a330ae09293c62aae381cb2c7f36cfa76b86e813 (diff) | |
parent | b22bd25a611304d63f270633b7e83969b6506f15 (diff) | |
download | etbsa-traccar-web-cdce6e8dd567acf01f2d477b6c1bb0ecba9efd23.tar.gz etbsa-traccar-web-cdce6e8dd567acf01f2d477b6c1bb0ecba9efd23.tar.bz2 etbsa-traccar-web-cdce6e8dd567acf01f2d477b6c1bb0ecba9efd23.zip |
Merge pull request #504 from Abyss777/report_stops
Implement Stops report
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Application.js | 2 | ||||
-rw-r--r-- | web/app/model/ReportStop.js | 50 | ||||
-rw-r--r-- | web/app/store/ReportStops.js | 30 | ||||
-rw-r--r-- | web/app/store/ReportTypes.js | 3 | ||||
-rw-r--r-- | web/app/view/ReportController.js | 74 |
5 files changed, 141 insertions, 18 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index 3f09a0a..0d41fc8 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 0000000..c0ca400 --- /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 0000000..60826b7 --- /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 26a3627..48400b8 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 3daa295..36eceb0 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') }] }); |