diff options
Diffstat (limited to 'web/app/view')
25 files changed, 1446 insertions, 1339 deletions
diff --git a/web/app/view/BaseDialog.js b/web/app/view/BaseDialog.js index d875e14c9..2a8084698 100644 --- a/web/app/view/BaseDialog.js +++ b/web/app/view/BaseDialog.js @@ -13,11 +13,15 @@ * 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: styles.panelPadding, - resizable: false, - modal: true -}); + bodyPadding: styles.panelPadding, + resizable: false, + modal: true + }); + +})(); diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js index 0788c30d2..81831e2fb 100644 --- a/web/app/view/BaseEditDialog.js +++ b/web/app/view/BaseEditDialog.js @@ -13,15 +13,19 @@ * 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 3b43cacf3..1820d9c9a 100644 --- a/web/app/view/BaseEditDialogController.js +++ b/web/app/view/BaseEditDialogController.js @@ -13,33 +13,37 @@ * 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()); + 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); } - }); - } else { - record.save(); + 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(); } - button.up('window').close(); - } -}); + }); + +})(); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js index 5d37f3173..388c0afce 100644 --- a/web/app/view/CommandDialog.js +++ b/web/app/view/CommandDialog.js @@ -13,55 +13,59 @@ * 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, - - 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, + controller: 'commandDialog', + title: strings.commandTitle, + items: { + xtype: 'form', items: [{ - xtype: 'numberfield', - fieldLabel: strings.commandFrequency, - name: 'frequency' - }, { xtype: 'combobox', - fieldLabel: strings.commandUnit, - name: 'unit', - store: 'TimeUnits', + name: 'type', + fieldLabel: strings.commandType, + store: 'CommandTypes', displayField: 'name', - valueField: 'factor' + 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' + }] }] + }, + + 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 88e72d6e3..1c6b361a7 100644 --- a/web/app/view/CommandDialogController.js +++ b/web/app/view/CommandDialogController.js @@ -13,45 +13,49 @@ * 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', + Ext.define('Traccar.view.CommandDialogController', { + extend: 'Ext.app.ViewController', + alias: 'controller.commandDialog', - onSelect: function (selected) { - this.lookupReference('paramPositionPeriodic').setHidden( + 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 + }, + + 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 }); - } + }, - 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(); + 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 de2c7ed4c..ce9d24659 100644 --- a/web/app/view/Device.js +++ b/web/app/view/Device.js @@ -13,81 +13,85 @@ * 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' - ], - - controller: 'device', - store: 'Devices', + requires: [ + 'Traccar.view.DeviceController' + ], - 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' - }, { - 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' + controller: 'device', + store: 'Devices', + + 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' + }, { + 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' }, { - text: strings.settingsServer, - hidden: true, - handler: 'onServerClick', - reference: 'settingsServerButton' + 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 }, { - text: strings.settingsUsers, - hidden: true, - handler: 'onUsersClick', - reference: 'settingsUsersButton' + text: strings.deviceIdentifier, + dataIndex: 'uniqueId', flex: 1 }] - }, { - 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 2e2fdb2a6..748ebabe6 100644 --- a/web/app/view/DeviceController.js +++ b/web/app/view/DeviceController.js @@ -13,126 +13,130 @@ * 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', - - requires: [ - 'Traccar.view.CommandDialog', - 'Traccar.view.DeviceDialog', - 'Traccar.view.UserDialog', - 'Traccar.view.User', - 'Traccar.view.LoginController' - ], + Ext.define('Traccar.view.DeviceController', { + extend: 'Ext.app.ViewController', + alias: 'controller.device', - config: { - listen: { - controller: { - '*': { - selectReport: 'selectReport' + requires: [ + 'Traccar.view.CommandDialog', + 'Traccar.view.DeviceDialog', + 'Traccar.view.UserDialog', + 'Traccar.view.User', + 'Traccar.view.LoginController' + ], + + config: { + listen: { + controller: { + '*': { + selectReport: 'selectReport' + } } } - } - }, + }, - 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(); - }, - - 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(); - }, - - 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(); - } + init: function () { + if (Traccar.app.getUser().get('admin')) { + this.lookupReference('settingsServerButton').setHidden(false); + this.lookupReference('settingsUsersButton').setHidden(false); } - }); - }, + }, - 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(); - }, + onLogoutClick: function () { + Ext.create('Traccar.view.LoginController').logout(); + }, - 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()); - } - }, + 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(); + }, - onUserClick: function () { - var dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(Traccar.app.getUser()); - 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(); + } + } + }); + }, - onServerClick: function () { - var dialog = Ext.create('Traccar.view.ServerDialog'); - dialog.down('form').loadRecord(Traccar.app.getServer()); - 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(); + }, - onUsersClick: function () { - Ext.create('Ext.window.Window', { - title: strings.settingsUsers, - width: styles.windowWidth, - height: styles.windowHeight, - layout: 'fit', - modal: true, - items: { - xtype: 'userView' + 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()); } - }).show(); - }, + }, - selectReport: function (position) { - if (position !== undefined) { - this.getView().getSelectionModel().deselectAll(); + 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(); + }, + + onUsersClick: function () { + Ext.create('Ext.window.Window', { + title: strings.settingsUsers, + width: styles.windowWidth, + height: styles.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 759fade6d..012048b8a 100644 --- a/web/app/view/DeviceDialog.js +++ b/web/app/view/DeviceDialog.js @@ -13,29 +13,33 @@ * 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 23f813c66..b68f80b07 100644 --- a/web/app/view/Login.js +++ b/web/app/view/Login.js @@ -13,79 +13,83 @@ * 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', - - requires: [ - 'Traccar.view.LoginController' - ], - - controller: 'login', + Ext.define('Traccar.view.Login', { + extend: 'Traccar.view.BaseDialog', + alias: 'widget.login', - closable: false, + requires: [ + 'Traccar.view.LoginController' + ], - items: { - xtype: 'form', - reference: 'form', + controller: 'login', - autoEl: { - tag: 'form', - method: 'POST', - action: 'blank', - target: 'submitTarget' - }, + closable: false, - 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' + items: { + xtype: 'form', + reference: 'form', + + autoEl: { + tag: 'form', + method: 'POST', + action: 'blank', + target: 'submitTarget' }, - inputAttrTpl: ['autocomplete="on"'] - }, { - xtype: 'component', - html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>' + + 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">' + }] + }, + + buttons: [{ + text: strings.loginRegister, + handler: 'onRegisterClick', + reference: 'registerButton' }, { - xtype: 'component', - html: '<input type="submit" id="submitButton" style="display:none">' + text: strings.loginLogin, + handler: 'onLoginClick' }] - }, + }); - 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 bc73661ed..011fddc25 100644 --- a/web/app/view/LoginController.js +++ b/web/app/view/LoginController.js @@ -13,92 +13,96 @@ * 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', - - requires: [ - 'Traccar.view.Register' - ], + Ext.define('Traccar.view.LoginController', { + extend: 'Ext.app.ViewController', + alias: 'controller.login', - init: function () { - this.lookupReference('registerButton').setDisabled( - !Traccar.app.getServer().get('registration')); - this.lookupReference('languageField').setValue(language); - }, + requires: [ + 'Traccar.view.Register' + ], - 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) { - Ext.getBody().unmask(); - if (Traccar.ErrorManager.check(success, response)) { - var result = Ext.decode(response.responseText); - if (result.success) { - Traccar.app.setUser(result.data); - this.fireViewEvent('login'); - } else { - Traccar.ErrorManager.error(strings.loginFailed); + init: function () { + this.lookupReference('registerButton').setDisabled( + !Traccar.app.getServer().get('registration')); + this.lookupReference('languageField').setValue(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) { + Ext.getBody().unmask(); + if (Traccar.ErrorManager.check(success, response)) { + var 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(); } }); - } - }, + }, - 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; + 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 { - url += '&' + paramName + '=' + paramValue; + if (url.indexOf('?') < 0) { + url += '?' + paramName + '=' + paramValue; + } else { + url += '&' + paramName + '=' + paramValue; + } } - } - window.location.href = url; - }, + window.location.href = url; + }, - onAfterRender: function (field) { - field.focus(); - }, + onAfterRender: function (field) { + field.focus(); + }, - onSpecialKey: function (field, e) { - if (e.getKey() === e.ENTER) { + 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.login.Register').show(); } - }, - - onLoginClick: function () { - Ext.getElementById('submitButton').click(); - this.login(); - }, + }); - onRegisterClick: function () { - Ext.create('Traccar.view.login.Register').show(); - } -}); +})(); diff --git a/web/app/view/Main.js b/web/app/view/Main.js index ee1073e92..1ad61d73f 100644 --- a/web/app/view/Main.js +++ b/web/app/view/Main.js @@ -13,51 +13,55 @@ * 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: styles.deviceWidth, defaults: { - split: true, - flex: 1 + header: false, + collapsible: true, + split: true }, items: [{ - region: 'center', - xtype: 'deviceView' + region: 'west', + layout: 'border', + width: styles.deviceWidth, + + defaults: { + split: true, + flex: 1 + }, + + items: [{ + region: 'center', + xtype: 'deviceView' + }, { + region: 'south', + xtype: 'stateView' + }] }, { region: 'south', - xtype: 'stateView' + xtype: 'reportView', + height: styles.reportHeight + }, { + region: 'center', + xtype: 'mapView', + header: true, + collapsible: false }] - }, { - region: 'south', - xtype: 'reportView', - height: styles.reportHeight - }, { - region: 'center', - xtype: 'mapView', - header: true, - collapsible: false - }] -}); + }); + +})(); diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js index e42fc7f7f..d822f4978 100644 --- a/web/app/view/MainMobile.js +++ b/web/app/view/MainMobile.js @@ -13,37 +13,41 @@ * 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 f7a763b9d..e356c4678 100644 --- a/web/app/view/Map.js +++ b/web/app/view/Map.js @@ -13,73 +13,84 @@ * 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({ - })}); - } + 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 - }); + this.vectorSource = new ol.source.Vector({}); + var vectorLayer = new ol.layer.Vector({ + source: this.vectorSource + }); - var lat = user.get('latitude') || server.get('latitude') || styles.mapDefaultLat; - var lon = user.get('longitude') || server.get('longitude') || styles.mapDefaultLon; - var zoom = user.get('zoom') || server.get('zoom') || styles.mapDefaultZoom; + var lat = user.get('latitude') || server.get('latitude') || styles.mapDefaultLat; + var lon = user.get('longitude') || server.get('longitude') || styles.mapDefaultLon; + var zoom = user.get('zoom') || server.get('zoom') || styles.mapDefaultZoom; - this.mapView = new ol.View({ - center: ol.proj.fromLonLat([lon, lat]), - zoom: zoom, - maxZoom: styles.mapMaxZoom - }); + this.mapView = new ol.View({ + center: ol.proj.fromLonLat([lon, lat]), + zoom: zoom, + maxZoom: styles.mapMaxZoom + }); - this.map = new ol.Map({ - target: this.body.dom.id, - layers: [layer, vectorLayer], - view: this.mapView - }); - }, + this.map = new ol.Map({ + target: this.body.dom.id, + layers: [layer, vectorLayer], + view: this.mapView + }); + }, - resize: function () { - this.map.updateSize(); + resize: function () { + this.map.updateSize(); + } } - } -}); + }); + +})(); diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index 66cbe6b31..cca746a20 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -13,202 +13,206 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -Ext.define('Traccar.view.MapController', { - extend: 'Ext.app.ViewController', - alias: 'controller.map', - - config: { - listen: { - controller: { - '*': { - reportShow: 'reportShow', - reportClear: 'reportClear', - selectDevice: 'selectDevice', - selectReport: 'selectReport' +(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' + } } } - } - }, - - 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])); + }, + + 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(styles.mapLiveRadius, styles.mapLiveColor); + var marker = new ol.Feature({ + geometry: geometry, + originalStyle: style + }); + marker.setStyle(style); + this.getView().vectorSource.addFeature(marker); + this.liveData[data[i].deviceId] = marker; + } } - 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(styles.mapLiveRadius, styles.mapLiveColor); - var marker = new ol.Feature({ - geometry: geometry, - originalStyle: style - }); - marker.setStyle(style); - this.getView().vectorSource.addFeature(marker); - this.liveData[data[i].deviceId] = marker; - } + this.update(false); + }, + failure: function () { + // TODO: error } - - this.update(false); - }, - failure: function () { - // TODO: error - } - }); - }, - - getLineStyle: function () { - return new ol.style.Style({ - stroke: new ol.style.Stroke({ - color: styles.mapStrokeColor, - width: styles.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 - }), + }); + }, + + getLineStyle: function () { + return new ol.style.Style({ stroke: new ol.style.Stroke({ color: styles.mapStrokeColor, - width: styles.mapMarkerStroke + width: styles.mapRouteWidth }) - }) - }); - }, - - reportShow: function () { - this.reportClear(); - - var vectorSource = this.getView().vectorSource; - - var data = Ext.getStore('Positions').getData(); - - 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(styles.mapReportRadius, styles.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; - } + }, + + 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: styles.mapStrokeColor, + width: styles.mapMarkerStroke + }) + }) + }); + }, - this.reportRoute = new ol.Feature({ - geometry: new ol.geom.LineString(positions) - }); - this.reportRoute.setStyle(this.getLineStyle()); - vectorSource.addFeature(this.reportRoute); + reportShow: function () { + this.reportClear(); - for (var key in this.reportRoutePoints) { - if (this.reportRoutePoints.hasOwnProperty(key)) { - vectorSource.addFeature(this.reportRoutePoints[key]); - } - } - }, + var vectorSource = this.getView().vectorSource; - reportClear: function () { - var index; - var vectorSource = this.getView().vectorSource; + var data = Ext.getStore('Positions').getData(); - if (this.reportRoute !== undefined) { - vectorSource.removeFeature(this.reportRoute); - this.reportRoute = undefined; - } + 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(styles.mapReportRadius, styles.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; + } + + this.reportRoute = new ol.Feature({ + geometry: new ol.geom.LineString(positions) + }); + this.reportRoute.setStyle(this.getLineStyle()); + vectorSource.addFeature(this.reportRoute); - if (this.reportRoutePoints !== undefined) { for (var key in this.reportRoutePoints) { if (this.reportRoutePoints.hasOwnProperty(key)) { - vectorSource.removeFeature(this.reportRoutePoints[key]); + vectorSource.addFeature(this.reportRoutePoints[key]); } } - this.reportRoutePoints = {}; - } - }, + }, - selectPosition: function (feature) { - if (this.currentFeature !== undefined) { - this.currentFeature.setStyle(this.currentFeature.get('originalStyle')); - } + reportClear: function () { + var index; + var vectorSource = this.getView().vectorSource; - if (feature !== undefined) { - feature.setStyle(this.getMarkerStyle(styles.mapSelectRadius, styles.mapSelectColor)); + if (this.reportRoute !== undefined) { + vectorSource.removeFeature(this.reportRoute); + this.reportRoute = undefined; + } - var pan = ol.animation.pan({ - duration: styles.mapDelay, - source: this.getView().mapView.getCenter() - }); - this.getView().map.beforeRender(pan); - this.getView().mapView.setCenter(feature.getGeometry().getCoordinates()); - } + if (this.reportRoutePoints !== undefined) { + for (var key in this.reportRoutePoints) { + if (this.reportRoutePoints.hasOwnProperty(key)) { + vectorSource.removeFeature(this.reportRoutePoints[key]); + } + } + this.reportRoutePoints = {}; + } + }, - this.currentFeature = feature; - }, + selectPosition: function (feature) { + if (this.currentFeature !== undefined) { + this.currentFeature.setStyle(this.currentFeature.get('originalStyle')); + } - selectDevice: function (device) { - this.selectPosition(this.liveData[device.get('id')]); - }, + if (feature !== undefined) { + feature.setStyle(this.getMarkerStyle(styles.mapSelectRadius, styles.mapSelectColor)); + + var pan = ol.animation.pan({ + duration: styles.mapDelay, + source: this.getView().mapView.getCenter() + }); + this.getView().map.beforeRender(pan); + this.getView().mapView.setCenter(feature.getGeometry().getCoordinates()); + } - selectReport: function (position) { - if (this.reportRoutePoints[position.get('id')] !== undefined) { - this.selectPosition(this.reportRoutePoints[position.get('id')]); + this.currentFeature = feature; + }, + + 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')]); + } } - } -}); + }); + +})(); diff --git a/web/app/view/Register.js b/web/app/view/Register.js index 464b7bb1f..c8fbf0722 100644 --- a/web/app/view/Register.js +++ b/web/app/view/Register.js @@ -13,46 +13,50 @@ * 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', - - requires: [ - 'Traccar.view.RegisterController' - ], - - controller: 'register', + Ext.define('Traccar.view.Register', { + extend: 'Traccar.view.BaseDialog', - items: { - xtype: 'form', - reference: 'form', - jsonSubmit: true, + requires: [ + 'Traccar.view.RegisterController' + ], - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: strings.userName, - allowBlank: false - }, { - xtype: 'textfield', - name: 'email', - fieldLabel: strings.userEmail, - vtype: 'email', - allowBlank: false + controller: 'register', + + 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' }, { - xtype: 'textfield', - name: 'password', - fieldLabel: strings.userPassword, - inputType: 'password', - allowBlank: false + text: strings.sharedCancel, + handler: 'closeView' }] - }, + }); - 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 2547d631c..94238acf3 100644 --- a/web/app/view/RegisterController.js +++ b/web/app/view/RegisterController.js @@ -13,28 +13,32 @@ * 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 060c9c46a..73ba6e12b 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -13,106 +13,110 @@ * 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: styles.weekStartDay, - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }, { - xtype: 'timefield', - reference: 'fromTimeField', - maxWidth: styles.reportTime, - format: styles.timeFormat, - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }, '-', { - xtype: 'tbtext', - html: strings.reportTo - }, { - xtype: 'datefield', - reference: 'toDateField', - startDay: styles.weekStartDay, - value: new Date() - }, { - xtype: 'timefield', - reference: 'toTimeField', - maxWidth: styles.reportTime, - format: styles.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: styles.weekStartDay, + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }, { + xtype: 'timefield', + reference: 'fromTimeField', + maxWidth: styles.reportTime, + format: styles.timeFormat, + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }, '-', { + xtype: 'tbtext', + html: strings.reportTo + }, { + xtype: 'datefield', + reference: 'toDateField', + startDay: styles.weekStartDay, + value: new Date() + }, { + xtype: 'timefield', + reference: 'toTimeField', + maxWidth: styles.reportTime, + format: styles.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 99c1a9b07..8653784ab 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -13,68 +13,72 @@ * 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; + onShowClick: function () { + var deviceId, fromDate, fromTime, from, toDate, toTime, to, store; - deviceId = this.lookupReference('deviceField').getValue(); + deviceId = this.lookupReference('deviceField').getValue(); - fromDate = this.lookupReference('fromDateField').getValue(); - fromTime = this.lookupReference('fromTimeField').getValue(); + 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()); + from = new Date( + fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(), + fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds()); - toDate = this.lookupReference('toDateField').getValue(); - toTime = this.lookupReference('toTimeField').getValue(); + toDate = this.lookupReference('toDateField').getValue(); + toTime = this.lookupReference('toTimeField').getValue(); - to = new Date( - toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), - toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); + to = new Date( + toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), + toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); - store = Ext.getStore('Positions'); - store.load({ - params:{ - deviceId: deviceId, - from: from.toISOString(), - to: to.toISOString() - }, - scope: this, - callback: function () { - this.fireEvent("reportShow"); - } - }); - }, + store = Ext.getStore('Positions'); + store.load({ + params: { + deviceId: deviceId, + from: from.toISOString(), + to: to.toISOString() + }, + scope: this, + callback: function () { + this.fireEvent("reportShow"); + } + }); + }, - onClearClick: function () { - Ext.getStore('Positions').removeAll(); - this.fireEvent("reportClear"); - }, + onClearClick: function () { + Ext.getStore('Positions').removeAll(); + this.fireEvent("reportClear"); + }, - onSelectionChange: function (selected) { - if (selected.getCount() > 0) { - this.fireEvent("selectReport", selected.getLastSelected()); - } - }, + onSelectionChange: function (selected) { + if (selected.getCount() > 0) { + this.fireEvent("selectReport", selected.getLastSelected()); + } + }, - selectDevice: function (device) { - if (device !== undefined) { - this.getView().getSelectionModel().deselectAll(); + 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 1339786ab..a9751d647 100644 --- a/web/app/view/ServerDialog.js +++ b/web/app/view/ServerDialog.js @@ -13,65 +13,69 @@ * 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 0804234f9..5cb31c676 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -13,27 +13,31 @@ * 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', - - requires: [ - 'Traccar.view.StateController' - ], - - controller: 'state', - store: 'Attributes', + Ext.define('Traccar.view.State', { + extend: 'Ext.grid.Panel', + xtype: 'stateView', - title: strings.stateTitle, + requires: [ + 'Traccar.view.StateController' + ], - columns: [{ - text: strings.stateName, - dataIndex: 'name', - flex: 1 - }, { - text: strings.stateValue, - dataIndex: 'value', - flex: 1 - }] -}); + controller: 'state', + store: 'Attributes', + + 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 index ce9a21af4..489662ee7 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -13,125 +13,129 @@ * 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); - }, - - 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; - } - }, + init: function () { + var store = Ext.getStore('LatestPositions'); + store.on('add', this.add, this); + store.on('update', this.update, this); + }, - updatePosition: function (position) { - var attributes, value, unit, store, key; - store = Ext.getStore('Attributes'); - store.removeAll(); + 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 + } + }, - 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)) - })); + 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(); - attributes = position.get('attributes'); - if (attributes instanceof Object) { - for (key in attributes) { - if (attributes.hasOwnProperty(key)) { + for (key in position.data) { + if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) { store.add(Ext.create('Traccar.model.Attribute', { - priority: 1024, - name: key.replace(/^./, function (match) { - return match.toUpperCase(); - }), - value: Traccar.AttributeFormatter.getFormatter(key)(attributes[key]) + 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 807095ebe..61ff01ab5 100644 --- a/web/app/view/User.js +++ b/web/app/view/User.js @@ -13,48 +13,52 @@ * 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', - - requires: [ - 'Traccar.view.UserController' - ], - - controller: 'user', - store: 'Users', - - 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' - }], - - 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 } - ] -}); + Ext.define('Traccar.view.User', { + extend: 'Ext.grid.Panel', + xtype: 'userView', + + requires: [ + 'Traccar.view.UserController' + ], + + controller: 'user', + store: 'Users', + + 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' + }], + + 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} + ] + }); + +})(); diff --git a/web/app/view/UserController.js b/web/app/view/UserController.js index f541914e4..670565dcb 100644 --- a/web/app/view/UserController.js +++ b/web/app/view/UserController.js @@ -13,72 +13,76 @@ * 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 = Ext.create('Traccar.model.User'); - var dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(user); - dialog.show(); - }, + onAddClick: function () { + var user = Ext.create('Traccar.model.User'); + var dialog = Ext.create('Traccar.view.UserDialog'); + dialog.down('form').loadRecord(user); + dialog.show(); + }, - onEditClick: function () { - var user = this.getView().getSelectionModel().getSelection()[0]; - var dialog = Ext.create('Traccar.view.UserDialog'); - dialog.down('form').loadRecord(user); - dialog.show(); - }, + onEditClick: function () { + var user = this.getView().getSelectionModel().getSelection()[0]; + var 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: styles.windowWidth, - height: styles.windowHeight, - layout: 'fit', - modal: true, - items: { - xtype: 'userView' - } - }).show();*/ - }, + onDevicesClick: function () { + // TODO show devices + /*Ext.create('Ext.window.Window', { + title: strings.settingsUsers, + width: styles.windowWidth, + height: styles.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 0c5914ce0..2048051be 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -13,75 +13,79 @@ * 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 0bd9d87e3..6dbd44fa7 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -13,35 +13,39 @@ * 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); - } - }, - - onSaveClick: function (button) { - var dialog = button.up('window').down('form'); - dialog.updateRecord(); - var record = dialog.getRecord(); - if (record === Traccar.app.getUser()) { - record.save(); - } else { - var store = Ext.getStore('Users'); - if (record.phantom) { - store.add(record); + init: function () { + if (Traccar.app.getUser().get('admin')) { + this.lookupReference('adminField').setDisabled(false); } - store.sync({ - failure: function (batch) { - store.rejectChanges(); // TODO - Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); + }, + + onSaveClick: function (button) { + var dialog = button.up('window').down('form'); + dialog.updateRecord(); + var record = dialog.getRecord(); + if (record === Traccar.app.getUser()) { + record.save(); + } else { + var 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()); + } + }); + } + button.up('window').close(); } - button.up('window').close(); - } -}); + }); + +})(); |