diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-05 18:47:24 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-05 18:47:24 +1200 |
commit | c2afe93f1443181bc7bcce2df708a88c331b8800 (patch) | |
tree | 808dc50805ee76a882d299142ee0201bafc5a90c /web | |
parent | 35ae7fbd26180fa56072095ef47d6c54a4e22393 (diff) | |
download | trackermap-server-c2afe93f1443181bc7bcce2df708a88c331b8800.tar.gz trackermap-server-c2afe93f1443181bc7bcce2df708a88c331b8800.tar.bz2 trackermap-server-c2afe93f1443181bc7bcce2df708a88c331b8800.zip |
Implement server settings
Diffstat (limited to 'web')
-rw-r--r-- | web/app/Resources.js | 11 | ||||
-rw-r--r-- | web/app/model/Server.js | 11 | ||||
-rw-r--r-- | web/app/view/admin/ServerDialog.js | 12 | ||||
-rw-r--r-- | web/app/view/admin/ServerDialogController.js | 12 | ||||
-rw-r--r-- | web/app/view/device/Device.js | 18 | ||||
-rw-r--r-- | web/app/view/device/DeviceController.js | 18 |
6 files changed, 61 insertions, 21 deletions
diff --git a/web/app/Resources.js b/web/app/Resources.js index be982bf55..def231844 100644 --- a/web/app/Resources.js +++ b/web/app/Resources.js @@ -33,7 +33,13 @@ var strings = { device_title: 'Devices', device_name: 'Name', device_identifier: 'Identifier', - device_remove: 'Remove device?', + device_remove_confirm: 'Remove device?', + device_add: 'Add', + device_edit: 'Edit', + device_remove: 'Remove', + device_logout: 'Logout', + device_settings: 'Settings', + device_settings_server: 'Server', report_title: 'Reports', report_device: 'Device', @@ -51,6 +57,9 @@ var strings = { report_address: 'Address', server_title: 'Server settings', + server_latitude: 'Latitude', + server_longitude: 'Longitude', + server_zoom: 'Zoom', server_registration: 'Registration', dialog_save: 'Save', diff --git a/web/app/model/Server.js b/web/app/model/Server.js index 289a13593..128855a2b 100644 --- a/web/app/model/Server.js +++ b/web/app/model/Server.js @@ -24,5 +24,14 @@ Ext.define('Traccar.model.Server', { { name: 'latitude', type: 'float' }, { name: 'longitude', type: 'float' }, { name: 'zoom', type: 'int' } - ] + ], + + proxy: { + type: 'ajax', + url: '/api/server/update', + writer: { + type: 'json', + writeAllFields: true + } + } }); diff --git a/web/app/view/admin/ServerDialog.js b/web/app/view/admin/ServerDialog.js index e654c9048..d3cbc3492 100644 --- a/web/app/view/admin/ServerDialog.js +++ b/web/app/view/admin/ServerDialog.js @@ -36,6 +36,18 @@ Ext.define('Traccar.view.admin.ServerDialog', { name: 'registration', fieldLabel: strings.server_registration, allowBlank: false + }, { + xtype: 'numberfield', + name: 'latitude', + fieldLabel: strings.server_latitude + }, { + xtype: 'numberfield', + name: 'longitude', + fieldLabel: strings.server_longitude + }, { + xtype: 'numberfield', + name: 'zoom', + fieldLabel: strings.server_zoom }] }, diff --git a/web/app/view/admin/ServerDialogController.js b/web/app/view/admin/ServerDialogController.js index 8e0910b3c..bbb98d3a0 100644 --- a/web/app/view/admin/ServerDialogController.js +++ b/web/app/view/admin/ServerDialogController.js @@ -21,17 +21,7 @@ Ext.define('Traccar.view.admin.ServerDialogController', { onSaveClick: function(button) { var dialog = button.up('window').down('form'); dialog.updateRecord(); - var store = Ext.getStore('Devices'); - var device = dialog.getRecord(); - if (device.phantom) { - store.add(device); - } - store.sync({ - failure: function(batch) { - store.rejectChanges(); // TODO - Traccar.ErrorManager.check(true, batch.exceptions[0].getResponse()); - } - }); + dialog.getRecord().save(); button.up('window').close(); }, diff --git a/web/app/view/device/Device.js b/web/app/view/device/Device.js index 64f53eeb2..bccb43e9e 100644 --- a/web/app/view/device/Device.js +++ b/web/app/view/device/Device.js @@ -15,7 +15,7 @@ */ Ext.define('Traccar.view.device.Device', { - extend: 'Ext.grid.Panel', + extend: 'Ext.grid.Panel', xtype: 'device-view', requires: [ @@ -29,25 +29,31 @@ Ext.define('Traccar.view.device.Device', { selType: 'rowmodel', tbar: [{ - text:'Add', + text: strings.device_add, handler: 'onAddClick', reference: 'deviceAddButton' }, { - text:'Edit', + text: strings.device_edit, disabled: true, handler: 'onEditClick', reference: 'deviceEditButton' }, { - text:'Remove', + text: strings.device_remove, disabled: true, handler: 'onRemoveClick', reference: 'deviceRemoveButton' }, { xtype: 'tbfill' }, { - text:'Settings' + text: strings.device_settings, + menu: [{ + text: strings.device_settings_server, + disabled: true, + handler: 'onServerClick', + reference: 'settingsServerButton' + }] }, { - text:'Logout', + text: strings.device_logout, handler: 'onLogoutClick' }], diff --git a/web/app/view/device/DeviceController.js b/web/app/view/device/DeviceController.js index 82c17860f..6d88d8d3e 100644 --- a/web/app/view/device/DeviceController.js +++ b/web/app/view/device/DeviceController.js @@ -19,8 +19,15 @@ Ext.define('Traccar.view.device.DeviceController', { alias: 'controller.device', requires: [ - 'Traccar.view.device.DeviceDialog' + 'Traccar.view.device.DeviceDialog', + 'Traccar.view.admin.ServerDialog' ], + + init: function() { + if (Traccar.getApplication().getUser().get('admin')) { + this.lookupReference('settingsServerButton').setDisabled(false); + } + }, onLogoutClick: function() { Traccar.LoginManager.logout(); @@ -44,7 +51,7 @@ Ext.define('Traccar.view.device.DeviceController', { var device = this.getView().getSelectionModel().getSelection()[0]; Ext.Msg.show({ title: strings.device_dialog, - message: strings.device_remove, + message: strings.device_remove_confirm, buttons: Ext.Msg.YESNO, buttonText: { yes: strings.dialog_delete, @@ -64,6 +71,13 @@ Ext.define('Traccar.view.device.DeviceController', { var disabled = selected.length > 0; this.lookupReference('deviceEditButton').setDisabled(disabled); this.lookupReference('deviceRemoveButton').setDisabled(disabled); + }, + + onServerClick: function() { + var server = Traccar.getApplication().getServer(); + var dialog = Ext.create('Traccar.view.admin.ServerDialog'); + dialog.down('form').loadRecord(server); + dialog.show(); } }); |