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/model/Statistics.js47
-rw-r--r--web/app/store/Statistics.js26
-rw-r--r--web/app/view/SettingsMenu.js5
-rw-r--r--web/app/view/SettingsMenuController.js12
-rw-r--r--web/app/view/Statistics.js78
-rw-r--r--web/app/view/StatisticsController.js29
-rw-r--r--web/l10n/en.json9
8 files changed, 207 insertions, 2 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index c2e0e777..be75a609 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -68,7 +68,8 @@ Ext.define('Traccar.Application', {
'ReportTrips',
'ReportSummary',
'ReportTypes',
- 'ReportEventTypes'
+ 'ReportEventTypes',
+ 'Statistics'
],
controllers: [
diff --git a/web/app/model/Statistics.js b/web/app/model/Statistics.js
new file mode 100644
index 00000000..9f66a201
--- /dev/null
+++ b/web/app/model/Statistics.js
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * 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.Statistics', {
+ extend: 'Ext.data.Model',
+ identifier: 'negative',
+
+ fields: [{
+ name: 'id',
+ type: 'int'
+ }, {
+ name: 'captureTime',
+ type: 'date',
+ dateFormat: 'c'
+ }, {
+ name: 'activeUsers',
+ type: 'int'
+ }, {
+ name: 'activeDevices',
+ type: 'int'
+ }, {
+ name: 'requests',
+ type: 'int'
+ }, {
+ name: 'messagesReceived',
+ type: 'int'
+ }, {
+ name: 'messagesStored',
+ type: 'int'
+ }, {
+ name: 'attributes'
+ }]
+});
diff --git a/web/app/store/Statistics.js b/web/app/store/Statistics.js
new file mode 100644
index 00000000..e1b5e8ea
--- /dev/null
+++ b/web/app/store/Statistics.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * 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.Statistics', {
+ extend: 'Ext.data.Store',
+ model: 'Traccar.model.Statistics',
+
+ proxy: {
+ type: 'rest',
+ url: 'api/statistics'
+ }
+});
diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js
index e1f6bf21..c494572f 100644
--- a/web/app/view/SettingsMenu.js
+++ b/web/app/view/SettingsMenu.js
@@ -62,6 +62,11 @@ Ext.define('Traccar.view.SettingsMenu', {
handler: 'onAttributeAliasesClick',
reference: 'settingsAttributeAliasesButton'
}, {
+ hidden: true,
+ text: Strings.statisticsTitle,
+ handler: 'onStatisticsClick',
+ reference: 'settingsStatisticsButton'
+ }, {
text: Strings.loginLogout,
handler: 'onLogoutClick'
}]
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index eee0097b..9d547c55 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -28,6 +28,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
'Traccar.view.Geofences',
'Traccar.view.Notifications',
'Traccar.view.AttributeAliases',
+ 'Traccar.view.Statistics',
'Traccar.view.BaseWindow'
],
@@ -38,6 +39,7 @@ Ext.define('Traccar.view.SettingsMenuController', {
if (admin) {
this.lookupReference('settingsServerButton').setHidden(false);
this.lookupReference('settingsUsersButton').setHidden(false);
+ this.lookupReference('settingsStatisticsButton').setHidden(false);
}
if (admin || !readonly) {
this.lookupReference('settingsGroupsButton').setHidden(false);
@@ -110,6 +112,16 @@ Ext.define('Traccar.view.SettingsMenuController', {
}).show();
},
+ onStatisticsClick: function () {
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.statisticsTitle,
+ modal: false,
+ items: {
+ xtype: 'statisticsView'
+ }
+ }).show();
+ },
+
onLogoutClick: function () {
Ext.create('Traccar.view.LoginController').logout();
}
diff --git a/web/app/view/Statistics.js b/web/app/view/Statistics.js
new file mode 100644
index 00000000..78195949
--- /dev/null
+++ b/web/app/view/Statistics.js
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * 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.Statistics', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'statisticsView',
+
+ requires: [
+ 'Traccar.view.StatisticsController'
+ ],
+
+ controller: 'statistics',
+ store: 'Statistics',
+
+ tbar: [{
+ xtype: 'tbtext',
+ html: Strings.reportFrom
+ }, {
+ xtype: 'datefield',
+ reference: 'fromDateField',
+ startDay: Traccar.Style.weekStartDay,
+ format: Traccar.Style.dateFormat,
+ value: new Date(new Date().getTime() - 24 * 60 * 60 * 1000)
+ }, '-', {
+ xtype: 'tbtext',
+ html: Strings.reportTo
+ }, {
+ xtype: 'datefield',
+ reference: 'toDateField',
+ startDay: Traccar.Style.weekStartDay,
+ format: Traccar.Style.dateFormat,
+ value: new Date()
+ }, '-', {
+ text: Strings.reportShow,
+ handler: 'onShowClick'
+ }],
+
+ columns: [{
+ text: Strings.statisticsCaptureTime,
+ dataIndex: 'captureTime',
+ flex: 1,
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.defaultFormatter()
+ }, {
+ text: Strings.statisticsActiveUsers,
+ dataIndex: 'activeUsers',
+ flex: 1
+ }, {
+ text: Strings.statisticsActiveDevices,
+ dataIndex: 'activeDevices',
+ flex: 1
+ }, {
+ text: Strings.statisticsRequests,
+ dataIndex: 'requests',
+ flex: 1
+ }, {
+ text: Strings.statisticsMessagesReceived,
+ dataIndex: 'messagesReceived',
+ flex: 1
+ }, {
+ text: Strings.statisticsMessagesStored,
+ dataIndex: 'messagesStored',
+ flex: 1
+ }]
+});
diff --git a/web/app/view/StatisticsController.js b/web/app/view/StatisticsController.js
new file mode 100644
index 00000000..339d8e95
--- /dev/null
+++ b/web/app/view/StatisticsController.js
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * 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.StatisticsController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.statistics',
+
+ onShowClick: function () {
+ Ext.getStore('Statistics').load({
+ params: {
+ from: this.lookupReference('fromDateField').getValue().toISOString(),
+ to: this.lookupReference('toDateField').getValue().toISOString()
+ }
+ });
+ }
+});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 45b3138a..30e15c71 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -170,5 +170,12 @@
"reportStartAddress": "Start Address",
"reportEndTime": "End Time",
"reportEndAddress": "End Address",
- "reportSpentFuel": "Spent Fuel"
+ "reportSpentFuel": "Spent Fuel",
+ "statisticsTitle": "Statistics",
+ "statisticsCaptureTime": "Capture Time",
+ "statisticsActiveUsers": "Active Users",
+ "statisticsActiveDevices": "Active Devices",
+ "statisticsRequests": "Requests",
+ "statisticsMessagesReceived": "Messages Received",
+ "statisticsMessagesStored": "Messages Stored"
} \ No newline at end of file