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/controller/Root.js | 4 +- web/app/view/AttributeAliasDialog.js | 57 ------ web/app/view/AttributeAliasesController.js | 6 +- web/app/view/AttributeController.js | 43 ----- web/app/view/AttributeDialog.js | 54 ------ web/app/view/AttributesController.js | 4 +- web/app/view/BaseDialog.js | 33 ---- web/app/view/BaseEditDialog.js | 45 ----- web/app/view/BaseEditDialogController.js | 62 ------- web/app/view/CalendarDialog.js | 62 ------- web/app/view/CalendarDialogController.js | 37 ---- web/app/view/CalendarsController.js | 4 +- web/app/view/CommandDialog.js | 147 --------------- web/app/view/CommandDialogController.js | 133 ------------- web/app/view/DeviceDialog.js | 84 --------- web/app/view/DeviceDistanceController.js | 44 ----- web/app/view/DeviceDistanceDialog.js | 62 ------- web/app/view/DevicesController.js | 8 +- web/app/view/GeofenceDialog.js | 86 --------- web/app/view/GeofenceDialogController.js | 53 ------ web/app/view/GeofencesController.js | 4 +- web/app/view/GroupDialog.js | 50 ----- web/app/view/GroupsController.js | 4 +- web/app/view/Login.js | 113 ----------- web/app/view/LoginController.js | 119 ------------ web/app/view/MapPickerDialogController.js | 42 ----- web/app/view/Register.js | 61 ------ web/app/view/RegisterController.js | 44 ----- web/app/view/ReportConfigController.js | 48 ----- web/app/view/ReportConfigDialog.js | 120 ------------ web/app/view/ReportController.js | 4 +- web/app/view/ServerDialog.js | 167 ----------------- web/app/view/SettingsMenuController.js | 14 +- web/app/view/StateController.js | 4 +- web/app/view/UserDialog.js | 227 ----------------------- web/app/view/UserDialogController.js | 79 -------- web/app/view/UsersController.js | 6 +- web/app/view/dialog/AttributeAliasDialog.js | 57 ++++++ web/app/view/dialog/AttributeController.js | 43 +++++ web/app/view/dialog/AttributeDialog.js | 54 ++++++ web/app/view/dialog/BaseDialog.js | 33 ++++ web/app/view/dialog/BaseEditDialog.js | 45 +++++ web/app/view/dialog/BaseEditDialogController.js | 62 +++++++ web/app/view/dialog/CalendarDialog.js | 62 +++++++ web/app/view/dialog/CalendarDialogController.js | 37 ++++ web/app/view/dialog/CommandDialog.js | 147 +++++++++++++++ web/app/view/dialog/CommandDialogController.js | 133 +++++++++++++ web/app/view/dialog/DeviceDialog.js | 84 +++++++++ web/app/view/dialog/DeviceDistanceController.js | 44 +++++ web/app/view/dialog/DeviceDistanceDialog.js | 62 +++++++ web/app/view/dialog/GeofenceDialog.js | 86 +++++++++ web/app/view/dialog/GeofenceDialogController.js | 53 ++++++ web/app/view/dialog/GroupDialog.js | 50 +++++ web/app/view/dialog/Login.js | 113 +++++++++++ web/app/view/dialog/LoginController.js | 119 ++++++++++++ web/app/view/dialog/MapPickerDialogController.js | 42 +++++ web/app/view/dialog/Register.js | 61 ++++++ web/app/view/dialog/RegisterController.js | 44 +++++ web/app/view/dialog/ReportConfigController.js | 48 +++++ web/app/view/dialog/ReportConfigDialog.js | 120 ++++++++++++ web/app/view/dialog/ServerDialog.js | 167 +++++++++++++++++ web/app/view/dialog/UserDialog.js | 227 +++++++++++++++++++++++ web/app/view/dialog/UserDialogController.js | 79 ++++++++ 63 files changed, 2103 insertions(+), 2103 deletions(-) delete mode 100644 web/app/view/AttributeAliasDialog.js delete mode 100644 web/app/view/AttributeController.js delete mode 100644 web/app/view/AttributeDialog.js delete mode 100644 web/app/view/BaseDialog.js delete mode 100644 web/app/view/BaseEditDialog.js delete mode 100644 web/app/view/BaseEditDialogController.js delete mode 100644 web/app/view/CalendarDialog.js delete mode 100644 web/app/view/CalendarDialogController.js delete mode 100644 web/app/view/CommandDialog.js delete mode 100644 web/app/view/CommandDialogController.js delete mode 100644 web/app/view/DeviceDialog.js delete mode 100644 web/app/view/DeviceDistanceController.js delete mode 100644 web/app/view/DeviceDistanceDialog.js delete mode 100644 web/app/view/GeofenceDialog.js delete mode 100644 web/app/view/GeofenceDialogController.js delete mode 100644 web/app/view/GroupDialog.js delete mode 100644 web/app/view/Login.js delete mode 100644 web/app/view/LoginController.js delete mode 100644 web/app/view/MapPickerDialogController.js delete mode 100644 web/app/view/Register.js delete mode 100644 web/app/view/RegisterController.js delete mode 100644 web/app/view/ReportConfigController.js delete mode 100644 web/app/view/ReportConfigDialog.js delete mode 100644 web/app/view/ServerDialog.js delete mode 100644 web/app/view/UserDialog.js delete mode 100644 web/app/view/UserDialogController.js create mode 100644 web/app/view/dialog/AttributeAliasDialog.js create mode 100644 web/app/view/dialog/AttributeController.js create mode 100644 web/app/view/dialog/AttributeDialog.js create mode 100644 web/app/view/dialog/BaseDialog.js create mode 100644 web/app/view/dialog/BaseEditDialog.js create mode 100644 web/app/view/dialog/BaseEditDialogController.js create mode 100644 web/app/view/dialog/CalendarDialog.js create mode 100644 web/app/view/dialog/CalendarDialogController.js create mode 100644 web/app/view/dialog/CommandDialog.js create mode 100644 web/app/view/dialog/CommandDialogController.js create mode 100644 web/app/view/dialog/DeviceDialog.js create mode 100644 web/app/view/dialog/DeviceDistanceController.js create mode 100644 web/app/view/dialog/DeviceDistanceDialog.js create mode 100644 web/app/view/dialog/GeofenceDialog.js create mode 100644 web/app/view/dialog/GeofenceDialogController.js create mode 100644 web/app/view/dialog/GroupDialog.js create mode 100644 web/app/view/dialog/Login.js create mode 100644 web/app/view/dialog/LoginController.js create mode 100644 web/app/view/dialog/MapPickerDialogController.js create mode 100644 web/app/view/dialog/Register.js create mode 100644 web/app/view/dialog/RegisterController.js create mode 100644 web/app/view/dialog/ReportConfigController.js create mode 100644 web/app/view/dialog/ReportConfigDialog.js create mode 100644 web/app/view/dialog/ServerDialog.js create mode 100644 web/app/view/dialog/UserDialog.js create mode 100644 web/app/view/dialog/UserDialogController.js (limited to 'web/app') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 673f7fb3..3bcc7bc5 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * 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 @@ -19,7 +19,7 @@ Ext.define('Traccar.controller.Root', { extend: 'Ext.app.Controller', requires: [ - 'Traccar.view.Login', + 'Traccar.view.dialog.Login', 'Traccar.view.Main', 'Traccar.view.MainMobile', 'Traccar.model.Position' diff --git a/web/app/view/AttributeAliasDialog.js b/web/app/view/AttributeAliasDialog.js deleted file mode 100644 index 74b12490..00000000 --- a/web/app/view/AttributeAliasDialog.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.AttributeAliasDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/AttributeAliasesController.js b/web/app/view/AttributeAliasesController.js index f5348301..36684077 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.AttributeAliasDialog', + 'Traccar.view.dialog.AttributeAliasDialog', 'Traccar.model.AttributeAlias' ], objectModel: 'Traccar.model.AttributeAlias', - objectDialog: 'Traccar.view.AttributeAliasDialog', + objectDialog: 'Traccar.view.dialog.AttributeAliasDialog', 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.AttributeAliasDialog'); + dialog = Ext.create('Traccar.view.dialog.AttributeAliasDialog'); dialog.down('form').loadRecord(attributeAlias); dialog.show(); }, diff --git a/web/app/view/AttributeController.js b/web/app/view/AttributeController.js deleted file mode 100644 index b8914d4e..00000000 --- a/web/app/view/AttributeController.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016 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.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/AttributeDialog.js b/web/app/view/AttributeDialog.js deleted file mode 100644 index 7d4908f9..00000000 --- a/web/app/view/AttributeDialog.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016 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.AttributeDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/AttributesController.js b/web/app/view/AttributesController.js index 1c5f5b4b..96efee71 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.AttributeDialog', + 'Traccar.view.dialog.AttributeDialog', 'Traccar.store.Attributes', 'Traccar.model.Attribute' ], objectModel: 'Traccar.model.Attribute', - objectDialog: 'Traccar.view.AttributeDialog', + objectDialog: 'Traccar.view.dialog.AttributeDialog', removeTitle: Strings.stateName, init: function () { diff --git a/web/app/view/BaseDialog.js b/web/app/view/BaseDialog.js deleted file mode 100644 index aa9782f1..00000000 --- a/web/app/view/BaseDialog.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 - 2016 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.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/BaseEditDialog.js b/web/app/view/BaseEditDialog.js deleted file mode 100644 index 18cfcf50..00000000 --- a/web/app/view/BaseEditDialog.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 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.BaseEditDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js deleted file mode 100644 index 8b74fbba..00000000 --- a/web/app/view/BaseEditDialogController.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2015 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.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/CalendarDialog.js b/web/app/view/CalendarDialog.js deleted file mode 100644 index 93c2d429..00000000 --- a/web/app/view/CalendarDialog.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.CalendarDialog', { - extend: 'Traccar.view.BaseEditDialog', - - requires: [ - 'Traccar.view.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/CalendarDialogController.js b/web/app/view/CalendarDialogController.js deleted file mode 100644 index a111ded6..00000000 --- a/web/app/view/CalendarDialogController.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.CalendarDialogController', { - extend: 'Traccar.view.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/CalendarsController.js b/web/app/view/CalendarsController.js index bfa7569d..7cb3fe5a 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.CalendarDialog', + 'Traccar.view.dialog.CalendarDialog', 'Traccar.model.Calendar' ], objectModel: 'Traccar.model.Calendar', - objectDialog: 'Traccar.view.CalendarDialog', + objectDialog: 'Traccar.view.dialog.CalendarDialog', removeTitle: Strings.sharedCalendar }); diff --git a/web/app/view/CommandDialog.js b/web/app/view/CommandDialog.js deleted file mode 100644 index ef486c41..00000000 --- a/web/app/view/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.CommandDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/CommandDialogController.js b/web/app/view/CommandDialogController.js deleted file mode 100644 index c2859d0a..00000000 --- a/web/app/view/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.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/DeviceDialog.js b/web/app/view/DeviceDialog.js deleted file mode 100644 index 38b0c080..00000000 --- a/web/app/view/DeviceDialog.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015 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.DeviceDialog', { - extend: 'Traccar.view.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/DeviceDistanceController.js b/web/app/view/DeviceDistanceController.js deleted file mode 100644 index eca82c4f..00000000 --- a/web/app/view/DeviceDistanceController.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.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/DeviceDistanceDialog.js b/web/app/view/DeviceDistanceDialog.js deleted file mode 100644 index 25b1ca32..00000000 --- a/web/app/view/DeviceDistanceDialog.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.DeviceDistanceDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/DevicesController.js b/web/app/view/DevicesController.js index 742077b2..5442f545 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.CommandDialog', - 'Traccar.view.DeviceDialog', + 'Traccar.view.dialog.CommandDialog', + 'Traccar.view.dialog.DeviceDialog', '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.DeviceDialog', + objectDialog: 'Traccar.view.dialog.DeviceDialog', 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.CommandDialog'); + dialog = Ext.create('Traccar.view.dialog.CommandDialog'); typesStore = dialog.lookupReference('commandType').getStore(); typesStore.getProxy().setExtraParam('deviceId', deviceId); diff --git a/web/app/view/GeofenceDialog.js b/web/app/view/GeofenceDialog.js deleted file mode 100644 index 4c2781e5..00000000 --- a/web/app/view/GeofenceDialog.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2016 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.GeofenceDialog', { - extend: 'Traccar.view.BaseEditDialog', - - requires: [ - 'Traccar.view.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/GeofenceDialogController.js b/web/app/view/GeofenceDialogController.js deleted file mode 100644 index e6bb753b..00000000 --- a/web/app/view/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.GeofenceDialogController', { - extend: 'Traccar.view.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/GeofencesController.js b/web/app/view/GeofencesController.js index 4ee06e81..17fb6665 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.GeofenceDialog', + 'Traccar.view.dialog.GeofenceDialog', 'Traccar.model.Geofence' ], objectModel: 'Traccar.model.Geofence', - objectDialog: 'Traccar.view.GeofenceDialog', + objectDialog: 'Traccar.view.dialog.GeofenceDialog', removeTitle: Strings.sharedGeofence }); diff --git a/web/app/view/GroupDialog.js b/web/app/view/GroupDialog.js deleted file mode 100644 index 95102302..00000000 --- a/web/app/view/GroupDialog.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 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.GroupDialog', { - extend: 'Traccar.view.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/GroupsController.js b/web/app/view/GroupsController.js index 98568db5..3e44329e 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.GroupDialog', + 'Traccar.view.dialog.GroupDialog', 'Traccar.view.GroupGeofences', 'Traccar.view.BaseWindow', 'Traccar.model.Group' ], objectModel: 'Traccar.model.Group', - objectDialog: 'Traccar.view.GroupDialog', + objectDialog: 'Traccar.view.dialog.GroupDialog', removeTitle: Strings.groupDialog, onGeofencesClick: function () { diff --git a/web/app/view/Login.js b/web/app/view/Login.js deleted file mode 100644 index 5d0da0f5..00000000 --- a/web/app/view/Login.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2015 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.Login', { - extend: 'Traccar.view.BaseDialog', - alias: 'widget.login', - - requires: [ - 'Traccar.view.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: '' - }, { - xtype: 'component', - html: '' - }] - }, - - buttons: [{ - text: Strings.loginRegister, - handler: 'onRegisterClick', - reference: 'registerButton' - }, { - text: Strings.loginLogin, - handler: 'onLoginClick' - }] -}); diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js deleted file mode 100644 index 9e8e8352..00000000 --- a/web/app/view/LoginController.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2015 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.LoginController', { - extend: 'Ext.app.ViewController', - alias: 'controller.login', - - requires: [ - 'Traccar.view.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.Register').show(); - } -}); diff --git a/web/app/view/MapPickerDialogController.js b/web/app/view/MapPickerDialogController.js deleted file mode 100644 index 1dc48ea0..00000000 --- a/web/app/view/MapPickerDialogController.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.MapPickerDialogController', { - extend: 'Traccar.view.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/Register.js b/web/app/view/Register.js deleted file mode 100644 index 5fb80020..00000000 --- a/web/app/view/Register.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2015 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.Register', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/RegisterController.js b/web/app/view/RegisterController.js deleted file mode 100644 index 0b9d534f..00000000 --- a/web/app/view/RegisterController.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 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.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/ReportConfigController.js b/web/app/view/ReportConfigController.js deleted file mode 100644 index 5ede1830..00000000 --- a/web/app/view/ReportConfigController.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.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/ReportConfigDialog.js b/web/app/view/ReportConfigDialog.js deleted file mode 100644 index 04be648c..00000000 --- a/web/app/view/ReportConfigDialog.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 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.ReportConfigDialog', { - extend: 'Traccar.view.BaseDialog', - - requires: [ - 'Traccar.view.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/ReportController.js b/web/app/view/ReportController.js index c02964e7..7dc5f654 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.ReportConfigDialog', + 'Traccar.view.dialog.ReportConfigDialog', 'Traccar.store.ReportEventTypes' ], @@ -65,7 +65,7 @@ Ext.define('Traccar.view.ReportController', { }, onConfigureClick: function () { - var dialog = Ext.create('Traccar.view.ReportConfigDialog'); + var dialog = Ext.create('Traccar.view.dialog.ReportConfigDialog'); 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/ServerDialog.js b/web/app/view/ServerDialog.js deleted file mode 100644 index 13ddcb31..00000000 --- a/web/app/view/ServerDialog.js +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2015 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.ServerDialog', { - extend: 'Traccar.view.BaseEditDialog', - - requires: [ - 'Traccar.view.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/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 8d1e5634..8e818d77 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -20,16 +20,16 @@ Ext.define('Traccar.view.SettingsMenuController', { alias: 'controller.settings', requires: [ - 'Traccar.view.LoginController', - 'Traccar.view.UserDialog', - 'Traccar.view.ServerDialog', + 'Traccar.view.dialog.LoginController', + 'Traccar.view.dialog.UserDialog', + 'Traccar.view.dialog.ServerDialog', 'Traccar.view.Users', 'Traccar.view.Groups', 'Traccar.view.Geofences', 'Traccar.view.Notifications', 'Traccar.view.AttributeAliases', 'Traccar.view.Statistics', - 'Traccar.view.DeviceDistanceDialog', + 'Traccar.view.dialog.DeviceDistanceDialog', 'Traccar.view.Calendars', 'Traccar.view.BaseWindow' ], @@ -61,7 +61,7 @@ Ext.define('Traccar.view.SettingsMenuController', { }, onUserClick: function () { - var dialog = Ext.create('Traccar.view.UserDialog', { + var dialog = Ext.create('Traccar.view.dialog.UserDialog', { 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.ServerDialog'); + var dialog = Ext.create('Traccar.view.dialog.ServerDialog'); 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.DeviceDistanceDialog'); + var dialog = Ext.create('Traccar.view.dialog.DeviceDistanceDialog'); dialog.show(); }, diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 661bc961..40362e85 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.AttributeAliasDialog' + 'Traccar.view.dialog.AttributeAliasDialog' ], @@ -192,7 +192,7 @@ Ext.define('Traccar.view.StateController', { }); attributeAlias.store = this.aliasesStore; } - dialog = Ext.create('Traccar.view.AttributeAliasDialog'); + dialog = Ext.create('Traccar.view.dialog.AttributeAliasDialog'); dialog.down('form').loadRecord(attributeAlias); dialog.show(); }, diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js deleted file mode 100644 index 8df7f2ff..00000000 --- a/web/app/view/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.UserDialog', { - extend: 'Traccar.view.BaseEditDialog', - - requires: [ - 'Traccar.view.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/UserDialogController.js b/web/app/view/UserDialogController.js deleted file mode 100644 index f001dead..00000000 --- a/web/app/view/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.UserDialogController', { - extend: 'Traccar.view.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(); - } -}); diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index a79f9586..365b3583 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.UserDialog', + 'Traccar.view.dialog.UserDialog', '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.UserDialog', + objectDialog: 'Traccar.view.dialog.UserDialog', 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.UserDialog', { + dialog = Ext.create('Traccar.view.dialog.UserDialog', { selfEdit: user.get('id') === Traccar.app.getUser().get('id') }); dialog.down('form').loadRecord(user); 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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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/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(); + } +}); 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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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: '' + }, { + xtype: 'component', + html: '' + }] + }, + + 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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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