aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-03 13:39:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-03 13:39:53 +1300
commit001424d7ada69390fd7ebea8e585fb0408e147ac (patch)
treed4bac262bbb0cc2122626004b95eb2d57e089937 /web
parent00ebfd00f204bdfbd8e66254b79c7b8814d7ee3b (diff)
downloadtrackermap-server-001424d7ada69390fd7ebea8e585fb0408e147ac.tar.gz
trackermap-server-001424d7ada69390fd7ebea8e585fb0408e147ac.tar.bz2
trackermap-server-001424d7ada69390fd7ebea8e585fb0408e147ac.zip
More clean up for web interface
Diffstat (limited to 'web')
-rw-r--r--web/app/Application.js124
-rw-r--r--web/app/controller/Root.js2
-rw-r--r--web/app/view/BaseEditDialog.js2
-rw-r--r--web/app/view/BaseEditDialogController.js2
-rw-r--r--web/app/view/CommandDialog.js2
-rw-r--r--web/app/view/CommandDialogController.js2
-rw-r--r--web/app/view/DeviceController.js4
-rw-r--r--web/app/view/Login.js (renamed from web/app/view/login/Login.js)10
-rw-r--r--web/app/view/LoginController.js (renamed from web/app/view/login/LoginController.js)5
-rw-r--r--web/app/view/Main.js4
-rw-r--r--web/app/view/MainMobile.js2
-rw-r--r--web/app/view/Map.js (renamed from web/app/view/map/Map.js)6
-rw-r--r--web/app/view/MapController.js (renamed from web/app/view/map/MapController.js)2
-rw-r--r--web/app/view/Register.js (renamed from web/app/view/login/Register.js)12
-rw-r--r--web/app/view/RegisterController.js (renamed from web/app/view/login/RegisterController.js)2
-rw-r--r--web/app/view/Report.js (renamed from web/app/view/report/Report.js)4
-rw-r--r--web/app/view/ReportController.js (renamed from web/app/view/report/ReportController.js)21
-rw-r--r--web/app/view/State.js (renamed from web/app/view/BaseDialogController.js)26
-rw-r--r--web/app/view/StateController.js137
19 files changed, 258 insertions, 111 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index 67dc96536..def000f04 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -13,67 +13,71 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+(function() {
+ "use strict";
-Ext.define('Traccar.Application', {
- extend: 'Ext.app.Application',
- name: 'Traccar',
+ Ext.define('Traccar.Application', {
+ extend: 'Ext.app.Application',
+ name: 'Traccar',
- requires: [
- 'Traccar.Resources',
- 'Traccar.ErrorManager',
- 'Traccar.AttributeFormatter'
- ],
-
- models: [
- 'Server',
- 'User',
- 'Device',
- 'Position',
- 'Attribute',
- 'Command'
- ],
-
- stores: [
- 'Devices',
- 'Positions',
- 'LatestPositions',
- 'Users',
- 'Attributes',
- 'MapTypes',
- 'DistanceUnits',
- 'SpeedUnits',
- 'CommandTypes',
- 'TimeUnits',
- 'Languages'
- ],
+ requires: [
+ 'Traccar.Resources',
+ 'Traccar.ErrorManager',
+ 'Traccar.AttributeFormatter'
+ ],
- controllers: [
- 'Root'
- ],
-
- setUser: function(data) {
- var reader = Ext.create('Ext.data.reader.Json', {
- model: 'Traccar.model.User'
- });
- this.user = reader.readRecords(data).getRecords()[0];
- },
-
- getUser: function() {
- return this.user;
- },
-
- setServer: function(data) {
- var reader = Ext.create('Ext.data.reader.Json', {
- model: 'Traccar.model.Server'
- });
- this.server = reader.readRecords(data).getRecords()[0];
- },
-
- getServer: function() {
- return this.server;
- },
+ models: [
+ 'Server',
+ 'User',
+ 'Device',
+ 'Position',
+ 'Attribute',
+ 'Command'
+ ],
- getPreference: function(key, defaultValue) {
- return this.getUser().get(key) || this.getServer().get(key) || defaultValue;
- }
-});
+ stores: [
+ 'Devices',
+ 'Positions',
+ 'LatestPositions',
+ 'Users',
+ 'Attributes',
+ 'MapTypes',
+ 'DistanceUnits',
+ 'SpeedUnits',
+ 'CommandTypes',
+ 'TimeUnits',
+ 'Languages'
+ ],
+
+ controllers: [
+ 'Root'
+ ],
+
+ setUser: function(data) {
+ var reader = Ext.create('Ext.data.reader.Json', {
+ model: 'Traccar.model.User'
+ });
+ this.user = reader.readRecords(data).getRecords()[0];
+ },
+
+ getUser: function() {
+ return this.user;
+ },
+
+ setServer: function(data) {
+ var reader = Ext.create('Ext.data.reader.Json', {
+ model: 'Traccar.model.Server'
+ });
+ this.server = reader.readRecords(data).getRecords()[0];
+ },
+
+ getServer: function() {
+ return this.server;
+ },
+
+ getPreference: function(key, defaultValue) {
+ return this.getUser().get(key) || this.getServer().get(key) || defaultValue;
+ }
+ });
+
+})();
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index d4b3e794d..490019b1a 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -19,7 +19,7 @@ Ext.define('Traccar.controller.Root', {
requires: [
'Traccar.LoginManager',
- 'Traccar.view.login.Login',
+ 'Traccar.view.Login',
'Traccar.view.Main',
'Traccar.view.MainMobile'
],
diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js
index df8bfda93..0788c30d2 100644
--- a/web/app/view/BaseEditDialog.js
+++ b/web/app/view/BaseEditDialog.js
@@ -22,6 +22,6 @@ Ext.define('Traccar.view.BaseEditDialog', {
handler: 'onSaveClick'
}, {
text: strings.sharedCancel,
- handler: 'onCancelClick'
+ handler: 'closeView'
}]
});
diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js
index 863a75dcb..0c45b3097 100644
--- a/web/app/view/BaseEditDialogController.js
+++ b/web/app/view/BaseEditDialogController.js
@@ -15,7 +15,7 @@
*/
Ext.define('Traccar.view.BaseEditDialogController', {
- extend: 'Traccar.view.BaseDialogController',
+ extend: 'Ext.app.ViewController',
alias: 'controller.baseEditDialog',
onSaveClick: function(button) {
diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js
index 1cc96b195..5d37f3173 100644
--- a/web/app/view/CommandDialog.js
+++ b/web/app/view/CommandDialog.js
@@ -62,6 +62,6 @@ Ext.define('Traccar.view.CommandDialog', {
handler: 'onSendClick'
}, {
text: strings.sharedCancel,
- handler: 'onCancelClick'
+ handler: 'closeView'
}]
});
diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js
index 66a10bbb6..6aba4a6f1 100644
--- a/web/app/view/CommandDialogController.js
+++ b/web/app/view/CommandDialogController.js
@@ -15,7 +15,7 @@
*/
Ext.define('Traccar.view.CommandDialogController', {
- extend: 'Traccar.view.BaseDialogController',
+ extend: 'Ext.app.ViewController',
alias: 'controller.commandDialog',
onSelect: function(selected) {
diff --git a/web/app/view/DeviceController.js b/web/app/view/DeviceController.js
index e315d6f8d..d714d89d4 100644
--- a/web/app/view/DeviceController.js
+++ b/web/app/view/DeviceController.js
@@ -23,7 +23,7 @@ Ext.define('Traccar.view.DeviceController', {
'Traccar.view.DeviceDialog',
'Traccar.view.user.UserDialog',
'Traccar.view.user.User',
- 'Traccar.view.login.LoginController'
+ 'Traccar.view.LoginController'
],
config: {
@@ -44,7 +44,7 @@ Ext.define('Traccar.view.DeviceController', {
},
onLogoutClick: function() {
- Ext.create('Traccar.view.login.LoginController').logout();
+ Ext.create('Traccar.view.LoginController').logout();
},
onAddClick: function() {
diff --git a/web/app/view/login/Login.js b/web/app/view/Login.js
index a2d53fdf1..23f813c66 100644
--- a/web/app/view/login/Login.js
+++ b/web/app/view/Login.js
@@ -14,20 +14,17 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.login.Login', {
- extend: 'Ext.window.Window',
+Ext.define('Traccar.view.Login', {
+ extend: 'Traccar.view.BaseDialog',
alias: 'widget.login',
requires: [
- 'Traccar.view.login.LoginController'
+ 'Traccar.view.LoginController'
],
controller: 'login',
- bodyPadding: styles.panelPadding,
- title: strings.loginTitle,
closable: false,
- resizable: false,
items: {
xtype: 'form',
@@ -91,5 +88,4 @@ Ext.define('Traccar.view.login.Login', {
text: strings.loginLogin,
handler: 'onLoginClick'
}]
-
});
diff --git a/web/app/view/login/LoginController.js b/web/app/view/LoginController.js
index 0344f5542..f6b2fe228 100644
--- a/web/app/view/login/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.login.LoginController', {
+Ext.define('Traccar.view.LoginController', {
extend: 'Ext.app.ViewController',
alias: 'controller.login',
requires: [
- 'Traccar.view.login.Register'
+ 'Traccar.view.Register'
],
init: function() {
@@ -101,5 +101,4 @@ Ext.define('Traccar.view.login.LoginController', {
onRegisterClick: function() {
Ext.create('Traccar.view.login.Register').show();
}
-
});
diff --git a/web/app/view/Main.js b/web/app/view/Main.js
index 781cfad6b..ee1073e92 100644
--- a/web/app/view/Main.js
+++ b/web/app/view/Main.js
@@ -21,8 +21,8 @@ Ext.define('Traccar.view.Main', {
requires: [
'Traccar.view.Device',
'Traccar.view.State',
- 'Traccar.view.report.Report',
- 'Traccar.view.map.Map'
+ 'Traccar.view.Report',
+ 'Traccar.view.Map'
],
layout: 'border',
diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js
index 0562edb70..e42fc7f7f 100644
--- a/web/app/view/MainMobile.js
+++ b/web/app/view/MainMobile.js
@@ -21,7 +21,7 @@ Ext.define('Traccar.view.MainMobile', {
requires: [
'Traccar.view.Device',
'Traccar.view.State',
- 'Traccar.view.map.Map'
+ 'Traccar.view.Map'
],
layout: 'border',
diff --git a/web/app/view/map/Map.js b/web/app/view/Map.js
index 6e8ab6fad..5d2fd579c 100644
--- a/web/app/view/map/Map.js
+++ b/web/app/view/Map.js
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.map.Map', {
+Ext.define('Traccar.view.Map', {
extend: 'Ext.form.Panel',
xtype: 'mapView',
requires: [
- 'Traccar.view.map.MapController'
+ 'Traccar.view.MapController'
],
controller: 'map',
@@ -36,7 +36,7 @@ Ext.define('Traccar.view.map.Map', {
var layer;
var mapLayer = user.get('map') || server.get('map');
- var bingKey = server.get('bingKey') || 'AseEs0DLJhLlTNoxbNXu7DGsnnH4UoWuGue7-irwKkE3fffaClwc9q_Mr6AyHY8F';
+ var bingKey = server.get('bingKey');
if (mapLayer === 'custom') {
layer = new ol.layer.Tile({ source: new ol.source.XYZ({
diff --git a/web/app/view/map/MapController.js b/web/app/view/MapController.js
index b0d8b8f39..4979cd920 100644
--- a/web/app/view/map/MapController.js
+++ b/web/app/view/MapController.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.map.MapController', {
+Ext.define('Traccar.view.MapController', {
extend: 'Ext.app.ViewController',
alias: 'controller.map',
diff --git a/web/app/view/login/Register.js b/web/app/view/Register.js
index 91a5775a1..464b7bb1f 100644
--- a/web/app/view/login/Register.js
+++ b/web/app/view/Register.js
@@ -14,20 +14,15 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.login.Register', {
- extend: 'Ext.window.Window',
+Ext.define('Traccar.view.Register', {
+ extend: 'Traccar.view.BaseDialog',
requires: [
- 'Traccar.view.login.RegisterController'
+ 'Traccar.view.RegisterController'
],
controller: 'register',
- bodyPadding: styles.panelPadding,
- title: strings.loginRegister,
- resizable: false,
- modal: true,
-
items: {
xtype: 'form',
reference: 'form',
@@ -60,5 +55,4 @@ Ext.define('Traccar.view.login.Register', {
text: strings.sharedCancel,
handler: 'closeView'
}]
-
});
diff --git a/web/app/view/login/RegisterController.js b/web/app/view/RegisterController.js
index b1957ba8f..b470aa343 100644
--- a/web/app/view/login/RegisterController.js
+++ b/web/app/view/RegisterController.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.login.RegisterController', {
+Ext.define('Traccar.view.RegisterController', {
extend: 'Ext.app.ViewController',
alias: 'controller.register',
diff --git a/web/app/view/report/Report.js b/web/app/view/Report.js
index 720de698f..060c9c46a 100644
--- a/web/app/view/report/Report.js
+++ b/web/app/view/Report.js
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.report.Report', {
+Ext.define('Traccar.view.Report', {
extend: 'Ext.grid.Panel',
xtype: 'reportView',
requires: [
- 'Traccar.view.report.ReportController'
+ 'Traccar.view.ReportController'
],
controller: 'report',
diff --git a/web/app/view/report/ReportController.js b/web/app/view/ReportController.js
index 64c89867d..0b3e30f17 100644
--- a/web/app/view/report/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.report.ReportController', {
+Ext.define('Traccar.view.ReportController', {
extend: 'Ext.app.ViewController',
alias: 'controller.report',
@@ -29,23 +29,25 @@ Ext.define('Traccar.view.report.ReportController', {
},
onShowClick: function() {
- var deviceId = this.lookupReference('deviceField').getValue();
+ var deviceId, fromDate, fromTime, from, toDate, toTime, to, store;
- var fromDate = this.lookupReference('fromDateField').getValue();
- var fromTime = this.lookupReference('fromTimeField').getValue();
+ deviceId = this.lookupReference('deviceField').getValue();
- var from = new Date(
+ fromDate = this.lookupReference('fromDateField').getValue();
+ fromTime = this.lookupReference('fromTimeField').getValue();
+
+ from = new Date(
fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
- var toDate = this.lookupReference('toDateField').getValue();
- var toTime = this.lookupReference('toTimeField').getValue();
+ toDate = this.lookupReference('toDateField').getValue();
+ toTime = this.lookupReference('toTimeField').getValue();
- var to = new Date(
+ to = new Date(
toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
- var store = Ext.getStore('Positions');
+ store = Ext.getStore('Positions');
store.load({
params:{
deviceId: deviceId,
@@ -75,5 +77,4 @@ Ext.define('Traccar.view.report.ReportController', {
this.getView().getSelectionModel().deselectAll();
}
}
-
});
diff --git a/web/app/view/BaseDialogController.js b/web/app/view/State.js
index 4bf23d94e..0804234f9 100644
--- a/web/app/view/BaseDialogController.js
+++ b/web/app/view/State.js
@@ -14,10 +14,26 @@
* limitations under the License.
*/
-Ext.define('Traccar.view.BaseDialogController', {
- extend: 'Ext.app.ViewController',
+Ext.define('Traccar.view.State', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'stateView',
+
+ requires: [
+ 'Traccar.view.StateController'
+ ],
+
+ controller: 'state',
+ store: 'Attributes',
- onCancelClick: function(button) {
- button.up('window').close();
- }
+ title: strings.stateTitle,
+
+ columns: [{
+ text: strings.stateName,
+ dataIndex: 'name',
+ flex: 1
+ }, {
+ text: strings.stateValue,
+ dataIndex: 'value',
+ flex: 1
+ }]
});
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
new file mode 100644
index 000000000..dc2ddfb2b
--- /dev/null
+++ b/web/app/view/StateController.js
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2015 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.StateController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.state',
+
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ selectDevice: 'selectDevice'
+ }
+ }
+ }
+ },
+
+ init: function() {
+ var store = Ext.getStore('LatestPositions');
+ store.on('add', this.add, this);
+ store.on('update', this.update, this);
+ },
+
+ keys: {
+ fixTime: {
+ priority: 1,
+ name: strings.positionTime
+ },
+ latitude: {
+ priority: 2,
+ name: strings.positionLatitude
+ },
+ longitude: {
+ priority: 3,
+ name: strings.positionLongitude
+ },
+ valid: {
+ priority: 4,
+ name: strings.positionValid
+ },
+ altitude: {
+ priority: 5,
+ name: strings.positionAltitude
+ },
+ speed: {
+ priority: 6,
+ name: strings.positionSpeed
+ },
+ course: {
+ priority: 7,
+ name: strings.positionCourse
+ },
+ address: {
+ priority: 8,
+ name: strings.positionAddress
+ },
+ protocol: {
+ priority: 9,
+ name: strings.positionProtocol
+ }
+ },
+
+ formatValue: function(value) {
+ if (typeof(id) === 'number') {
+ return value.toFixed(2);
+ } else {
+ return value;
+ }
+ },
+
+ updatePosition: function(position) {
+ var attributes, value, unit, store, key;
+ store = Ext.getStore('Attributes');
+ store.removeAll();
+
+ for (key in position.data) {
+ if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) {
+ store.add(Ext.create('Traccar.model.Attribute', {
+ priority: this.keys[key].priority,
+ name: this.keys[key].name,
+ value: Traccar.AttributeFormatter.getFormatter(key)(position.get(key))
+ }));
+ }
+ }
+
+ attributes = position.get('attributes');
+ if (attributes instanceof Object) {
+ for (key in attributes) {
+ if (attributes.hasOwnProperty(key)) {
+ store.add(Ext.create('Traccar.model.Attribute', {
+ priority: 1024,
+ name: key.replace(/^./, function (match) {
+ return match.toUpperCase();
+ }),
+ value: Traccar.AttributeFormatter.getFormatter(key)(attributes[key])
+ }));
+ }
+ }
+ }
+ },
+
+ selectDevice: function(device) {
+ var found;
+ this.deviceId = device.get('id');
+ found = Ext.getStore('LatestPositions').query('deviceId', this.deviceId);
+ if (found.getCount() > 0) {
+ this.updatePosition(found.first());
+ } else {
+ Ext.getStore('Attributes').removeAll();
+ }
+ },
+
+ add: function(store, data) {
+ if (this.deviceId === data[0].get('deviceId')) {
+ this.updatePosition(data[0]);
+ }
+ },
+
+ update: function(store, data) {
+ if (this.deviceId === data.get('deviceId')) {
+ this.updatePosition(data);
+ }
+ }
+});