aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/dialog
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-03-28 15:55:33 +0500
committerAbyss777 <abyss@fox5.ru>2017-03-28 16:08:48 +0500
commit69291297bab7e61af8596f6cca425fadbaf1304f (patch)
tree08db3c7567934c2f958413e3f077e4c1f15d31df /web/app/view/dialog
parent94973f80f543f82630351a7e5943dd4c9150a8b0 (diff)
downloadtrackermap-web-69291297bab7e61af8596f6cca425fadbaf1304f.tar.gz
trackermap-web-69291297bab7e61af8596f6cca425fadbaf1304f.tar.bz2
trackermap-web-69291297bab7e61af8596f6cca425fadbaf1304f.zip
Move BaseDialog, subclasses and their controllers to dialog subfolder
Diffstat (limited to 'web/app/view/dialog')
-rw-r--r--web/app/view/dialog/AttributeAliasDialog.js57
-rw-r--r--web/app/view/dialog/AttributeController.js43
-rw-r--r--web/app/view/dialog/AttributeDialog.js54
-rw-r--r--web/app/view/dialog/BaseDialog.js33
-rw-r--r--web/app/view/dialog/BaseEditDialog.js45
-rw-r--r--web/app/view/dialog/BaseEditDialogController.js62
-rw-r--r--web/app/view/dialog/CalendarDialog.js62
-rw-r--r--web/app/view/dialog/CalendarDialogController.js37
-rw-r--r--web/app/view/dialog/CommandDialog.js147
-rw-r--r--web/app/view/dialog/CommandDialogController.js133
-rw-r--r--web/app/view/dialog/DeviceDialog.js84
-rw-r--r--web/app/view/dialog/DeviceDistanceController.js44
-rw-r--r--web/app/view/dialog/DeviceDistanceDialog.js62
-rw-r--r--web/app/view/dialog/GeofenceDialog.js86
-rw-r--r--web/app/view/dialog/GeofenceDialogController.js53
-rw-r--r--web/app/view/dialog/GroupDialog.js50
-rw-r--r--web/app/view/dialog/Login.js113
-rw-r--r--web/app/view/dialog/LoginController.js119
-rw-r--r--web/app/view/dialog/MapPickerDialogController.js42
-rw-r--r--web/app/view/dialog/Register.js61
-rw-r--r--web/app/view/dialog/RegisterController.js44
-rw-r--r--web/app/view/dialog/ReportConfigController.js48
-rw-r--r--web/app/view/dialog/ReportConfigDialog.js120
-rw-r--r--web/app/view/dialog/ServerDialog.js167
-rw-r--r--web/app/view/dialog/UserDialog.js227
-rw-r--r--web/app/view/dialog/UserDialogController.js79
26 files changed, 2072 insertions, 0 deletions
diff --git a/web/app/view/dialog/AttributeAliasDialog.js b/web/app/view/dialog/AttributeAliasDialog.js
new file mode 100644
index 00000000..a8a6b82c
--- /dev/null
+++ b/web/app/view/dialog/AttributeAliasDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..cd6fc61e
--- /dev/null
+++ b/web/app/view/dialog/AttributeController.js
@@ -0,0 +1,43 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.AttributeController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.attributeDialog',
+
+ 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();
+ }
+});
diff --git a/web/app/view/dialog/AttributeDialog.js b/web/app/view/dialog/AttributeDialog.js
new file mode 100644
index 00000000..2dc851fd
--- /dev/null
+++ b/web/app/view/dialog/AttributeDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/BaseDialog.js b/web/app/view/dialog/BaseDialog.js
new file mode 100644
index 00000000..71fa6b32
--- /dev/null
+++ b/web/app/view/dialog/BaseDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/BaseEditDialog.js b/web/app/view/dialog/BaseEditDialog.js
new file mode 100644
index 00000000..f1314a96
--- /dev/null
+++ b/web/app/view/dialog/BaseEditDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..cc92c6f8
--- /dev/null
+++ b/web/app/view/dialog/BaseEditDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/CalendarDialog.js b/web/app/view/dialog/CalendarDialog.js
new file mode 100644
index 00000000..7b233404
--- /dev/null
+++ b/web/app/view/dialog/CalendarDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..b041c85e
--- /dev/null
+++ b/web/app/view/dialog/CalendarDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/CommandDialog.js b/web/app/view/dialog/CommandDialog.js
new file mode 100644
index 00000000..e02e1277
--- /dev/null
+++ b/web/app/view/dialog/CommandDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..a4b6c0d3
--- /dev/null
+++ b/web/app/view/dialog/CommandDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/DeviceDialog.js b/web/app/view/dialog/DeviceDialog.js
new file mode 100644
index 00000000..d1b067fd
--- /dev/null
+++ b/web/app/view/dialog/DeviceDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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 '<table><tr valign="middle" ><td><div align="center" style="width:40px;height:40px;" >' +
+ '{[new XMLSerializer().serializeToString(Traccar.DeviceImages.getImageSvg(' +
+ 'Traccar.Style.mapColorOnline, false, 0, values.key))]}</div></td>' +
+ '<td>- {name}</td></tr></table>';
+ }
+ }
+ }]
+ }]
+ }
+});
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 <http://www.gnu.org/licenses/>.
+ */
+
+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();
+ }
+});
diff --git a/web/app/view/dialog/DeviceDistanceDialog.js b/web/app/view/dialog/DeviceDistanceDialog.js
new file mode 100644
index 00000000..29738463
--- /dev/null
+++ b/web/app/view/dialog/DeviceDistanceDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/GeofenceDialog.js b/web/app/view/dialog/GeofenceDialog.js
new file mode 100644
index 00000000..bf93e7c1
--- /dev/null
+++ b/web/app/view/dialog/GeofenceDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..b38dd15f
--- /dev/null
+++ b/web/app/view/dialog/GeofenceDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/GroupDialog.js b/web/app/view/dialog/GroupDialog.js
new file mode 100644
index 00000000..366bb43f
--- /dev/null
+++ b/web/app/view/dialog/GroupDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..fbdc2b16
--- /dev/null
+++ b/web/app/view/dialog/Login.js
@@ -0,0 +1,113 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.Login', {
+ extend: 'Traccar.view.dialog.BaseDialog',
+ alias: 'widget.login',
+
+ requires: [
+ 'Traccar.view.dialog.LoginController'
+ ],
+
+ controller: 'login',
+
+ header: false,
+ closable: false,
+ modal: false,
+
+ items: {
+ xtype: 'form',
+ reference: 'form',
+
+ autoEl: {
+ tag: 'form',
+ method: 'POST',
+ action: 'fake-login.html',
+ target: 'submitTarget'
+ },
+
+ items: [{
+ xtype: 'image',
+ src: 'logo.svg',
+ alt: Strings.loginLogo,
+ width: 180,
+ height: 48,
+ style: {
+ display: 'block',
+ margin: '10px auto 25px'
+ }
+ }, {
+ xtype: 'combobox',
+ name: 'language',
+ fieldLabel: Strings.loginLanguage,
+ store: 'Languages',
+ displayField: 'name',
+ valueField: 'code',
+ editable: false,
+ submitValue: false,
+ listeners: {
+ select: 'onSelectLanguage'
+ },
+ reference: 'languageField'
+ }, {
+ xtype: 'textfield',
+ name: 'email',
+ reference: 'userField',
+ fieldLabel: Strings.userEmail,
+ allowBlank: false,
+ enableKeyEvents: true,
+ listeners: {
+ specialKey: 'onSpecialKey',
+ afterrender: 'onAfterRender'
+ },
+ inputAttrTpl: ['autocomplete="on"']
+ }, {
+ xtype: 'textfield',
+ name: 'password',
+ reference: 'passwordField',
+ fieldLabel: Strings.userPassword,
+ inputType: 'password',
+ allowBlank: false,
+ enableKeyEvents: true,
+ listeners: {
+ specialKey: 'onSpecialKey'
+ },
+ inputAttrTpl: ['autocomplete="on"']
+ }, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ reference: 'rememberField',
+ fieldLabel: Strings.userRemember
+ }, {
+ xtype: 'component',
+ html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>'
+ }, {
+ xtype: 'component',
+ html: '<input type="submit" id="submitButton" style="display:none">'
+ }]
+ },
+
+ buttons: [{
+ text: Strings.loginRegister,
+ handler: 'onRegisterClick',
+ reference: 'registerButton'
+ }, {
+ text: Strings.loginLogin,
+ handler: 'onLoginClick'
+ }]
+});
diff --git a/web/app/view/dialog/LoginController.js b/web/app/view/dialog/LoginController.js
new file mode 100644
index 00000000..1b5cd072
--- /dev/null
+++ b/web/app/view/dialog/LoginController.js
@@ -0,0 +1,119 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.LoginController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.login',
+
+ requires: [
+ 'Traccar.view.dialog.Register'
+ ],
+
+ init: function () {
+ this.lookupReference('registerButton').setDisabled(
+ !Traccar.app.getServer().get('registration'));
+ this.lookupReference('languageField').setValue(Locale.language);
+ },
+
+ login: function () {
+ var form = this.lookupReference('form');
+ if (form.isValid()) {
+ Ext.get('spinner').setVisible(true);
+ this.getView().setVisible(false);
+ Ext.Ajax.request({
+ scope: this,
+ method: 'POST',
+ url: 'api/session',
+ params: form.getValues(),
+ callback: function (options, success, response) {
+ var user, password;
+ Ext.get('spinner').setVisible(false);
+ if (success) {
+ if (this.lookupReference('rememberField').getValue()) {
+ user = Ext.util.Base64.encode(this.lookupReference('userField').getValue());
+ password = Ext.util.Base64.encode(this.lookupReference('passwordField').getValue());
+ Ext.util.Cookies.set('user', user, Ext.Date.add(new Date(), Ext.Date.YEAR, 1));
+ Ext.util.Cookies.set('password', password, Ext.Date.add(new Date(), Ext.Date.YEAR, 1));
+ }
+ Traccar.app.setUser(Ext.decode(response.responseText));
+ this.fireViewEvent('login');
+ } else {
+ this.getView().setVisible(true);
+ if (response.status === 401) {
+ Traccar.app.showError(Strings.loginFailed);
+ } else {
+ Traccar.app.showError(response.responseText);
+ }
+ }
+ }
+ });
+ }
+ },
+
+ logout: function () {
+ Ext.util.Cookies.clear('user');
+ Ext.util.Cookies.clear('password');
+ Ext.Ajax.request({
+ scope: this,
+ method: 'DELETE',
+ url: 'api/session',
+ callback: function () {
+ window.location.reload();
+ }
+ });
+ },
+
+ onSelectLanguage: function (selected) {
+ var paramName, paramValue, url, prefix, suffix;
+ paramName = 'locale';
+ paramValue = selected.getValue();
+ url = window.location.href;
+ if (url.indexOf(paramName + '=') >= 0) {
+ prefix = url.substring(0, url.indexOf(paramName));
+ suffix = url.substring(url.indexOf(paramName));
+ suffix = suffix.substring(suffix.indexOf('=') + 1);
+ suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
+ url = prefix + paramName + '=' + paramValue + suffix;
+ } else {
+ if (url.indexOf('?') < 0) {
+ url += '?' + paramName + '=' + paramValue;
+ } else {
+ url += '&' + paramName + '=' + paramValue;
+ }
+ }
+ window.location.href = url;
+ },
+
+ onAfterRender: function (field) {
+ field.focus();
+ },
+
+ onSpecialKey: function (field, e) {
+ if (e.getKey() === e.ENTER) {
+ this.login();
+ }
+ },
+
+ onLoginClick: function () {
+ Ext.getElementById('submitButton').click();
+ this.login();
+ },
+
+ onRegisterClick: function () {
+ Ext.create('Traccar.view.dialog.Register').show();
+ }
+});
diff --git a/web/app/view/dialog/MapPickerDialogController.js b/web/app/view/dialog/MapPickerDialogController.js
new file mode 100644
index 00000000..689449b1
--- /dev/null
+++ b/web/app/view/dialog/MapPickerDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..235e4805
--- /dev/null
+++ b/web/app/view/dialog/Register.js
@@ -0,0 +1,61 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.Register', {
+ extend: 'Traccar.view.dialog.BaseDialog',
+
+ requires: [
+ 'Traccar.view.dialog.RegisterController'
+ ],
+
+ controller: 'register',
+
+ title: Strings.loginRegister,
+
+ items: {
+ xtype: 'form',
+ reference: 'form',
+ jsonSubmit: true,
+
+ items: [{
+ xtype: 'textfield',
+ name: 'name',
+ fieldLabel: Strings.sharedName,
+ allowBlank: false
+ }, {
+ xtype: 'textfield',
+ name: 'email',
+ fieldLabel: Strings.userEmail,
+ vtype: 'email',
+ allowBlank: false
+ }, {
+ xtype: 'textfield',
+ name: 'password',
+ fieldLabel: Strings.userPassword,
+ inputType: 'password',
+ allowBlank: false
+ }]
+ },
+
+ buttons: [{
+ text: Strings.sharedSave,
+ handler: 'onCreateClick'
+ }, {
+ text: Strings.sharedCancel,
+ handler: 'closeView'
+ }]
+});
diff --git a/web/app/view/dialog/RegisterController.js b/web/app/view/dialog/RegisterController.js
new file mode 100644
index 00000000..46ec4b9b
--- /dev/null
+++ b/web/app/view/dialog/RegisterController.js
@@ -0,0 +1,44 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.RegisterController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.register',
+
+ onCreateClick: function () {
+ var form = this.lookupReference('form');
+ if (form.isValid()) {
+ Ext.Ajax.request({
+ scope: this,
+ method: 'POST',
+ url: 'api/users',
+ jsonData: form.getValues(),
+ callback: this.onCreateReturn
+ });
+ }
+ },
+
+ onCreateReturn: function (options, success, response) {
+ if (success) {
+ this.closeView();
+ Ext.toast(Strings.loginCreated);
+ } else {
+ Traccar.app.showError(response);
+ }
+ }
+
+});
diff --git a/web/app/view/dialog/ReportConfigController.js b/web/app/view/dialog/ReportConfigController.js
new file mode 100644
index 00000000..ccf78987
--- /dev/null
+++ b/web/app/view/dialog/ReportConfigController.js
@@ -0,0 +1,48 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.dialog.ReportConfigController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.reportConfigDialog',
+
+ requires: [
+ 'Traccar.store.ReportEventTypes',
+ 'Traccar.store.AllNotifications'
+ ],
+
+ onSaveClick: function (button) {
+ var eventType;
+ this.getView().callingPanel.deviceId = this.lookupReference('deviceField').getValue();
+ this.getView().callingPanel.groupId = this.lookupReference('groupField').getValue();
+ eventType = this.lookupReference('eventTypeField').getValue();
+ if (eventType.indexOf(Traccar.store.ReportEventTypes.allEvents) > -1) {
+ eventType = [Traccar.store.ReportEventTypes.allEvents];
+ } else if (eventType.length === this.lookupReference('eventTypeField').getStore().getCount() - 1) {
+ eventType = [Traccar.store.ReportEventTypes.allEvents];
+ }
+ this.getView().callingPanel.eventType = eventType;
+ this.getView().callingPanel.chartType = this.lookupReference('chartTypeField').getValue();
+ this.getView().callingPanel.showMarkers = this.lookupReference('showMarkersField').getValue();
+ this.getView().callingPanel.fromDate = this.lookupReference('fromDateField').getValue();
+ this.getView().callingPanel.fromTime = this.lookupReference('fromTimeField').getValue();
+ this.getView().callingPanel.toDate = this.lookupReference('toDateField').getValue();
+ this.getView().callingPanel.toTime = this.lookupReference('toTimeField').getValue();
+ this.getView().callingPanel.updateButtons();
+ button.up('window').close();
+ }
+});
diff --git a/web/app/view/dialog/ReportConfigDialog.js b/web/app/view/dialog/ReportConfigDialog.js
new file mode 100644
index 00000000..b63e88cd
--- /dev/null
+++ b/web/app/view/dialog/ReportConfigDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/ServerDialog.js b/web/app/view/dialog/ServerDialog.js
new file mode 100644
index 00000000..015335b5
--- /dev/null
+++ b/web/app/view/dialog/ServerDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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/UserDialog.js b/web/app/view/dialog/UserDialog.js
new file mode 100644
index 00000000..3c7518f0
--- /dev/null
+++ b/web/app/view/dialog/UserDialog.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 <http://www.gnu.org/licenses/>.
+ */
+
+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
new file mode 100644
index 00000000..c334df7c
--- /dev/null
+++ b/web/app/view/dialog/UserDialogController.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 <http://www.gnu.org/licenses/>.
+ */
+
+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();
+ }
+});