From 69291297bab7e61af8596f6cca425fadbaf1304f Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 28 Mar 2017 15:55:33 +0500 Subject: Move BaseDialog, subclasses and their controllers to dialog subfolder --- web/app/view/dialog/DeviceDistanceController.js | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 web/app/view/dialog/DeviceDistanceController.js (limited to 'web/app/view/dialog/DeviceDistanceController.js') diff --git a/web/app/view/dialog/DeviceDistanceController.js b/web/app/view/dialog/DeviceDistanceController.js new file mode 100644 index 00000000..a7c33b99 --- /dev/null +++ b/web/app/view/dialog/DeviceDistanceController.js @@ -0,0 +1,44 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.DeviceDistanceController', { + extend: 'Ext.app.ViewController', + alias: 'controller.deviceDistanceDialog', + + onDeviceChange: function (combobox, newValue) { + this.lookupReference('setButton').setDisabled(newValue === null); + }, + + onSetClick: function (button) { + var data = {}; + data.deviceId = this.lookupReference('deviceId').getValue(); + data.totalDistance = this.lookupReference('totalDistance').getValue(); + Ext.Ajax.request({ + scope: this, + method: 'PUT', + url: 'api/devices/' + data.deviceId + '/distance', + jsonData: Ext.util.JSON.encode(data), + callback: function (options, success, response) { + if (!success) { + Traccar.app.showError(response); + } + } + }); + button.up('window').close(); + } +}); -- cgit v1.2.3 From 6f0bcddcac9a2ec711f545f1278a4ec991d05aa6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 28 Mar 2017 17:00:40 +0500 Subject: Remove Dialog from names --- web/app/view/AttributeAliasesController.js | 6 +- web/app/view/AttributesController.js | 4 +- web/app/view/CalendarsController.js | 4 +- web/app/view/DevicesController.js | 8 +- web/app/view/GeofencesController.js | 4 +- web/app/view/GroupsController.js | 4 +- web/app/view/ReportController.js | 4 +- web/app/view/SettingsMenuController.js | 12 +- web/app/view/StateController.js | 4 +- web/app/view/UsersController.js | 8 +- web/app/view/dialog/Attribute.js | 54 ++++++ web/app/view/dialog/AttributeAlias.js | 57 ++++++ web/app/view/dialog/AttributeAliasDialog.js | 57 ------ web/app/view/dialog/AttributeController.js | 2 +- web/app/view/dialog/AttributeDialog.js | 54 ------ web/app/view/dialog/Base.js | 33 ++++ web/app/view/dialog/BaseDialog.js | 33 ---- web/app/view/dialog/BaseEdit.js | 45 +++++ web/app/view/dialog/BaseEditController.js | 62 +++++++ web/app/view/dialog/BaseEditDialog.js | 45 ----- web/app/view/dialog/BaseEditDialogController.js | 62 ------- web/app/view/dialog/Calendar.js | 62 +++++++ web/app/view/dialog/CalendarController.js | 37 ++++ web/app/view/dialog/CalendarDialog.js | 62 ------- web/app/view/dialog/CalendarDialogController.js | 37 ---- web/app/view/dialog/Command.js | 147 +++++++++++++++ web/app/view/dialog/CommandController.js | 133 +++++++++++++ web/app/view/dialog/CommandDialog.js | 147 --------------- web/app/view/dialog/CommandDialogController.js | 133 ------------- web/app/view/dialog/Device.js | 84 +++++++++ web/app/view/dialog/DeviceDialog.js | 84 --------- web/app/view/dialog/DeviceDistance.js | 62 +++++++ web/app/view/dialog/DeviceDistanceController.js | 2 +- web/app/view/dialog/DeviceDistanceDialog.js | 62 ------- web/app/view/dialog/Geofence.js | 86 +++++++++ web/app/view/dialog/GeofenceController.js | 53 ++++++ web/app/view/dialog/GeofenceDialog.js | 86 --------- web/app/view/dialog/GeofenceDialogController.js | 53 ------ web/app/view/dialog/Group.js | 50 +++++ web/app/view/dialog/GroupDialog.js | 50 ----- web/app/view/dialog/Login.js | 2 +- web/app/view/dialog/MapPickerController.js | 42 +++++ web/app/view/dialog/MapPickerDialogController.js | 42 ----- web/app/view/dialog/Register.js | 2 +- web/app/view/dialog/ReportConfig.js | 120 ++++++++++++ web/app/view/dialog/ReportConfigController.js | 2 +- web/app/view/dialog/ReportConfigDialog.js | 120 ------------ web/app/view/dialog/Server.js | 167 +++++++++++++++++ web/app/view/dialog/ServerDialog.js | 167 ----------------- web/app/view/dialog/User.js | 227 +++++++++++++++++++++++ web/app/view/dialog/UserController.js | 79 ++++++++ web/app/view/dialog/UserDialog.js | 227 ----------------------- web/app/view/dialog/UserDialogController.js | 79 -------- 53 files changed, 1634 insertions(+), 1634 deletions(-) create mode 100644 web/app/view/dialog/Attribute.js create mode 100644 web/app/view/dialog/AttributeAlias.js delete mode 100644 web/app/view/dialog/AttributeAliasDialog.js delete mode 100644 web/app/view/dialog/AttributeDialog.js create mode 100644 web/app/view/dialog/Base.js delete mode 100644 web/app/view/dialog/BaseDialog.js create mode 100644 web/app/view/dialog/BaseEdit.js create mode 100644 web/app/view/dialog/BaseEditController.js delete mode 100644 web/app/view/dialog/BaseEditDialog.js delete mode 100644 web/app/view/dialog/BaseEditDialogController.js create mode 100644 web/app/view/dialog/Calendar.js create mode 100644 web/app/view/dialog/CalendarController.js delete mode 100644 web/app/view/dialog/CalendarDialog.js delete mode 100644 web/app/view/dialog/CalendarDialogController.js create mode 100644 web/app/view/dialog/Command.js create mode 100644 web/app/view/dialog/CommandController.js delete mode 100644 web/app/view/dialog/CommandDialog.js delete mode 100644 web/app/view/dialog/CommandDialogController.js create mode 100644 web/app/view/dialog/Device.js delete mode 100644 web/app/view/dialog/DeviceDialog.js create mode 100644 web/app/view/dialog/DeviceDistance.js delete mode 100644 web/app/view/dialog/DeviceDistanceDialog.js create mode 100644 web/app/view/dialog/Geofence.js create mode 100644 web/app/view/dialog/GeofenceController.js delete mode 100644 web/app/view/dialog/GeofenceDialog.js delete mode 100644 web/app/view/dialog/GeofenceDialogController.js create mode 100644 web/app/view/dialog/Group.js delete mode 100644 web/app/view/dialog/GroupDialog.js create mode 100644 web/app/view/dialog/MapPickerController.js delete mode 100644 web/app/view/dialog/MapPickerDialogController.js create mode 100644 web/app/view/dialog/ReportConfig.js delete mode 100644 web/app/view/dialog/ReportConfigDialog.js create mode 100644 web/app/view/dialog/Server.js delete mode 100644 web/app/view/dialog/ServerDialog.js create mode 100644 web/app/view/dialog/User.js create mode 100644 web/app/view/dialog/UserController.js delete mode 100644 web/app/view/dialog/UserDialog.js delete mode 100644 web/app/view/dialog/UserDialogController.js (limited to 'web/app/view/dialog/DeviceDistanceController.js') diff --git a/web/app/view/AttributeAliasesController.js b/web/app/view/AttributeAliasesController.js index 36684077..3ebbc9af 100644 --- a/web/app/view/AttributeAliasesController.js +++ b/web/app/view/AttributeAliasesController.js @@ -21,12 +21,12 @@ Ext.define('Traccar.view.AttributeAliasesController', { alias: 'controller.attributeAliases', requires: [ - 'Traccar.view.dialog.AttributeAliasDialog', + 'Traccar.view.dialog.AttributeAlias', 'Traccar.model.AttributeAlias' ], objectModel: 'Traccar.model.AttributeAlias', - objectDialog: 'Traccar.view.dialog.AttributeAliasDialog', + objectDialog: 'Traccar.view.dialog.AttributeAlias', removeTitle: Strings.sharedAttributeAlias, init: function () { @@ -48,7 +48,7 @@ Ext.define('Traccar.view.AttributeAliasesController', { attributeAlias.store = Ext.getStore('AttributeAliases'); deviceId = this.lookupReference('deviceField').getValue(); attributeAlias.set('deviceId', deviceId); - dialog = Ext.create('Traccar.view.dialog.AttributeAliasDialog'); + dialog = Ext.create('Traccar.view.dialog.AttributeAlias'); dialog.down('form').loadRecord(attributeAlias); dialog.show(); }, diff --git a/web/app/view/AttributesController.js b/web/app/view/AttributesController.js index 96efee71..fe0c3153 100644 --- a/web/app/view/AttributesController.js +++ b/web/app/view/AttributesController.js @@ -20,13 +20,13 @@ Ext.define('Traccar.view.AttributesController', { alias: 'controller.attributes', requires: [ - 'Traccar.view.dialog.AttributeDialog', + 'Traccar.view.dialog.Attribute', 'Traccar.store.Attributes', 'Traccar.model.Attribute' ], objectModel: 'Traccar.model.Attribute', - objectDialog: 'Traccar.view.dialog.AttributeDialog', + objectDialog: 'Traccar.view.dialog.Attribute', removeTitle: Strings.stateName, init: function () { diff --git a/web/app/view/CalendarsController.js b/web/app/view/CalendarsController.js index 7cb3fe5a..668fbd0c 100644 --- a/web/app/view/CalendarsController.js +++ b/web/app/view/CalendarsController.js @@ -21,12 +21,12 @@ Ext.define('Traccar.view.CalendarsController', { alias: 'controller.calendars', requires: [ - 'Traccar.view.dialog.CalendarDialog', + 'Traccar.view.dialog.Calendar', 'Traccar.model.Calendar' ], objectModel: 'Traccar.model.Calendar', - objectDialog: 'Traccar.view.dialog.CalendarDialog', + objectDialog: 'Traccar.view.dialog.Calendar', removeTitle: Strings.sharedCalendar }); diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 5442f545..9d426911 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -20,8 +20,8 @@ Ext.define('Traccar.view.DevicesController', { alias: 'controller.devices', requires: [ - 'Traccar.view.dialog.CommandDialog', - 'Traccar.view.dialog.DeviceDialog', + 'Traccar.view.dialog.Command', + 'Traccar.view.dialog.Device', 'Traccar.view.DeviceGeofences', 'Traccar.view.BaseWindow', 'Traccar.model.Device', @@ -48,7 +48,7 @@ Ext.define('Traccar.view.DevicesController', { }, objectModel: 'Traccar.model.Device', - objectDialog: 'Traccar.view.dialog.DeviceDialog', + objectDialog: 'Traccar.view.dialog.Device', removeTitle: Strings.sharedDevice, init: function () { @@ -83,7 +83,7 @@ Ext.define('Traccar.view.DevicesController', { command.set('deviceId', deviceId); command.set('textChannel', !online); - dialog = Ext.create('Traccar.view.dialog.CommandDialog'); + dialog = Ext.create('Traccar.view.dialog.Command'); typesStore = dialog.lookupReference('commandType').getStore(); typesStore.getProxy().setExtraParam('deviceId', deviceId); diff --git a/web/app/view/GeofencesController.js b/web/app/view/GeofencesController.js index 17fb6665..80bb6718 100644 --- a/web/app/view/GeofencesController.js +++ b/web/app/view/GeofencesController.js @@ -20,11 +20,11 @@ Ext.define('Traccar.view.GeofencesController', { alias: 'controller.geofences', requires: [ - 'Traccar.view.dialog.GeofenceDialog', + 'Traccar.view.dialog.Geofence', 'Traccar.model.Geofence' ], objectModel: 'Traccar.model.Geofence', - objectDialog: 'Traccar.view.dialog.GeofenceDialog', + objectDialog: 'Traccar.view.dialog.Geofence', removeTitle: Strings.sharedGeofence }); diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js index 3e44329e..471e4952 100644 --- a/web/app/view/GroupsController.js +++ b/web/app/view/GroupsController.js @@ -20,14 +20,14 @@ Ext.define('Traccar.view.GroupsController', { alias: 'controller.groups', requires: [ - 'Traccar.view.dialog.GroupDialog', + 'Traccar.view.dialog.Group', 'Traccar.view.GroupGeofences', 'Traccar.view.BaseWindow', 'Traccar.model.Group' ], objectModel: 'Traccar.model.Group', - objectDialog: 'Traccar.view.dialog.GroupDialog', + objectDialog: 'Traccar.view.dialog.Group', removeTitle: Strings.groupDialog, onGeofencesClick: function () { diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 7dc5f654..e8955a8c 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -24,7 +24,7 @@ Ext.define('Traccar.view.ReportController', { 'Traccar.AttributeFormatter', 'Traccar.model.Position', 'Traccar.model.ReportTrip', - 'Traccar.view.dialog.ReportConfigDialog', + 'Traccar.view.dialog.ReportConfig', 'Traccar.store.ReportEventTypes' ], @@ -65,7 +65,7 @@ Ext.define('Traccar.view.ReportController', { }, onConfigureClick: function () { - var dialog = Ext.create('Traccar.view.dialog.ReportConfigDialog'); + var dialog = Ext.create('Traccar.view.dialog.ReportConfig'); dialog.lookupReference('eventTypeField').setHidden(this.lookupReference('reportTypeField').getValue() !== 'events'); dialog.lookupReference('chartTypeField').setHidden(this.lookupReference('reportTypeField').getValue() !== 'chart'); dialog.callingPanel = this; diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 8e818d77..8147bbe6 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -21,15 +21,15 @@ Ext.define('Traccar.view.SettingsMenuController', { requires: [ 'Traccar.view.dialog.LoginController', - 'Traccar.view.dialog.UserDialog', - 'Traccar.view.dialog.ServerDialog', + 'Traccar.view.dialog.User', + 'Traccar.view.dialog.Server', 'Traccar.view.Users', 'Traccar.view.Groups', 'Traccar.view.Geofences', 'Traccar.view.Notifications', 'Traccar.view.AttributeAliases', 'Traccar.view.Statistics', - 'Traccar.view.dialog.DeviceDistanceDialog', + 'Traccar.view.dialog.DeviceDistance', 'Traccar.view.Calendars', 'Traccar.view.BaseWindow' ], @@ -61,7 +61,7 @@ Ext.define('Traccar.view.SettingsMenuController', { }, onUserClick: function () { - var dialog = Ext.create('Traccar.view.dialog.UserDialog', { + var dialog = Ext.create('Traccar.view.dialog.User', { selfEdit: true }); dialog.down('form').loadRecord(Traccar.app.getUser()); @@ -90,7 +90,7 @@ Ext.define('Traccar.view.SettingsMenuController', { }, onServerClick: function () { - var dialog = Ext.create('Traccar.view.dialog.ServerDialog'); + var dialog = Ext.create('Traccar.view.dialog.Server'); dialog.down('form').loadRecord(Traccar.app.getServer()); dialog.show(); }, @@ -138,7 +138,7 @@ Ext.define('Traccar.view.SettingsMenuController', { }, onDeviceDistanceClick: function () { - var dialog = Ext.create('Traccar.view.dialog.DeviceDistanceDialog'); + var dialog = Ext.create('Traccar.view.dialog.DeviceDistance'); dialog.show(); }, diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 40362e85..f0370f96 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -24,7 +24,7 @@ Ext.define('Traccar.view.StateController', { 'Traccar.model.Attribute', 'Traccar.model.AttributeAlias', 'Traccar.model.Position', - 'Traccar.view.dialog.AttributeAliasDialog' + 'Traccar.view.dialog.AttributeAlias' ], @@ -192,7 +192,7 @@ Ext.define('Traccar.view.StateController', { }); attributeAlias.store = this.aliasesStore; } - dialog = Ext.create('Traccar.view.dialog.AttributeAliasDialog'); + dialog = Ext.create('Traccar.view.dialog.AttributeAlias'); dialog.down('form').loadRecord(attributeAlias); dialog.show(); }, diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index 365b3583..eaae230c 100644 --- a/web/app/view/UsersController.js +++ b/web/app/view/UsersController.js @@ -21,7 +21,7 @@ Ext.define('Traccar.view.UsersController', { alias: 'controller.users', requires: [ - 'Traccar.view.dialog.UserDialog', + 'Traccar.view.dialog.User', 'Traccar.view.UserDevices', 'Traccar.view.UserGroups', 'Traccar.view.UserGeofences', @@ -33,7 +33,7 @@ Ext.define('Traccar.view.UsersController', { ], objectModel: 'Traccar.model.User', - objectDialog: 'Traccar.view.dialog.UserDialog', + objectDialog: 'Traccar.view.dialog.User', removeTitle: Strings.settingsUser, init: function () { @@ -43,7 +43,7 @@ Ext.define('Traccar.view.UsersController', { onEditClick: function () { var dialog, user = this.getView().getSelectionModel().getSelection()[0]; - dialog = Ext.create('Traccar.view.dialog.UserDialog', { + dialog = Ext.create('Traccar.view.dialog.User', { selfEdit: user.get('id') === Traccar.app.getUser().get('id') }); dialog.down('form').loadRecord(user); @@ -59,7 +59,7 @@ Ext.define('Traccar.view.UsersController', { if (Traccar.app.getUser().get('expirationTime')) { user.set('expirationTime', Traccar.app.getUser().get('expirationTime')); } - dialog = Ext.create('Traccar.view.UserDialog'); + dialog = Ext.create('Traccar.view.dialog.User'); dialog.down('form').loadRecord(user); dialog.show(); }, diff --git a/web/app/view/dialog/Attribute.js b/web/app/view/dialog/Attribute.js new file mode 100644 index 00000000..993c2b12 --- /dev/null +++ b/web/app/view/dialog/Attribute.js @@ -0,0 +1,54 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Attribute', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.AttributeController' + ], + + controller: 'attribute', + title: Strings.sharedAttribute, + + items: { + xtype: 'form', + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName + }, { + xtype: 'textfield', + name: 'value', + fieldLabel: Strings.stateValue + }] + }, + + buttons: [{ + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/AttributeAlias.js b/web/app/view/dialog/AttributeAlias.js new file mode 100644 index 00000000..6072a306 --- /dev/null +++ b/web/app/view/dialog/AttributeAlias.js @@ -0,0 +1,57 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.AttributeAlias', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.AttributeController' + ], + + controller: 'attribute', + title: Strings.sharedAttributeAlias, + + items: { + xtype: 'form', + items: [{ + xtype: 'textfield', + name: 'attribute', + fieldLabel: Strings.sharedAttribute, + allowBlank: false + }, { + xtype: 'textfield', + name: 'alias', + fieldLabel: Strings.sharedAlias, + allowBlank: false + }] + }, + + buttons: [{ + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/AttributeAliasDialog.js b/web/app/view/dialog/AttributeAliasDialog.js deleted file mode 100644 index a8a6b82c..00000000 --- a/web/app/view/dialog/AttributeAliasDialog.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.AttributeAliasDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.AttributeController' - ], - - controller: 'attributeDialog', - title: Strings.sharedAttributeAlias, - - items: { - xtype: 'form', - items: [{ - xtype: 'textfield', - name: 'attribute', - fieldLabel: Strings.sharedAttribute, - allowBlank: false - }, { - xtype: 'textfield', - name: 'alias', - fieldLabel: Strings.sharedAlias, - allowBlank: false - }] - }, - - buttons: [{ - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index cd6fc61e..365a0df5 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -17,7 +17,7 @@ Ext.define('Traccar.view.dialog.AttributeController', { extend: 'Ext.app.ViewController', - alias: 'controller.attributeDialog', + alias: 'controller.attribute', onSaveClick: function (button) { var dialog, store, record; diff --git a/web/app/view/dialog/AttributeDialog.js b/web/app/view/dialog/AttributeDialog.js deleted file mode 100644 index 2dc851fd..00000000 --- a/web/app/view/dialog/AttributeDialog.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.AttributeDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.AttributeController' - ], - - controller: 'attributeDialog', - title: Strings.sharedAttribute, - - items: { - xtype: 'form', - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName - }, { - xtype: 'textfield', - name: 'value', - fieldLabel: Strings.stateValue - }] - }, - - buttons: [{ - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/Base.js b/web/app/view/dialog/Base.js new file mode 100644 index 00000000..5aad254d --- /dev/null +++ b/web/app/view/dialog/Base.js @@ -0,0 +1,33 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Base', { + extend: 'Ext.window.Window', + + bodyPadding: Traccar.Style.normalPadding, + resizable: false, + modal: true, + autoScroll: true, + constrain: true, + + initComponent: function () { + if (window.innerHeight) { + this.maxHeight = window.innerHeight - Traccar.Style.normalPadding * 2; + } + this.callParent(); + } +}); diff --git a/web/app/view/dialog/BaseDialog.js b/web/app/view/dialog/BaseDialog.js deleted file mode 100644 index 71fa6b32..00000000 --- a/web/app/view/dialog/BaseDialog.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.BaseDialog', { - extend: 'Ext.window.Window', - - bodyPadding: Traccar.Style.normalPadding, - resizable: false, - modal: true, - autoScroll: true, - constrain: true, - - initComponent: function () { - if (window.innerHeight) { - this.maxHeight = window.innerHeight - Traccar.Style.normalPadding * 2; - } - this.callParent(); - } -}); diff --git a/web/app/view/dialog/BaseEdit.js b/web/app/view/dialog/BaseEdit.js new file mode 100644 index 00000000..362823e3 --- /dev/null +++ b/web/app/view/dialog/BaseEdit.js @@ -0,0 +1,45 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.BaseEdit', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.BaseEditController' + ], + + controller: 'baseEdit', + + buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + xtype: 'tbfill' + }, { + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/BaseEditController.js b/web/app/view/dialog/BaseEditController.js new file mode 100644 index 00000000..287893b0 --- /dev/null +++ b/web/app/view/dialog/BaseEditController.js @@ -0,0 +1,62 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.BaseEditController', { + extend: 'Ext.app.ViewController', + alias: 'controller.baseEdit', + + requires: [ + 'Traccar.view.BaseWindow', + 'Traccar.view.Attributes' + ], + + 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({ + failure: function (batch) { + store.rejectChanges(); + Traccar.app.showError(batch.exceptions[0].getError().response); + } + }); + } else { + record.save(); + } + button.up('window').close(); + }, + + showAttributesView: function (button) { + var dialog, record; + dialog = button.up('window').down('form'); + record = dialog.getRecord(); + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedAttributes, + modal: false, + items: { + xtype: 'attributesView', + record: record + } + }).show(); + } +}); diff --git a/web/app/view/dialog/BaseEditDialog.js b/web/app/view/dialog/BaseEditDialog.js deleted file mode 100644 index f1314a96..00000000 --- a/web/app/view/dialog/BaseEditDialog.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.BaseEditDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.BaseEditDialogController' - ], - - controller: 'baseEditDialog', - - buttons: [{ - text: Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - xtype: 'tbfill' - }, { - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/BaseEditDialogController.js b/web/app/view/dialog/BaseEditDialogController.js deleted file mode 100644 index cc92c6f8..00000000 --- a/web/app/view/dialog/BaseEditDialogController.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.BaseEditDialogController', { - extend: 'Ext.app.ViewController', - alias: 'controller.baseEditDialog', - - requires: [ - 'Traccar.view.BaseWindow', - 'Traccar.view.Attributes' - ], - - 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({ - failure: function (batch) { - store.rejectChanges(); - Traccar.app.showError(batch.exceptions[0].getError().response); - } - }); - } else { - record.save(); - } - button.up('window').close(); - }, - - showAttributesView: function (button) { - var dialog, record; - dialog = button.up('window').down('form'); - record = dialog.getRecord(); - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedAttributes, - modal: false, - items: { - xtype: 'attributesView', - record: record - } - }).show(); - } -}); diff --git a/web/app/view/dialog/Calendar.js b/web/app/view/dialog/Calendar.js new file mode 100644 index 00000000..9880d4e6 --- /dev/null +++ b/web/app/view/dialog/Calendar.js @@ -0,0 +1,62 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Calendar', { + extend: 'Traccar.view.dialog.BaseEdit', + + requires: [ + 'Traccar.view.dialog.CalendarController' + ], + + controller: 'calendar', + title: Strings.sharedCalendar, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName, + allowBlank: false + }, { + xtype: 'filefield', + name: 'file', + fieldLabel: Strings.sharedFile, + allowBlank: false, + buttonConfig: { + glyph: 'xf093@FontAwesome', + text: '', + tooltip: Strings.sharedSelectFile, + tooltipType: 'title', + minWidth: 0 + }, + listeners: { + change: 'onFileChange' + } + }] + }, { + xtype: 'hiddenfield', + name: 'data', + allowBlank: false, + reference: 'dataField' + }] + } +}); diff --git a/web/app/view/dialog/CalendarController.js b/web/app/view/dialog/CalendarController.js new file mode 100644 index 00000000..14d8294a --- /dev/null +++ b/web/app/view/dialog/CalendarController.js @@ -0,0 +1,37 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.CalendarController', { + extend: 'Traccar.view.dialog.BaseEditController', + alias: 'controller.calendar', + + onFileChange: function (fileField) { + var reader; + if (fileField.fileInputEl.dom.files.length > 0) { + reader = new FileReader(); + reader.onload = function (event) { + fileField.up('window').lookupReference('dataField').setValue( + btoa(String.fromCharCode.apply(null, new Uint8Array(event.target.result)))); + }; + reader.onerror = function (event) { + Traccar.app.showError(event.target.error); + }; + reader.readAsArrayBuffer(fileField.fileInputEl.dom.files[0]); + } + } +}); diff --git a/web/app/view/dialog/CalendarDialog.js b/web/app/view/dialog/CalendarDialog.js deleted file mode 100644 index 7b233404..00000000 --- a/web/app/view/dialog/CalendarDialog.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.CalendarDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - requires: [ - 'Traccar.view.dialog.CalendarDialogController' - ], - - controller: 'calendarDialog', - title: Strings.sharedCalendar, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedRequired, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName, - allowBlank: false - }, { - xtype: 'filefield', - name: 'file', - fieldLabel: Strings.sharedFile, - allowBlank: false, - buttonConfig: { - glyph: 'xf093@FontAwesome', - text: '', - tooltip: Strings.sharedSelectFile, - tooltipType: 'title', - minWidth: 0 - }, - listeners: { - change: 'onFileChange' - } - }] - }, { - xtype: 'hiddenfield', - name: 'data', - allowBlank: false, - reference: 'dataField' - }] - } -}); diff --git a/web/app/view/dialog/CalendarDialogController.js b/web/app/view/dialog/CalendarDialogController.js deleted file mode 100644 index b041c85e..00000000 --- a/web/app/view/dialog/CalendarDialogController.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.CalendarDialogController', { - extend: 'Traccar.view.dialog.BaseEditDialogController', - alias: 'controller.calendarDialog', - - onFileChange: function (fileField) { - var reader; - if (fileField.fileInputEl.dom.files.length > 0) { - reader = new FileReader(); - reader.onload = function (event) { - fileField.up('window').lookupReference('dataField').setValue( - btoa(String.fromCharCode.apply(null, new Uint8Array(event.target.result)))); - }; - reader.onerror = function (event) { - Traccar.app.showError(event.target.error); - }; - reader.readAsArrayBuffer(fileField.fileInputEl.dom.files[0]); - } - } -}); diff --git a/web/app/view/dialog/Command.js b/web/app/view/dialog/Command.js new file mode 100644 index 00000000..ec98b29f --- /dev/null +++ b/web/app/view/dialog/Command.js @@ -0,0 +1,147 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Command', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.CommandController' + ], + + controller: 'command', + title: Strings.commandTitle, + + items: { + xtype: 'form', + items: [{ + xtype: 'checkboxfield', + name: 'textChannel', + reference: 'textChannelCheckBox', + inputValue: true, + uncheckedValue: false, + fieldLabel: Strings.notificationSms, + listeners: { + change: 'onTextChannelChange' + } + }, { + xtype: 'combobox', + name: 'type', + reference: 'commandType', + fieldLabel: Strings.sharedType, + store: 'CommandTypes', + displayField: 'name', + valueField: 'type', + editable: false, + 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' + }] + }, { + xtype: 'fieldcontainer', + reference: 'paramOutputControl', + name: 'attributes', + hidden: true, + + items: [{ + xtype: 'numberfield', + fieldLabel: Strings.commandIndex, + name: 'index', + allowBlank: false + }, { + xtype: 'textfield', + fieldLabel: Strings.commandData, + name: 'data' + }] + }, { + xtype: 'fieldcontainer', + reference: 'paramSendSmsUssd', + name: 'attributes', + hidden: true, + + items: [{ + xtype: 'textfield', + fieldLabel: Strings.commandPhone, + name: 'phone' + }, { + xtype: 'textfield', + reference: 'paramSmsMessage', + fieldLabel: Strings.commandMessage, + name: 'message', + hidden: true + }] + }, { + xtype: 'fieldcontainer', + reference: 'paramSetTimezone', + name: 'attributes', + hidden: true, + + items: [{ + xtype: 'numberfield', + fieldLabel: Strings.commandTimezone, + name: 'timezone', + minValue: -12, + step: 0.5, + maxValue: +14 + }] + }, { + xtype: 'fieldcontainer', + reference: 'paramSetIndicator', + name: 'attributes', + hidden: true, + + items: [{ + xtype: 'numberfield', + fieldLabel: Strings.commandData, + name: 'data', + minValue: 0, + maxValue: 99 + }] + }, { + xtype: 'textfield', + reference: 'paramCustom', + fieldLabel: Strings.commandCustom, + name: 'customCommand', + hidden: true, + allowBlank: false + }] + }, + + buttons: [{ + text: Strings.commandSend, + handler: 'onSendClick' + }, { + text: Strings.sharedCancel, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/CommandController.js b/web/app/view/dialog/CommandController.js new file mode 100644 index 00000000..be6245b0 --- /dev/null +++ b/web/app/view/dialog/CommandController.js @@ -0,0 +1,133 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.CommandController', { + extend: 'Ext.app.ViewController', + alias: 'controller.command', + + onSelect: function (selected) { + this.lookupReference('paramPositionPeriodic').setHidden( + selected.getValue() !== 'positionPeriodic'); + this.lookupReference('paramOutputControl').setHidden( + selected.getValue() !== 'outputControl'); + this.lookupReference('paramSendSmsUssd').setHidden( + selected.getValue() !== 'sendSms' && selected.getValue() !== 'sendUssd'); + this.lookupReference('paramSmsMessage').setHidden( + selected.getValue() !== 'sendSms'); + this.lookupReference('paramSetTimezone').setHidden( + selected.getValue() !== 'setTimezone'); + this.lookupReference('paramSetIndicator').setHidden( + selected.getValue() !== 'setIndicator'); + this.lookupReference('paramCustom').setHidden( + selected.getValue() !== 'custom'); + }, + + onSendClick: function (button) { + var attributes, value, record, form, index, phone; + + 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 + }); + } + + if (record.get('type') === 'outputControl') { + attributes = this.lookupReference('paramOutputControl'); + index = attributes.down('numberfield[name="index"]').getValue(); + value = attributes.down('textfield[name="data"]').getValue(); + + record.set('attributes', { + index: index, + data: value + }); + } + + if (record.get('type') === 'sendUssd') { + attributes = this.lookupReference('paramSendSmsUssd'); + phone = attributes.down('textfield[name="phone"]').getValue(); + record.set('attributes', { + phone: phone + }); + } + + if (record.get('type') === 'sendSms') { + attributes = this.lookupReference('paramSendSmsUssd'); + phone = attributes.down('textfield[name="phone"]').getValue(); + value = attributes.down('textfield[name="message"]').getValue(); + record.set('attributes', { + phone: phone, + message: value + }); + } + + if (record.get('type') === 'setTimezone') { + attributes = this.lookupReference('paramSetTimezone'); + value = attributes.down('numberfield[name="timezone"]').getValue(); + record.set('attributes', { + timezone: value * 3600 + }); + } + + if (record.get('type') === 'setIndicator') { + attributes = this.lookupReference('paramSetIndicator'); + value = attributes.down('numberfield[name="data"]').getValue(); + record.set('attributes', { + data: value + }); + } + + if (record.get('type') === 'custom') { + value = this.lookupReference('paramCustom').getValue(); + record.set('attributes', { + data: value + }); + } + + Ext.Ajax.request({ + scope: this, + url: 'api/commands', + jsonData: record.getData(), + callback: this.onSendResult + }); + }, + + onTextChannelChange: function (checkbox, newValue) { + var typesStore = this.lookupReference('commandType').getStore(); + typesStore.getProxy().setExtraParam('textChannel', newValue); + typesStore.reload(); + }, + + onSendResult: function (options, success, response) { + if (success) { + Ext.toast({ + html: Strings.commandSent, + align: 'br' + }); + this.closeView(); + } else { + Traccar.app.showError(response); + } + } +}); diff --git a/web/app/view/dialog/CommandDialog.js b/web/app/view/dialog/CommandDialog.js deleted file mode 100644 index e02e1277..00000000 --- a/web/app/view/dialog/CommandDialog.js +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.CommandDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.CommandDialogController' - ], - - controller: 'commandDialog', - title: Strings.commandTitle, - - items: { - xtype: 'form', - items: [{ - xtype: 'checkboxfield', - name: 'textChannel', - reference: 'textChannelCheckBox', - inputValue: true, - uncheckedValue: false, - fieldLabel: Strings.notificationSms, - listeners: { - change: 'onTextChannelChange' - } - }, { - xtype: 'combobox', - name: 'type', - reference: 'commandType', - fieldLabel: Strings.sharedType, - store: 'CommandTypes', - displayField: 'name', - valueField: 'type', - editable: false, - 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' - }] - }, { - xtype: 'fieldcontainer', - reference: 'paramOutputControl', - name: 'attributes', - hidden: true, - - items: [{ - xtype: 'numberfield', - fieldLabel: Strings.commandIndex, - name: 'index', - allowBlank: false - }, { - xtype: 'textfield', - fieldLabel: Strings.commandData, - name: 'data' - }] - }, { - xtype: 'fieldcontainer', - reference: 'paramSendSmsUssd', - name: 'attributes', - hidden: true, - - items: [{ - xtype: 'textfield', - fieldLabel: Strings.commandPhone, - name: 'phone' - }, { - xtype: 'textfield', - reference: 'paramSmsMessage', - fieldLabel: Strings.commandMessage, - name: 'message', - hidden: true - }] - }, { - xtype: 'fieldcontainer', - reference: 'paramSetTimezone', - name: 'attributes', - hidden: true, - - items: [{ - xtype: 'numberfield', - fieldLabel: Strings.commandTimezone, - name: 'timezone', - minValue: -12, - step: 0.5, - maxValue: +14 - }] - }, { - xtype: 'fieldcontainer', - reference: 'paramSetIndicator', - name: 'attributes', - hidden: true, - - items: [{ - xtype: 'numberfield', - fieldLabel: Strings.commandData, - name: 'data', - minValue: 0, - maxValue: 99 - }] - }, { - xtype: 'textfield', - reference: 'paramCustom', - fieldLabel: Strings.commandCustom, - name: 'customCommand', - hidden: true, - allowBlank: false - }] - }, - - buttons: [{ - text: Strings.commandSend, - handler: 'onSendClick' - }, { - text: Strings.sharedCancel, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/CommandDialogController.js b/web/app/view/dialog/CommandDialogController.js deleted file mode 100644 index a4b6c0d3..00000000 --- a/web/app/view/dialog/CommandDialogController.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.CommandDialogController', { - extend: 'Ext.app.ViewController', - alias: 'controller.commandDialog', - - onSelect: function (selected) { - this.lookupReference('paramPositionPeriodic').setHidden( - selected.getValue() !== 'positionPeriodic'); - this.lookupReference('paramOutputControl').setHidden( - selected.getValue() !== 'outputControl'); - this.lookupReference('paramSendSmsUssd').setHidden( - selected.getValue() !== 'sendSms' && selected.getValue() !== 'sendUssd'); - this.lookupReference('paramSmsMessage').setHidden( - selected.getValue() !== 'sendSms'); - this.lookupReference('paramSetTimezone').setHidden( - selected.getValue() !== 'setTimezone'); - this.lookupReference('paramSetIndicator').setHidden( - selected.getValue() !== 'setIndicator'); - this.lookupReference('paramCustom').setHidden( - selected.getValue() !== 'custom'); - }, - - onSendClick: function (button) { - var attributes, value, record, form, index, phone; - - 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 - }); - } - - if (record.get('type') === 'outputControl') { - attributes = this.lookupReference('paramOutputControl'); - index = attributes.down('numberfield[name="index"]').getValue(); - value = attributes.down('textfield[name="data"]').getValue(); - - record.set('attributes', { - index: index, - data: value - }); - } - - if (record.get('type') === 'sendUssd') { - attributes = this.lookupReference('paramSendSmsUssd'); - phone = attributes.down('textfield[name="phone"]').getValue(); - record.set('attributes', { - phone: phone - }); - } - - if (record.get('type') === 'sendSms') { - attributes = this.lookupReference('paramSendSmsUssd'); - phone = attributes.down('textfield[name="phone"]').getValue(); - value = attributes.down('textfield[name="message"]').getValue(); - record.set('attributes', { - phone: phone, - message: value - }); - } - - if (record.get('type') === 'setTimezone') { - attributes = this.lookupReference('paramSetTimezone'); - value = attributes.down('numberfield[name="timezone"]').getValue(); - record.set('attributes', { - timezone: value * 3600 - }); - } - - if (record.get('type') === 'setIndicator') { - attributes = this.lookupReference('paramSetIndicator'); - value = attributes.down('numberfield[name="data"]').getValue(); - record.set('attributes', { - data: value - }); - } - - if (record.get('type') === 'custom') { - value = this.lookupReference('paramCustom').getValue(); - record.set('attributes', { - data: value - }); - } - - Ext.Ajax.request({ - scope: this, - url: 'api/commands', - jsonData: record.getData(), - callback: this.onSendResult - }); - }, - - onTextChannelChange: function (checkbox, newValue) { - var typesStore = this.lookupReference('commandType').getStore(); - typesStore.getProxy().setExtraParam('textChannel', newValue); - typesStore.reload(); - }, - - onSendResult: function (options, success, response) { - if (success) { - Ext.toast({ - html: Strings.commandSent, - align: 'br' - }); - this.closeView(); - } else { - Traccar.app.showError(response); - } - } -}); diff --git a/web/app/view/dialog/Device.js b/web/app/view/dialog/Device.js new file mode 100644 index 00000000..bd4a1286 --- /dev/null +++ b/web/app/view/dialog/Device.js @@ -0,0 +1,84 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Device', { + extend: 'Traccar.view.dialog.BaseEdit', + + title: Strings.sharedDevice, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName, + allowBlank: false + }, { + xtype: 'textfield', + name: 'uniqueId', + fieldLabel: Strings.deviceIdentifier, + allowBlank: false + }] + }, { + xtype: 'fieldset', + title: Strings.sharedExtra, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'combobox', + name: 'groupId', + fieldLabel: Strings.groupParent, + store: 'Groups', + queryMode: 'local', + displayField: 'name', + valueField: 'id' + }, { + xtype: 'textfield', + name: 'phone', + fieldLabel: Strings.sharedPhone + }, { + xtype: 'textfield', + name: 'model', + fieldLabel: Strings.deviceModel + }, { + xtype: 'textfield', + name: 'contact', + fieldLabel: Strings.deviceContact + }, { + xtype: 'combobox', + name: 'category', + fieldLabel: Strings.deviceCategory, + store: 'DeviceImages', + queryMode: 'local', + displayField: 'name', + valueField: 'key', + editable: false, + listConfig: { + getInnerTpl: function () { + return '' + + '
' + + '{[new XMLSerializer().serializeToString(Traccar.DeviceImages.getImageSvg(' + + 'Traccar.Style.mapColorOnline, false, 0, values.key))]}
- {name}
'; + } + } + }] + }] + } +}); diff --git a/web/app/view/dialog/DeviceDialog.js b/web/app/view/dialog/DeviceDialog.js deleted file mode 100644 index d1b067fd..00000000 --- a/web/app/view/dialog/DeviceDialog.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.DeviceDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - title: Strings.sharedDevice, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedRequired, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName, - allowBlank: false - }, { - xtype: 'textfield', - name: 'uniqueId', - fieldLabel: Strings.deviceIdentifier, - allowBlank: false - }] - }, { - xtype: 'fieldset', - title: Strings.sharedExtra, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'combobox', - name: 'groupId', - fieldLabel: Strings.groupParent, - store: 'Groups', - queryMode: 'local', - displayField: 'name', - valueField: 'id' - }, { - xtype: 'textfield', - name: 'phone', - fieldLabel: Strings.sharedPhone - }, { - xtype: 'textfield', - name: 'model', - fieldLabel: Strings.deviceModel - }, { - xtype: 'textfield', - name: 'contact', - fieldLabel: Strings.deviceContact - }, { - xtype: 'combobox', - name: 'category', - fieldLabel: Strings.deviceCategory, - store: 'DeviceImages', - queryMode: 'local', - displayField: 'name', - valueField: 'key', - editable: false, - listConfig: { - getInnerTpl: function () { - return '' + - '
' + - '{[new XMLSerializer().serializeToString(Traccar.DeviceImages.getImageSvg(' + - 'Traccar.Style.mapColorOnline, false, 0, values.key))]}
- {name}
'; - } - } - }] - }] - } -}); diff --git a/web/app/view/dialog/DeviceDistance.js b/web/app/view/dialog/DeviceDistance.js new file mode 100644 index 00000000..14a795ad --- /dev/null +++ b/web/app/view/dialog/DeviceDistance.js @@ -0,0 +1,62 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.DeviceDistance', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.DeviceDistanceController' + ], + + controller: 'deviceDistance', + title: Strings.sharedDeviceDistance, + + items: [{ + xtype: 'combobox', + reference: 'deviceId', + fieldLabel: Strings.sharedDevice, + store: 'AllDevices', + displayField: 'name', + valueField: 'id', + editable: false, + listeners: { + change: 'onDeviceChange' + } + }, { + xtype: 'numberfield', + reference: 'totalDistance', + fieldLabel: Strings.deviceTotalDistance, + value: 0 + }], + + buttons: [{ + disabled: true, + reference: 'setButton', + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSet, + tooltipType: 'title', + minWidth: 0, + handler: 'onSetClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/DeviceDistanceController.js b/web/app/view/dialog/DeviceDistanceController.js index a7c33b99..fd106a8d 100644 --- a/web/app/view/dialog/DeviceDistanceController.js +++ b/web/app/view/dialog/DeviceDistanceController.js @@ -18,7 +18,7 @@ Ext.define('Traccar.view.dialog.DeviceDistanceController', { extend: 'Ext.app.ViewController', - alias: 'controller.deviceDistanceDialog', + alias: 'controller.deviceDistance', onDeviceChange: function (combobox, newValue) { this.lookupReference('setButton').setDisabled(newValue === null); diff --git a/web/app/view/dialog/DeviceDistanceDialog.js b/web/app/view/dialog/DeviceDistanceDialog.js deleted file mode 100644 index 29738463..00000000 --- a/web/app/view/dialog/DeviceDistanceDialog.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.DeviceDistanceDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.DeviceDistanceController' - ], - - controller: 'deviceDistanceDialog', - title: Strings.sharedDeviceDistance, - - items: [{ - xtype: 'combobox', - reference: 'deviceId', - fieldLabel: Strings.sharedDevice, - store: 'AllDevices', - displayField: 'name', - valueField: 'id', - editable: false, - listeners: { - change: 'onDeviceChange' - } - }, { - xtype: 'numberfield', - reference: 'totalDistance', - fieldLabel: Strings.deviceTotalDistance, - value: 0 - }], - - buttons: [{ - disabled: true, - reference: 'setButton', - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSet, - tooltipType: 'title', - minWidth: 0, - handler: 'onSetClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/Geofence.js b/web/app/view/dialog/Geofence.js new file mode 100644 index 00000000..93f17de5 --- /dev/null +++ b/web/app/view/dialog/Geofence.js @@ -0,0 +1,86 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Geofence', { + extend: 'Traccar.view.dialog.BaseEdit', + + requires: [ + 'Traccar.view.dialog.GeofenceController' + ], + + controller: 'geofence', + title: Strings.sharedGeofence, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName + }] + }, { + xtype: 'fieldset', + title: Strings.sharedExtra, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'textfield', + name: 'description', + fieldLabel: Strings.sharedDescription + }, { + xtype: 'combobox', + name: 'calendarId', + store: 'Calendars', + queryMode: 'local', + displayField: 'name', + valueField: 'id', + fieldLabel: Strings.sharedCalendar + }, { + xtype: 'hiddenfield', + name: 'area', + allowBlank: false, + reference: 'areaField' + }] + }] + }, + + buttons: [{ + text: Strings.sharedArea, + glyph: 'xf21d@FontAwesome', + handler: 'onAreaClick' + }, { + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + xtype: 'tbfill' + }, { + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/GeofenceController.js b/web/app/view/dialog/GeofenceController.js new file mode 100644 index 00000000..9fdad61b --- /dev/null +++ b/web/app/view/dialog/GeofenceController.js @@ -0,0 +1,53 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.GeofenceController', { + extend: 'Traccar.view.dialog.BaseEditController', + alias: 'controller.geofence', + + requires: [ + 'Traccar.view.BaseWindow', + 'Traccar.view.map.GeofenceMap' + ], + + config: { + listen: { + controller: { + '*': { + savearea: 'saveArea' + } + } + } + }, + + saveArea: function (value) { + this.lookupReference('areaField').setValue(value); + }, + + onAreaClick: function (button) { + var dialog, record; + dialog = button.up('window').down('form'); + record = dialog.getRecord(); + Ext.create('Traccar.view.BaseWindow', { + title: Strings.sharedArea, + items: { + xtype: 'geofenceMapView', + area: record.get('area') + } + }).show(); + } +}); diff --git a/web/app/view/dialog/GeofenceDialog.js b/web/app/view/dialog/GeofenceDialog.js deleted file mode 100644 index bf93e7c1..00000000 --- a/web/app/view/dialog/GeofenceDialog.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.GeofenceDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - requires: [ - 'Traccar.view.dialog.GeofenceDialogController' - ], - - controller: 'geofenceDialog', - title: Strings.sharedGeofence, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedRequired, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName - }] - }, { - xtype: 'fieldset', - title: Strings.sharedExtra, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'textfield', - name: 'description', - fieldLabel: Strings.sharedDescription - }, { - xtype: 'combobox', - name: 'calendarId', - store: 'Calendars', - queryMode: 'local', - displayField: 'name', - valueField: 'id', - fieldLabel: Strings.sharedCalendar - }, { - xtype: 'hiddenfield', - name: 'area', - allowBlank: false, - reference: 'areaField' - }] - }] - }, - - buttons: [{ - text: Strings.sharedArea, - glyph: 'xf21d@FontAwesome', - handler: 'onAreaClick' - }, { - text: Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - xtype: 'tbfill' - }, { - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/GeofenceDialogController.js b/web/app/view/dialog/GeofenceDialogController.js deleted file mode 100644 index b38dd15f..00000000 --- a/web/app/view/dialog/GeofenceDialogController.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.GeofenceDialogController', { - extend: 'Traccar.view.dialog.BaseEditDialogController', - alias: 'controller.geofenceDialog', - - requires: [ - 'Traccar.view.BaseWindow', - 'Traccar.view.map.GeofenceMap' - ], - - config: { - listen: { - controller: { - '*': { - savearea: 'saveArea' - } - } - } - }, - - saveArea: function (value) { - this.lookupReference('areaField').setValue(value); - }, - - onAreaClick: function (button) { - var dialog, record; - dialog = button.up('window').down('form'); - record = dialog.getRecord(); - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedArea, - items: { - xtype: 'geofenceMapView', - area: record.get('area') - } - }).show(); - } -}); diff --git a/web/app/view/dialog/Group.js b/web/app/view/dialog/Group.js new file mode 100644 index 00000000..1f351a54 --- /dev/null +++ b/web/app/view/dialog/Group.js @@ -0,0 +1,50 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Group', { + extend: 'Traccar.view.dialog.BaseEdit', + + title: Strings.groupDialog, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName, + allowBlank: false + }] + }, { + xtype: 'fieldset', + title: Strings.sharedExtra, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'combobox', + name: 'groupId', + fieldLabel: Strings.groupParent, + store: 'Groups', + queryMode: 'local', + displayField: 'name', + valueField: 'id' + }] + }] + } +}); diff --git a/web/app/view/dialog/GroupDialog.js b/web/app/view/dialog/GroupDialog.js deleted file mode 100644 index 366bb43f..00000000 --- a/web/app/view/dialog/GroupDialog.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.GroupDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - title: Strings.groupDialog, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedRequired, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName, - allowBlank: false - }] - }, { - xtype: 'fieldset', - title: Strings.sharedExtra, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'combobox', - name: 'groupId', - fieldLabel: Strings.groupParent, - store: 'Groups', - queryMode: 'local', - displayField: 'name', - valueField: 'id' - }] - }] - } -}); diff --git a/web/app/view/dialog/Login.js b/web/app/view/dialog/Login.js index fbdc2b16..5a0695ee 100644 --- a/web/app/view/dialog/Login.js +++ b/web/app/view/dialog/Login.js @@ -16,7 +16,7 @@ */ Ext.define('Traccar.view.dialog.Login', { - extend: 'Traccar.view.dialog.BaseDialog', + extend: 'Traccar.view.dialog.Base', alias: 'widget.login', requires: [ diff --git a/web/app/view/dialog/MapPickerController.js b/web/app/view/dialog/MapPickerController.js new file mode 100644 index 00000000..23f60ece --- /dev/null +++ b/web/app/view/dialog/MapPickerController.js @@ -0,0 +1,42 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.MapPickerController', { + extend: 'Traccar.view.dialog.BaseEditController', + alias: 'controller.mapPicker', + + config: { + listen: { + controller: { + '*': { + mapstate: 'setMapState' + } + } + } + }, + + getMapState: function (button) { + this.fireEvent('mapstaterequest'); + }, + + setMapState: function (lat, lon, zoom) { + this.lookupReference('latitude').setValue(lat); + this.lookupReference('longitude').setValue(lon); + this.lookupReference('zoom').setValue(zoom); + } +}); diff --git a/web/app/view/dialog/MapPickerDialogController.js b/web/app/view/dialog/MapPickerDialogController.js deleted file mode 100644 index 689449b1..00000000 --- a/web/app/view/dialog/MapPickerDialogController.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.MapPickerDialogController', { - extend: 'Traccar.view.dialog.BaseEditDialogController', - alias: 'controller.mapPickerDialog', - - config: { - listen: { - controller: { - '*': { - mapstate: 'setMapState' - } - } - } - }, - - getMapState: function (button) { - this.fireEvent('mapstaterequest'); - }, - - setMapState: function (lat, lon, zoom) { - this.lookupReference('latitude').setValue(lat); - this.lookupReference('longitude').setValue(lon); - this.lookupReference('zoom').setValue(zoom); - } -}); diff --git a/web/app/view/dialog/Register.js b/web/app/view/dialog/Register.js index 235e4805..f4f5a395 100644 --- a/web/app/view/dialog/Register.js +++ b/web/app/view/dialog/Register.js @@ -16,7 +16,7 @@ */ Ext.define('Traccar.view.dialog.Register', { - extend: 'Traccar.view.dialog.BaseDialog', + extend: 'Traccar.view.dialog.Base', requires: [ 'Traccar.view.dialog.RegisterController' diff --git a/web/app/view/dialog/ReportConfig.js b/web/app/view/dialog/ReportConfig.js new file mode 100644 index 00000000..b8493cbb --- /dev/null +++ b/web/app/view/dialog/ReportConfig.js @@ -0,0 +1,120 @@ +/* + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.ReportConfig', { + extend: 'Traccar.view.dialog.Base', + + requires: [ + 'Traccar.view.dialog.ReportConfigController', + 'Traccar.view.CustomTimeField' + ], + + controller: 'reportConfig', + title: Strings.reportConfigure, + + items: [{ + fieldLabel: Strings.reportDevice, + xtype: 'tagfield', + reference: 'deviceField', + maxWidth: Traccar.Style.formFieldWidth, + store: 'Devices', + valueField: 'id', + displayField: 'name', + queryMode: 'local' + }, { + fieldLabel: Strings.reportGroup, + xtype: 'tagfield', + reference: 'groupField', + maxWidth: Traccar.Style.formFieldWidth, + store: 'Groups', + valueField: 'id', + displayField: 'name', + queryMode: 'local' + }, { + fieldLabel: Strings.reportEventTypes, + xtype: 'tagfield', + reference: 'eventTypeField', + maxWidth: Traccar.Style.formFieldWidth, + store: 'ReportEventTypes', + hidden: true, + valueField: 'type', + displayField: 'name', + queryMode: 'local' + }, { + fieldLabel: Strings.reportChartType, + xtype: 'combobox', + reference: 'chartTypeField', + store: 'ReportChartTypes', + hidden: true, + value: 'speedConverted', + valueField: 'key', + displayField: 'name', + queryMode: 'local' + }, { + fieldLabel: Strings.reportShowMarkers, + xtype: 'checkbox', + reference: 'showMarkersField', + inputValue: true, + uncheckedValue: false, + value: false + }, { + xtype: 'fieldcontainer', + layout: 'vbox', + fieldLabel: Strings.reportFrom, + items: [{ + xtype: 'datefield', + reference: 'fromDateField', + startDay: Traccar.Style.weekStartDay, + format: Traccar.Style.dateFormat, + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }, { + xtype: 'customTimeField', + reference: 'fromTimeField', + value: new Date(new Date().getTime() - 30 * 60 * 1000) + }] + }, { + xtype: 'fieldcontainer', + layout: 'vbox', + fieldLabel: Strings.reportTo, + items: [{ + xtype: 'datefield', + reference: 'toDateField', + startDay: Traccar.Style.weekStartDay, + format: Traccar.Style.dateFormat, + value: new Date() + }, { + xtype: 'customTimeField', + reference: 'toTimeField', + value: new Date() + }] + }], + + buttons: [{ + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/ReportConfigController.js b/web/app/view/dialog/ReportConfigController.js index ccf78987..7233562b 100644 --- a/web/app/view/dialog/ReportConfigController.js +++ b/web/app/view/dialog/ReportConfigController.js @@ -18,7 +18,7 @@ Ext.define('Traccar.view.dialog.ReportConfigController', { extend: 'Ext.app.ViewController', - alias: 'controller.reportConfigDialog', + alias: 'controller.reportConfig', requires: [ 'Traccar.store.ReportEventTypes', diff --git a/web/app/view/dialog/ReportConfigDialog.js b/web/app/view/dialog/ReportConfigDialog.js deleted file mode 100644 index b63e88cd..00000000 --- a/web/app/view/dialog/ReportConfigDialog.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.ReportConfigDialog', { - extend: 'Traccar.view.dialog.BaseDialog', - - requires: [ - 'Traccar.view.dialog.ReportConfigController', - 'Traccar.view.CustomTimeField' - ], - - controller: 'reportConfigDialog', - title: Strings.reportConfigure, - - items: [{ - fieldLabel: Strings.reportDevice, - xtype: 'tagfield', - reference: 'deviceField', - maxWidth: Traccar.Style.formFieldWidth, - store: 'Devices', - valueField: 'id', - displayField: 'name', - queryMode: 'local' - }, { - fieldLabel: Strings.reportGroup, - xtype: 'tagfield', - reference: 'groupField', - maxWidth: Traccar.Style.formFieldWidth, - store: 'Groups', - valueField: 'id', - displayField: 'name', - queryMode: 'local' - }, { - fieldLabel: Strings.reportEventTypes, - xtype: 'tagfield', - reference: 'eventTypeField', - maxWidth: Traccar.Style.formFieldWidth, - store: 'ReportEventTypes', - hidden: true, - valueField: 'type', - displayField: 'name', - queryMode: 'local' - }, { - fieldLabel: Strings.reportChartType, - xtype: 'combobox', - reference: 'chartTypeField', - store: 'ReportChartTypes', - hidden: true, - value: 'speedConverted', - valueField: 'key', - displayField: 'name', - queryMode: 'local' - }, { - fieldLabel: Strings.reportShowMarkers, - xtype: 'checkbox', - reference: 'showMarkersField', - inputValue: true, - uncheckedValue: false, - value: false - }, { - xtype: 'fieldcontainer', - layout: 'vbox', - fieldLabel: Strings.reportFrom, - items: [{ - xtype: 'datefield', - reference: 'fromDateField', - startDay: Traccar.Style.weekStartDay, - format: Traccar.Style.dateFormat, - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }, { - xtype: 'customTimeField', - reference: 'fromTimeField', - value: new Date(new Date().getTime() - 30 * 60 * 1000) - }] - }, { - xtype: 'fieldcontainer', - layout: 'vbox', - fieldLabel: Strings.reportTo, - items: [{ - xtype: 'datefield', - reference: 'toDateField', - startDay: Traccar.Style.weekStartDay, - format: Traccar.Style.dateFormat, - value: new Date() - }, { - xtype: 'customTimeField', - reference: 'toTimeField', - value: new Date() - }] - }], - - buttons: [{ - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/Server.js b/web/app/view/dialog/Server.js new file mode 100644 index 00000000..a86b7b77 --- /dev/null +++ b/web/app/view/dialog/Server.js @@ -0,0 +1,167 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.Server', { + extend: 'Traccar.view.dialog.BaseEdit', + + requires: [ + 'Traccar.view.dialog.MapPickerController' + ], + + controller: 'mapPicker', + title: Strings.serverTitle, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedPreferences, + items: [{ + xtype: 'combobox', + name: 'map', + fieldLabel: Strings.mapLayer, + store: 'MapTypes', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'textfield', + name: 'bingKey', + fieldLabel: Strings.mapBingKey + }, { + xtype: 'textfield', + name: 'mapUrl', + fieldLabel: Strings.mapCustom + }, { + xtype: 'combobox', + name: 'distanceUnit', + fieldLabel: Strings.sharedDistance, + store: 'DistanceUnits', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'combobox', + name: 'speedUnit', + fieldLabel: Strings.settingsSpeedUnit, + store: 'SpeedUnits', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'numberfield', + reference: 'latitude', + name: 'latitude', + fieldLabel: Strings.positionLatitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'longitude', + name: 'longitude', + fieldLabel: Strings.positionLongitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'zoom', + name: 'zoom', + fieldLabel: Strings.serverZoom + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'twelveHourFormat', + fieldLabel: Strings.settingsTwelveHourFormat, + allowBlank: false + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'forceSettings', + fieldLabel: Strings.serverForceSettings, + allowBlank: false + }, { + xtype: 'combobox', + name: 'coordinateFormat', + fieldLabel: Strings.settingsCoordinateFormat, + store: 'CoordinateFormats', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'combobox', + name: 'timezone', + fieldLabel: Strings.sharedTimezone, + store: 'AllTimezones', + queryMode: 'local', + displayField: 'key', + editable: false + }] + }, { + xtype: 'fieldset', + title: Strings.sharedPermissions, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'registration', + fieldLabel: Strings.serverRegistration, + allowBlank: false + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'readonly', + fieldLabel: Strings.serverReadonly, + allowBlank: false + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'deviceReadonly', + fieldLabel: Strings.userDeviceReadonly, + allowBlank: false + }] + }] + }, + + buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + glyph: 'xf041@FontAwesome', + minWidth: 0, + handler: 'getMapState', + tooltip: Strings.sharedGetMapState, + tooltipType: 'title' + }, { + xtype: 'tbfill' + }, { + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/ServerDialog.js b/web/app/view/dialog/ServerDialog.js deleted file mode 100644 index 015335b5..00000000 --- a/web/app/view/dialog/ServerDialog.js +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.ServerDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - requires: [ - 'Traccar.view.dialog.MapPickerDialogController' - ], - - controller: 'mapPickerDialog', - title: Strings.serverTitle, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedPreferences, - items: [{ - xtype: 'combobox', - name: 'map', - fieldLabel: Strings.mapLayer, - store: 'MapTypes', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'textfield', - name: 'bingKey', - fieldLabel: Strings.mapBingKey - }, { - xtype: 'textfield', - name: 'mapUrl', - fieldLabel: Strings.mapCustom - }, { - xtype: 'combobox', - name: 'distanceUnit', - fieldLabel: Strings.sharedDistance, - store: 'DistanceUnits', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'combobox', - name: 'speedUnit', - fieldLabel: Strings.settingsSpeedUnit, - store: 'SpeedUnits', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'numberfield', - reference: 'latitude', - name: 'latitude', - fieldLabel: Strings.positionLatitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - reference: 'longitude', - name: 'longitude', - fieldLabel: Strings.positionLongitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - reference: 'zoom', - name: 'zoom', - fieldLabel: Strings.serverZoom - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'twelveHourFormat', - fieldLabel: Strings.settingsTwelveHourFormat, - allowBlank: false - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'forceSettings', - fieldLabel: Strings.serverForceSettings, - allowBlank: false - }, { - xtype: 'combobox', - name: 'coordinateFormat', - fieldLabel: Strings.settingsCoordinateFormat, - store: 'CoordinateFormats', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'combobox', - name: 'timezone', - fieldLabel: Strings.sharedTimezone, - store: 'AllTimezones', - queryMode: 'local', - displayField: 'key', - editable: false - }] - }, { - xtype: 'fieldset', - title: Strings.sharedPermissions, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'registration', - fieldLabel: Strings.serverRegistration, - allowBlank: false - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'readonly', - fieldLabel: Strings.serverReadonly, - allowBlank: false - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'deviceReadonly', - fieldLabel: Strings.userDeviceReadonly, - allowBlank: false - }] - }] - }, - - buttons: [{ - text: Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - glyph: 'xf041@FontAwesome', - minWidth: 0, - handler: 'getMapState', - tooltip: Strings.sharedGetMapState, - tooltipType: 'title' - }, { - xtype: 'tbfill' - }, { - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/User.js b/web/app/view/dialog/User.js new file mode 100644 index 00000000..344a8f6d --- /dev/null +++ b/web/app/view/dialog/User.js @@ -0,0 +1,227 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.User', { + extend: 'Traccar.view.dialog.BaseEdit', + + requires: [ + 'Traccar.view.dialog.UserController' + ], + + controller: 'user', + title: Strings.settingsUser, + + items: { + xtype: 'form', + items: [{ + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName + }, { + xtype: 'textfield', + name: 'email', + fieldLabel: Strings.userEmail, + allowBlank: false + }, { + xtype: 'textfield', + name: 'password', + fieldLabel: Strings.userPassword, + inputType: 'password', + allowBlank: false + }] + }, { + xtype: 'fieldset', + title: Strings.sharedPreferences, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'textfield', + name: 'phone', + fieldLabel: Strings.sharedPhone + }, { + xtype: 'combobox', + name: 'map', + fieldLabel: Strings.mapLayer, + store: 'MapTypes', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'combobox', + name: 'distanceUnit', + fieldLabel: Strings.sharedDistance, + store: 'DistanceUnits', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'combobox', + name: 'speedUnit', + fieldLabel: Strings.settingsSpeedUnit, + store: 'SpeedUnits', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'numberfield', + reference: 'latitude', + name: 'latitude', + fieldLabel: Strings.positionLatitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'longitude', + name: 'longitude', + fieldLabel: Strings.positionLongitude, + decimalPrecision: Traccar.Style.coordinatePrecision + }, { + xtype: 'numberfield', + reference: 'zoom', + name: 'zoom', + fieldLabel: Strings.serverZoom + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'twelveHourFormat', + fieldLabel: Strings.settingsTwelveHourFormat, + allowBlank: false + }, { + xtype: 'combobox', + name: 'coordinateFormat', + fieldLabel: Strings.settingsCoordinateFormat, + store: 'CoordinateFormats', + displayField: 'name', + valueField: 'key', + editable: false + }, { + xtype: 'combobox', + name: 'timezone', + fieldLabel: Strings.sharedTimezone, + store: 'AllTimezones', + queryMode: 'local', + displayField: 'key', + editable: false + }] + }, { + xtype: 'fieldset', + title: Strings.sharedPermissions, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'disabled', + fieldLabel: Strings.userDisabled, + disabled: true, + reference: 'disabledField' + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'admin', + fieldLabel: Strings.userAdmin, + disabled: true, + reference: 'adminField' + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'readonly', + fieldLabel: Strings.serverReadonly, + disabled: true, + reference: 'readonlyField' + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'deviceReadonly', + fieldLabel: Strings.userDeviceReadonly, + disabled: true, + reference: 'deviceReadonlyField' + }, { + xtype: 'datefield', + name: 'expirationTime', + fieldLabel: Strings.userExpirationTime, + disabled: true, + reference: 'expirationTimeField', + startDay: Traccar.Style.weekStartDay, + format: Traccar.Style.dateFormat + }, { + xtype: 'numberfield', + name: 'deviceLimit', + fieldLabel: Strings.userDeviceLimit, + disabled: true, + reference: 'deviceLimitField' + }, { + xtype: 'numberfield', + name: 'userLimit', + fieldLabel: Strings.userUserLimit, + disabled: true, + reference: 'userLimitField' + }, { + xtype: 'textfield', + name: 'token', + reference: 'tokenField', + fieldLabel: Strings.userToken, + triggers: { + generate: { + cls: 'iconCls: x-fa fa-refresh', + handler: 'generateToken' + } + } + }] + }] + }, + + buttons: [{ + text: Strings.sharedAttributes, + handler: 'showAttributesView' + }, { + glyph: 'xf041@FontAwesome', + minWidth: 0, + handler: 'getMapState', + tooltip: Strings.sharedGetMapState, + tooltipType: 'title' + }, { + glyph: 'xf003@FontAwesome', + minWidth: 0, + handler: 'testNotification', + hidden: true, + reference: 'testNotificationButton', + tooltip: Strings.sharedTestNotification, + tooltipType: 'title' + }, { + xtype: 'tbfill' + }, { + glyph: 'xf00c@FontAwesome', + tooltip: Strings.sharedSave, + tooltipType: 'title', + minWidth: 0, + handler: 'onSaveClick' + }, { + glyph: 'xf00d@FontAwesome', + tooltip: Strings.sharedCancel, + tooltipType: 'title', + minWidth: 0, + handler: 'closeView' + }] +}); diff --git a/web/app/view/dialog/UserController.js b/web/app/view/dialog/UserController.js new file mode 100644 index 00000000..89b0bc83 --- /dev/null +++ b/web/app/view/dialog/UserController.js @@ -0,0 +1,79 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +Ext.define('Traccar.view.dialog.UserController', { + extend: 'Traccar.view.dialog.MapPickerController', + alias: 'controller.user', + + init: function () { + if (Traccar.app.getUser().get('admin')) { + this.lookupReference('adminField').setDisabled(false); + this.lookupReference('deviceLimitField').setDisabled(false); + this.lookupReference('userLimitField').setDisabled(false); + } + if (Traccar.app.getUser().get('admin') || !this.getView().selfEdit) { + this.lookupReference('readonlyField').setDisabled(false); + this.lookupReference('disabledField').setDisabled(false); + this.lookupReference('expirationTimeField').setDisabled(false); + this.lookupReference('deviceReadonlyField').setDisabled(false); + } + }, + + symbols: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', + + generateToken: function () { + var i, newToken = ''; + + for (i = 0; i < 32; i++) { + newToken += this.symbols.charAt(Math.floor(Math.random() * this.symbols.length)); + } + + this.lookupReference('tokenField').setValue(newToken); + }, + + testNotification: function () { + Ext.Ajax.request({ + url: 'api/users/notifications/test', + method: 'POST', + failure: function (response) { + Traccar.app.showError(response); + } + }); + }, + + 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(); + Traccar.app.showError(batch.exceptions[0].getError().response); + } + }); + } + button.up('window').close(); + } +}); diff --git a/web/app/view/dialog/UserDialog.js b/web/app/view/dialog/UserDialog.js deleted file mode 100644 index 3c7518f0..00000000 --- a/web/app/view/dialog/UserDialog.js +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.UserDialog', { - extend: 'Traccar.view.dialog.BaseEditDialog', - - requires: [ - 'Traccar.view.dialog.UserDialogController' - ], - - controller: 'userDialog', - title: Strings.settingsUser, - - items: { - xtype: 'form', - items: [{ - xtype: 'fieldset', - title: Strings.sharedRequired, - items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName - }, { - xtype: 'textfield', - name: 'email', - fieldLabel: Strings.userEmail, - allowBlank: false - }, { - xtype: 'textfield', - name: 'password', - fieldLabel: Strings.userPassword, - inputType: 'password', - allowBlank: false - }] - }, { - xtype: 'fieldset', - title: Strings.sharedPreferences, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'textfield', - name: 'phone', - fieldLabel: Strings.sharedPhone - }, { - xtype: 'combobox', - name: 'map', - fieldLabel: Strings.mapLayer, - store: 'MapTypes', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'combobox', - name: 'distanceUnit', - fieldLabel: Strings.sharedDistance, - store: 'DistanceUnits', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'combobox', - name: 'speedUnit', - fieldLabel: Strings.settingsSpeedUnit, - store: 'SpeedUnits', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'numberfield', - reference: 'latitude', - name: 'latitude', - fieldLabel: Strings.positionLatitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - reference: 'longitude', - name: 'longitude', - fieldLabel: Strings.positionLongitude, - decimalPrecision: Traccar.Style.coordinatePrecision - }, { - xtype: 'numberfield', - reference: 'zoom', - name: 'zoom', - fieldLabel: Strings.serverZoom - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'twelveHourFormat', - fieldLabel: Strings.settingsTwelveHourFormat, - allowBlank: false - }, { - xtype: 'combobox', - name: 'coordinateFormat', - fieldLabel: Strings.settingsCoordinateFormat, - store: 'CoordinateFormats', - displayField: 'name', - valueField: 'key', - editable: false - }, { - xtype: 'combobox', - name: 'timezone', - fieldLabel: Strings.sharedTimezone, - store: 'AllTimezones', - queryMode: 'local', - displayField: 'key', - editable: false - }] - }, { - xtype: 'fieldset', - title: Strings.sharedPermissions, - collapsible: true, - collapsed: true, - items: [{ - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'disabled', - fieldLabel: Strings.userDisabled, - disabled: true, - reference: 'disabledField' - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'admin', - fieldLabel: Strings.userAdmin, - disabled: true, - reference: 'adminField' - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'readonly', - fieldLabel: Strings.serverReadonly, - disabled: true, - reference: 'readonlyField' - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'deviceReadonly', - fieldLabel: Strings.userDeviceReadonly, - disabled: true, - reference: 'deviceReadonlyField' - }, { - xtype: 'datefield', - name: 'expirationTime', - fieldLabel: Strings.userExpirationTime, - disabled: true, - reference: 'expirationTimeField', - startDay: Traccar.Style.weekStartDay, - format: Traccar.Style.dateFormat - }, { - xtype: 'numberfield', - name: 'deviceLimit', - fieldLabel: Strings.userDeviceLimit, - disabled: true, - reference: 'deviceLimitField' - }, { - xtype: 'numberfield', - name: 'userLimit', - fieldLabel: Strings.userUserLimit, - disabled: true, - reference: 'userLimitField' - }, { - xtype: 'textfield', - name: 'token', - reference: 'tokenField', - fieldLabel: Strings.userToken, - triggers: { - generate: { - cls: 'iconCls: x-fa fa-refresh', - handler: 'generateToken' - } - } - }] - }] - }, - - buttons: [{ - text: Strings.sharedAttributes, - handler: 'showAttributesView' - }, { - glyph: 'xf041@FontAwesome', - minWidth: 0, - handler: 'getMapState', - tooltip: Strings.sharedGetMapState, - tooltipType: 'title' - }, { - glyph: 'xf003@FontAwesome', - minWidth: 0, - handler: 'testNotification', - hidden: true, - reference: 'testNotificationButton', - tooltip: Strings.sharedTestNotification, - tooltipType: 'title' - }, { - xtype: 'tbfill' - }, { - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/dialog/UserDialogController.js b/web/app/view/dialog/UserDialogController.js deleted file mode 100644 index c334df7c..00000000 --- a/web/app/view/dialog/UserDialogController.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.UserDialogController', { - extend: 'Traccar.view.dialog.MapPickerDialogController', - alias: 'controller.userDialog', - - init: function () { - if (Traccar.app.getUser().get('admin')) { - this.lookupReference('adminField').setDisabled(false); - this.lookupReference('deviceLimitField').setDisabled(false); - this.lookupReference('userLimitField').setDisabled(false); - } - if (Traccar.app.getUser().get('admin') || !this.getView().selfEdit) { - this.lookupReference('readonlyField').setDisabled(false); - this.lookupReference('disabledField').setDisabled(false); - this.lookupReference('expirationTimeField').setDisabled(false); - this.lookupReference('deviceReadonlyField').setDisabled(false); - } - }, - - symbols: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', - - generateToken: function () { - var i, newToken = ''; - - for (i = 0; i < 32; i++) { - newToken += this.symbols.charAt(Math.floor(Math.random() * this.symbols.length)); - } - - this.lookupReference('tokenField').setValue(newToken); - }, - - testNotification: function () { - Ext.Ajax.request({ - url: 'api/users/notifications/test', - method: 'POST', - failure: function (response) { - Traccar.app.showError(response); - } - }); - }, - - 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(); - Traccar.app.showError(batch.exceptions[0].getError().response); - } - }); - } - button.up('window').close(); - } -}); -- cgit v1.2.3