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/Application.js | 8 ++++++++ web/app/store/ServerAttributes.js | 4 ++++ web/app/store/UserAttributes.js | 4 ++++ 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 +- web/l10n/en.json | 1 + 10 files changed, 43 insertions(+), 5 deletions(-) (limited to 'web') diff --git a/web/app/Application.js b/web/app/Application.js index c14dd4d..3cee7b7 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -104,6 +104,10 @@ Ext.define('Traccar.Application', { return window.matchMedia && window.matchMedia('(max-width: 768px)').matches; }, + isVehicleFeaturesDisabled: function () { + return this.getBooleanAttributePreference('ui.disableVehicleFetures'); + }, + getEventString: function (eventType) { var key = 'event' + eventType.charAt(0).toUpperCase() + eventType.slice(1); return Strings[key] || key; @@ -161,6 +165,10 @@ Ext.define('Traccar.Application', { } }, + getBooleanAttributePreference: function (key) { + return this.getAttributePreference(key, false).toString() === 'true'; + }, + getReportColor: function (deviceId) { var index, reportColor, device = Ext.getStore('Devices').getById(deviceId); if (device) { diff --git a/web/app/store/ServerAttributes.js b/web/app/store/ServerAttributes.js index 89a0137..438ca3e 100644 --- a/web/app/store/ServerAttributes.js +++ b/web/app/store/ServerAttributes.js @@ -51,5 +51,9 @@ Ext.define('Traccar.store.ServerAttributes', { key: 'ui.disableReport', name: Strings.attributeUiDisableReport, valueType: 'boolean' + }, { + key: 'ui.disableVehicleFetures', + name: Strings.attributeUiDisableVehicleFetures, + valueType: 'boolean' }] }); diff --git a/web/app/store/UserAttributes.js b/web/app/store/UserAttributes.js index 6cf06fb..8e1acfb 100644 --- a/web/app/store/UserAttributes.js +++ b/web/app/store/UserAttributes.js @@ -83,5 +83,9 @@ Ext.define('Traccar.store.UserAttributes', { key: 'ui.disableReport', name: Strings.attributeUiDisableReport, valueType: 'boolean' + }, { + key: 'ui.disableVehicleFetures', + name: Strings.attributeUiDisableVehicleFetures, + valueType: 'boolean' }] }); diff --git a/web/app/view/MainController.js b/web/app/view/MainController.js index 76645e4..126d9af 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 5850086..85af559 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 102120d..11bfb53 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 ae65fbb..b98a8d4 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 21f17ff..941f5f1 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 f2a561a..651bd9f 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()); }, diff --git a/web/l10n/en.json b/web/l10n/en.json index 6476b0d..6ea5410 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -89,6 +89,7 @@ "attributeMailSmtpUsername": "Mail: SMTP Username", "attributeMailSmtpPassword": "Mail: SMTP Password", "attributeUiDisableReport": "UI: Disable Report", + "attributeUiDisableVehicleFetures": "UI: Disable Vehicle Fetures", "errorTitle": "Error", "errorGeneral": "Invalid parameters or constraints violation", "errorConnection": "Connection error", -- cgit v1.2.3