From 8c4337fb90487ce9986ab67fcb695a53e90f74d9 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 4 Apr 2017 17:16:05 +0500 Subject: Implement known attributes --- web/app/Application.js | 10 ++++- web/app/model/KnownAttribute.js | 29 ++++++++++++++ web/app/store/DeviceAttributes.js | 45 ++++++++++++++++++++++ web/app/store/GeofenceAttributes.js | 27 +++++++++++++ web/app/store/GroupAttributes.js | 39 +++++++++++++++++++ web/app/store/ServerAttributes.js | 36 +++++++++++++++++ web/app/store/UserAttributes.js | 62 ++++++++++++++++++++++++++++++ web/app/view/dialog/Attribute.js | 8 ++++ web/app/view/dialog/AttributeController.js | 52 +++++++++++++++++++++++++ web/app/view/edit/AttributesController.js | 60 ++++++++++++++++++++++++++--- 10 files changed, 360 insertions(+), 8 deletions(-) create mode 100644 web/app/model/KnownAttribute.js create mode 100644 web/app/store/DeviceAttributes.js create mode 100644 web/app/store/GeofenceAttributes.js create mode 100644 web/app/store/GroupAttributes.js create mode 100644 web/app/store/ServerAttributes.js create mode 100644 web/app/store/UserAttributes.js (limited to 'web/app') diff --git a/web/app/Application.js b/web/app/Application.js index 9b45046..1658e7d 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -38,7 +38,8 @@ Ext.define('Traccar.Application', { 'AttributeAlias', 'ReportSummary', 'ReportTrip', - 'Calendar' + 'Calendar', + 'KnownAttribute' ], stores: [ @@ -77,7 +78,12 @@ Ext.define('Traccar.Application', { 'AllCalendars', 'AllTimezones', 'VisibleDevices', - 'DeviceStatuses' + 'DeviceStatuses', + 'DeviceAttributes', + 'GeofenceAttributes', + 'GroupAttributes', + 'ServerAttributes', + 'UserAttributes' ], controllers: [ diff --git a/web/app/model/KnownAttribute.js b/web/app/model/KnownAttribute.js new file mode 100644 index 0000000..8e578d9 --- /dev/null +++ b/web/app/model/KnownAttribute.js @@ -0,0 +1,29 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.model.KnownAttribute', { + extend: 'Ext.data.Model', + idProperty: 'key', + + fields: [{ + name: 'key', + type: 'string' + }, { + name: 'type', + type: 'string' + }] +}); diff --git a/web/app/store/DeviceAttributes.js b/web/app/store/DeviceAttributes.js new file mode 100644 index 0000000..9f1ec50 --- /dev/null +++ b/web/app/store/DeviceAttributes.js @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.store.DeviceAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + proxy: 'memory', + + data: [{ + key: 'speedLimit', + type: 'number' + }, { + key: 'report.ignoreOdometer', + type: 'boolean' + }, { + key: 'maintenance.start', + type: 'number' + }, { + key: 'maintenance.interval', + type: 'number' + }, { + key: 'web.reportColor', + type: 'color' + }, { + key: 'devicePassword', + type: 'string' + }, { + key: 'processing.copyAttributes', + type: 'string' + }] +}); diff --git a/web/app/store/GeofenceAttributes.js b/web/app/store/GeofenceAttributes.js new file mode 100644 index 0000000..79217f6 --- /dev/null +++ b/web/app/store/GeofenceAttributes.js @@ -0,0 +1,27 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.store.GeofenceAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + proxy: 'memory', + + data: [{ + key: 'color', + type: 'color' + }] +}); diff --git a/web/app/store/GroupAttributes.js b/web/app/store/GroupAttributes.js new file mode 100644 index 0000000..baf2286 --- /dev/null +++ b/web/app/store/GroupAttributes.js @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.store.GroupAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + proxy: 'memory', + + data: [{ + key: 'speedLimit', + type: 'number' + }, { + key: 'report.ignoreOdometer', + type: 'boolean' + }, { + key: 'maintenance.start', + type: 'number' + }, { + key: 'maintenance.interval', + type: 'number' + }, { + key: 'processing.copyAttributes', + type: 'string' + }] +}); diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js new file mode 100644 index 0000000..23755ba --- /dev/null +++ b/web/app/store/ServerAttributes.js @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.store.ServerAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + proxy: 'memory', + + data: [{ + key: 'speedLimit', + type: 'number' + }, { + key: 'maintenance.start', + type: 'number' + }, { + key: 'maintenance.interval', + type: 'number' + }, { + key: 'web.liveRouteLength', + type: 'number' + }] +}); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js new file mode 100644 index 0000000..3720475 --- /dev/null +++ b/web/app/store/UserAttributes.js @@ -0,0 +1,62 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.store.UserAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + proxy: 'memory', + + data: [{ + key: 'mail.smtp.host', + type: 'string' + }, { + key: 'mail.smtp.port', + type: 'number', + minValue: 1, + maxValue: 65535 + }, { + key: 'mail.smtp.starttls.enable', + type: 'boolean' + }, { + key: 'mail.smtp.starttls.required', + type: 'boolean' + }, { + key: 'mail.smtp.ssl.enable', + type: 'boolean' + }, { + key: 'mail.smtp.ssl.trust', + type: 'string' + }, { + key: 'mail.smtp.ssl.protocols', + type: 'string' + }, { + key: 'mail.smtp.from', + type: 'string' + }, { + key: 'mail.smtp.auth', + type: 'boolean' + }, { + key: 'mail.smtp.username', + type: 'string' + }, { + key: 'mail.smtp.password', + type: 'string' + }, { + key: 'web.liveRouteLength', + type: 'number' + }] +}); diff --git a/web/app/view/dialog/Attribute.js b/web/app/view/dialog/Attribute.js index 993c2b1..7f0de78 100644 --- a/web/app/view/dialog/Attribute.js +++ b/web/app/view/dialog/Attribute.js @@ -27,19 +27,27 @@ Ext.define('Traccar.view.dialog.Attribute', { items: { xtype: 'form', + listeners: { + validitychange: 'onValidityChange' + }, items: [{ xtype: 'textfield', + reference: 'nameTextField', name: 'name', + allowBlank: false, fieldLabel: Strings.sharedName }, { xtype: 'textfield', name: 'value', + reference: 'valueField', + allowBlank: false, fieldLabel: Strings.stateValue }] }, buttons: [{ glyph: 'xf00c@FontAwesome', + reference: 'saveButton', tooltip: Strings.sharedSave, tooltipType: 'title', minWidth: 0, diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index 365a0df..daa33be 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -39,5 +39,57 @@ Ext.define('Traccar.view.dialog.AttributeController', { record.save(); } button.up('window').close(); + }, + + onValidityChange: function (form, valid) { + this.lookupReference('saveButton').setDisabled(!valid); + }, + + defaultFieldConfig: { + name: 'value', + reference: 'valueField', + allowBlank: false, + fieldLabel: Strings.stateValue + }, + + onNameChange: function (combobox, newValue) { + var type, config, valueField = this.lookupReference('valueField'), + attribute = combobox.getStore().getById(newValue); + if (attribute) { + type = attribute.get('type'); + config = Ext.clone(this.defaultFieldConfig); + if (type === 'number') { + config.xtype = 'numberfield'; + config.allowDecimals = false; + if (attribute.get('maxValue')) { + config.maxValue = attribute.get('maxValue'); + } + if (attribute.get('minValue')) { + config.minValue = attribute.get('minValue'); + } + } else if (type === 'boolean') { + config.xtype = 'checkboxfield'; + config.inputValue = true; + config.uncheckedValue = false; + } else if (type === 'color') { + config.xtype = 'colorfield'; + config.format = '#hex6'; + config.beforeBodyEl = [ + '
' + + '
' + + '
' + ]; + } else { + config.xtype = 'textfield'; + } + if (valueField.getXType() !== config.xtype) { + this.getView().down('form').insert(this.getView().down('form').items.indexOf(valueField), config); + this.getView().down('form').remove(valueField); + } else if (config.xtype === 'numberfield') { + valueField.setMinValue(config.minValue); + valueField.setMaxValue(config.maxValue); + } + } } }); diff --git a/web/app/view/edit/AttributesController.js b/web/app/view/edit/AttributesController.js index 1ae32c7..cf4f64c 100644 --- a/web/app/view/edit/AttributesController.js +++ b/web/app/view/edit/AttributesController.js @@ -25,8 +25,6 @@ Ext.define('Traccar.view.edit.AttributesController', { 'Traccar.model.Attribute' ], - objectModel: 'Traccar.model.Attribute', - objectDialog: 'Traccar.view.dialog.Attribute', removeTitle: Strings.stateName, init: function () { @@ -42,18 +40,18 @@ Ext.define('Traccar.view.edit.AttributesController', { store.add(Ext.create('Traccar.model.Attribute', { priority: i++, name: propertyName, - value: this.getView().record.get('attributes')[propertyName] + value: attributes[propertyName] })); } } - store.addListener('add', function (store, records, index, eOpts) { + store.addListener('add', function (store, records) { var i; for (i = 0; i < records.length; i++) { this.getView().record.get('attributes')[records[i].get('name')] = records[i].get('value'); } this.getView().record.dirty = true; }, this); - store.addListener('update', function (store, record, operation, modifiedFieldNames, details, eOpts) { + store.addListener('update', function (store, record, operation) { if (operation === Ext.data.Model.EDIT) { if (record.modified.name !== record.get('name')) { delete this.getView().record.get('attributes')[record.modified.name]; @@ -62,7 +60,7 @@ Ext.define('Traccar.view.edit.AttributesController', { this.getView().record.dirty = true; } }, this); - store.addListener('remove', function (store, records, index, isMove, eOpts) { + store.addListener('remove', function (store, records) { var i; for (i = 0; i < records.length; i++) { delete this.getView().record.get('attributes')[records[i].get('name')]; @@ -71,5 +69,55 @@ Ext.define('Traccar.view.edit.AttributesController', { }, this); this.getView().setStore(store); + }, + + comboConfig: { + xtype: 'combobox', + reference: 'nameComboField', + name: 'name', + fieldLabel: Strings.sharedName, + displayField: 'key', + allowBlank: false, + listeners: { + change: 'onNameChange' + } + }, + + replaceNameField: function (dialog, config) { + var nameTextField = dialog.lookupReference('nameTextField'); + dialog.down('form').insert(0, config); + dialog.down('form').remove(nameTextField); + }, + + initDialog: function (record) { + var dialog = Ext.create('Traccar.view.dialog.Attribute'); + if (this.getView().record instanceof Traccar.model.Device) { + this.comboConfig.store = 'DeviceAttributes'; + this.replaceNameField(dialog, this.comboConfig); + } else if (this.getView().record instanceof Traccar.model.Geofence) { + this.comboConfig.store = 'GeofenceAttributes'; + this.replaceNameField(dialog, this.comboConfig); + } else if (this.getView().record instanceof Traccar.model.Group) { + this.comboConfig.store = 'GroupAttributes'; + this.replaceNameField(dialog, this.comboConfig); + } else if (this.getView().record instanceof Traccar.model.Server) { + this.comboConfig.store = 'ServerAttributes'; + this.replaceNameField(dialog, this.comboConfig); + } else if (this.getView().record instanceof Traccar.model.User) { + this.comboConfig.store = 'UserAttributes'; + this.replaceNameField(dialog, this.comboConfig); + } + dialog.down('form').loadRecord(record); + dialog.show(); + }, + + onAddClick: function () { + var objectInstance = Ext.create('Traccar.model.Attribute'); + objectInstance.store = this.getView().getStore(); + this.initDialog(objectInstance); + }, + + onEditClick: function () { + this.initDialog(this.getView().getSelectionModel().getSelection()[0]); } }); -- cgit v1.2.3 From 94fc6862c6635c680afc600a19f61fb9aaefe0ef Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 4 Apr 2017 19:39:34 +0500 Subject: Use simple color picker instead of ux --- web/app.css | 5 ---- web/app/view/ColorPicker.js | 43 ++++++++++++++++++++++++++++++ web/app/view/dialog/Attribute.js | 3 ++- web/app/view/dialog/AttributeController.js | 9 +------ web/load.js | 3 --- 5 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 web/app/view/ColorPicker.js (limited to 'web/app') diff --git a/web/app.css b/web/app.css index 73398cd..cb9d2bc 100644 --- a/web/app.css +++ b/web/app.css @@ -12,11 +12,6 @@ background-color: #5fa2dd !important; } -/* workaround for https://www.sencha.com/forum/showthread.php?330718-6-2-ColorField-color-preview-doesn-t-match-color */ -.custom-color-picker-swatch { - z-index: 10 !important; -} - body.x-border-layout-ct, div.x-border-layout-ct { background-color: #bbbbbb !important; } diff --git a/web/app/view/ColorPicker.js b/web/app/view/ColorPicker.js new file mode 100644 index 0000000..5de03aa --- /dev/null +++ b/web/app/view/ColorPicker.js @@ -0,0 +1,43 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 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.ColorPicker', { + extend: 'Ext.form.field.Picker', + xtype: 'customcolorpicker', + + config: { + value: '#008000' + }, + + editable: false, + + createPicker: function () { + return Ext.create('Ext.picker.Color', { + floating: true, + picker: this, + select: function (selColor) { + this.picker.setValue('#' + selColor); + this.picker.collapse(); + } + }); + }, + + setValue: function (color) { + this.callParent([color]); + this.setFieldStyle('background-color:' + color); + } +}); diff --git a/web/app/view/dialog/Attribute.js b/web/app/view/dialog/Attribute.js index 7f0de78..6614c87 100644 --- a/web/app/view/dialog/Attribute.js +++ b/web/app/view/dialog/Attribute.js @@ -19,7 +19,8 @@ Ext.define('Traccar.view.dialog.Attribute', { extend: 'Traccar.view.dialog.Base', requires: [ - 'Traccar.view.dialog.AttributeController' + 'Traccar.view.dialog.AttributeController', + 'Traccar.view.ColorPicker' ], controller: 'attribute', diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index daa33be..7ddab11 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -72,14 +72,7 @@ Ext.define('Traccar.view.dialog.AttributeController', { config.inputValue = true; config.uncheckedValue = false; } else if (type === 'color') { - config.xtype = 'colorfield'; - config.format = '#hex6'; - config.beforeBodyEl = [ - '
' + - '
' + - '
' - ]; + config.xtype = 'customcolorpicker'; } else { config.xtype = 'textfield'; } diff --git a/web/load.js b/web/load.js index b6cec03..fc676b7 100644 --- a/web/load.js +++ b/web/load.js @@ -124,11 +124,9 @@ if (debugMode) { addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/ext-all-debug.js'); addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/charts/classic/charts-debug.js'); - addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/ux/classic/ux-debug.js'); } else { addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/ext-all.js'); addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/charts/classic/charts.js'); - addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/ux/classic/ux.js'); } addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/classic/locale/locale-' + locale.languages[locale.language].code + '.js'); @@ -136,7 +134,6 @@ addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/classic/theme-triton/theme-triton.js'); addStyleFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/charts/classic/triton/resources/charts-all.css'); - addStyleFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/packages/ux/classic/triton/resources/ux-all.css'); addStyleFile('//cdnjs.cloudflare.com/ajax/libs/font-awesome/' + fontAwesomeVersion + '/css/font-awesome.min.css'); -- cgit v1.2.3 From fbe7831f7765d62853641750b85861b19a2a8715 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 5 Apr 2017 09:38:40 +0500 Subject: Handle allowDecimals config --- web/app/store/ServerAttributes.js | 3 ++- web/app/store/UserAttributes.js | 4 +++- web/app/view/dialog/AttributeController.js | 17 ++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'web/app') diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index 23755ba..aca81f2 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -31,6 +31,7 @@ Ext.define('Traccar.store.ServerAttributes', { type: 'number' }, { key: 'web.liveRouteLength', - type: 'number' + type: 'number', + allowDecimals: false }] }); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index 3720475..80ded0d 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -26,6 +26,7 @@ Ext.define('Traccar.store.UserAttributes', { }, { key: 'mail.smtp.port', type: 'number', + allowDecimals: false, minValue: 1, maxValue: 65535 }, { @@ -57,6 +58,7 @@ Ext.define('Traccar.store.UserAttributes', { type: 'string' }, { key: 'web.liveRouteLength', - type: 'number' + type: 'number', + allowDecimals: false }] }); diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index 7ddab11..ca1436f 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -54,19 +54,19 @@ Ext.define('Traccar.view.dialog.AttributeController', { onNameChange: function (combobox, newValue) { var type, config, valueField = this.lookupReference('valueField'), - attribute = combobox.getStore().getById(newValue); + attribute = combobox.getStore().getById(newValue); if (attribute) { type = attribute.get('type'); config = Ext.clone(this.defaultFieldConfig); if (type === 'number') { config.xtype = 'numberfield'; - config.allowDecimals = false; - if (attribute.get('maxValue')) { - config.maxValue = attribute.get('maxValue'); - } - if (attribute.get('minValue')) { - config.minValue = attribute.get('minValue'); + if (attribute.get('allowDecimals') !== undefined) { + config.allowDecimals = attribute.get('allowDecimals'); + } else { + config.allowDecimals = true; } + config.maxValue = attribute.get('maxValue'); + config.minValue = attribute.get('minValue'); } else if (type === 'boolean') { config.xtype = 'checkboxfield'; config.inputValue = true; @@ -80,8 +80,7 @@ Ext.define('Traccar.view.dialog.AttributeController', { this.getView().down('form').insert(this.getView().down('form').items.indexOf(valueField), config); this.getView().down('form').remove(valueField); } else if (config.xtype === 'numberfield') { - valueField.setMinValue(config.minValue); - valueField.setMaxValue(config.maxValue); + valueField.setConfig(config); } } } -- cgit v1.2.3 From 22b764a71a450e4f4e8ad1a0439cf708e6bcd952 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 17 Apr 2017 15:52:22 +0500 Subject: Translate known attributes --- web/app/model/KnownAttribute.js | 3 +++ web/app/store/DeviceAttributes.js | 7 ++++++ web/app/store/GeofenceAttributes.js | 1 + web/app/store/GroupAttributes.js | 5 ++++ web/app/store/ServerAttributes.js | 4 +++ web/app/store/UserAttributes.js | 12 +++++++++ web/app/view/edit/Attributes.js | 9 ++++++- web/app/view/edit/AttributesController.js | 42 ++++++++++++++----------------- web/l10n/en.json | 20 +++++++++++++++ 9 files changed, 79 insertions(+), 24 deletions(-) (limited to 'web/app') diff --git a/web/app/model/KnownAttribute.js b/web/app/model/KnownAttribute.js index 8e578d9..9bb14db 100644 --- a/web/app/model/KnownAttribute.js +++ b/web/app/model/KnownAttribute.js @@ -22,6 +22,9 @@ Ext.define('Traccar.model.KnownAttribute', { fields: [{ name: 'key', type: 'string' + }, { + name: 'name', + type: 'string' }, { name: 'type', type: 'string' diff --git a/web/app/store/DeviceAttributes.js b/web/app/store/DeviceAttributes.js index 9f1ec50..341a769 100644 --- a/web/app/store/DeviceAttributes.js +++ b/web/app/store/DeviceAttributes.js @@ -22,24 +22,31 @@ Ext.define('Traccar.store.DeviceAttributes', { data: [{ key: 'speedLimit', + name: Strings.sharedAttributeSpeedLimit, type: 'number' }, { key: 'report.ignoreOdometer', + name: Strings.sharedAttributeReportIgnoreOdometer, type: 'boolean' }, { key: 'maintenance.start', + name: Strings.sharedAttributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', + name: Strings.sharedAttributeMaintenanceInterval, type: 'number' }, { key: 'web.reportColor', + name: Strings.sharedAttributeWebReportColor, type: 'color' }, { key: 'devicePassword', + name: Strings.sharedAttributeDevicePassword, type: 'string' }, { key: 'processing.copyAttributes', + name: Strings.sharedAttributeProcessingCopyAttributes, type: 'string' }] }); diff --git a/web/app/store/GeofenceAttributes.js b/web/app/store/GeofenceAttributes.js index 79217f6..d8c8bb9 100644 --- a/web/app/store/GeofenceAttributes.js +++ b/web/app/store/GeofenceAttributes.js @@ -22,6 +22,7 @@ Ext.define('Traccar.store.GeofenceAttributes', { data: [{ key: 'color', + name: Strings.sharedAttributeColor, type: 'color' }] }); diff --git a/web/app/store/GroupAttributes.js b/web/app/store/GroupAttributes.js index baf2286..5ef2aa0 100644 --- a/web/app/store/GroupAttributes.js +++ b/web/app/store/GroupAttributes.js @@ -22,18 +22,23 @@ Ext.define('Traccar.store.GroupAttributes', { data: [{ key: 'speedLimit', + name: Strings.sharedAttributeSpeedLimit, type: 'number' }, { key: 'report.ignoreOdometer', + name: Strings.sharedAttributeReportIgnoreOdometer, type: 'boolean' }, { key: 'maintenance.start', + name: Strings.sharedAttributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', + name: Strings.sharedAttributeMaintenanceInterval, type: 'number' }, { key: 'processing.copyAttributes', + name: Strings.sharedAttributeProcessingCopyAttributes, type: 'string' }] }); diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index aca81f2..3443142 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -22,15 +22,19 @@ Ext.define('Traccar.store.ServerAttributes', { data: [{ key: 'speedLimit', + name: Strings.sharedAttributeSpeedLimit, type: 'number' }, { key: 'maintenance.start', + name: Strings.sharedAttributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', + name: Strings.sharedAttributeMaintenanceInterval, type: 'number' }, { key: 'web.liveRouteLength', + name: Strings.sharedAttributeWebLiveRouteLength, type: 'number', allowDecimals: false }] diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index 80ded0d..f286d1b 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -22,42 +22,54 @@ Ext.define('Traccar.store.UserAttributes', { data: [{ key: 'mail.smtp.host', + name: Strings.sharedAttributeMailSmtpHost, type: 'string' }, { key: 'mail.smtp.port', + name: Strings.sharedAttributeMailSmtpPort, type: 'number', allowDecimals: false, minValue: 1, maxValue: 65535 }, { key: 'mail.smtp.starttls.enable', + name: Strings.sharedAttributeMailSmtpStarttlsEnable, type: 'boolean' }, { key: 'mail.smtp.starttls.required', + name: Strings.sharedAttributeMailSmtpStarttlsRequired, type: 'boolean' }, { key: 'mail.smtp.ssl.enable', + name: Strings.sharedAttributeMailSmtpSslEnable, type: 'boolean' }, { key: 'mail.smtp.ssl.trust', + name: Strings.sharedAttributeMailSmtpSslTrust, type: 'string' }, { key: 'mail.smtp.ssl.protocols', + name: Strings.sharedAttributeMailSmtpSslProtocols, type: 'string' }, { key: 'mail.smtp.from', + name: Strings.sharedAttributeMailSmtpFrom, type: 'string' }, { key: 'mail.smtp.auth', + name: Strings.sharedAttributeMailSmtpAuth, type: 'boolean' }, { key: 'mail.smtp.username', + name: Strings.sharedAttributeMailSmtpUsername, type: 'string' }, { key: 'mail.smtp.password', + name: Strings.sharedAttributeMailSmtpPassword, type: 'string' }, { key: 'web.liveRouteLength', + name: Strings.sharedAttributeWebLiveRouteLength, type: 'number', allowDecimals: false }] diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js index 93e5a3a..8008319 100644 --- a/web/app/view/edit/Attributes.js +++ b/web/app/view/edit/Attributes.js @@ -41,7 +41,14 @@ Ext.define('Traccar.view.edit.Attributes', { }, items: [{ text: Strings.sharedName, - dataIndex: 'name' + dataIndex: 'name', + renderer: function (value, metaData) { + var result; + if (this.attributesStore) { + result = Ext.getStore(this.attributesStore).getById(value); + } + return result && result.get('name') ? result.get('name') : value; + } }, { text: Strings.stateValue, dataIndex: 'value' diff --git a/web/app/view/edit/AttributesController.js b/web/app/view/edit/AttributesController.js index cf4f64c..235f2c5 100644 --- a/web/app/view/edit/AttributesController.js +++ b/web/app/view/edit/AttributesController.js @@ -69,6 +69,17 @@ Ext.define('Traccar.view.edit.AttributesController', { }, this); this.getView().setStore(store); + if (this.getView().record instanceof Traccar.model.Device) { + this.getView().attributesStore = 'DeviceAttributes'; + } else if (this.getView().record instanceof Traccar.model.Geofence) { + this.getView().attributesStore = 'GeofenceAttributes'; + } else if (this.getView().record instanceof Traccar.model.Group) { + this.getView().attributesStore = 'GroupAttributes'; + } else if (this.getView().record instanceof Traccar.model.Server) { + this.getView().attributesStore = 'ServerAttributes'; + } else if (this.getView().record instanceof Traccar.model.User) { + this.getView().attributesStore = 'UserAttributes'; + } }, comboConfig: { @@ -76,36 +87,21 @@ Ext.define('Traccar.view.edit.AttributesController', { reference: 'nameComboField', name: 'name', fieldLabel: Strings.sharedName, - displayField: 'key', + displayField: 'name', + valueField: 'key', allowBlank: false, listeners: { change: 'onNameChange' } }, - replaceNameField: function (dialog, config) { - var nameTextField = dialog.lookupReference('nameTextField'); - dialog.down('form').insert(0, config); - dialog.down('form').remove(nameTextField); - }, - initDialog: function (record) { - var dialog = Ext.create('Traccar.view.dialog.Attribute'); - if (this.getView().record instanceof Traccar.model.Device) { - this.comboConfig.store = 'DeviceAttributes'; - this.replaceNameField(dialog, this.comboConfig); - } else if (this.getView().record instanceof Traccar.model.Geofence) { - this.comboConfig.store = 'GeofenceAttributes'; - this.replaceNameField(dialog, this.comboConfig); - } else if (this.getView().record instanceof Traccar.model.Group) { - this.comboConfig.store = 'GroupAttributes'; - this.replaceNameField(dialog, this.comboConfig); - } else if (this.getView().record instanceof Traccar.model.Server) { - this.comboConfig.store = 'ServerAttributes'; - this.replaceNameField(dialog, this.comboConfig); - } else if (this.getView().record instanceof Traccar.model.User) { - this.comboConfig.store = 'UserAttributes'; - this.replaceNameField(dialog, this.comboConfig); + var nameTextField, dialog = Ext.create('Traccar.view.dialog.Attribute'); + if (this.getView().attributesStore) { + this.comboConfig.store = this.getView().attributesStore; + nameTextField = dialog.lookupReference('nameTextField'); + dialog.down('form').insert(0, this.comboConfig); + dialog.down('form').remove(nameTextField); } dialog.down('form').loadRecord(record); dialog.show(); diff --git a/web/l10n/en.json b/web/l10n/en.json index f494978..68106e9 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -54,6 +54,26 @@ "sharedPermissions": "Permissions", "sharedExtra": "Extra", "sharedTimezone": "Timezone", + "sharedAttributeSpeedLimit": "Speed Limit", + "sharedAttributeReportIgnoreOdometer": "Report: Ignore Odometer", + "sharedAttributeMaintenanceStart": "Maintenance: Start", + "sharedAttributeMaintenanceInterval": "Maintenance: Interval", + "sharedAttributeWebReportColor": "Web: Report Color", + "sharedAttributeDevicePassword": "Device Password", + "sharedAttributeProcessingCopyAttributes": "Processing: Copy Attributes", + "sharedAttributeColor": "Color", + "sharedAttributeWebLiveRouteLength": "Web: Live Route Length", + "sharedAttributeMailSmtpHost": "Mail: SMTP Host", + "sharedAttributeMailSmtpPort": "Mail: SMTP Port", + "sharedAttributeMailSmtpStarttlsEnable": "Mail: SMTP STARTTLS Enable", + "sharedAttributeMailSmtpStarttlsRequired": "Mail: SMTP STARTTLS Required", + "sharedAttributeMailSmtpSslEnable": "Mail: SMTP SSL Enable", + "sharedAttributeMailSmtpSslTrust": "Mail: SMTP SSL Trust", + "sharedAttributeMailSmtpSslProtocols": "Mail: SMTP SSL Protocols", + "sharedAttributeMailSmtpFrom": "Mail: SMTP From", + "sharedAttributeMailSmtpAuth": "Mail: SMTP Auth Enable", + "sharedAttributeMailSmtpUsername": "Mail: SMTP Username", + "sharedAttributeMailSmtpPassword": "Mail: SMTP Password", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", -- cgit v1.2.3 From 6c8e4716489bc5d05a0c7794ee1cee342de417e3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 18 Apr 2017 09:01:50 +0500 Subject: Remove shared prefix --- web/app/store/DeviceAttributes.js | 14 +++++------ web/app/store/GeofenceAttributes.js | 2 +- web/app/store/GroupAttributes.js | 10 ++++---- web/app/store/ServerAttributes.js | 8 +++--- web/app/store/UserAttributes.js | 24 +++++++++--------- web/app/view/dialog/AttributeController.js | 4 +-- web/l10n/en.json | 40 +++++++++++++++--------------- 7 files changed, 51 insertions(+), 51 deletions(-) (limited to 'web/app') diff --git a/web/app/store/DeviceAttributes.js b/web/app/store/DeviceAttributes.js index 341a769..a430354 100644 --- a/web/app/store/DeviceAttributes.js +++ b/web/app/store/DeviceAttributes.js @@ -22,31 +22,31 @@ Ext.define('Traccar.store.DeviceAttributes', { data: [{ key: 'speedLimit', - name: Strings.sharedAttributeSpeedLimit, + name: Strings.attributeSpeedLimit, type: 'number' }, { key: 'report.ignoreOdometer', - name: Strings.sharedAttributeReportIgnoreOdometer, + name: Strings.attributeReportIgnoreOdometer, type: 'boolean' }, { key: 'maintenance.start', - name: Strings.sharedAttributeMaintenanceStart, + name: Strings.attributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', - name: Strings.sharedAttributeMaintenanceInterval, + name: Strings.attributeMaintenanceInterval, type: 'number' }, { key: 'web.reportColor', - name: Strings.sharedAttributeWebReportColor, + name: Strings.attributeWebReportColor, type: 'color' }, { key: 'devicePassword', - name: Strings.sharedAttributeDevicePassword, + name: Strings.attributeDevicePassword, type: 'string' }, { key: 'processing.copyAttributes', - name: Strings.sharedAttributeProcessingCopyAttributes, + name: Strings.attributeProcessingCopyAttributes, type: 'string' }] }); diff --git a/web/app/store/GeofenceAttributes.js b/web/app/store/GeofenceAttributes.js index d8c8bb9..9034b3f 100644 --- a/web/app/store/GeofenceAttributes.js +++ b/web/app/store/GeofenceAttributes.js @@ -22,7 +22,7 @@ Ext.define('Traccar.store.GeofenceAttributes', { data: [{ key: 'color', - name: Strings.sharedAttributeColor, + name: Strings.attributeColor, type: 'color' }] }); diff --git a/web/app/store/GroupAttributes.js b/web/app/store/GroupAttributes.js index 5ef2aa0..35caa8c 100644 --- a/web/app/store/GroupAttributes.js +++ b/web/app/store/GroupAttributes.js @@ -22,23 +22,23 @@ Ext.define('Traccar.store.GroupAttributes', { data: [{ key: 'speedLimit', - name: Strings.sharedAttributeSpeedLimit, + name: Strings.attributeSpeedLimit, type: 'number' }, { key: 'report.ignoreOdometer', - name: Strings.sharedAttributeReportIgnoreOdometer, + name: Strings.attributeReportIgnoreOdometer, type: 'boolean' }, { key: 'maintenance.start', - name: Strings.sharedAttributeMaintenanceStart, + name: Strings.attributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', - name: Strings.sharedAttributeMaintenanceInterval, + name: Strings.attributeMaintenanceInterval, type: 'number' }, { key: 'processing.copyAttributes', - name: Strings.sharedAttributeProcessingCopyAttributes, + name: Strings.attributeProcessingCopyAttributes, type: 'string' }] }); diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index 3443142..71705e0 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -22,19 +22,19 @@ Ext.define('Traccar.store.ServerAttributes', { data: [{ key: 'speedLimit', - name: Strings.sharedAttributeSpeedLimit, + name: Strings.attributeSpeedLimit, type: 'number' }, { key: 'maintenance.start', - name: Strings.sharedAttributeMaintenanceStart, + name: Strings.attributeMaintenanceStart, type: 'number' }, { key: 'maintenance.interval', - name: Strings.sharedAttributeMaintenanceInterval, + name: Strings.attributeMaintenanceInterval, type: 'number' }, { key: 'web.liveRouteLength', - name: Strings.sharedAttributeWebLiveRouteLength, + name: Strings.attributeWebLiveRouteLength, type: 'number', allowDecimals: false }] diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index f286d1b..8649eb8 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -22,54 +22,54 @@ Ext.define('Traccar.store.UserAttributes', { data: [{ key: 'mail.smtp.host', - name: Strings.sharedAttributeMailSmtpHost, + name: Strings.attributeMailSmtpHost, type: 'string' }, { key: 'mail.smtp.port', - name: Strings.sharedAttributeMailSmtpPort, + name: Strings.attributeMailSmtpPort, type: 'number', allowDecimals: false, minValue: 1, maxValue: 65535 }, { key: 'mail.smtp.starttls.enable', - name: Strings.sharedAttributeMailSmtpStarttlsEnable, + name: Strings.attributeMailSmtpStarttlsEnable, type: 'boolean' }, { key: 'mail.smtp.starttls.required', - name: Strings.sharedAttributeMailSmtpStarttlsRequired, + name: Strings.attributeMailSmtpStarttlsRequired, type: 'boolean' }, { key: 'mail.smtp.ssl.enable', - name: Strings.sharedAttributeMailSmtpSslEnable, + name: Strings.attributeMailSmtpSslEnable, type: 'boolean' }, { key: 'mail.smtp.ssl.trust', - name: Strings.sharedAttributeMailSmtpSslTrust, + name: Strings.attributeMailSmtpSslTrust, type: 'string' }, { key: 'mail.smtp.ssl.protocols', - name: Strings.sharedAttributeMailSmtpSslProtocols, + name: Strings.attributeMailSmtpSslProtocols, type: 'string' }, { key: 'mail.smtp.from', - name: Strings.sharedAttributeMailSmtpFrom, + name: Strings.attributeMailSmtpFrom, type: 'string' }, { key: 'mail.smtp.auth', - name: Strings.sharedAttributeMailSmtpAuth, + name: Strings.attributeMailSmtpAuth, type: 'boolean' }, { key: 'mail.smtp.username', - name: Strings.sharedAttributeMailSmtpUsername, + name: Strings.attributeMailSmtpUsername, type: 'string' }, { key: 'mail.smtp.password', - name: Strings.sharedAttributeMailSmtpPassword, + name: Strings.attributeMailSmtpPassword, type: 'string' }, { key: 'web.liveRouteLength', - name: Strings.sharedAttributeWebLiveRouteLength, + name: Strings.attributeWebLiveRouteLength, type: 'number', allowDecimals: false }] diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index ca1436f..da5205b 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -53,8 +53,8 @@ Ext.define('Traccar.view.dialog.AttributeController', { }, onNameChange: function (combobox, newValue) { - var type, config, valueField = this.lookupReference('valueField'), - attribute = combobox.getStore().getById(newValue); + var type, config, attribute, valueField = this.lookupReference('valueField'); + attribute = combobox.getStore().getById(newValue); if (attribute) { type = attribute.get('type'); config = Ext.clone(this.defaultFieldConfig); diff --git a/web/l10n/en.json b/web/l10n/en.json index 68106e9..18edf52 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -54,26 +54,26 @@ "sharedPermissions": "Permissions", "sharedExtra": "Extra", "sharedTimezone": "Timezone", - "sharedAttributeSpeedLimit": "Speed Limit", - "sharedAttributeReportIgnoreOdometer": "Report: Ignore Odometer", - "sharedAttributeMaintenanceStart": "Maintenance: Start", - "sharedAttributeMaintenanceInterval": "Maintenance: Interval", - "sharedAttributeWebReportColor": "Web: Report Color", - "sharedAttributeDevicePassword": "Device Password", - "sharedAttributeProcessingCopyAttributes": "Processing: Copy Attributes", - "sharedAttributeColor": "Color", - "sharedAttributeWebLiveRouteLength": "Web: Live Route Length", - "sharedAttributeMailSmtpHost": "Mail: SMTP Host", - "sharedAttributeMailSmtpPort": "Mail: SMTP Port", - "sharedAttributeMailSmtpStarttlsEnable": "Mail: SMTP STARTTLS Enable", - "sharedAttributeMailSmtpStarttlsRequired": "Mail: SMTP STARTTLS Required", - "sharedAttributeMailSmtpSslEnable": "Mail: SMTP SSL Enable", - "sharedAttributeMailSmtpSslTrust": "Mail: SMTP SSL Trust", - "sharedAttributeMailSmtpSslProtocols": "Mail: SMTP SSL Protocols", - "sharedAttributeMailSmtpFrom": "Mail: SMTP From", - "sharedAttributeMailSmtpAuth": "Mail: SMTP Auth Enable", - "sharedAttributeMailSmtpUsername": "Mail: SMTP Username", - "sharedAttributeMailSmtpPassword": "Mail: SMTP Password", + "attributeSpeedLimit": "Speed Limit", + "attributeReportIgnoreOdometer": "Report: Ignore Odometer", + "attributeMaintenanceStart": "Maintenance: Start", + "attributeMaintenanceInterval": "Maintenance: Interval", + "attributeWebReportColor": "Web: Report Color", + "attributeDevicePassword": "Device Password", + "attributeProcessingCopyAttributes": "Processing: Copy Attributes", + "attributeColor": "Color", + "attributeWebLiveRouteLength": "Web: Live Route Length", + "attributeMailSmtpHost": "Mail: SMTP Host", + "attributeMailSmtpPort": "Mail: SMTP Port", + "attributeMailSmtpStarttlsEnable": "Mail: SMTP STARTTLS Enable", + "attributeMailSmtpStarttlsRequired": "Mail: SMTP STARTTLS Required", + "attributeMailSmtpSslEnable": "Mail: SMTP SSL Enable", + "attributeMailSmtpSslTrust": "Mail: SMTP SSL Trust", + "attributeMailSmtpSslProtocols": "Mail: SMTP SSL Protocols", + "attributeMailSmtpFrom": "Mail: SMTP From", + "attributeMailSmtpAuth": "Mail: SMTP Auth Enable", + "attributeMailSmtpUsername": "Mail: SMTP Username", + "attributeMailSmtpPassword": "Mail: SMTP Password", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", -- cgit v1.2.3