From 9829184c5f941fd32d9d6c351dbdd113f00d352d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 29 Aug 2016 17:16:22 +0500 Subject: Implemented "Configure" dialog for reports --- web/app/Application.js | 3 +- web/app/Style.js | 3 +- web/app/store/ReportEventTypes.js | 26 +++++++++ web/app/view/Report.js | 41 +------------- web/app/view/ReportConfigController.js | 59 +++++++++++++++++++++ web/app/view/ReportConfigDialog.js | 97 ++++++++++++++++++++++++++++++++++ web/app/view/ReportController.js | 60 ++++++++++++++------- web/l10n/en.json | 4 ++ 8 files changed, 233 insertions(+), 60 deletions(-) create mode 100644 web/app/store/ReportEventTypes.js create mode 100644 web/app/view/ReportConfigController.js create mode 100644 web/app/view/ReportConfigDialog.js 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", -- cgit v1.2.3 From a09d2276f093504f8ab07bfadf0fbb3854ce5292 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 09:02:21 +0500 Subject: Disable buttons if report not configured --- web/app/view/Report.js | 2 ++ web/app/view/ReportConfigController.js | 1 + web/app/view/ReportController.js | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 161ac4c64..02513c05f 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -46,10 +46,12 @@ Ext.define('Traccar.view.Report', { }, '-', { text: Strings.reportShow, reference: 'showButton', + disabled: true, handler: 'onReportClick' }, { text: Strings.reportCsv, reference: 'csvButton', + disabled: true, handler: 'onReportClick' }, { text: Strings.reportClear, diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js index 2ee68ea9f..d98690e95 100644 --- a/web/app/view/ReportConfigController.js +++ b/web/app/view/ReportConfigController.js @@ -54,6 +54,7 @@ Ext.define('Traccar.view.ReportConfigController', { this.getView().callingPanel.fromTime = this.lookupReference('fromTimeField').getValue(); this.getView().callingPanel.toDate = this.lookupReference('toDateField').getValue(); this.getView().callingPanel.toTime = this.lookupReference('toTimeField').getValue(); + this.getView().callingPanel.updateButtons(); button.up('window').close(); } }); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 0247c96a9..6f998396c 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -60,6 +60,15 @@ Ext.define('Traccar.view.ReportController', { dialog.show(); }, + updateButtons: function () { + var reportType, disabled, devices; + reportType = this.lookupReference('reportTypeField').getValue(); + devices = this.deviceId && this.deviceId.length !== 0 || this.groupId && this.groupId.length !== 0; + disabled = !reportType || !devices; + this.lookupReference('showButton').setDisabled(disabled); + this.lookupReference('csvButton').setDisabled(disabled); + }, + onReportClick: function (button) { var reportType, from, to, store, url; @@ -324,6 +333,8 @@ Ext.define('Traccar.view.ReportController', { } else if (newValue === 'trips') { this.getView().reconfigure('ReportTrips', tripsColumns); } + + this.updateButtons(); } }); -- cgit v1.2.3 From c5aa95ad2aa5a5949a61aa139e05a1c807bb2ba6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 09:19:56 +0500 Subject: Added time check --- web/app/view/ReportController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 6f998396c..8f2b9b871 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -61,10 +61,11 @@ Ext.define('Traccar.view.ReportController', { }, updateButtons: function () { - var reportType, disabled, devices; + var reportType, disabled, devices, time; reportType = this.lookupReference('reportTypeField').getValue(); devices = this.deviceId && this.deviceId.length !== 0 || this.groupId && this.groupId.length !== 0; - disabled = !reportType || !devices; + time = this.fromDate && this.fromTime && this.toDate && this.toTime; + disabled = !reportType || !devices || !time; this.lookupReference('showButton').setDisabled(disabled); this.lookupReference('csvButton').setDisabled(disabled); }, -- cgit v1.2.3 From 52634dfe47878d3ecfd2612582b354bd39ea4fac Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 11:35:41 +0500 Subject: Add alias allEvents for "%" --- web/app/store/ReportEventTypes.js | 2 ++ web/app/view/ReportConfigController.js | 6 +++--- web/app/view/ReportController.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/app/store/ReportEventTypes.js b/web/app/store/ReportEventTypes.js index 4c2f69bb4..c5840305a 100644 --- a/web/app/store/ReportEventTypes.js +++ b/web/app/store/ReportEventTypes.js @@ -19,6 +19,8 @@ Ext.define('Traccar.store.ReportEventTypes', { extend: 'Ext.data.Store', fields: ['type', 'name'], + allEvents: '%', + data: [{ type: '%', name: Strings.eventAll diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js index d98690e95..5bd6ae7ef 100644 --- a/web/app/view/ReportConfigController.js +++ b/web/app/view/ReportConfigController.js @@ -44,10 +44,10 @@ Ext.define('Traccar.view.ReportConfigController', { 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 = ['%']; + if (eventType.indexOf(Ext.getStore('ReportEventTypes').allEvents) > -1) { + eventType = [Ext.getStore('ReportEventTypes').allEvents]; } else if (eventType.length === this.lookupReference('eventTypeField').getStore().getCount() - 1) { - eventType = ['%']; + eventType = [Ext.getStore('ReportEventTypes').allEvents]; } this.getView().callingPanel.eventType = eventType; this.getView().callingPanel.fromDate = this.lookupReference('fromDateField').getValue(); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 8f2b9b871..3fa26fcca 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -43,7 +43,7 @@ Ext.define('Traccar.view.ReportController', { if (this.eventType !== undefined) { dialog.lookupReference('eventTypeField').setValue(this.eventType); } else { - dialog.lookupReference('eventTypeField').setValue(['%']); + dialog.lookupReference('eventTypeField').setValue([Ext.getStore('ReportEventTypes').allEvents]); } if (this.fromDate !== undefined) { dialog.lookupReference('fromDateField').setValue(this.fromDate); @@ -143,7 +143,7 @@ Ext.define('Traccar.view.ReportController', { disposition = response.getResponseHeader('Content-Disposition'); filename = disposition.slice(disposition.indexOf("=") + 1, disposition.length); type = response.getResponseHeader('Content-Type'); - blob = new Blob([response.responseText], { type: type }); + blob = new Blob([response.responseText], {type: type}); if (typeof window.navigator.msSaveBlob !== 'undefined') { // IE workaround window.navigator.msSaveBlob(blob, filename); -- cgit v1.2.3 From bcaad78df62ea695757a37f97757b1a34e228ed5 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 12:25:01 +0500 Subject: Style fixes --- web/app/view/ReportController.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 3fa26fcca..4cc42456c 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -20,7 +20,7 @@ Ext.define('Traccar.view.ReportController', { alias: 'controller.report', requires: [ - 'Traccar.view.ReportConfigDialog' + 'Traccar.view.ReportConfigDialog' ], config: { @@ -63,7 +63,7 @@ Ext.define('Traccar.view.ReportController', { updateButtons: function () { var reportType, disabled, devices, time; reportType = this.lookupReference('reportTypeField').getValue(); - devices = this.deviceId && this.deviceId.length !== 0 || this.groupId && this.groupId.length !== 0; + devices = (this.deviceId && this.deviceId.length !== 0) || (this.groupId && this.groupId.length !== 0); time = this.fromDate && this.fromTime && this.toDate && this.toTime; disabled = !reportType || !devices || !time; this.lookupReference('showButton').setDisabled(disabled); @@ -84,7 +84,7 @@ Ext.define('Traccar.view.ReportController', { 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") { + if (button.reference === 'showButton') { store = this.getView().getStore(); store.load({ params: { @@ -95,7 +95,7 @@ Ext.define('Traccar.view.ReportController', { to: to.toISOString() } }); - } else if (button.reference === "csvButton") { + } else if (button.reference === 'csvButton') { url = this.getView().getStore().getProxy().url; this.downloadCsv(url, { deviceId: this.deviceId, @@ -141,7 +141,7 @@ Ext.define('Traccar.view.ReportController', { success: function (response) { var disposition, filename, type, blob, url, downloadUrl, elementA; disposition = response.getResponseHeader('Content-Disposition'); - filename = disposition.slice(disposition.indexOf("=") + 1, disposition.length); + filename = disposition.slice(disposition.indexOf('=') + 1, disposition.length); type = response.getResponseHeader('Content-Type'); blob = new Blob([response.responseText], {type: type}); if (typeof window.navigator.msSaveBlob !== 'undefined') { @@ -151,7 +151,7 @@ Ext.define('Traccar.view.ReportController', { url = window.URL || window.webkitURL; downloadUrl = url.createObjectURL(blob); if (filename) { - elementA = document.createElement("a"); + elementA = document.createElement('a'); elementA.href = downloadUrl; elementA.download = filename; document.body.appendChild(elementA); -- cgit v1.2.3 From 72dd6fa3f04a12df346ef3996878092cde407681 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 14:31:21 +0500 Subject: Used static variable and move creation allEvents item from config to ReportConfigController.init() --- web/app/store/ReportEventTypes.js | 9 +++------ web/app/view/ReportConfigController.js | 12 ++++++++---- web/app/view/ReportController.js | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/web/app/store/ReportEventTypes.js b/web/app/store/ReportEventTypes.js index c5840305a..27bc1fd5d 100644 --- a/web/app/store/ReportEventTypes.js +++ b/web/app/store/ReportEventTypes.js @@ -19,10 +19,7 @@ Ext.define('Traccar.store.ReportEventTypes', { extend: 'Ext.data.Store', fields: ['type', 'name'], - allEvents: '%', - - data: [{ - type: '%', - name: Strings.eventAll - }] + statics: { + allEvents: '%' + } }); diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js index 5bd6ae7ef..64acb7403 100644 --- a/web/app/view/ReportConfigController.js +++ b/web/app/view/ReportConfigController.js @@ -21,7 +21,11 @@ Ext.define('Traccar.view.ReportConfigController', { init: function () { var store = this.lookupReference('eventTypeField').getStore(); - if (store.getCount() === 1) { + if (store.getCount() === 0) { + store.add({ + type: Traccar.store.ReportEventTypes.allEvents, + name: Strings.eventAll + }); Ext.create('Traccar.store.AllNotifications').load({ scope: this, callback: function (records, operation, success) { @@ -44,10 +48,10 @@ Ext.define('Traccar.view.ReportConfigController', { this.getView().callingPanel.deviceId = this.lookupReference('deviceField').getValue(); this.getView().callingPanel.groupId = this.lookupReference('groupField').getValue(); eventType = this.lookupReference('eventTypeField').getValue(); - if (eventType.indexOf(Ext.getStore('ReportEventTypes').allEvents) > -1) { - eventType = [Ext.getStore('ReportEventTypes').allEvents]; + if (eventType.indexOf(Traccar.store.ReportEventTypes.allEvents) > -1) { + eventType = [Traccar.store.ReportEventTypes.allEvents]; } else if (eventType.length === this.lookupReference('eventTypeField').getStore().getCount() - 1) { - eventType = [Ext.getStore('ReportEventTypes').allEvents]; + eventType = [Traccar.store.ReportEventTypes.allEvents]; } this.getView().callingPanel.eventType = eventType; this.getView().callingPanel.fromDate = this.lookupReference('fromDateField').getValue(); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 4cc42456c..a4a5c6227 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -43,7 +43,7 @@ Ext.define('Traccar.view.ReportController', { if (this.eventType !== undefined) { dialog.lookupReference('eventTypeField').setValue(this.eventType); } else { - dialog.lookupReference('eventTypeField').setValue([Ext.getStore('ReportEventTypes').allEvents]); + dialog.lookupReference('eventTypeField').setValue([Traccar.store.ReportEventTypes.allEvents]); } if (this.fromDate !== undefined) { dialog.lookupReference('fromDateField').setValue(this.fromDate); -- cgit v1.2.3 From 85a30079e6ef125376e9e661f6749a000ed6103b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 15:36:02 +0500 Subject: Fix missed import --- web/app/view/Report.js | 3 +-- web/app/view/ReportConfigDialog.js | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 02513c05f..7e77ef4f4 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -19,8 +19,7 @@ Ext.define('Traccar.view.Report', { xtype: 'reportView', requires: [ - 'Traccar.view.ReportController', - 'Traccar.view.CustomTimeField' + 'Traccar.view.ReportController' ], controller: 'report', diff --git a/web/app/view/ReportConfigDialog.js b/web/app/view/ReportConfigDialog.js index 70effdaa0..547bd2975 100644 --- a/web/app/view/ReportConfigDialog.js +++ b/web/app/view/ReportConfigDialog.js @@ -19,7 +19,8 @@ Ext.define('Traccar.view.ReportConfigDialog', { extend: 'Traccar.view.BaseDialog', requires: [ - 'Traccar.view.ReportConfigController' + 'Traccar.view.ReportConfigController', + 'Traccar.view.CustomTimeField' ], controller: 'reportConfigDialog', -- cgit v1.2.3 From f786390fb1e79fa81024e03e68dc1067550d28e4 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 15:56:05 +0500 Subject: Added missed "requires" --- web/app/view/ReportConfigController.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js index 64acb7403..df0c1ce4a 100644 --- a/web/app/view/ReportConfigController.js +++ b/web/app/view/ReportConfigController.js @@ -19,6 +19,11 @@ Ext.define('Traccar.view.ReportConfigController', { extend: 'Ext.app.ViewController', alias: 'controller.reportConfigDialog', + requires: [ + 'Traccar.store.ReportEventTypes', + 'Traccar.store.AllNotifications' + ], + init: function () { var store = this.lookupReference('eventTypeField').getStore(); if (store.getCount() === 0) { -- cgit v1.2.3 From 08348a1ccf66803cad85116b62019e3090f07eda Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 16:34:41 +0500 Subject: One more missed import --- web/app/view/ReportController.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index a4a5c6227..28227e24d 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -20,7 +20,8 @@ Ext.define('Traccar.view.ReportController', { alias: 'controller.report', requires: [ - 'Traccar.view.ReportConfigDialog' + 'Traccar.view.ReportConfigDialog', + 'Traccar.store.ReportEventTypes' ], config: { -- cgit v1.2.3 From 80fc64fb46255c40729fa78e730a19cc9e5203cd Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 31 Aug 2016 10:16:29 +0500 Subject: Added other missed imports --- web/app/controller/Root.js | 3 ++- web/app/view/AttributesController.js | 3 ++- web/app/view/DevicesController.js | 5 ++++- web/app/view/GeofencesController.js | 2 +- web/app/view/GroupsController.js | 4 +++- web/app/view/NotificationsController.js | 4 ++++ web/app/view/ReportController.js | 1 + web/app/view/StateController.js | 5 +++++ web/app/view/UsersController.js | 3 ++- 9 files changed, 24 insertions(+), 6 deletions(-) diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 9ca7c9e40..dc759a08b 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -20,7 +20,8 @@ Ext.define('Traccar.controller.Root', { requires: [ 'Traccar.view.Login', 'Traccar.view.Main', - 'Traccar.view.MainMobile' + 'Traccar.view.MainMobile', + 'Traccar.model.Position' ], init: function () { diff --git a/web/app/view/AttributesController.js b/web/app/view/AttributesController.js index 5be94dec3..91d69a8e2 100644 --- a/web/app/view/AttributesController.js +++ b/web/app/view/AttributesController.js @@ -20,7 +20,8 @@ Ext.define('Traccar.view.AttributesController', { requires: [ 'Traccar.view.AttributeDialog', - 'Traccar.store.Attributes' + 'Traccar.store.Attributes', + 'Traccar.model.Attribute' ], init: function () { diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 8058db376..17f98629f 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -21,7 +21,10 @@ Ext.define('Traccar.view.DevicesController', { requires: [ 'Traccar.view.CommandDialog', 'Traccar.view.DeviceDialog', - 'Traccar.view.DeviceGeofences' + 'Traccar.view.DeviceGeofences', + 'Traccar.view.BaseWindow', + 'Traccar.model.Device', + 'Traccar.model.Command' ], config: { diff --git a/web/app/view/GeofencesController.js b/web/app/view/GeofencesController.js index 59e416d56..5faee139f 100644 --- a/web/app/view/GeofencesController.js +++ b/web/app/view/GeofencesController.js @@ -20,7 +20,7 @@ Ext.define('Traccar.view.GeofencesController', { requires: [ 'Traccar.view.GeofenceDialog', - 'Traccar.view.BaseWindow' + 'Traccar.model.Geofence' ], init: function () { diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js index 7413f64a8..f1d6e53f3 100644 --- a/web/app/view/GroupsController.js +++ b/web/app/view/GroupsController.js @@ -20,7 +20,9 @@ Ext.define('Traccar.view.GroupsController', { requires: [ 'Traccar.view.GroupDialog', - 'Traccar.view.GroupGeofences' + 'Traccar.view.GroupGeofences', + 'Traccar.view.BaseWindow', + 'Traccar.model.Group' ], onAddClick: function () { diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js index 628343a84..d880c5d41 100644 --- a/web/app/view/NotificationsController.js +++ b/web/app/view/NotificationsController.js @@ -18,6 +18,10 @@ Ext.define('Traccar.view.NotificationsController', { extend: 'Ext.app.ViewController', alias: 'controller.notificationsController', + requires: [ + 'Traccar.store.Notifications' + ], + init: function () { this.userId = this.getView().user.getData().id; this.getView().getStore().load({ diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 28227e24d..3a3345d83 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -20,6 +20,7 @@ Ext.define('Traccar.view.ReportController', { alias: 'controller.report', requires: [ + 'Traccar.AttributeFormatter', 'Traccar.view.ReportConfigDialog', 'Traccar.store.ReportEventTypes' ], diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 01df6645d..fca41bbc7 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -17,6 +17,11 @@ Ext.define('Traccar.view.StateController', { extend: 'Ext.app.ViewController', alias: 'controller.state', + + requires: [ + 'Traccar.AttributeFormatter', + 'Traccar.model.Attribute' + ], config: { listen: { diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index 73088a40e..da7dd8f13 100644 --- a/web/app/view/UsersController.js +++ b/web/app/view/UsersController.js @@ -24,7 +24,8 @@ Ext.define('Traccar.view.UsersController', { 'Traccar.view.UserGroups', 'Traccar.view.UserGeofences', 'Traccar.view.Notifications', - 'Traccar.view.BaseWindow' + 'Traccar.view.BaseWindow', + 'Traccar.model.User' ], init: function () { -- cgit v1.2.3 From 9377bef7e0c0abae2ca0f7638662dc61c89fbc31 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 31 Aug 2016 10:54:27 +0500 Subject: Fixed trailing spaces --- web/app/view/StateController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index fca41bbc7..567a3925d 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -17,7 +17,7 @@ Ext.define('Traccar.view.StateController', { extend: 'Ext.app.ViewController', alias: 'controller.state', - + requires: [ 'Traccar.AttributeFormatter', 'Traccar.model.Attribute' -- cgit v1.2.3