From 4808ca260bbbc2c87f8e079360db316215b76854 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 5 Sep 2017 18:09:39 +0500 Subject: Remove Attribute Aliases support --- web/app/Application.js | 2 - web/app/controller/Root.js | 1 - web/app/model/AttributeAlias.js | 36 ----------- web/app/store/AttributeAliases.js | 30 ---------- web/app/view/SettingsMenu.js | 6 -- web/app/view/SettingsMenuController.js | 11 ---- web/app/view/State.js | 14 ----- web/app/view/StateController.js | 54 +---------------- web/app/view/dialog/AttributeAlias.js | 57 ------------------ web/app/view/edit/AttributeAliases.js | 65 -------------------- web/app/view/edit/AttributeAliasesController.js | 79 ------------------------- 11 files changed, 3 insertions(+), 352 deletions(-) delete mode 100644 web/app/model/AttributeAlias.js delete mode 100644 web/app/store/AttributeAliases.js delete mode 100644 web/app/view/dialog/AttributeAlias.js delete mode 100644 web/app/view/edit/AttributeAliases.js delete mode 100644 web/app/view/edit/AttributeAliasesController.js (limited to 'web/app') diff --git a/web/app/Application.js b/web/app/Application.js index dddca84..4f43900 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -35,7 +35,6 @@ Ext.define('Traccar.Application', { 'Event', 'Geofence', 'Notification', - 'AttributeAlias', 'ReportSummary', 'ReportTrip', 'ReportStop', @@ -68,7 +67,6 @@ Ext.define('Traccar.Application', { 'Notifications', 'AllNotifications', 'GeofenceTypes', - 'AttributeAliases', 'ReportRoute', 'ReportEvents', 'ReportTrips', diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 1c70dd0..04bdb40 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -110,7 +110,6 @@ Ext.define('Traccar.controller.Root', { Ext.getStore('Drivers').load(); Ext.getStore('Geofences').load(); Ext.getStore('Calendars').load(); - Ext.getStore('AttributeAliases').load(); Ext.getStore('ComputedAttributes').load(); this.initReportEventTypesStore(); diff --git a/web/app/model/AttributeAlias.js b/web/app/model/AttributeAlias.js deleted file mode 100644 index 39fe833..0000000 --- a/web/app/model/AttributeAlias.js +++ /dev/null @@ -1,36 +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.model.AttributeAlias', { - extend: 'Ext.data.Model', - identifier: 'negative', - - fields: [{ - name: 'id', - type: 'int' - }, { - name: 'deviceId', - type: 'int' - }, { - name: 'attribute', - type: 'string' - }, { - name: 'alias', - type: 'string' - }] -}); diff --git a/web/app/store/AttributeAliases.js b/web/app/store/AttributeAliases.js deleted file mode 100644 index 79bc581..0000000 --- a/web/app/store/AttributeAliases.js +++ /dev/null @@ -1,30 +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.store.AttributeAliases', { - extend: 'Ext.data.Store', - model: 'Traccar.model.AttributeAlias', - - proxy: { - type: 'rest', - url: 'api/attributes/aliases', - writer: { - writeAllFields: true - } - } -}); diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js index f893a15..7fb7636 100644 --- a/web/app/view/SettingsMenu.js +++ b/web/app/view/SettingsMenu.js @@ -72,12 +72,6 @@ Ext.define('Traccar.view.SettingsMenu', { glyph: 'xf003@FontAwesome', handler: 'onNotificationsClick', reference: 'settingsNotificationsButton' - }, { - hidden: true, - text: Strings.sharedAttributeAliases, - glyph: 'xf02c@FontAwesome', - handler: 'onAttributeAliasesClick', - reference: 'settingsAttributeAliasesButton' }, { hidden: true, text: Strings.sharedComputedAttributes, diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 7175260..5968a53 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -28,7 +28,6 @@ Ext.define('Traccar.view.SettingsMenuController', { 'Traccar.view.edit.Geofences', 'Traccar.view.edit.Drivers', 'Traccar.view.Notifications', - 'Traccar.view.edit.AttributeAliases', 'Traccar.view.edit.ComputedAttributes', 'Traccar.view.Statistics', 'Traccar.view.dialog.DeviceDistance', @@ -61,7 +60,6 @@ Ext.define('Traccar.view.SettingsMenuController', { Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); } if (admin || !deviceReadonly && !readonly) { - this.lookupReference('settingsAttributeAliasesButton').setHidden(false); this.lookupReference('settingsComputedAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); } @@ -120,15 +118,6 @@ Ext.define('Traccar.view.SettingsMenuController', { }).show(); }, - onAttributeAliasesClick: function () { - Ext.create('Traccar.view.BaseWindow', { - title: Strings.sharedAttributeAliases, - items: { - xtype: 'attributeAliasesView' - } - }).show(); - }, - onComputedAttributesClick: function () { Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedComputedAttributes, diff --git a/web/app/view/State.js b/web/app/view/State.js index 23113c6..8214971 100644 --- a/web/app/view/State.js +++ b/web/app/view/State.js @@ -35,23 +35,9 @@ Ext.define('Traccar.view.State', { xtype: 'tbtext', html: Strings.stateTitle, baseCls: 'x-panel-header-title-default' - }, { - xtype: 'tbfill' - }, { - xtype: 'button', - disabled: true, - handler: 'onAliasEditClick', - reference: 'aliasEditButton', - glyph: 'xf02b@FontAwesome', - tooltip: Strings.sharedEdit, - tooltipType: 'title' }] }, - listeners: { - selectionchange: 'onSelectionChange' - }, - columns: { defaults: { minWidth: Traccar.Style.columnWidthNormal, diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 95f5f55..3bf7671 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -22,9 +22,7 @@ Ext.define('Traccar.view.StateController', { requires: [ 'Traccar.AttributeFormatter', 'Traccar.model.Attribute', - 'Traccar.model.AttributeAlias', - 'Traccar.model.Position', - 'Traccar.view.dialog.AttributeAlias' + 'Traccar.model.Position' ], config: { @@ -33,7 +31,6 @@ Ext.define('Traccar.view.StateController', { '*': { selectdevice: 'selectDevice', selectreport: 'selectReport', - updatealiases: 'updateAliases', deselectfeature: 'deselectFeature' } }, @@ -44,21 +41,11 @@ Ext.define('Traccar.view.StateController', { }, '#ReportRoute': { clear: 'clearReport' - }, - '#AttributeAliases': { - add: 'updateAliases', - update: 'updateAliases' } } } }, - init: function () { - var visible = !Traccar.app.getUser().get('deviceReadonly') && !Traccar.app.getPreference('readonly', false); - this.lookupReference('aliasEditButton').setVisible(visible); - this.aliasesStore = Ext.getStore('AttributeAliases'); - }, - keys: (function () { var i, list, result; result = {}; @@ -100,7 +87,7 @@ Ext.define('Traccar.view.StateController', { }, updatePosition: function () { - var attributes, store, key, aliasIndex, name, value; + var attributes, store, key, name, value; store = Ext.getStore('Attributes'); store.removeAll(); @@ -119,12 +106,7 @@ Ext.define('Traccar.view.StateController', { for (key in attributes) { if (attributes.hasOwnProperty(key)) { this.lookupAttribute = key; - aliasIndex = this.aliasesStore.findBy(this.findAttribute, this); - if (aliasIndex !== -1) { - name = this.aliasesStore.getAt(aliasIndex).get('alias'); - } else { - name = Ext.getStore('PositionAttributes').getAttributeName(key, true); - } + name = Ext.getStore('PositionAttributes').getAttributeName(key, true); if (this.position.get('attribute.' + key) !== undefined) { value = Traccar.AttributeFormatter.getAttributeFormatter(key)(this.position.get('attribute.' + key)); } else { @@ -173,35 +155,5 @@ Ext.define('Traccar.view.StateController', { this.position = null; Ext.getStore('Attributes').removeAll(); } - }, - - onSelectionChange: function (selection, selected) { - var enabled = selected.length > 0 && selected[0].get('priority') === 1024; - this.lookupReference('aliasEditButton').setDisabled(!enabled); - }, - - onAliasEditClick: function () { - var attribute, aliasIndex, attributeAlias, dialog; - attribute = this.getView().getSelectionModel().getSelection()[0]; - this.lookupAttribute = attribute.get('attribute'); - aliasIndex = this.aliasesStore.findBy(this.findAttribute, this); - if (aliasIndex !== -1) { - attributeAlias = this.aliasesStore.getAt(aliasIndex); - } else { - attributeAlias = Ext.create('Traccar.model.AttributeAlias', { - deviceId: this.position.get('deviceId'), - attribute: attribute.get('attribute') - }); - attributeAlias.store = this.aliasesStore; - } - dialog = Ext.create('Traccar.view.dialog.AttributeAlias'); - dialog.down('form').loadRecord(attributeAlias); - dialog.show(); - }, - - updateAliases: function () { - if (this.position) { - this.updatePosition(); - } } }); diff --git a/web/app/view/dialog/AttributeAlias.js b/web/app/view/dialog/AttributeAlias.js deleted file mode 100644 index 6072a30..0000000 --- a/web/app/view/dialog/AttributeAlias.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.dialog.AttributeAlias', { - extend: 'Traccar.view.dialog.Base', - - requires: [ - 'Traccar.view.dialog.AttributeController' - ], - - controller: 'attribute', - title: Strings.sharedAttributeAlias, - - items: { - xtype: 'form', - items: [{ - xtype: 'textfield', - name: 'attribute', - fieldLabel: Strings.sharedAttribute, - allowBlank: false - }, { - xtype: 'textfield', - name: 'alias', - fieldLabel: Strings.sharedAlias, - allowBlank: false - }] - }, - - buttons: [{ - glyph: 'xf00c@FontAwesome', - tooltip: Strings.sharedSave, - tooltipType: 'title', - minWidth: 0, - handler: 'onSaveClick' - }, { - glyph: 'xf00d@FontAwesome', - tooltip: Strings.sharedCancel, - tooltipType: 'title', - minWidth: 0, - handler: 'closeView' - }] -}); diff --git a/web/app/view/edit/AttributeAliases.js b/web/app/view/edit/AttributeAliases.js deleted file mode 100644 index 6e11016..0000000 --- a/web/app/view/edit/AttributeAliases.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.edit.AttributeAliases', { - extend: 'Ext.grid.Panel', - xtype: 'attributeAliasesView', - - requires: [ - 'Traccar.view.edit.AttributeAliasesController', - 'Traccar.view.edit.Toolbar' - ], - - controller: 'attributeAliases', - - tbar: { - xtype: 'editToolbar', - items: ['-', { - xtype: 'tbtext', - html: Strings.sharedDevice - }, { - xtype: 'combobox', - reference: 'deviceField', - store: 'Devices', - displayField: 'name', - valueField: 'id', - editable: false, - listeners: { - change: 'onDeviceChange' - } - }] - }, - - listeners: { - selectionchange: 'onSelectionChange' - }, - - columns: { - defaults: { - flex: 1, - minWidth: Traccar.Style.columnWidthNormal - }, - items: [{ - text: Strings.sharedAttribute, - dataIndex: 'attribute' - }, { - text: Strings.sharedAlias, - dataIndex: 'alias' - }] - } -}); diff --git a/web/app/view/edit/AttributeAliasesController.js b/web/app/view/edit/AttributeAliasesController.js deleted file mode 100644 index 8ac68bc..0000000 --- a/web/app/view/edit/AttributeAliasesController.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -Ext.define('Traccar.view.edit.AttributeAliasesController', { - extend: 'Traccar.view.edit.ToolbarController', - alias: 'controller.attributeAliases', - - requires: [ - 'Traccar.view.dialog.AttributeAlias', - 'Traccar.model.AttributeAlias' - ], - - objectModel: 'Traccar.model.AttributeAlias', - objectDialog: 'Traccar.view.dialog.AttributeAlias', - removeTitle: Strings.sharedAttributeAlias, - - init: function () { - var manager = Traccar.app.getUser().get('admin') || Traccar.app.getUser().get('userLimit') > 0; - this.lookupReference('deviceField').setStore(manager ? 'AllDevices' : 'Devices'); - this.lookupReference('toolbarAddButton').setDisabled(true); - this.lookupReference('toolbarEditButton').setDisabled(true); - this.lookupReference('toolbarRemoveButton').setDisabled(true); - this.getView().setStore(Ext.create('Ext.data.ChainedStore', { - storeId: 'EditorAttributeAliases', - source: 'AttributeAliases' - })); - this.getView().getStore().filter('deviceId', 0); - }, - - onAddClick: function () { - var attributeAlias, dialog, deviceId; - attributeAlias = Ext.create('Traccar.model.AttributeAlias'); - attributeAlias.store = Ext.getStore('AttributeAliases'); - deviceId = this.lookupReference('deviceField').getValue(); - attributeAlias.set('deviceId', deviceId); - dialog = Ext.create('Traccar.view.dialog.AttributeAlias'); - dialog.down('form').loadRecord(attributeAlias); - dialog.show(); - }, - - onSelectionChange: function (selection, selected) { - var disabled = !this.lookupReference('deviceField').getValue(); - this.lookupReference('toolbarAddButton').setDisabled(disabled); - disabled = !selected || selected.length === 0 || !this.lookupReference('deviceField').getValue(); - this.lookupReference('toolbarEditButton').setDisabled(disabled); - this.lookupReference('toolbarRemoveButton').setDisabled(disabled); - }, - - onDeviceChange: function (combobox, value) { - var manager = Traccar.app.getUser().get('admin') || Traccar.app.getUser().get('userLimit') > 0; - this.onSelectionChange(); - if (value !== null) { - this.getView().getStore().filter('deviceId', value); - if (manager && this.getView().getStore().getCount() === 0) { - Ext.getStore('AttributeAliases').getProxy().setExtraParam('deviceId', value); - Ext.getStore('AttributeAliases').load({ - addRecords: true - }); - } - } else { - this.getView().getStore().filter('deviceId', 0); - } - } -}); -- cgit v1.2.3