From a2b7e07df1cc4548e27c51e1545cf210b0ef0ab7 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 11 Aug 2017 15:03:39 +0500 Subject: Implement attribute to disable vehicle related UI features --- web/app/view/MainController.js | 3 +-- web/app/view/ReportController.js | 17 +++++++++++++++++ web/app/view/SettingsMenuController.js | 4 ++-- web/app/view/edit/DevicesController.js | 1 + web/app/view/edit/GroupsController.js | 4 ++++ web/app/view/map/MapController.js | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/MainController.js b/web/app/view/MainController.js index 76645e43..126d9af5 100644 --- a/web/app/view/MainController.js +++ b/web/app/view/MainController.js @@ -20,7 +20,6 @@ Ext.define('Traccar.view.MainController', { alias: 'controller.mainController', init: function () { - this.lookupReference('reportView').setHidden( - Traccar.app.getAttributePreference('ui.disableReport', false).toString() === 'true'); + this.lookupReference('reportView').setHidden(Traccar.app.getBooleanAttributePreference('ui.disableReport')); } }); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 58500860..85af559a 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -79,6 +79,23 @@ Ext.define('Traccar.view.ReportController', { hidden: true }); } + if (Traccar.app.isVehicleFeaturesDisabled()) { + for (i = 0; i < this.summaryColumns.length; i++) { + if (this.summaryColumns[i].dataIndex.match('engineHours|spentFuel')) { + this.summaryColumns[i].hidden = true; + } + } + for (i = 0; i < this.tripsColumns.length; i++) { + if (this.tripsColumns[i].dataIndex.match('spentFuel|driverUniqueId')) { + this.tripsColumns[i].hidden = true; + } + } + for (i = 0; i < this.stopsColumns.length; i++) { + if (this.stopsColumns[i].dataIndex.match('engineHours|spentFuel')) { + this.stopsColumns[i].hidden = true; + } + } + } }, onConfigureClick: function () { diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 102120d8..11bfb538 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -45,7 +45,7 @@ Ext.define('Traccar.view.SettingsMenuController', { if (admin) { this.lookupReference('settingsServerButton').setHidden(false); this.lookupReference('settingsStatisticsButton').setHidden(false); - this.lookupReference('settingsDeviceDistanceButton').setHidden(false); + this.lookupReference('settingsDeviceDistanceButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); } if (admin || manager) { this.lookupReference('settingsUsersButton').setHidden(false); @@ -56,7 +56,7 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsGeofencesButton').setHidden(false); this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden(false); - this.lookupReference('settingsDriversButton').setHidden(false); + this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); } if (admin || (!deviceReadonly && !readonly)) { this.lookupReference('settingsAttributeAliasesButton').setHidden(false); diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index ae65fbb1..b98a8d4f 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -61,6 +61,7 @@ Ext.define('Traccar.view.edit.DevicesController', { deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); + this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); setInterval(function () { self.getView().getView().refresh(); diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index 21f17ffa..941f5f18 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -32,6 +32,10 @@ Ext.define('Traccar.view.edit.GroupsController', { objectDialog: 'Traccar.view.dialog.Group', removeTitle: Strings.groupDialog, + init: function () { + this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); + }, + onGeofencesClick: function () { var admin, group; admin = Traccar.app.getUser().get('admin'); diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index f2a561a3..651bd9f0 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -45,7 +45,7 @@ Ext.define('Traccar.view.map.MapController', { init: function () { this.callParent(); this.lookupReference('showReportsButton').setVisible(Traccar.app.isMobile() && - !Traccar.app.getAttributePreference('ui.disableReport', false)); + !Traccar.app.getBooleanAttributePreference('ui.disableReport')); this.lookupReference('showEventsButton').setVisible(Traccar.app.isMobile()); }, -- cgit v1.2.3 From c52d923d60815fcc6c1e9592edbcd578caf1147c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 11 Aug 2017 17:41:42 +0500 Subject: Implement disable Drivers and Computed Attributes separately --- web/app/store/ServerAttributes.js | 8 ++++++++ web/app/store/UserAttributes.js | 8 ++++++++ web/app/view/SettingsMenuController.js | 6 ++++-- web/app/view/edit/DevicesController.js | 5 ++++- web/app/view/edit/GroupsController.js | 5 ++++- web/app/view/edit/UsersController.js | 4 ++++ web/l10n/en.json | 2 ++ 7 files changed, 34 insertions(+), 4 deletions(-) (limited to 'web/app/view') diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index 438ca3e1..f4e2a848 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -55,5 +55,13 @@ Ext.define('Traccar.store.ServerAttributes', { key: 'ui.disableVehicleFetures', name: Strings.attributeUiDisableVehicleFetures, valueType: 'boolean' + }, { + key: 'ui.disableDrivers', + name: Strings.attributeUiDisableDrivers, + valueType: 'boolean' + }, { + key: 'ui.disableComputedAttributes', + name: Strings.attributeUiDisableComputedAttributes, + valueType: 'boolean' }] }); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index 8e1acfb1..dbee1ed8 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -87,5 +87,13 @@ Ext.define('Traccar.store.UserAttributes', { key: 'ui.disableVehicleFetures', name: Strings.attributeUiDisableVehicleFetures, valueType: 'boolean' + }, { + key: 'ui.disableDrivers', + name: Strings.attributeUiDisableDrivers, + valueType: 'boolean' + }, { + key: 'ui.disableComputedAttributes', + name: Strings.attributeUiDisableComputedAttributes, + valueType: 'boolean' }] }); diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 11bfb538..cc17ca3a 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -56,11 +56,13 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsGeofencesButton').setHidden(false); this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden(false); - this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); + this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || + Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); } if (admin || (!deviceReadonly && !readonly)) { this.lookupReference('settingsAttributeAliasesButton').setHidden(false); - this.lookupReference('settingsComputedAttributesButton').setHidden(false); + this.lookupReference('settingsComputedAttributesButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); } }, diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index b98a8d4f..59a10bb3 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -61,7 +61,10 @@ Ext.define('Traccar.view.edit.DevicesController', { deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); - this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); + this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || + Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('toolbarAttributesButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); setInterval(function () { self.getView().getView().refresh(); diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index 941f5f18..f1da19ce 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -33,7 +33,10 @@ Ext.define('Traccar.view.edit.GroupsController', { removeTitle: Strings.groupDialog, init: function () { - this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); + this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || + Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('toolbarAttributesButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); }, onGeofencesClick: function () { diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index fb7a36e2..1e7238a9 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -41,6 +41,10 @@ Ext.define('Traccar.view.edit.UsersController', { init: function () { Ext.getStore('Users').load(); this.lookupReference('userUsersButton').setHidden(!Traccar.app.getUser().get('admin')); + this.lookupReference('userDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || + Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('userAttributesButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); }, onEditClick: function () { diff --git a/web/l10n/en.json b/web/l10n/en.json index 6ea54105..8eba834c 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -90,6 +90,8 @@ "attributeMailSmtpPassword": "Mail: SMTP Password", "attributeUiDisableReport": "UI: Disable Report", "attributeUiDisableVehicleFetures": "UI: Disable Vehicle Fetures", + "attributeUiDisableDrivers": "UI: Disable Drivers", + "attributeUiDisableComputedAttributes": "UI: Disable Computed Attributes", "errorTitle": "Error", "errorGeneral": "Invalid parameters or constraints violation", "errorConnection": "Connection error", -- cgit v1.2.3 From 01af5f520e24a33d7e22523d8ed11e9f14a19516 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 14 Aug 2017 12:26:02 +0500 Subject: Implement disable Calendars --- web/app/store/ServerAttributes.js | 4 ++++ web/app/store/UserAttributes.js | 4 ++++ web/app/view/SettingsMenuController.js | 3 ++- web/app/view/dialog/Geofence.js | 1 + web/app/view/dialog/GeofenceController.js | 5 +++++ web/app/view/edit/UsersController.js | 2 ++ web/l10n/en.json | 1 + 7 files changed, 19 insertions(+), 1 deletion(-) (limited to 'web/app/view') diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index f4e2a848..109b09e0 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -63,5 +63,9 @@ Ext.define('Traccar.store.ServerAttributes', { key: 'ui.disableComputedAttributes', name: Strings.attributeUiDisableComputedAttributes, valueType: 'boolean' + }, { + key: 'ui.disableCalendars', + name: Strings.attributeUiDisableCalendars, + valueType: 'boolean' }] }); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index dbee1ed8..a004a54d 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -95,5 +95,9 @@ Ext.define('Traccar.store.UserAttributes', { key: 'ui.disableComputedAttributes', name: Strings.attributeUiDisableComputedAttributes, valueType: 'boolean' + }, { + key: 'ui.disableCalendars', + name: Strings.attributeUiDisableCalendars, + valueType: 'boolean' }] }); diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index cc17ca3a..f459da7a 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -55,7 +55,8 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsGroupsButton').setHidden(false); this.lookupReference('settingsGeofencesButton').setHidden(false); this.lookupReference('settingsNotificationsButton').setHidden(false); - this.lookupReference('settingsCalendarsButton').setHidden(false); + this.lookupReference('settingsCalendarsButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); } diff --git a/web/app/view/dialog/Geofence.js b/web/app/view/dialog/Geofence.js index 93f17de5..bed20d38 100644 --- a/web/app/view/dialog/Geofence.js +++ b/web/app/view/dialog/Geofence.js @@ -46,6 +46,7 @@ Ext.define('Traccar.view.dialog.Geofence', { fieldLabel: Strings.sharedDescription }, { xtype: 'combobox', + reference: 'calendarCombo', name: 'calendarId', store: 'Calendars', queryMode: 'local', diff --git a/web/app/view/dialog/GeofenceController.js b/web/app/view/dialog/GeofenceController.js index 9fdad61b..2f96987d 100644 --- a/web/app/view/dialog/GeofenceController.js +++ b/web/app/view/dialog/GeofenceController.js @@ -34,6 +34,11 @@ Ext.define('Traccar.view.dialog.GeofenceController', { } }, + init: function () { + this.lookupReference('calendarCombo').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + }, + saveArea: function (value) { this.lookupReference('areaField').setValue(value); }, diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index 1e7238a9..42fc0cd9 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -45,6 +45,8 @@ Ext.define('Traccar.view.edit.UsersController', { Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('userAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + this.lookupReference('userCalendarsButton').setHidden( + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); }, onEditClick: function () { diff --git a/web/l10n/en.json b/web/l10n/en.json index 8eba834c..69df1563 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -92,6 +92,7 @@ "attributeUiDisableVehicleFetures": "UI: Disable Vehicle Fetures", "attributeUiDisableDrivers": "UI: Disable Drivers", "attributeUiDisableComputedAttributes": "UI: Disable Computed Attributes", + "attributeUiDisableCalendars": "UI: Disable Calendars", "errorTitle": "Error", "errorGeneral": "Invalid parameters or constraints violation", "errorConnection": "Connection error", -- cgit v1.2.3 From d1d7d230a0262d9f6ae05f1c4c6718699edb8de3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 18 Aug 2017 13:56:46 +0500 Subject: Fix style --- web/app/view/SettingsMenuController.js | 4 ++-- web/app/view/dialog/GeofenceController.js | 2 +- web/app/view/edit/DevicesController.js | 2 +- web/app/view/edit/GroupsController.js | 2 +- web/app/view/edit/UsersController.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 54543358..7985700a 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -56,14 +56,14 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsGeofencesButton').setHidden(false); this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); } if (admin || !deviceReadonly && !readonly) { this.lookupReference('settingsAttributeAliasesButton').setHidden(false); this.lookupReference('settingsComputedAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); } }, diff --git a/web/app/view/dialog/GeofenceController.js b/web/app/view/dialog/GeofenceController.js index 2f96987d..e4ac5a2e 100644 --- a/web/app/view/dialog/GeofenceController.js +++ b/web/app/view/dialog/GeofenceController.js @@ -36,7 +36,7 @@ Ext.define('Traccar.view.dialog.GeofenceController', { init: function () { this.lookupReference('calendarCombo').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); }, saveArea: function (value) { diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index ffe9c9af..9616dbd2 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -64,7 +64,7 @@ Ext.define('Traccar.view.edit.DevicesController', { this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('toolbarAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); setInterval(function () { self.getView().getView().refresh(); diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index f1da19ce..d40c1e69 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -36,7 +36,7 @@ Ext.define('Traccar.view.edit.GroupsController', { this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('toolbarAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); }, onGeofencesClick: function () { diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index 42fc0cd9..8da5caa9 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -44,9 +44,9 @@ Ext.define('Traccar.view.edit.UsersController', { this.lookupReference('userDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('userAttributesButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); + Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); this.lookupReference('userCalendarsButton').setHidden( - Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); + Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); }, onEditClick: function () { -- cgit v1.2.3 From f26159a40b3b23fbd63de312f121b1fe1bf64bd1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 18 Aug 2017 15:40:39 +0500 Subject: - Detach common known attributes - Rename function --- web/app/Application.js | 4 ++- web/app/controller/Root.js | 7 ++++ web/app/store/CommonDeviceAttributes.js | 42 +++++++++++++++++++++++ web/app/store/CommonUserAttributes.js | 55 +++++++++++++++++++++++++++++++ web/app/store/DeviceAttributes.js | 20 ----------- web/app/store/GroupAttributes.js | 20 ----------- web/app/store/ServerAttributes.js | 50 +--------------------------- web/app/store/UserAttributes.js | 33 ------------------- web/app/view/ReportController.js | 2 +- web/app/view/SettingsMenuController.js | 6 ++-- web/app/view/edit/AttributesController.js | 1 + web/app/view/edit/DevicesController.js | 4 +-- web/app/view/edit/GroupsController.js | 4 +-- web/app/view/edit/UsersController.js | 4 +-- web/app/view/map/MapController.js | 4 +-- 15 files changed, 121 insertions(+), 135 deletions(-) create mode 100644 web/app/store/CommonDeviceAttributes.js create mode 100644 web/app/store/CommonUserAttributes.js (limited to 'web/app/view') diff --git a/web/app/Application.js b/web/app/Application.js index 3cee7b78..e0f0aa45 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -83,10 +83,12 @@ Ext.define('Traccar.Application', { 'AllTimezones', 'VisibleDevices', 'DeviceStatuses', + 'CommonDeviceAttributes', 'DeviceAttributes', 'GeofenceAttributes', 'GroupAttributes', 'ServerAttributes', + 'CommonUserAttributes', 'UserAttributes', 'ComputedAttributes', 'AllComputedAttributes', @@ -104,7 +106,7 @@ Ext.define('Traccar.Application', { return window.matchMedia && window.matchMedia('(max-width: 768px)').matches; }, - isVehicleFeaturesDisabled: function () { + getVehicleFeaturesDisabled: function () { return this.getBooleanAttributePreference('ui.disableVehicleFetures'); }, diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 92620115..1c70dd03 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -113,6 +113,13 @@ Ext.define('Traccar.controller.Root', { Ext.getStore('AttributeAliases').load(); Ext.getStore('ComputedAttributes').load(); this.initReportEventTypesStore(); + + Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true); + Ext.getStore('ServerAttributes').loadData(Ext.getStore('CommonUserAttributes').getData().items, true); + Ext.getStore('UserAttributes').loadData(Ext.getStore('CommonUserAttributes').getData().items, true); + Ext.getStore('DeviceAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true); + Ext.getStore('GroupAttributes').loadData(Ext.getStore('CommonDeviceAttributes').getData().items, true); + Ext.getStore('Devices').load({ scope: this, callback: function () { diff --git a/web/app/store/CommonDeviceAttributes.js b/web/app/store/CommonDeviceAttributes.js new file mode 100644 index 00000000..83dd4114 --- /dev/null +++ b/web/app/store/CommonDeviceAttributes.js @@ -0,0 +1,42 @@ +/* + * 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.CommonDeviceAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + + data: [{ + key: 'speedLimit', + name: Strings.attributeSpeedLimit, + valueType: 'number', + dataType: 'speed' + }, { + key: 'report.ignoreOdometer', + name: Strings.attributeReportIgnoreOdometer, + valueType: 'boolean' + }, { + key: 'maintenance.start', + name: Strings.attributeMaintenanceStart, + valueType: 'number', + dataType: 'distance' + }, { + key: 'maintenance.interval', + name: Strings.attributeMaintenanceInterval, + valueType: 'number', + dataType: 'distance' + }] +}); diff --git a/web/app/store/CommonUserAttributes.js b/web/app/store/CommonUserAttributes.js new file mode 100644 index 00000000..85d652df --- /dev/null +++ b/web/app/store/CommonUserAttributes.js @@ -0,0 +1,55 @@ +/* + * 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.CommonUserAttributes', { + extend: 'Ext.data.Store', + model: 'Traccar.model.KnownAttribute', + + data: [{ + key: 'web.liveRouteLength', + name: Strings.attributeWebLiveRouteLength, + valueType: 'number', + allowDecimals: false + }, { + key: 'web.selectZoom', + name: Strings.attributeWebSelectZoom, + valueType: 'number', + allowDecimals: false, + minValue: Traccar.Style.mapDefaultZoom, + maxValue: Traccar.Style.mapMaxZoom + }, { + key: 'ui.disableReport', + name: Strings.attributeUiDisableReport, + valueType: 'boolean' + }, { + key: 'ui.disableVehicleFetures', + name: Strings.attributeUiDisableVehicleFetures, + valueType: 'boolean' + }, { + key: 'ui.disableDrivers', + name: Strings.attributeUiDisableDrivers, + valueType: 'boolean' + }, { + key: 'ui.disableComputedAttributes', + name: Strings.attributeUiDisableComputedAttributes, + valueType: 'boolean' + }, { + key: 'ui.disableCalendars', + name: Strings.attributeUiDisableCalendars, + valueType: 'boolean' + }] +}); diff --git a/web/app/store/DeviceAttributes.js b/web/app/store/DeviceAttributes.js index 220f9a5b..4b1d9204 100644 --- a/web/app/store/DeviceAttributes.js +++ b/web/app/store/DeviceAttributes.js @@ -18,28 +18,8 @@ Ext.define('Traccar.store.DeviceAttributes', { extend: 'Ext.data.Store', model: 'Traccar.model.KnownAttribute', - proxy: 'memory', data: [{ - key: 'speedLimit', - name: Strings.attributeSpeedLimit, - valueType: 'number', - dataType: 'speed' - }, { - key: 'report.ignoreOdometer', - name: Strings.attributeReportIgnoreOdometer, - valueType: 'boolean' - }, { - key: 'maintenance.start', - name: Strings.attributeMaintenanceStart, - valueType: 'number', - dataType: 'distance' - }, { - key: 'maintenance.interval', - name: Strings.attributeMaintenanceInterval, - valueType: 'number', - dataType: 'distance' - }, { key: 'web.reportColor', name: Strings.attributeWebReportColor, valueType: 'color' diff --git a/web/app/store/GroupAttributes.js b/web/app/store/GroupAttributes.js index 2a2765f5..9389db1c 100644 --- a/web/app/store/GroupAttributes.js +++ b/web/app/store/GroupAttributes.js @@ -18,28 +18,8 @@ Ext.define('Traccar.store.GroupAttributes', { extend: 'Ext.data.Store', model: 'Traccar.model.KnownAttribute', - proxy: 'memory', data: [{ - key: 'speedLimit', - name: Strings.attributeSpeedLimit, - valueType: 'number', - dataType: 'speed' - }, { - key: 'report.ignoreOdometer', - name: Strings.attributeReportIgnoreOdometer, - valueType: 'boolean' - }, { - key: 'maintenance.start', - name: Strings.attributeMaintenanceStart, - valueType: 'number', - dataType: 'distance' - }, { - key: 'maintenance.interval', - name: Strings.attributeMaintenanceInterval, - valueType: 'number', - dataType: 'distance' - }, { key: 'processing.copyAttributes', name: Strings.attributeProcessingCopyAttributes, valueType: 'string' diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index 109b09e0..204f885b 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -18,54 +18,6 @@ Ext.define('Traccar.store.ServerAttributes', { extend: 'Ext.data.Store', model: 'Traccar.model.KnownAttribute', - proxy: 'memory', - data: [{ - key: 'speedLimit', - name: Strings.attributeSpeedLimit, - valueType: 'number', - dataType: 'speed' - }, { - key: 'maintenance.start', - name: Strings.attributeMaintenanceStart, - valueType: 'number', - dataType: 'distance' - }, { - key: 'maintenance.interval', - name: Strings.attributeMaintenanceInterval, - valueType: 'number', - dataType: 'distance' - }, { - key: 'web.liveRouteLength', - name: Strings.attributeWebLiveRouteLength, - valueType: 'number', - allowDecimals: false - }, { - key: 'web.selectZoom', - name: Strings.attributeWebSelectZoom, - valueType: 'number', - allowDecimals: false, - minValue: Traccar.Style.mapDefaultZoom, - maxValue: Traccar.Style.mapMaxZoom - }, { - key: 'ui.disableReport', - name: Strings.attributeUiDisableReport, - valueType: 'boolean' - }, { - key: 'ui.disableVehicleFetures', - name: Strings.attributeUiDisableVehicleFetures, - valueType: 'boolean' - }, { - key: 'ui.disableDrivers', - name: Strings.attributeUiDisableDrivers, - valueType: 'boolean' - }, { - key: 'ui.disableComputedAttributes', - name: Strings.attributeUiDisableComputedAttributes, - valueType: 'boolean' - }, { - key: 'ui.disableCalendars', - name: Strings.attributeUiDisableCalendars, - valueType: 'boolean' - }] + data: [] }); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index a004a54d..dfe69421 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -18,7 +18,6 @@ Ext.define('Traccar.store.UserAttributes', { extend: 'Ext.data.Store', model: 'Traccar.model.KnownAttribute', - proxy: 'memory', data: [{ key: 'mail.smtp.host', @@ -67,37 +66,5 @@ Ext.define('Traccar.store.UserAttributes', { key: 'mail.smtp.password', name: Strings.attributeMailSmtpPassword, valueType: 'string' - }, { - key: 'web.liveRouteLength', - name: Strings.attributeWebLiveRouteLength, - valueType: 'number', - allowDecimals: false - }, { - key: 'web.selectZoom', - name: Strings.attributeWebSelectZoom, - valueType: 'number', - allowDecimals: false, - minValue: Traccar.Style.mapDefaultZoom, - maxValue: Traccar.Style.mapMaxZoom - }, { - key: 'ui.disableReport', - name: Strings.attributeUiDisableReport, - valueType: 'boolean' - }, { - key: 'ui.disableVehicleFetures', - name: Strings.attributeUiDisableVehicleFetures, - valueType: 'boolean' - }, { - key: 'ui.disableDrivers', - name: Strings.attributeUiDisableDrivers, - valueType: 'boolean' - }, { - key: 'ui.disableComputedAttributes', - name: Strings.attributeUiDisableComputedAttributes, - valueType: 'boolean' - }, { - key: 'ui.disableCalendars', - name: Strings.attributeUiDisableCalendars, - valueType: 'boolean' }] }); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 5c052b50..f9dbc03c 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -79,7 +79,7 @@ Ext.define('Traccar.view.ReportController', { hidden: true }); } - if (Traccar.app.isVehicleFeaturesDisabled()) { + if (Traccar.app.getVehicleFeaturesDisabled()) { for (i = 0; i < this.summaryColumns.length; i++) { if (this.summaryColumns[i].dataIndex.match('engineHours|spentFuel')) { this.summaryColumns[i].hidden = true; diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 7985700a..7175260c 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -45,7 +45,7 @@ Ext.define('Traccar.view.SettingsMenuController', { if (admin) { this.lookupReference('settingsServerButton').setHidden(false); this.lookupReference('settingsStatisticsButton').setHidden(false); - this.lookupReference('settingsDeviceDistanceButton').setHidden(Traccar.app.isVehicleFeaturesDisabled()); + this.lookupReference('settingsDeviceDistanceButton').setHidden(Traccar.app.getVehicleFeaturesDisabled()); } if (admin || manager) { this.lookupReference('settingsUsersButton').setHidden(false); @@ -57,8 +57,8 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableCalendars')); - this.lookupReference('settingsDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || - Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('settingsDriversButton').setHidden( + Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); } if (admin || !deviceReadonly && !readonly) { this.lookupReference('settingsAttributeAliasesButton').setHidden(false); diff --git a/web/app/view/edit/AttributesController.js b/web/app/view/edit/AttributesController.js index 235f2c5b..c12c1968 100644 --- a/web/app/view/edit/AttributesController.js +++ b/web/app/view/edit/AttributesController.js @@ -90,6 +90,7 @@ Ext.define('Traccar.view.edit.AttributesController', { displayField: 'name', valueField: 'key', allowBlank: false, + queryMode: 'local', listeners: { change: 'onNameChange' } diff --git a/web/app/view/edit/DevicesController.js b/web/app/view/edit/DevicesController.js index 9616dbd2..df75b1d4 100644 --- a/web/app/view/edit/DevicesController.js +++ b/web/app/view/edit/DevicesController.js @@ -61,8 +61,8 @@ Ext.define('Traccar.view.edit.DevicesController', { deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); - this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || - Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('toolbarDriversButton').setHidden( + Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('toolbarAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); diff --git a/web/app/view/edit/GroupsController.js b/web/app/view/edit/GroupsController.js index d40c1e69..be26cc93 100644 --- a/web/app/view/edit/GroupsController.js +++ b/web/app/view/edit/GroupsController.js @@ -33,8 +33,8 @@ Ext.define('Traccar.view.edit.GroupsController', { removeTitle: Strings.groupDialog, init: function () { - this.lookupReference('toolbarDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || - Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('toolbarDriversButton').setHidden( + Traccar.app.getVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('toolbarAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); }, diff --git a/web/app/view/edit/UsersController.js b/web/app/view/edit/UsersController.js index 8da5caa9..d67f5a70 100644 --- a/web/app/view/edit/UsersController.js +++ b/web/app/view/edit/UsersController.js @@ -41,8 +41,8 @@ Ext.define('Traccar.view.edit.UsersController', { init: function () { Ext.getStore('Users').load(); this.lookupReference('userUsersButton').setHidden(!Traccar.app.getUser().get('admin')); - this.lookupReference('userDriversButton').setHidden(Traccar.app.isVehicleFeaturesDisabled() || - Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); + this.lookupReference('userDriversButton').setHidden( + Traccar.app.isVehicleFeaturesDisabled() || Traccar.app.getBooleanAttributePreference('ui.disableDrivers')); this.lookupReference('userAttributesButton').setHidden( Traccar.app.getBooleanAttributePreference('ui.disableComputedAttributes')); this.lookupReference('userCalendarsButton').setHidden( diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index d8d2249d..75796f9b 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -44,8 +44,8 @@ Ext.define('Traccar.view.map.MapController', { init: function () { this.callParent(); - this.lookupReference('showReportsButton').setVisible(Traccar.app.isMobile() && - !Traccar.app.getBooleanAttributePreference('ui.disableReport')); + this.lookupReference('showReportsButton').setVisible( + Traccar.app.isMobile() && !Traccar.app.getBooleanAttributePreference('ui.disableReport')); this.lookupReference('showEventsButton').setVisible(Traccar.app.isMobile()); }, -- cgit v1.2.3