aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/BaseDialog.js16
-rw-r--r--web/app/view/BaseEditDialog.js24
-rw-r--r--web/app/view/BaseEditDialogController.js56
-rw-r--r--web/app/view/CommandDialog.js88
-rw-r--r--web/app/view/CommandDialogController.js82
-rw-r--r--web/app/view/Device.js150
-rw-r--r--web/app/view/DeviceController.js214
-rw-r--r--web/app/view/DeviceDialog.js48
-rw-r--r--web/app/view/Login.js136
-rw-r--r--web/app/view/LoginController.js150
-rw-r--r--web/app/view/Main.js76
-rw-r--r--web/app/view/MainMobile.js62
-rw-r--r--web/app/view/Map.js130
-rw-r--r--web/app/view/MapController.js338
-rw-r--r--web/app/view/Register.js74
-rw-r--r--web/app/view/RegisterController.js44
-rw-r--r--web/app/view/Report.js196
-rw-r--r--web/app/view/ReportController.js104
-rw-r--r--web/app/view/ServerDialog.js120
-rw-r--r--web/app/view/State.js42
-rw-r--r--web/app/view/StateController.js212
-rw-r--r--web/app/view/User.js88
-rw-r--r--web/app/view/UserController.js126
-rw-r--r--web/app/view/UserDialog.js138
-rw-r--r--web/app/view/UserDialogController.js60
25 files changed, 1354 insertions, 1420 deletions
diff --git a/web/app/view/BaseDialog.js b/web/app/view/BaseDialog.js
index f5cb8ca1d..fb09f12d1 100644
--- a/web/app/view/BaseDialog.js
+++ b/web/app/view/BaseDialog.js
@@ -13,15 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.BaseDialog', {
- extend: 'Ext.window.Window',
+Ext.define('Traccar.view.BaseDialog', {
+ extend: 'Ext.window.Window',
- bodyPadding: Traccar.Style.panelPadding,
- resizable: false,
- modal: true
- });
-
-})();
+ bodyPadding: Traccar.Style.panelPadding,
+ resizable: false,
+ modal: true
+});
diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js
index bf1e52749..051dfbe93 100644
--- a/web/app/view/BaseEditDialog.js
+++ b/web/app/view/BaseEditDialog.js
@@ -13,19 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.BaseEditDialog', {
- extend: 'Traccar.view.BaseDialog',
+Ext.define('Traccar.view.BaseEditDialog', {
+ extend: 'Traccar.view.BaseDialog',
- buttons: [{
- text: Strings.sharedSave,
- handler: 'onSaveClick'
- }, {
- text: Strings.sharedCancel,
- handler: 'closeView'
- }]
- });
-
-})();
+ buttons: [{
+ text: Strings.sharedSave,
+ handler: 'onSaveClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js
index 1820d9c9a..3b43cacf3 100644
--- a/web/app/view/BaseEditDialogController.js
+++ b/web/app/view/BaseEditDialogController.js
@@ -13,37 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.BaseEditDialogController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.baseEditDialog',
+Ext.define('Traccar.view.BaseEditDialogController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.baseEditDialog',
- onSaveClick: function (button) {
- var dialog, store, record;
- dialog = button.up('window').down('form');
- dialog.updateRecord();
- record = dialog.getRecord();
- store = record.store;
- if (store) {
- if (record.phantom) {
- store.add(record);
- }
- store.sync({
- success: function () {
- store.reload(); // workaround for selection problem
- },
- failure: function (batch) {
- store.rejectChanges();
- Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse());
- }
- });
- } else {
- record.save();
+ onSaveClick: function (button) {
+ var dialog, store, record;
+ dialog = button.up('window').down('form');
+ dialog.updateRecord();
+ record = dialog.getRecord();
+ store = record.store;
+ if (store) {
+ if (record.phantom) {
+ store.add(record);
}
- button.up('window').close();
+ store.sync({
+ success: function () {
+ store.reload(); // workaround for selection problem
+ },
+ failure: function (batch) {
+ store.rejectChanges();
+ Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse());
+ }
+ });
+ } else {
+ record.save();
}
- });
-
-})();
+ button.up('window').close();
+ }
+});
diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js
index 36024a172..66cd190ea 100644
--- a/web/app/view/CommandDialog.js
+++ b/web/app/view/CommandDialog.js
@@ -13,59 +13,55 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.CommandDialog', {
- extend: 'Traccar.view.BaseDialog',
+Ext.define('Traccar.view.CommandDialog', {
+ extend: 'Traccar.view.BaseDialog',
- requires: [
- 'Traccar.view.CommandDialogController'
- ],
+ requires: [
+ 'Traccar.view.CommandDialogController'
+ ],
- controller: 'commandDialog',
- title: Strings.commandTitle,
+ controller: 'commandDialog',
+ title: Strings.commandTitle,
+
+ items: {
+ xtype: 'form',
+ items: [{
+ xtype: 'combobox',
+ name: 'type',
+ fieldLabel: Strings.commandType,
+ store: 'CommandTypes',
+ displayField: 'name',
+ valueField: 'key',
+ listeners: {
+ select: 'onSelect'
+ }
+ }, {
+ xtype: 'fieldcontainer',
+ reference: 'paramPositionPeriodic',
+ name: 'attributes',
+ hidden: true,
- items: {
- xtype: 'form',
items: [{
+ xtype: 'numberfield',
+ fieldLabel: Strings.commandFrequency,
+ name: 'frequency'
+ }, {
xtype: 'combobox',
- name: 'type',
- fieldLabel: Strings.commandType,
- store: 'CommandTypes',
+ fieldLabel: Strings.commandUnit,
+ name: 'unit',
+ store: 'TimeUnits',
displayField: 'name',
- valueField: 'key',
- listeners: {
- select: 'onSelect'
- }
- }, {
- xtype: 'fieldcontainer',
- reference: 'paramPositionPeriodic',
- name: 'attributes',
- hidden: true,
-
- items: [{
- xtype: 'numberfield',
- fieldLabel: Strings.commandFrequency,
- name: 'frequency'
- }, {
- xtype: 'combobox',
- fieldLabel: Strings.commandUnit,
- name: 'unit',
- store: 'TimeUnits',
- displayField: 'name',
- valueField: 'factor'
- }]
+ valueField: 'factor'
}]
- },
-
- buttons: [{
- text: Strings.commandSend,
- handler: 'onSendClick'
- }, {
- text: Strings.sharedCancel,
- handler: 'closeView'
}]
- });
+ },
-})();
+ buttons: [{
+ text: Strings.commandSend,
+ handler: 'onSendClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/CommandDialogController.js b/web/app/view/CommandDialogController.js
index 39149c5a5..94df2ec42 100644
--- a/web/app/view/CommandDialogController.js
+++ b/web/app/view/CommandDialogController.js
@@ -13,49 +13,45 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
-
- Ext.define('Traccar.view.CommandDialogController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.commandDialog',
-
- onSelect: function (selected) {
- this.lookupReference('paramPositionPeriodic').setHidden(
- selected.getValue() !== 'positionPeriodic');
- },
-
- onSendClick: function (button) {
- var attributes, value, record, form;
-
- form = button.up('window').down('form');
- form.updateRecord();
- record = form.getRecord();
-
- if (record.get('type') === 'positionPeriodic') {
- attributes = this.lookupReference('paramPositionPeriodic');
- value = attributes.down('numberfield[name="frequency"]').getValue();
- value *= attributes.down('combobox[name="unit"]').getValue();
-
- record.set('attributes', {
- frequency: value
- });
- }
-
- Ext.Ajax.request({
- scope: this,
- url: '/api/command/send',
- jsonData: record.getData(),
- callback: this.onSendResult
- });
- },
- onSendResult: function (options, success, response) {
- if (Traccar.ErrorManager.check(success, response)) {
- Ext.toast(Strings.commandSent);
- this.closeView();
- }
+Ext.define('Traccar.view.CommandDialogController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.commandDialog',
+
+ onSelect: function (selected) {
+ this.lookupReference('paramPositionPeriodic').setHidden(
+ selected.getValue() !== 'positionPeriodic');
+ },
+
+ onSendClick: function (button) {
+ var attributes, value, record, form;
+
+ form = button.up('window').down('form');
+ form.updateRecord();
+ record = form.getRecord();
+
+ if (record.get('type') === 'positionPeriodic') {
+ attributes = this.lookupReference('paramPositionPeriodic');
+ value = attributes.down('numberfield[name="frequency"]').getValue();
+ value *= attributes.down('combobox[name="unit"]').getValue();
+
+ record.set('attributes', {
+ frequency: value
+ });
}
- });
-})();
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/command/send',
+ jsonData: record.getData(),
+ callback: this.onSendResult
+ });
+ },
+
+ onSendResult: function (options, success, response) {
+ if (Traccar.ErrorManager.check(success, response)) {
+ Ext.toast(Strings.commandSent);
+ this.closeView();
+ }
+ }
+});
diff --git a/web/app/view/Device.js b/web/app/view/Device.js
index 3feb008a2..cf7e3e473 100644
--- a/web/app/view/Device.js
+++ b/web/app/view/Device.js
@@ -13,85 +13,107 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Device', {
- extend: 'Ext.grid.Panel',
- xtype: 'deviceView',
+Ext.define('Traccar.view.Device', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'deviceView',
- requires: [
- 'Traccar.view.DeviceController'
- ],
+ requires: [
+ 'Traccar.view.DeviceController',
+ 'Traccar.view.BaseEditToolbar'
+ ],
- controller: 'device',
- store: 'Devices',
+ controller: 'device',
+ store: 'Devices',
- title: Strings.deviceTitle,
- selType: 'rowmodel',
+ title: Strings.deviceTitle,
+ selType: 'rowmodel',
- tbar: [{
- handler: 'onAddClick',
- reference: 'deviceAddButton',
- glyph: 'xf067@FontAwesome',
- tooltip: Strings.sharedAdd,
- tooltipType: 'title'
- }, {
- disabled: true,
- handler: 'onEditClick',
- reference: 'deviceEditButton',
- glyph: 'xf040@FontAwesome',
- tooltip: Strings.sharedEdit,
- tooltipType: 'title'
- }, {
+ dockedItems: [{
+ xtype : 'baseEditToolbar',
+ dock : "top",
+ items: [{
disabled: true,
- handler: 'onRemoveClick',
- reference: 'deviceRemoveButton',
- glyph: 'xf00d@FontAwesome',
- tooltip: Strings.sharedRemove,
+ handler: 'onCommandClick',
+ reference: 'deviceCommandButton',
+ glyph: 'xf093@FontAwesome',
+ tooltip: Strings.deviceCommand,
tooltipType: 'title'
- }, {
+ }]
+ }],
+
+ //tbar: {
+ // xtype: 'baseEditToolbar',
+ /*items: [{
disabled: true,
handler: 'onCommandClick',
reference: 'deviceCommandButton',
glyph: 'xf093@FontAwesome',
tooltip: Strings.deviceCommand,
tooltipType: 'title'
- }, {
- xtype: 'tbfill'
- }, {
- text: Strings.settingsTitle,
- menu: [{
- text: Strings.settingsUser,
- handler: 'onUserClick'
- }, {
- text: Strings.settingsServer,
- hidden: true,
- handler: 'onServerClick',
- reference: 'settingsServerButton'
- }, {
- text: Strings.settingsUsers,
- hidden: true,
- handler: 'onUsersClick',
- reference: 'settingsUsersButton'
- }]
- }, {
- text: Strings.loginLogout,
- handler: 'onLogoutClick'
- }],
-
- listeners: {
- selectionchange: 'onSelectionChange'
- },
+ }]*/
+ //},
- columns: [{
- text: Strings.deviceName,
- dataIndex: 'name', flex: 1
+ /*tbar: [{
+ handler: 'onAddClick',
+ reference: 'deviceAddButton',
+ glyph: 'xf067@FontAwesome',
+ tooltip: Strings.sharedAdd,
+ tooltipType: 'title'
+ }, {
+ disabled: true,
+ handler: 'onEditClick',
+ reference: 'deviceEditButton',
+ glyph: 'xf040@FontAwesome',
+ tooltip: Strings.sharedEdit,
+ tooltipType: 'title'
+ }, {
+ disabled: true,
+ handler: 'onRemoveClick',
+ reference: 'deviceRemoveButton',
+ glyph: 'xf00d@FontAwesome',
+ tooltip: Strings.sharedRemove,
+ tooltipType: 'title'
+ }, {
+ disabled: true,
+ handler: 'onCommandClick',
+ reference: 'deviceCommandButton',
+ glyph: 'xf093@FontAwesome',
+ tooltip: Strings.deviceCommand,
+ tooltipType: 'title'
+ }, {
+ xtype: 'tbfill'
+ }, {
+ text: Strings.settingsTitle,
+ menu: [{
+ text: Strings.settingsUser,
+ handler: 'onUserClick'
}, {
- text: Strings.deviceIdentifier,
- dataIndex: 'uniqueId', flex: 1
+ text: Strings.settingsServer,
+ hidden: true,
+ handler: 'onServerClick',
+ reference: 'settingsServerButton'
+ }, {
+ text: Strings.settingsUsers,
+ hidden: true,
+ handler: 'onUsersClick',
+ reference: 'settingsUsersButton'
}]
+ }, {
+ text: Strings.loginLogout,
+ handler: 'onLogoutClick'
+ }],*/
+
+ listeners: {
+ selectionchange: 'onSelectionChange'
+ },
- });
+ columns: [{
+ text: Strings.deviceName,
+ dataIndex: 'name', flex: 1
+ }, {
+ text: Strings.deviceIdentifier,
+ dataIndex: 'uniqueId', flex: 1
+ }]
-})();
+});
diff --git a/web/app/view/DeviceController.js b/web/app/view/DeviceController.js
index 4d26f799f..a2e0aaae8 100644
--- a/web/app/view/DeviceController.js
+++ b/web/app/view/DeviceController.js
@@ -13,130 +13,126 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.DeviceController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.device',
+Ext.define('Traccar.view.DeviceController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.device',
- requires: [
- 'Traccar.view.CommandDialog',
- 'Traccar.view.DeviceDialog',
- 'Traccar.view.UserDialog',
- 'Traccar.view.User',
- 'Traccar.view.LoginController'
- ],
+ requires: [
+ 'Traccar.view.CommandDialog',
+ 'Traccar.view.DeviceDialog',
+ 'Traccar.view.UserDialog',
+ 'Traccar.view.User',
+ 'Traccar.view.LoginController'
+ ],
- config: {
- listen: {
- controller: {
- '*': {
- selectReport: 'selectReport'
- }
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ selectReport: 'selectReport'
}
}
- },
+ }
+ },
- init: function () {
- if (Traccar.app.getUser().get('admin')) {
- this.lookupReference('settingsServerButton').setHidden(false);
- this.lookupReference('settingsUsersButton').setHidden(false);
- }
- },
+ init: function () {
+ if (Traccar.app.getUser().get('admin')) {
+ this.lookupReference('settingsServerButton').setHidden(false);
+ this.lookupReference('settingsUsersButton').setHidden(false);
+ }
+ },
- onLogoutClick: function () {
- Ext.create('Traccar.view.LoginController').logout();
- },
+ onLogoutClick: function () {
+ Ext.create('Traccar.view.LoginController').logout();
+ },
- onAddClick: function () {
- var device, dialog;
- device = Ext.create('Traccar.model.Device');
- device.store = this.getView().getStore();
- dialog = Ext.create('Traccar.view.DeviceDialog');
- dialog.down('form').loadRecord(device);
- dialog.show();
- },
+ onAddClick: function () {
+ var device, dialog;
+ device = Ext.create('Traccar.model.Device');
+ device.store = this.getView().getStore();
+ dialog = Ext.create('Traccar.view.DeviceDialog');
+ dialog.down('form').loadRecord(device);
+ dialog.show();
+ },
- onEditClick: function () {
- var device, dialog;
- device = this.getView().getSelectionModel().getSelection()[0];
- dialog = Ext.create('Traccar.view.DeviceDialog');
- dialog.down('form').loadRecord(device);
- dialog.show();
- },
+ onEditClick: function () {
+ var device, dialog;
+ device = this.getView().getSelectionModel().getSelection()[0];
+ dialog = Ext.create('Traccar.view.DeviceDialog');
+ dialog.down('form').loadRecord(device);
+ dialog.show();
+ },
- onRemoveClick: function () {
- var device = this.getView().getSelectionModel().getSelection()[0];
- Ext.Msg.show({
- title: Strings.deviceDialog,
- message: Strings.sharedRemoveConfirm,
- buttons: Ext.Msg.YESNO,
- buttonText: {
- yes: Strings.sharedRemove,
- no: Strings.sharedCancel
- },
- fn: function (btn) {
- var store;
- if (btn === 'yes') {
- store = Ext.getStore('Devices');
- store.remove(device);
- store.sync();
- }
+ onRemoveClick: function () {
+ var device = this.getView().getSelectionModel().getSelection()[0];
+ Ext.Msg.show({
+ title: Strings.deviceDialog,
+ message: Strings.sharedRemoveConfirm,
+ buttons: Ext.Msg.YESNO,
+ buttonText: {
+ yes: Strings.sharedRemove,
+ no: Strings.sharedCancel
+ },
+ fn: function (btn) {
+ var store;
+ if (btn === 'yes') {
+ store = Ext.getStore('Devices');
+ store.remove(device);
+ store.sync();
}
- });
- },
-
- onCommandClick: function () {
- var device, command, dialog;
- device = this.getView().getSelectionModel().getSelection()[0];
- command = Ext.create('Traccar.model.Command');
- command.set('deviceId', device.get('id'));
- dialog = Ext.create('Traccar.view.CommandDialog');
- dialog.down('form').loadRecord(command);
- dialog.show();
- },
-
- onSelectionChange: function (selected) {
- var empty = selected.getCount() === 0;
- this.lookupReference('deviceEditButton').setDisabled(empty);
- this.lookupReference('deviceRemoveButton').setDisabled(empty);
- this.lookupReference('deviceCommandButton').setDisabled(empty);
- if (!empty) {
- this.fireEvent('selectDevice', selected.getLastSelected());
}
- },
+ });
+ },
- onUserClick: function () {
- var dialog = Ext.create('Traccar.view.UserDialog');
- dialog.down('form').loadRecord(Traccar.app.getUser());
- dialog.show();
- },
+ onCommandClick: function () {
+ var device, command, dialog;
+ device = this.getView().getSelectionModel().getSelection()[0];
+ command = Ext.create('Traccar.model.Command');
+ command.set('deviceId', device.get('id'));
+ dialog = Ext.create('Traccar.view.CommandDialog');
+ dialog.down('form').loadRecord(command);
+ dialog.show();
+ },
- onServerClick: function () {
- var dialog = Ext.create('Traccar.view.ServerDialog');
- dialog.down('form').loadRecord(Traccar.app.getServer());
- dialog.show();
- },
+ onSelectionChange: function (selected) {
+ var empty = selected.getCount() === 0;
+ this.lookupReference('deviceEditButton').setDisabled(empty);
+ this.lookupReference('deviceRemoveButton').setDisabled(empty);
+ this.lookupReference('deviceCommandButton').setDisabled(empty);
+ if (!empty) {
+ this.fireEvent('selectDevice', selected.getLastSelected());
+ }
+ },
- onUsersClick: function () {
- Ext.create('Ext.window.Window', {
- title: Strings.settingsUsers,
- width: Traccar.Style.windowWidth,
- height: Traccar.Style.windowHeight,
- layout: 'fit',
- modal: true,
- items: {
- xtype: 'userView'
- }
- }).show();
- },
+ onUserClick: function () {
+ var dialog = Ext.create('Traccar.view.UserDialog');
+ dialog.down('form').loadRecord(Traccar.app.getUser());
+ dialog.show();
+ },
+
+ onServerClick: function () {
+ var dialog = Ext.create('Traccar.view.ServerDialog');
+ dialog.down('form').loadRecord(Traccar.app.getServer());
+ dialog.show();
+ },
- selectReport: function (position) {
- if (position !== undefined) {
- this.getView().getSelectionModel().deselectAll();
+ onUsersClick: function () {
+ Ext.create('Ext.window.Window', {
+ title: Strings.settingsUsers,
+ width: Traccar.Style.windowWidth,
+ height: Traccar.Style.windowHeight,
+ layout: 'fit',
+ modal: true,
+ items: {
+ xtype: 'userView'
}
- }
- });
+ }).show();
+ },
-})();
+ selectReport: function (position) {
+ if (position !== undefined) {
+ this.getView().getSelectionModel().deselectAll();
+ }
+ }
+});
diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js
index 2349676b1..c42af95d0 100644
--- a/web/app/view/DeviceDialog.js
+++ b/web/app/view/DeviceDialog.js
@@ -13,33 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.DeviceDialog', {
- extend: 'Traccar.view.BaseEditDialog',
+Ext.define('Traccar.view.DeviceDialog', {
+ extend: 'Traccar.view.BaseEditDialog',
- requires: [
- 'Traccar.view.BaseEditDialogController'
- ],
+ requires: [
+ 'Traccar.view.BaseEditDialogController'
+ ],
- controller: 'baseEditDialog',
- title: Strings.deviceDialog,
+ controller: 'baseEditDialog',
+ title: Strings.deviceDialog,
- items: {
- xtype: 'form',
- items: [{
- xtype: 'textfield',
- name: 'name',
- fieldLabel: Strings.deviceName,
- allowBlank: false
- }, {
- xtype: 'textfield',
- name: 'uniqueId',
- fieldLabel: Strings.deviceIdentifier,
- allowBlank: false
- }]
- }
- });
-
-})();
+ items: {
+ xtype: 'form',
+ items: [{
+ xtype: 'textfield',
+ name: 'name',
+ fieldLabel: Strings.deviceName,
+ allowBlank: false
+ }, {
+ xtype: 'textfield',
+ name: 'uniqueId',
+ fieldLabel: Strings.deviceIdentifier,
+ allowBlank: false
+ }]
+ }
+});
diff --git a/web/app/view/Login.js b/web/app/view/Login.js
index 6e10a6824..a4a68843d 100644
--- a/web/app/view/Login.js
+++ b/web/app/view/Login.js
@@ -13,84 +13,80 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Login', {
- extend: 'Traccar.view.BaseDialog',
- alias: 'widget.login',
+Ext.define('Traccar.view.Login', {
+ extend: 'Traccar.view.BaseDialog',
+ alias: 'widget.login',
- requires: [
- 'Traccar.view.LoginController'
- ],
+ requires: [
+ 'Traccar.view.LoginController'
+ ],
- controller: 'login',
+ controller: 'login',
- closable: false,
- modal: false,
+ closable: false,
+ modal: false,
- items: {
- xtype: 'form',
- reference: 'form',
+ items: {
+ xtype: 'form',
+ reference: 'form',
- autoEl: {
- tag: 'form',
- method: 'POST',
- action: 'blank',
- target: 'submitTarget'
- },
-
- items: [{
- xtype: 'combobox',
- name: 'language',
- fieldLabel: Strings.loginLanguage,
- store: 'Languages',
- displayField: 'name',
- valueField: 'code',
- submitValue: false,
- listeners: {
- select: 'onSelectLanguage'
- },
- reference: 'languageField'
- }, {
- xtype: 'textfield',
- name: 'email',
- fieldLabel: Strings.userEmail,
- allowBlank: false,
- enableKeyEvents: true,
- listeners: {
- specialKey: 'onSpecialKey',
- afterrender: 'onAfterRender'
- },
- inputAttrTpl: ['autocomplete="on"']
- }, {
- xtype: 'textfield',
- name: 'password',
- fieldLabel: Strings.userPassword,
- inputType: 'password',
- allowBlank: false,
- enableKeyEvents: true,
- listeners: {
- specialKey: 'onSpecialKey'
- },
- inputAttrTpl: ['autocomplete="on"']
- }, {
- xtype: 'component',
- html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>'
- }, {
- xtype: 'component',
- html: '<input type="submit" id="submitButton" style="display:none">'
- }]
+ autoEl: {
+ tag: 'form',
+ method: 'POST',
+ action: 'blank',
+ target: 'submitTarget'
},
- buttons: [{
- text: Strings.loginRegister,
- handler: 'onRegisterClick',
- reference: 'registerButton'
+ items: [{
+ xtype: 'combobox',
+ name: 'language',
+ fieldLabel: Strings.loginLanguage,
+ store: 'Languages',
+ displayField: 'name',
+ valueField: 'code',
+ submitValue: false,
+ listeners: {
+ select: 'onSelectLanguage'
+ },
+ reference: 'languageField'
+ }, {
+ xtype: 'textfield',
+ name: 'email',
+ fieldLabel: Strings.userEmail,
+ allowBlank: false,
+ enableKeyEvents: true,
+ listeners: {
+ specialKey: 'onSpecialKey',
+ afterrender: 'onAfterRender'
+ },
+ inputAttrTpl: ['autocomplete="on"']
+ }, {
+ xtype: 'textfield',
+ name: 'password',
+ fieldLabel: Strings.userPassword,
+ inputType: 'password',
+ allowBlank: false,
+ enableKeyEvents: true,
+ listeners: {
+ specialKey: 'onSpecialKey'
+ },
+ inputAttrTpl: ['autocomplete="on"']
+ }, {
+ xtype: 'component',
+ html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>'
}, {
- text: Strings.loginLogin,
- handler: 'onLoginClick'
+ xtype: 'component',
+ html: '<input type="submit" id="submitButton" style="display:none">'
}]
- });
+ },
-})();
+ buttons: [{
+ text: Strings.loginRegister,
+ handler: 'onRegisterClick',
+ reference: 'registerButton'
+ }, {
+ text: Strings.loginLogin,
+ handler: 'onLoginClick'
+ }]
+});
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index baf27a751..e0dbcce88 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -13,97 +13,93 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.LoginController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.login',
+Ext.define('Traccar.view.LoginController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.login',
- requires: [
- 'Traccar.view.Register'
- ],
+ requires: [
+ 'Traccar.view.Register'
+ ],
- init: function () {
- this.lookupReference('registerButton').setDisabled(
- !Traccar.app.getServer().get('registration'));
- this.lookupReference('languageField').setValue(Locale.language);
- },
+ init: function () {
+ this.lookupReference('registerButton').setDisabled(
+ !Traccar.app.getServer().get('registration'));
+ this.lookupReference('languageField').setValue(Locale.language);
+ },
- login: function () {
- var form = this.lookupReference('form');
- if (form.isValid()) {
- Ext.getBody().mask(Strings.sharedLoading);
- Ext.Ajax.request({
- scope: this,
- url: '/api/login',
- params: form.getValues(),
- callback: function (options, success, response) {
- var result;
- Ext.getBody().unmask();
- if (Traccar.ErrorManager.check(success, response)) {
- result = Ext.decode(response.responseText);
- if (result.success) {
- Traccar.app.setUser(result.data);
- this.fireViewEvent('login');
- } else {
- Traccar.ErrorManager.error(Strings.loginFailed);
- }
+ login: function () {
+ var form = this.lookupReference('form');
+ if (form.isValid()) {
+ Ext.getBody().mask(Strings.sharedLoading);
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/login',
+ params: form.getValues(),
+ callback: function (options, success, response) {
+ var result;
+ Ext.getBody().unmask();
+ if (Traccar.ErrorManager.check(success, response)) {
+ result = Ext.decode(response.responseText);
+ if (result.success) {
+ Traccar.app.setUser(result.data);
+ this.fireViewEvent('login');
+ } else {
+ Traccar.ErrorManager.error(Strings.loginFailed);
}
-
}
- });
- }
- },
- logout: function () {
- Ext.Ajax.request({
- scope: this,
- url: '/api/logout',
- callback: function () {
- window.location.reload();
}
});
- },
+ }
+ },
- onSelectLanguage: function (selected) {
- var paramName = 'locale';
- var paramValue = selected.getValue();
- var url = window.location.href;
- if (url.indexOf(paramName + '=') >= 0) {
- var prefix = url.substring(0, url.indexOf(paramName));
- var suffix = url.substring(url.indexOf(paramName));
- suffix = suffix.substring(suffix.indexOf('=') + 1);
- suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
- url = prefix + paramName + '=' + paramValue + suffix;
- } else {
- if (url.indexOf('?') < 0) {
- url += '?' + paramName + '=' + paramValue;
- } else {
- url += '&' + paramName + '=' + paramValue;
- }
+ logout: function () {
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/logout',
+ callback: function () {
+ window.location.reload();
}
- window.location.href = url;
- },
-
- onAfterRender: function (field) {
- field.focus();
- },
+ });
+ },
- onSpecialKey: function (field, e) {
- if (e.getKey() === e.ENTER) {
- this.login();
+ onSelectLanguage: function (selected) {
+ var paramName = 'locale';
+ var paramValue = selected.getValue();
+ var url = window.location.href;
+ if (url.indexOf(paramName + '=') >= 0) {
+ var prefix = url.substring(0, url.indexOf(paramName));
+ var suffix = url.substring(url.indexOf(paramName));
+ suffix = suffix.substring(suffix.indexOf('=') + 1);
+ suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
+ url = prefix + paramName + '=' + paramValue + suffix;
+ } else {
+ if (url.indexOf('?') < 0) {
+ url += '?' + paramName + '=' + paramValue;
+ } else {
+ url += '&' + paramName + '=' + paramValue;
}
- },
+ }
+ window.location.href = url;
+ },
- onLoginClick: function () {
- Ext.getElementById('submitButton').click();
- this.login();
- },
+ onAfterRender: function (field) {
+ field.focus();
+ },
- onRegisterClick: function () {
- Ext.create('Traccar.view.Register').show();
+ onSpecialKey: function (field, e) {
+ if (e.getKey() === e.ENTER) {
+ this.login();
}
- });
+ },
+
+ onLoginClick: function () {
+ Ext.getElementById('submitButton').click();
+ this.login();
+ },
-})();
+ onRegisterClick: function () {
+ Ext.create('Traccar.view.Register').show();
+ }
+});
diff --git a/web/app/view/Main.js b/web/app/view/Main.js
index 04ad5ea48..fc29d43aa 100644
--- a/web/app/view/Main.js
+++ b/web/app/view/Main.js
@@ -13,55 +13,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Main', {
- extend: 'Ext.container.Viewport',
- alias: 'widget.main',
+Ext.define('Traccar.view.Main', {
+ extend: 'Ext.container.Viewport',
+ alias: 'widget.main',
- requires: [
- 'Traccar.view.Device',
- 'Traccar.view.State',
- 'Traccar.view.Report',
- 'Traccar.view.Map'
- ],
+ requires: [
+ 'Traccar.view.Device',
+ 'Traccar.view.State',
+ 'Traccar.view.Report',
+ 'Traccar.view.Map'
+ ],
+ layout: 'border',
+
+ defaults: {
+ header: false,
+ collapsible: true,
+ split: true
+ },
+
+ items: [{
+ region: 'west',
layout: 'border',
+ width: Traccar.Style.deviceWidth,
defaults: {
- header: false,
- collapsible: true,
- split: true
+ split: true,
+ flex: 1
},
items: [{
- region: 'west',
- layout: 'border',
- width: Traccar.Style.deviceWidth,
-
- defaults: {
- split: true,
- flex: 1
- },
-
- items: [{
- region: 'center',
- xtype: 'deviceView'
- }, {
- region: 'south',
- xtype: 'stateView'
- }]
+ region: 'center',
+ xtype: 'deviceView'
}, {
region: 'south',
- xtype: 'reportView',
- height: Traccar.Style.reportHeight
- }, {
- region: 'center',
- xtype: 'mapView',
- header: true,
- collapsible: false
+ xtype: 'stateView'
}]
- });
-
-})();
+ }, {
+ region: 'south',
+ xtype: 'reportView',
+ height: Traccar.Style.reportHeight
+ }, {
+ region: 'center',
+ xtype: 'mapView',
+ header: true,
+ collapsible: false
+ }]
+});
diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js
index d822f4978..e42fc7f7f 100644
--- a/web/app/view/MainMobile.js
+++ b/web/app/view/MainMobile.js
@@ -13,41 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.MainMobile', {
- extend: 'Ext.container.Viewport',
- alias: 'widget.mainMobile',
+Ext.define('Traccar.view.MainMobile', {
+ extend: 'Ext.container.Viewport',
+ alias: 'widget.mainMobile',
- requires: [
- 'Traccar.view.Device',
- 'Traccar.view.State',
- 'Traccar.view.Map'
- ],
+ requires: [
+ 'Traccar.view.Device',
+ 'Traccar.view.State',
+ 'Traccar.view.Map'
+ ],
- layout: 'border',
+ layout: 'border',
- defaults: {
- header: false,
- collapsible: true,
- split: true
- },
+ defaults: {
+ header: false,
+ collapsible: true,
+ split: true
+ },
- items: [{
- region: 'east',
- xtype: 'stateView',
- flex: 4
- }, {
- region: 'center',
- xtype: 'mapView',
- collapsible: false,
- flex: 2
- }, {
- region: 'south',
- xtype: 'deviceView',
- flex: 1
- }]
- });
-
-})();
+ items: [{
+ region: 'east',
+ xtype: 'stateView',
+ flex: 4
+ }, {
+ region: 'center',
+ xtype: 'mapView',
+ collapsible: false,
+ flex: 2
+ }, {
+ region: 'south',
+ xtype: 'deviceView',
+ flex: 1
+ }]
+});
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index 7165bfb56..709684e29 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -13,84 +13,80 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Map', {
- extend: 'Ext.form.Panel',
- xtype: 'mapView',
+Ext.define('Traccar.view.Map', {
+ extend: 'Ext.form.Panel',
+ xtype: 'mapView',
- requires: [
- 'Traccar.view.MapController'
- ],
+ requires: [
+ 'Traccar.view.MapController'
+ ],
- controller: 'map',
+ controller: 'map',
- title: Strings.mapTitle,
- layout: 'fit',
+ title: Strings.mapTitle,
+ layout: 'fit',
- listeners: {
- afterrender: function () {
- var user = Traccar.app.getUser();
- var server = Traccar.app.getServer();
+ listeners: {
+ afterrender: function () {
+ var user = Traccar.app.getUser();
+ var server = Traccar.app.getServer();
- var layer;
- var mapLayer = user.get('map') || server.get('map');
+ var layer;
+ var mapLayer = user.get('map') || server.get('map');
- var bingKey = server.get('bingKey');
+ var bingKey = server.get('bingKey');
- if (mapLayer === 'custom') {
- layer = new ol.layer.Tile({
- source: new ol.source.XYZ({
- url: server.get('mapUrl')
- })
- });
- } else if (mapLayer === 'bingRoad') {
- layer = new ol.layer.Tile({
- source: new ol.source.BingMaps({
- key: bingKey,
- imagerySet: 'Road'
- })
- });
- } else if (mapLayer === 'bingAerial') {
- layer = new ol.layer.Tile({
- source: new ol.source.BingMaps({
- key: bingKey,
- imagerySet: 'Aerial'
- })
- });
- } else {
- layer = new ol.layer.Tile({
- source: new ol.source.OSM({})
- });
- }
-
- this.vectorSource = new ol.source.Vector({});
- var vectorLayer = new ol.layer.Vector({
- source: this.vectorSource
+ if (mapLayer === 'custom') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.XYZ({
+ url: server.get('mapUrl')
+ })
+ });
+ } else if (mapLayer === 'bingRoad') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.BingMaps({
+ key: bingKey,
+ imagerySet: 'Road'
+ })
+ });
+ } else if (mapLayer === 'bingAerial') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.BingMaps({
+ key: bingKey,
+ imagerySet: 'Aerial'
+ })
});
+ } else {
+ layer = new ol.layer.Tile({
+ source: new ol.source.OSM({})
+ });
+ }
- var lat = user.get('latitude') || server.get('latitude') || Traccar.Style.mapDefaultLat;
- var lon = user.get('longitude') || server.get('longitude') || Traccar.Style.mapDefaultLon;
- var zoom = user.get('zoom') || server.get('zoom') || Traccar.Style.mapDefaultZoom;
+ this.vectorSource = new ol.source.Vector({});
+ var vectorLayer = new ol.layer.Vector({
+ source: this.vectorSource
+ });
- this.mapView = new ol.View({
- center: ol.proj.fromLonLat([lon, lat]),
- zoom: zoom,
- maxZoom: Traccar.Style.mapMaxZoom
- });
+ var lat = user.get('latitude') || server.get('latitude') || Traccar.Style.mapDefaultLat;
+ var lon = user.get('longitude') || server.get('longitude') || Traccar.Style.mapDefaultLon;
+ var zoom = user.get('zoom') || server.get('zoom') || Traccar.Style.mapDefaultZoom;
- this.map = new ol.Map({
- target: this.body.dom.id,
- layers: [layer, vectorLayer],
- view: this.mapView
- });
- },
+ this.mapView = new ol.View({
+ center: ol.proj.fromLonLat([lon, lat]),
+ zoom: zoom,
+ maxZoom: Traccar.Style.mapMaxZoom
+ });
- resize: function () {
- this.map.updateSize();
- }
- }
- });
+ this.map = new ol.Map({
+ target: this.body.dom.id,
+ layers: [layer, vectorLayer],
+ view: this.mapView
+ });
+ },
-})();
+ resize: function () {
+ this.map.updateSize();
+ }
+ }
+});
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index 7bb878241..d8177335b 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -13,205 +13,201 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
-
- Ext.define('Traccar.view.MapController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.map',
-
- config: {
- listen: {
- controller: {
- '*': {
- reportShow: 'reportShow',
- reportClear: 'reportClear',
- selectDevice: 'selectDevice',
- selectReport: 'selectReport'
- }
+
+Ext.define('Traccar.view.MapController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.map',
+
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ reportShow: 'reportShow',
+ reportClear: 'reportClear',
+ selectDevice: 'selectDevice',
+ selectReport: 'selectReport'
}
}
- },
-
- init: function () {
- this.liveData = {};
- this.update(true);
- },
-
- update: function (first) {
- Ext.Ajax.request({
- scope: this,
- url: '/api/async',
- params: {
- first: first
- },
- success: function (response) {
- var data = Ext.decode(response.responseText).data;
-
- var i;
- for (i = 0; i < data.length; i++) {
-
- var store = Ext.getStore('LatestPositions');
-
- var found = store.query('deviceId', data[i].deviceId);
- if (found.getCount() > 0) {
- found.first().set(data[i]);
- } else {
- store.add(Ext.create('Traccar.model.Position', data[i]));
- }
-
- var geometry = new ol.geom.Point(ol.proj.fromLonLat([
- data[i].longitude,
- data[i].latitude
- ]));
-
- if (data[i].deviceId in this.liveData) {
- this.liveData[data[i].deviceId].setGeometry(geometry);
- } else {
- var style = this.getMarkerStyle(Traccar.Style.mapLiveRadius, Traccar.Style.mapLiveColor);
- var marker = new ol.Feature({
- geometry: geometry,
- originalStyle: style
- });
- marker.setStyle(style);
- this.getView().vectorSource.addFeature(marker);
- this.liveData[data[i].deviceId] = marker;
- }
+ }
+ },
+
+ init: function () {
+ this.liveData = {};
+ this.update(true);
+ },
+
+ update: function (first) {
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/async',
+ params: {
+ first: first
+ },
+ success: function (response) {
+ var data = Ext.decode(response.responseText).data;
+
+ var i;
+ for (i = 0; i < data.length; i++) {
+
+ var store = Ext.getStore('LatestPositions');
+
+ var found = store.query('deviceId', data[i].deviceId);
+ if (found.getCount() > 0) {
+ found.first().set(data[i]);
+ } else {
+ store.add(Ext.create('Traccar.model.Position', data[i]));
}
- this.update(false);
- },
- failure: function () {
- // TODO: error
+ var geometry = new ol.geom.Point(ol.proj.fromLonLat([
+ data[i].longitude,
+ data[i].latitude
+ ]));
+
+ if (data[i].deviceId in this.liveData) {
+ this.liveData[data[i].deviceId].setGeometry(geometry);
+ } else {
+ var style = this.getMarkerStyle(Traccar.Style.mapLiveRadius, Traccar.Style.mapLiveColor);
+ var marker = new ol.Feature({
+ geometry: geometry,
+ originalStyle: style
+ });
+ marker.setStyle(style);
+ this.getView().vectorSource.addFeature(marker);
+ this.liveData[data[i].deviceId] = marker;
+ }
}
- });
- },
- getLineStyle: function () {
- return new ol.style.Style({
+ this.update(false);
+ },
+ failure: function () {
+ // TODO: error
+ }
+ });
+ },
+
+ getLineStyle: function () {
+ return new ol.style.Style({
+ stroke: new ol.style.Stroke({
+ color: Traccar.Style.mapStrokeColor,
+ width: Traccar.Style.mapRouteWidth
+ })
+ });
+ },
+
+ getMarkerStyle: function (radius, color) {
+ /*return new ol.style.Style({
+ text: new ol.style.Text({
+ text: '\uf041',
+ font: 'normal 32px FontAwesome',
+ textBaseline: 'Bottom',
+ fill: new ol.style.Fill({
+ color: color
+ }),
+ stroke: new ol.style.Stroke({
+ color: 'black',
+ width: 2
+ })
+ })
+ });*/
+ return new ol.style.Style({
+ image: new ol.style.Circle({
+ radius: radius,
+ fill: new ol.style.Fill({
+ color: color
+ }),
stroke: new ol.style.Stroke({
color: Traccar.Style.mapStrokeColor,
- width: Traccar.Style.mapRouteWidth
- })
- });
- },
-
- getMarkerStyle: function (radius, color) {
- /*return new ol.style.Style({
- text: new ol.style.Text({
- text: '\uf041',
- font: 'normal 32px FontAwesome',
- textBaseline: 'Bottom',
- fill: new ol.style.Fill({
- color: color
- }),
- stroke: new ol.style.Stroke({
- color: 'black',
- width: 2
- })
- })
- });*/
- return new ol.style.Style({
- image: new ol.style.Circle({
- radius: radius,
- fill: new ol.style.Fill({
- color: color
- }),
- stroke: new ol.style.Stroke({
- color: Traccar.Style.mapStrokeColor,
- width: Traccar.Style.mapMarkerStroke
- })
+ width: Traccar.Style.mapMarkerStroke
})
- });
- },
+ })
+ });
+ },
- reportShow: function () {
- this.reportClear();
+ reportShow: function () {
+ this.reportClear();
- var vectorSource = this.getView().vectorSource;
+ var vectorSource = this.getView().vectorSource;
- var data = Ext.getStore('Positions').getData();
+ var data = Ext.getStore('Positions').getData();
- var index;
- var positions = [];
- this.reportRoutePoints = {};
+ var index;
+ var positions = [];
+ this.reportRoutePoints = {};
- for (index = 0; index < data.getCount(); index++) {
- var point = ol.proj.fromLonLat([
- data.getAt(index).data.longitude,
- data.getAt(index).data.latitude
- ]);
- positions.push(point);
-
- var style = this.getMarkerStyle(Traccar.Style.mapReportRadius, Traccar.Style.mapReportColor);
- var feature = new ol.Feature({
- geometry: new ol.geom.Point(positions[index]),
- originalStyle: style
- });
- feature.setStyle(style);
- this.reportRoutePoints[data.getAt(index).get('id')] = feature;
- }
+ for (index = 0; index < data.getCount(); index++) {
+ var point = ol.proj.fromLonLat([
+ data.getAt(index).data.longitude,
+ data.getAt(index).data.latitude
+ ]);
+ positions.push(point);
- this.reportRoute = new ol.Feature({
- geometry: new ol.geom.LineString(positions)
+ var style = this.getMarkerStyle(Traccar.Style.mapReportRadius, Traccar.Style.mapReportColor);
+ var feature = new ol.Feature({
+ geometry: new ol.geom.Point(positions[index]),
+ originalStyle: style
});
- this.reportRoute.setStyle(this.getLineStyle());
- vectorSource.addFeature(this.reportRoute);
+ feature.setStyle(style);
+ this.reportRoutePoints[data.getAt(index).get('id')] = feature;
+ }
- for (var key in this.reportRoutePoints) {
- if (this.reportRoutePoints.hasOwnProperty(key)) {
- vectorSource.addFeature(this.reportRoutePoints[key]);
- }
+ this.reportRoute = new ol.Feature({
+ geometry: new ol.geom.LineString(positions)
+ });
+ this.reportRoute.setStyle(this.getLineStyle());
+ vectorSource.addFeature(this.reportRoute);
+
+ for (var key in this.reportRoutePoints) {
+ if (this.reportRoutePoints.hasOwnProperty(key)) {
+ vectorSource.addFeature(this.reportRoutePoints[key]);
}
- },
+ }
+ },
- reportClear: function () {
- var vectorSource = this.getView().vectorSource;
+ reportClear: function () {
+ var vectorSource = this.getView().vectorSource;
- if (this.reportRoute !== undefined) {
- vectorSource.removeFeature(this.reportRoute);
- this.reportRoute = undefined;
- }
+ if (this.reportRoute !== undefined) {
+ vectorSource.removeFeature(this.reportRoute);
+ this.reportRoute = undefined;
+ }
- if (this.reportRoutePoints !== undefined) {
- for (var key in this.reportRoutePoints) {
- if (this.reportRoutePoints.hasOwnProperty(key)) {
- vectorSource.removeFeature(this.reportRoutePoints[key]);
- }
+ if (this.reportRoutePoints !== undefined) {
+ for (var key in this.reportRoutePoints) {
+ if (this.reportRoutePoints.hasOwnProperty(key)) {
+ vectorSource.removeFeature(this.reportRoutePoints[key]);
}
- this.reportRoutePoints = {};
}
- },
+ this.reportRoutePoints = {};
+ }
+ },
- selectPosition: function (feature) {
- if (this.currentFeature !== undefined) {
- this.currentFeature.setStyle(this.currentFeature.get('originalStyle'));
- }
+ selectPosition: function (feature) {
+ if (this.currentFeature !== undefined) {
+ this.currentFeature.setStyle(this.currentFeature.get('originalStyle'));
+ }
- if (feature !== undefined) {
- feature.setStyle(this.getMarkerStyle(Traccar.Style.mapSelectRadius, Traccar.Style.mapSelectColor));
+ if (feature !== undefined) {
+ feature.setStyle(this.getMarkerStyle(Traccar.Style.mapSelectRadius, Traccar.Style.mapSelectColor));
- var pan = ol.animation.pan({
- duration: Traccar.Style.mapDelay,
- source: this.getView().mapView.getCenter()
- });
- this.getView().map.beforeRender(pan);
- this.getView().mapView.setCenter(feature.getGeometry().getCoordinates());
- }
+ var pan = ol.animation.pan({
+ duration: Traccar.Style.mapDelay,
+ source: this.getView().mapView.getCenter()
+ });
+ this.getView().map.beforeRender(pan);
+ this.getView().mapView.setCenter(feature.getGeometry().getCoordinates());
+ }
- this.currentFeature = feature;
- },
+ this.currentFeature = feature;
+ },
- selectDevice: function (device) {
- this.selectPosition(this.liveData[device.get('id')]);
- },
+ selectDevice: function (device) {
+ this.selectPosition(this.liveData[device.get('id')]);
+ },
- selectReport: function (position) {
- if (this.reportRoutePoints[position.get('id')] !== undefined) {
- this.selectPosition(this.reportRoutePoints[position.get('id')]);
- }
+ selectReport: function (position) {
+ if (this.reportRoutePoints[position.get('id')] !== undefined) {
+ this.selectPosition(this.reportRoutePoints[position.get('id')]);
}
+ }
- });
-
-})();
+});
diff --git a/web/app/view/Register.js b/web/app/view/Register.js
index 04975c74e..445f335f9 100644
--- a/web/app/view/Register.js
+++ b/web/app/view/Register.js
@@ -13,50 +13,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Register', {
- extend: 'Traccar.view.BaseDialog',
+Ext.define('Traccar.view.Register', {
+ extend: 'Traccar.view.BaseDialog',
- requires: [
- 'Traccar.view.RegisterController'
- ],
+ requires: [
+ 'Traccar.view.RegisterController'
+ ],
- controller: 'register',
+ controller: 'register',
- items: {
- xtype: 'form',
- reference: 'form',
- jsonSubmit: true,
+ items: {
+ xtype: 'form',
+ reference: 'form',
+ jsonSubmit: true,
- items: [{
- xtype: 'textfield',
- name: 'name',
- fieldLabel: Strings.userName,
- allowBlank: false
- }, {
- xtype: 'textfield',
- name: 'email',
- fieldLabel: Strings.userEmail,
- vtype: 'email',
- allowBlank: false
- }, {
- xtype: 'textfield',
- name: 'password',
- fieldLabel: Strings.userPassword,
- inputType: 'password',
- allowBlank: false
- }]
- },
-
- buttons: [{
- text: Strings.sharedSave,
- handler: 'onCreateClick'
+ items: [{
+ xtype: 'textfield',
+ name: 'name',
+ fieldLabel: Strings.userName,
+ allowBlank: false
+ }, {
+ xtype: 'textfield',
+ name: 'email',
+ fieldLabel: Strings.userEmail,
+ vtype: 'email',
+ allowBlank: false
}, {
- text: Strings.sharedCancel,
- handler: 'closeView'
+ xtype: 'textfield',
+ name: 'password',
+ fieldLabel: Strings.userPassword,
+ inputType: 'password',
+ allowBlank: false
}]
- });
+ },
-})();
+ buttons: [{
+ text: Strings.sharedSave,
+ handler: 'onCreateClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/RegisterController.js b/web/app/view/RegisterController.js
index 36a423a30..5cf41fc65 100644
--- a/web/app/view/RegisterController.js
+++ b/web/app/view/RegisterController.js
@@ -13,32 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.RegisterController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.register',
+Ext.define('Traccar.view.RegisterController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.register',
- onCreateClick: function () {
- var form = this.lookupReference('form');
- if (form.isValid()) {
- Ext.Ajax.request({
- scope: this,
- url: '/api/register',
- jsonData: form.getValues(),
- callback: this.onCreateReturn
- });
- }
- },
-
- onCreateReturn: function (options, success, response) {
- if (Traccar.ErrorManager.check(success, response)) {
- this.closeView();
- Ext.toast(Strings.loginCreated);
- }
+ onCreateClick: function () {
+ var form = this.lookupReference('form');
+ if (form.isValid()) {
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/register',
+ jsonData: form.getValues(),
+ callback: this.onCreateReturn
+ });
}
+ },
- });
+ onCreateReturn: function (options, success, response) {
+ if (Traccar.ErrorManager.check(success, response)) {
+ this.closeView();
+ Ext.toast(Strings.loginCreated);
+ }
+ }
-})();
+});
diff --git a/web/app/view/Report.js b/web/app/view/Report.js
index 93f2ca1ee..6f2359253 100644
--- a/web/app/view/Report.js
+++ b/web/app/view/Report.js
@@ -13,110 +13,106 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.Report', {
- extend: 'Ext.grid.Panel',
- xtype: 'reportView',
+Ext.define('Traccar.view.Report', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'reportView',
- requires: [
- 'Traccar.view.ReportController'
- ],
+ requires: [
+ 'Traccar.view.ReportController'
+ ],
- controller: 'report',
- store: 'Positions',
+ controller: 'report',
+ store: 'Positions',
- title: Strings.reportTitle,
+ title: Strings.reportTitle,
- tbar: [{
- xtype: 'tbtext',
- html: Strings.reportDevice
- }, {
- xtype: 'combobox',
- reference: 'deviceField',
- store: 'Devices',
- valueField: 'id',
- displayField: 'name',
- typeAhead: true,
- queryMode: 'local'
- }, '-', {
- xtype: 'tbtext',
- html: Strings.reportFrom
- }, {
- xtype: 'datefield',
- reference: 'fromDateField',
- startDay: Traccar.Style.weekStartDay,
- value: new Date(new Date().getTime() - 30 * 60 * 1000)
- }, {
- xtype: 'timefield',
- reference: 'fromTimeField',
- maxWidth: Traccar.Style.reportTime,
- format: Traccar.Style.timeFormat,
- value: new Date(new Date().getTime() - 30 * 60 * 1000)
- }, '-', {
- xtype: 'tbtext',
- html: Strings.reportTo
- }, {
- xtype: 'datefield',
- reference: 'toDateField',
- startDay: Traccar.Style.weekStartDay,
- value: new Date()
- }, {
- xtype: 'timefield',
- reference: 'toTimeField',
- maxWidth: Traccar.Style.reportTime,
- format: Traccar.Style.timeFormat,
- value: new Date()
- }, '-', {
- text: Strings.reportShow,
- handler: 'onShowClick'
- }, {
- text: Strings.reportClear,
- handler: 'onClearClick'
- }],
+ tbar: [{
+ xtype: 'tbtext',
+ html: Strings.reportDevice
+ }, {
+ xtype: 'combobox',
+ reference: 'deviceField',
+ store: 'Devices',
+ valueField: 'id',
+ displayField: 'name',
+ typeAhead: true,
+ queryMode: 'local'
+ }, '-', {
+ xtype: 'tbtext',
+ html: Strings.reportFrom
+ }, {
+ xtype: 'datefield',
+ reference: 'fromDateField',
+ startDay: Traccar.Style.weekStartDay,
+ value: new Date(new Date().getTime() - 30 * 60 * 1000)
+ }, {
+ xtype: 'timefield',
+ reference: 'fromTimeField',
+ maxWidth: Traccar.Style.reportTime,
+ format: Traccar.Style.timeFormat,
+ value: new Date(new Date().getTime() - 30 * 60 * 1000)
+ }, '-', {
+ xtype: 'tbtext',
+ html: Strings.reportTo
+ }, {
+ xtype: 'datefield',
+ reference: 'toDateField',
+ startDay: Traccar.Style.weekStartDay,
+ value: new Date()
+ }, {
+ xtype: 'timefield',
+ reference: 'toTimeField',
+ maxWidth: Traccar.Style.reportTime,
+ format: Traccar.Style.timeFormat,
+ value: new Date()
+ }, '-', {
+ text: Strings.reportShow,
+ handler: 'onShowClick'
+ }, {
+ text: Strings.reportClear,
+ handler: 'onClearClick'
+ }],
- listeners: {
- selectionchange: 'onSelectionChange'
- },
+ listeners: {
+ selectionchange: 'onSelectionChange'
+ },
- columns: [{
- text: Strings.positionValid,
- dataIndex: 'valid',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('valid')
- }, {
- text: Strings.positionTime,
- dataIndex: 'fixTime',
- flex: 1,
- xtype: 'datecolumn',
- renderer: Traccar.AttributeFormatter.getFormatter('fixTime')
- }, {
- text: Strings.positionLatitude,
- dataIndex: 'latitude',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('latitude')
- }, {
- text: Strings.positionLongitude,
- dataIndex: 'longitude',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('latitude')
- }, {
- text: Strings.positionAltitude,
- dataIndex: 'altitude',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('altitude')
- }, {
- text: Strings.positionSpeed,
- dataIndex: 'speed',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('speed')
- }, {
- text: Strings.positionAddress,
- dataIndex: 'address',
- flex: 1,
- renderer: Traccar.AttributeFormatter.getFormatter('address')
- }]
- });
-
-})();
+ columns: [{
+ text: Strings.positionValid,
+ dataIndex: 'valid',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('valid')
+ }, {
+ text: Strings.positionTime,
+ dataIndex: 'fixTime',
+ flex: 1,
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.getFormatter('fixTime')
+ }, {
+ text: Strings.positionLatitude,
+ dataIndex: 'latitude',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('latitude')
+ }, {
+ text: Strings.positionLongitude,
+ dataIndex: 'longitude',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('latitude')
+ }, {
+ text: Strings.positionAltitude,
+ dataIndex: 'altitude',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('altitude')
+ }, {
+ text: Strings.positionSpeed,
+ dataIndex: 'speed',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('speed')
+ }, {
+ text: Strings.positionAddress,
+ dataIndex: 'address',
+ flex: 1,
+ renderer: Traccar.AttributeFormatter.getFormatter('address')
+ }]
+});
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 1b226fd55..2badfea63 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -13,72 +13,68 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.ReportController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.report',
+Ext.define('Traccar.view.ReportController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.report',
- config: {
- listen: {
- controller: {
- '*': {
- selectDevice: 'selectDevice'
- }
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ selectDevice: 'selectDevice'
}
}
- },
-
- onShowClick: function () {
- var deviceId, fromDate, fromTime, from, toDate, toTime, to, store;
-
- deviceId = this.lookupReference('deviceField').getValue();
+ }
+ },
- fromDate = this.lookupReference('fromDateField').getValue();
- fromTime = this.lookupReference('fromTimeField').getValue();
+ onShowClick: function () {
+ var deviceId, fromDate, fromTime, from, toDate, toTime, to, store;
- from = new Date(
- fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
- fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
+ deviceId = this.lookupReference('deviceField').getValue();
- toDate = this.lookupReference('toDateField').getValue();
- toTime = this.lookupReference('toTimeField').getValue();
+ fromDate = this.lookupReference('fromDateField').getValue();
+ fromTime = this.lookupReference('fromTimeField').getValue();
- to = new Date(
- toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
- toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
+ from = new Date(
+ fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
+ fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
- store = Ext.getStore('Positions');
- store.load({
- params: {
- deviceId: deviceId,
- from: from.toISOString(),
- to: to.toISOString()
- },
- scope: this,
- callback: function () {
- this.fireEvent('reportShow');
- }
- });
- },
+ toDate = this.lookupReference('toDateField').getValue();
+ toTime = this.lookupReference('toTimeField').getValue();
- onClearClick: function () {
- Ext.getStore('Positions').removeAll();
- this.fireEvent('reportClear');
- },
+ to = new Date(
+ toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
+ toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
- onSelectionChange: function (selected) {
- if (selected.getCount() > 0) {
- this.fireEvent('selectReport', selected.getLastSelected());
+ store = Ext.getStore('Positions');
+ store.load({
+ params: {
+ deviceId: deviceId,
+ from: from.toISOString(),
+ to: to.toISOString()
+ },
+ scope: this,
+ callback: function () {
+ this.fireEvent('reportShow');
}
- },
+ });
+ },
- selectDevice: function (device) {
- if (device !== undefined) {
- this.getView().getSelectionModel().deselectAll();
- }
+ onClearClick: function () {
+ Ext.getStore('Positions').removeAll();
+ this.fireEvent('reportClear');
+ },
+
+ onSelectionChange: function (selected) {
+ if (selected.getCount() > 0) {
+ this.fireEvent('selectReport', selected.getLastSelected());
}
- });
+ },
-})();
+ selectDevice: function (device) {
+ if (device !== undefined) {
+ this.getView().getSelectionModel().deselectAll();
+ }
+ }
+});
diff --git a/web/app/view/ServerDialog.js b/web/app/view/ServerDialog.js
index fa5ede524..8f81bb9b9 100644
--- a/web/app/view/ServerDialog.js
+++ b/web/app/view/ServerDialog.js
@@ -13,69 +13,65 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.ServerDialog', {
- extend: 'Traccar.view.BaseEditDialog',
+Ext.define('Traccar.view.ServerDialog', {
+ extend: 'Traccar.view.BaseEditDialog',
- requires: [
- 'Traccar.view.BaseEditDialogController'
- ],
+ requires: [
+ 'Traccar.view.BaseEditDialogController'
+ ],
- controller: 'baseEditDialog',
- title: Strings.serverTitle,
+ controller: 'baseEditDialog',
+ title: Strings.serverTitle,
- items: {
- xtype: 'form',
- items: [{
- xtype: 'checkboxfield',
- name: 'registration',
- fieldLabel: Strings.serverRegistration,
- allowBlank: false
- }, {
- xtype: 'combobox',
- name: 'map',
- fieldLabel: Strings.mapLayer,
- store: 'MapTypes',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'textfield',
- name: 'bingKey',
- fieldLabel: Strings.mapBingKey
- }, {
- xtype: 'textfield',
- name: 'mapUrl',
- fieldLabel: Strings.mapCustom
- }, {
- xtype: 'combobox',
- name: 'distanceUnit',
- fieldLabel: Strings.settingsDistanceUnit,
- store: 'DistanceUnits',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'combobox',
- name: 'speedUnit',
- fieldLabel: Strings.settingsSpeedUnit,
- store: 'SpeedUnits',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'numberfield',
- name: 'latitude',
- fieldLabel: Strings.positionLatitude
- }, {
- xtype: 'numberfield',
- name: 'longitude',
- fieldLabel: Strings.positionLongitude
- }, {
- xtype: 'numberfield',
- name: 'zoom',
- fieldLabel: Strings.serverZoom
- }]
- }
- });
-
-})();
+ items: {
+ xtype: 'form',
+ items: [{
+ xtype: 'checkboxfield',
+ name: 'registration',
+ fieldLabel: Strings.serverRegistration,
+ allowBlank: false
+ }, {
+ xtype: 'combobox',
+ name: 'map',
+ fieldLabel: Strings.mapLayer,
+ store: 'MapTypes',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'textfield',
+ name: 'bingKey',
+ fieldLabel: Strings.mapBingKey
+ }, {
+ xtype: 'textfield',
+ name: 'mapUrl',
+ fieldLabel: Strings.mapCustom
+ }, {
+ xtype: 'combobox',
+ name: 'distanceUnit',
+ fieldLabel: Strings.settingsDistanceUnit,
+ store: 'DistanceUnits',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'combobox',
+ name: 'speedUnit',
+ fieldLabel: Strings.settingsSpeedUnit,
+ store: 'SpeedUnits',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'numberfield',
+ name: 'latitude',
+ fieldLabel: Strings.positionLatitude
+ }, {
+ xtype: 'numberfield',
+ name: 'longitude',
+ fieldLabel: Strings.positionLongitude
+ }, {
+ xtype: 'numberfield',
+ name: 'zoom',
+ fieldLabel: Strings.serverZoom
+ }]
+ }
+});
diff --git a/web/app/view/State.js b/web/app/view/State.js
index b67c9a46f..1a9f014f5 100644
--- a/web/app/view/State.js
+++ b/web/app/view/State.js
@@ -13,31 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.State', {
- extend: 'Ext.grid.Panel',
- xtype: 'stateView',
+Ext.define('Traccar.view.State', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'stateView',
- requires: [
- 'Traccar.view.StateController'
- ],
+ requires: [
+ 'Traccar.view.StateController'
+ ],
- controller: 'state',
- store: 'Attributes',
+ controller: 'state',
+ store: 'Attributes',
- title: Strings.stateTitle,
+ title: Strings.stateTitle,
- columns: [{
- text: Strings.stateName,
- dataIndex: 'name',
- flex: 1
- }, {
- text: Strings.stateValue,
- dataIndex: 'value',
- flex: 1
- }]
- });
-
-})();
+ 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
index 9aa23de64..a6adfc908 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -13,129 +13,125 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.StateController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.state',
+Ext.define('Traccar.view.StateController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.state',
- config: {
- listen: {
- controller: {
- '*': {
- selectDevice: 'selectDevice'
- }
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ selectDevice: 'selectDevice'
}
}
- },
+ }
+ },
- init: function () {
- var store = Ext.getStore('LatestPositions');
- store.on('add', this.add, this);
- store.on('update', this.update, this);
- },
+ 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
- }
+ keys: {
+ fixTime: {
+ priority: 1,
+ name: Strings.positionTime
},
-
- formatValue: function (value) {
- if (typeof (id) === 'number') {
- return value.toFixed(2);
- } else {
- return value;
- }
+ 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
+ }
+ },
- updatePosition: function (position) {
- var attributes, store, key;
- store = Ext.getStore('Attributes');
- store.removeAll();
+ formatValue: function (value) {
+ if (typeof (id) === 'number') {
+ return value.toFixed(2);
+ } else {
+ return value;
+ }
+ },
- 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))
- }));
- }
- }
+ updatePosition: function (position) {
+ var attributes, store, key;
+ store = Ext.getStore('Attributes');
+ store.removeAll();
- 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])
- }));
- }
- }
+ 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))
+ }));
}
- },
+ }
- 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();
+ 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])
+ }));
+ }
}
- },
+ }
+ },
- add: function (store, data) {
- if (this.deviceId === data[0].get('deviceId')) {
- this.updatePosition(data[0]);
- }
- },
+ 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();
+ }
+ },
- update: function (store, data) {
- if (this.deviceId === data.get('deviceId')) {
- this.updatePosition(data);
- }
+ 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);
+ }
+ }
+});
diff --git a/web/app/view/User.js b/web/app/view/User.js
index 9eb0232f7..b642b5518 100644
--- a/web/app/view/User.js
+++ b/web/app/view/User.js
@@ -13,52 +13,56 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.User', {
- extend: 'Ext.grid.Panel',
- xtype: 'userView',
+Ext.define('Traccar.view.User', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'userView',
- requires: [
- 'Traccar.view.UserController'
- ],
+ requires: [
+ 'Traccar.view.UserController'
+ ],
- controller: 'user',
- store: 'Users',
+ controller: 'user',
+ store: 'Users',
- selType: 'rowmodel',
+ selType: 'rowmodel',
- tbar: [{
- text: Strings.sharedAdd,
- handler: 'onAddClick',
- reference: 'deviceAddButton'
- }, {
- text: Strings.sharedEdit,
- disabled: true,
- handler: 'onEditClick',
- reference: 'userEditButton'
- }, {
- text: Strings.sharedRemove,
- disabled: true,
- handler: 'onRemoveClick',
- reference: 'userRemoveButton'
- }, {
- text: Strings.deviceTitle,
- disabled: true,
- handler: 'onDevicesClick',
- reference: 'userDevicesButton'
- }],
+ tbar: [{
+ text: Strings.sharedAdd,
+ handler: 'onAddClick',
+ reference: 'deviceAddButton'
+ }, {
+ text: Strings.sharedEdit,
+ disabled: true,
+ handler: 'onEditClick',
+ reference: 'userEditButton'
+ }, {
+ text: Strings.sharedRemove,
+ disabled: true,
+ handler: 'onRemoveClick',
+ reference: 'userRemoveButton'
+ }, {
+ text: Strings.deviceTitle,
+ disabled: true,
+ handler: 'onDevicesClick',
+ reference: 'userDevicesButton'
+ }],
- listeners: {
- selectionchange: 'onSelectionChange'
- },
+ listeners: {
+ selectionchange: 'onSelectionChange'
+ },
- columns: [
- {text: Strings.userName, dataIndex: 'name', flex: 1},
- {text: Strings.userEmail, dataIndex: 'email', flex: 1},
- {text: Strings.userAdmin, dataIndex: 'admin', flex: 1}
- ]
- });
-
-})();
+ columns: [{
+ text: Strings.userName,
+ dataIndex: 'name',
+ flex: 1
+ }, {
+ text: Strings.userEmail,
+ dataIndex: 'email',
+ flex: 1
+ }, {
+ text: Strings.userAdmin,
+ dataIndex: 'admin',
+ flex: 1
+ }]
+});
diff --git a/web/app/view/UserController.js b/web/app/view/UserController.js
index 0a6e4f553..6615c7e49 100644
--- a/web/app/view/UserController.js
+++ b/web/app/view/UserController.js
@@ -13,78 +13,74 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.UserController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.user',
+Ext.define('Traccar.view.UserController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.user',
- requires: [
- 'Traccar.view.UserDialog'
- ],
+ requires: [
+ 'Traccar.view.UserDialog'
+ ],
- init: function () {
- Ext.getStore('Users').load();
- },
+ init: function () {
+ Ext.getStore('Users').load();
+ },
- onAddClick: function () {
- var user, dialog;
- user = Ext.create('Traccar.model.User'),
- dialog = Ext.create('Traccar.view.UserDialog');
- dialog.down('form').loadRecord(user);
- dialog.show();
- },
+ onAddClick: function () {
+ var user, dialog;
+ user = Ext.create('Traccar.model.User');
+ dialog = Ext.create('Traccar.view.UserDialog');
+ dialog.down('form').loadRecord(user);
+ dialog.show();
+ },
- onEditClick: function () {
- var user, dialog;
- user = this.getView().getSelectionModel().getSelection()[0];
- dialog = Ext.create('Traccar.view.UserDialog');
- dialog.down('form').loadRecord(user);
- dialog.show();
- },
+ onEditClick: function () {
+ var user, dialog;
+ user = this.getView().getSelectionModel().getSelection()[0];
+ dialog = Ext.create('Traccar.view.UserDialog');
+ dialog.down('form').loadRecord(user);
+ dialog.show();
+ },
- onRemoveClick: function () {
- var user = this.getView().getSelectionModel().getSelection()[0];
- Ext.Msg.show({
- title: Strings.settingsUser,
- message: Strings.sharedRemoveConfirm,
- buttons: Ext.Msg.YESNO,
- buttonText: {
- yes: Strings.sharedRemove,
- no: Strings.sharedCancel
- },
- fn: function (btn) {
- if (btn === 'yes') {
- var store = Ext.getStore('Users');
- store.remove(user);
- store.sync();
- }
+ onRemoveClick: function () {
+ var user = this.getView().getSelectionModel().getSelection()[0];
+ Ext.Msg.show({
+ title: Strings.settingsUser,
+ message: Strings.sharedRemoveConfirm,
+ buttons: Ext.Msg.YESNO,
+ buttonText: {
+ yes: Strings.sharedRemove,
+ no: Strings.sharedCancel
+ },
+ fn: function (btn) {
+ if (btn === 'yes') {
+ var store = Ext.getStore('Users');
+ store.remove(user);
+ store.sync();
}
- });
- },
+ }
+ });
+ },
- onDevicesClick: function () {
- // TODO show devices
- /*Ext.create('Ext.window.Window', {
- title: Strings.settingsUsers,
- width: Traccar.Style.windowWidth,
- height: Traccar.Style.windowHeight,
- layout: 'fit',
- modal: true,
- items: {
- xtype: 'userView'
- }
- }).show();*/
- },
+ onDevicesClick: function () {
+ // TODO show devices
+ /*Ext.create('Ext.window.Window', {
+ title: Strings.settingsUsers,
+ width: Traccar.Style.windowWidth,
+ height: Traccar.Style.windowHeight,
+ layout: 'fit',
+ modal: true,
+ items: {
+ xtype: 'userView'
+ }
+ }).show();*/
+ },
- onSelectionChange: function (selected) {
- var disabled = selected.length > 0;
- this.lookupReference('userEditButton').setDisabled(disabled);
- this.lookupReference('userRemoveButton').setDisabled(disabled);
- this.lookupReference('userDevicesButton').setDisabled(disabled);
- }
+ onSelectionChange: function (selected) {
+ var disabled = selected.length > 0;
+ this.lookupReference('userEditButton').setDisabled(disabled);
+ this.lookupReference('userRemoveButton').setDisabled(disabled);
+ this.lookupReference('userDevicesButton').setDisabled(disabled);
+ }
- });
-
-})();
+});
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index f66c5af02..32acd950c 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -13,79 +13,75 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.UserDialog', {
- extend: 'Traccar.view.BaseEditDialog',
+Ext.define('Traccar.view.UserDialog', {
+ extend: 'Traccar.view.BaseEditDialog',
- requires: [
- 'Traccar.view.UserDialogController'
- ],
+ requires: [
+ 'Traccar.view.UserDialogController'
+ ],
- controller: 'userDialog',
+ controller: 'userDialog',
- title: Strings.settingsUser,
+ title: Strings.settingsUser,
- items: {
- xtype: 'form',
- items: [{
- xtype: 'textfield',
- name: 'name',
- fieldLabel: Strings.userName
- }, {
- xtype: 'textfield',
- name: 'email',
- fieldLabel: Strings.userEmail,
- allowBlank: false
- }, {
- xtype: 'textfield',
- name: 'password',
- fieldLabel: Strings.userPassword,
- inputType: 'password',
- allowBlank: false
- }, {
- xtype: 'checkboxfield',
- name: 'admin',
- fieldLabel: Strings.userAdmin,
- allowBlank: false,
- disabled: true,
- reference: 'adminField'
- }, {
- xtype: 'combobox',
- name: 'map',
- fieldLabel: Strings.mapLayer,
- store: 'MapTypes',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'combobox',
- name: 'distanceUnit',
- fieldLabel: Strings.settingsDistanceUnit,
- store: 'DistanceUnits',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'combobox',
- name: 'speedUnit',
- fieldLabel: Strings.settingsSpeedUnit,
- store: 'SpeedUnits',
- displayField: 'name',
- valueField: 'key'
- }, {
- xtype: 'numberfield',
- name: 'latitude',
- fieldLabel: Strings.positionLatitude
- }, {
- xtype: 'numberfield',
- name: 'longitude',
- fieldLabel: Strings.positionLongitude
- }, {
- xtype: 'numberfield',
- name: 'zoom',
- fieldLabel: Strings.serverZoom
- }]
- }
- });
-
-})();
+ items: {
+ xtype: 'form',
+ items: [{
+ xtype: 'textfield',
+ name: 'name',
+ fieldLabel: Strings.userName
+ }, {
+ xtype: 'textfield',
+ name: 'email',
+ fieldLabel: Strings.userEmail,
+ allowBlank: false
+ }, {
+ xtype: 'textfield',
+ name: 'password',
+ fieldLabel: Strings.userPassword,
+ inputType: 'password',
+ allowBlank: false
+ }, {
+ xtype: 'checkboxfield',
+ name: 'admin',
+ fieldLabel: Strings.userAdmin,
+ allowBlank: false,
+ disabled: true,
+ reference: 'adminField'
+ }, {
+ xtype: 'combobox',
+ name: 'map',
+ fieldLabel: Strings.mapLayer,
+ store: 'MapTypes',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'combobox',
+ name: 'distanceUnit',
+ fieldLabel: Strings.settingsDistanceUnit,
+ store: 'DistanceUnits',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'combobox',
+ name: 'speedUnit',
+ fieldLabel: Strings.settingsSpeedUnit,
+ store: 'SpeedUnits',
+ displayField: 'name',
+ valueField: 'key'
+ }, {
+ xtype: 'numberfield',
+ name: 'latitude',
+ fieldLabel: Strings.positionLatitude
+ }, {
+ xtype: 'numberfield',
+ name: 'longitude',
+ fieldLabel: Strings.positionLongitude
+ }, {
+ xtype: 'numberfield',
+ name: 'zoom',
+ fieldLabel: Strings.serverZoom
+ }]
+ }
+});
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index 40c88a8b4..a5d045f5b 100644
--- a/web/app/view/UserDialogController.js
+++ b/web/app/view/UserDialogController.js
@@ -13,40 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.view.UserDialogController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.userDialog',
+Ext.define('Traccar.view.UserDialogController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.userDialog',
- init: function () {
- if (Traccar.app.getUser().get('admin')) {
- this.lookupReference('adminField').setDisabled(false);
- }
- },
+ init: function () {
+ if (Traccar.app.getUser().get('admin')) {
+ this.lookupReference('adminField').setDisabled(false);
+ }
+ },
- onSaveClick: function (button) {
- var dialog, record, store;
- dialog = button.up('window').down('form');
- dialog.updateRecord();
- record = dialog.getRecord();
- if (record === Traccar.app.getUser()) {
- record.save();
- } else {
- store = Ext.getStore('Users');
- if (record.phantom) {
- store.add(record);
- }
- store.sync({
- failure: function (batch) {
- store.rejectChanges(); // TODO
- Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse());
- }
- });
+ onSaveClick: function (button) {
+ var dialog, record, store;
+ dialog = button.up('window').down('form');
+ dialog.updateRecord();
+ record = dialog.getRecord();
+ if (record === Traccar.app.getUser()) {
+ record.save();
+ } else {
+ store = Ext.getStore('Users');
+ if (record.phantom) {
+ store.add(record);
}
- button.up('window').close();
+ store.sync({
+ failure: function (batch) {
+ store.rejectChanges(); // TODO
+ Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse());
+ }
+ });
}
- });
-
-})();
+ button.up('window').close();
+ }
+});