aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-28 17:51:10 +1300
committerGitHub <noreply@github.com>2017-01-28 17:51:10 +1300
commitd1dd9f84e819d70154861ac2487f902da12885ed (patch)
tree01a8be83810df3722e86d5c7182e96c075d0a215 /web
parentb32387fe01dafc1e85509c8e5312831d9cd0aef2 (diff)
parentaec5f5b0f0b00492742919358a9aaa03e72e3a5b (diff)
downloadtrackermap-web-d1dd9f84e819d70154861ac2487f902da12885ed.tar.gz
trackermap-web-d1dd9f84e819d70154861ac2487f902da12885ed.tar.bz2
trackermap-web-d1dd9f84e819d70154861ac2487f902da12885ed.zip
Merge pull request #390 from Abyss777/permissions_polishing
Improve permissions
Diffstat (limited to 'web')
-rw-r--r--web/app/model/User.js3
-rw-r--r--web/app/view/BaseEditDialog.js6
-rw-r--r--web/app/view/BaseEditDialogController.js1
-rw-r--r--web/app/view/DeviceDialog.js5
-rw-r--r--web/app/view/Devices.js3
-rw-r--r--web/app/view/DevicesController.js17
-rw-r--r--web/app/view/GeofenceDialogController.js1
-rw-r--r--web/app/view/GroupDialog.js5
-rw-r--r--web/app/view/MainMobile.js1
-rw-r--r--web/app/view/Map.js3
-rw-r--r--web/app/view/NotificationsController.js4
-rw-r--r--web/app/view/SettingsMenu.js5
-rw-r--r--web/app/view/SettingsMenuController.js11
-rw-r--r--web/app/view/StateController.js2
-rw-r--r--web/app/view/UserDialog.js9
-rw-r--r--web/app/view/UserDialogController.js2
-rw-r--r--web/app/view/UsersController.js6
-rw-r--r--web/l10n/en.json1
18 files changed, 57 insertions, 28 deletions
diff --git a/web/app/model/User.js b/web/app/model/User.js
index a88b9440..df346eee 100644
--- a/web/app/model/User.js
+++ b/web/app/model/User.js
@@ -75,6 +75,9 @@ Ext.define('Traccar.model.User', {
name: 'userLimit',
type: 'int'
}, {
+ name: 'deviceReadonly',
+ type: 'boolean'
+ }, {
name: 'token',
type: 'string'
}, {
diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js
index 7ccaad39..18cfcf50 100644
--- a/web/app/view/BaseEditDialog.js
+++ b/web/app/view/BaseEditDialog.js
@@ -18,6 +18,12 @@
Ext.define('Traccar.view.BaseEditDialog', {
extend: 'Traccar.view.BaseDialog',
+ requires: [
+ 'Traccar.view.BaseEditDialogController'
+ ],
+
+ controller: 'baseEditDialog',
+
buttons: [{
text: Strings.sharedAttributes,
handler: 'showAttributesView'
diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js
index 3e386689..8b74fbba 100644
--- a/web/app/view/BaseEditDialogController.js
+++ b/web/app/view/BaseEditDialogController.js
@@ -20,6 +20,7 @@ Ext.define('Traccar.view.BaseEditDialogController', {
alias: 'controller.baseEditDialog',
requires: [
+ 'Traccar.view.BaseWindow',
'Traccar.view.Attributes'
],
diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js
index d3f964ed..960b3f9b 100644
--- a/web/app/view/DeviceDialog.js
+++ b/web/app/view/DeviceDialog.js
@@ -18,11 +18,6 @@
Ext.define('Traccar.view.DeviceDialog', {
extend: 'Traccar.view.BaseEditDialog',
- requires: [
- 'Traccar.view.BaseEditDialog'
- ],
-
- controller: 'baseEditDialog',
title: Strings.sharedDevice,
items: {
diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js
index 519826e2..6ca40987 100644
--- a/web/app/view/Devices.js
+++ b/web/app/view/Devices.js
@@ -21,8 +21,7 @@ Ext.define('Traccar.view.Devices', {
requires: [
'Traccar.view.DevicesController',
- 'Traccar.view.EditToolbar',
- 'Traccar.view.SettingsMenu'
+ 'Traccar.view.EditToolbar'
],
controller: 'devices',
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js
index 20b90b3b..f7e4bb47 100644
--- a/web/app/view/DevicesController.js
+++ b/web/app/view/DevicesController.js
@@ -48,10 +48,12 @@ Ext.define('Traccar.view.DevicesController', {
},
init: function () {
- var readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin');
- this.lookupReference('toolbarAddButton').setVisible(!readonly);
- this.lookupReference('toolbarEditButton').setVisible(!readonly);
- this.lookupReference('toolbarRemoveButton').setVisible(!readonly);
+ var readonly, deviceReadonly;
+ deviceReadonly = Traccar.app.getUser().get('deviceReadonly');
+ readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin');
+ this.lookupReference('toolbarAddButton').setVisible(!readonly && !deviceReadonly);
+ this.lookupReference('toolbarEditButton').setVisible(!readonly && !deviceReadonly);
+ this.lookupReference('toolbarRemoveButton').setVisible(!readonly && !deviceReadonly);
this.lookupReference('toolbarGeofencesButton').setVisible(!readonly);
},
@@ -87,7 +89,12 @@ Ext.define('Traccar.view.DevicesController', {
if (btn === 'yes') {
store = Ext.getStore('Devices');
store.remove(device);
- store.sync();
+ store.sync({
+ failure: function (batch) {
+ store.rejectChanges();
+ Traccar.app.showError(batch.exceptions[0].getError().response);
+ }
+ });
}
}
});
diff --git a/web/app/view/GeofenceDialogController.js b/web/app/view/GeofenceDialogController.js
index be346c47..936c46dc 100644
--- a/web/app/view/GeofenceDialogController.js
+++ b/web/app/view/GeofenceDialogController.js
@@ -20,6 +20,7 @@ Ext.define('Traccar.view.GeofenceDialogController', {
alias: 'controller.geofenceDialog',
requires: [
+ 'Traccar.view.BaseWindow',
'Traccar.view.GeofenceMap'
],
diff --git a/web/app/view/GroupDialog.js b/web/app/view/GroupDialog.js
index 2dda74fb..01fdc85e 100644
--- a/web/app/view/GroupDialog.js
+++ b/web/app/view/GroupDialog.js
@@ -18,11 +18,6 @@
Ext.define('Traccar.view.GroupDialog', {
extend: 'Traccar.view.BaseEditDialog',
- requires: [
- 'Traccar.view.BaseEditDialogController'
- ],
-
- controller: 'baseEditDialog',
title: Strings.groupDialog,
items: {
diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js
index 2659e2fb..347db315 100644
--- a/web/app/view/MainMobile.js
+++ b/web/app/view/MainMobile.js
@@ -24,6 +24,7 @@ Ext.define('Traccar.view.MainMobile', {
requires: [
'Traccar.view.Devices',
'Traccar.view.State',
+ 'Traccar.view.Report',
'Traccar.view.Map'
],
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index 88bdf8b4..ebc6bbb0 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -20,7 +20,8 @@ Ext.define('Traccar.view.Map', {
xtype: 'mapView',
requires: [
- 'Traccar.view.MapController'
+ 'Traccar.view.MapController',
+ 'Traccar.view.SettingsMenu'
],
controller: 'map',
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
index 4c83b145..f50e8d82 100644
--- a/web/app/view/NotificationsController.js
+++ b/web/app/view/NotificationsController.js
@@ -19,10 +19,6 @@ Ext.define('Traccar.view.NotificationsController', {
extend: 'Ext.app.ViewController',
alias: 'controller.notificationsController',
- requires: [
- 'Traccar.store.Notifications'
- ],
-
init: function () {
this.getView().getStore().load({
params: {
diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js
index c71c8372..423dc42b 100644
--- a/web/app/view/SettingsMenu.js
+++ b/web/app/view/SettingsMenu.js
@@ -31,9 +31,11 @@ Ext.define('Traccar.view.SettingsMenu', {
controller: 'settings',
items: [{
+ hidden: true,
text: Strings.settingsUser,
glyph: 'xf007@FontAwesome',
- handler: 'onUserClick'
+ handler: 'onUserClick',
+ reference: 'settingsUserButton'
}, {
hidden: true,
text: Strings.settingsGroups,
@@ -59,6 +61,7 @@ Ext.define('Traccar.view.SettingsMenu', {
handler: 'onUsersClick',
reference: 'settingsUsersButton'
}, {
+ hidden: true,
text: Strings.sharedNotifications,
glyph: 'xf003@FontAwesome',
handler: 'onNotificationsClick',
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index 1f5907d1..16813fa6 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -35,10 +35,11 @@ Ext.define('Traccar.view.SettingsMenuController', {
],
init: function () {
- var admin, manager, readonly;
+ var admin, manager, readonly, deviceReadonly;
admin = Traccar.app.getUser().get('admin');
- manager = Traccar.app.getUser().get('userLimit') > 0;
+ manager = Traccar.app.getUser().get('userLimit') !== 0;
readonly = Traccar.app.getPreference('readonly', false);
+ deviceReadonly = Traccar.app.getUser().get('deviceReadonly');
if (admin) {
this.lookupReference('settingsServerButton').setHidden(false);
this.lookupReference('settingsStatisticsButton').setHidden(false);
@@ -48,11 +49,15 @@ Ext.define('Traccar.view.SettingsMenuController', {
this.lookupReference('settingsUsersButton').setHidden(false);
}
if (admin || !readonly) {
+ this.lookupReference('settingsUserButton').setHidden(false);
this.lookupReference('settingsGroupsButton').setHidden(false);
this.lookupReference('settingsGeofencesButton').setHidden(false);
- this.lookupReference('settingsAttributeAliasesButton').setHidden(false);
+ this.lookupReference('settingsNotificationsButton').setHidden(false);
this.lookupReference('settingsCalendarsButton').setHidden(false);
}
+ if (admin || (!deviceReadonly && !readonly)) {
+ this.lookupReference('settingsAttributeAliasesButton').setHidden(false);
+ }
},
onUserClick: function () {
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index f84caac2..08331867 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -55,6 +55,8 @@ Ext.define('Traccar.view.StateController', {
},
init: function () {
+ var visible = !Traccar.app.getUser().get('deviceReadonly') && !Traccar.app.getPreference('readonly', false);
+ this.lookupReference('aliasEditButton').setVisible(visible);
this.aliasesStore = Ext.getStore('AttributeAliases');
},
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index 8ab3f6b2..34c3b4a1 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -145,11 +145,18 @@ Ext.define('Traccar.view.UserDialog', {
disabled: true,
reference: 'userLimitField'
}, {
+ xtype: 'checkboxfield',
+ inputValue: true,
+ uncheckedValue: false,
+ name: 'deviceReadonly',
+ fieldLabel: Strings.userDeviceReadonly,
+ disabled: true,
+ reference: 'deviceReadonlyField'
+ }, {
xtype: 'textfield',
name: 'token',
reference: 'tokenField',
fieldLabel: Strings.userToken,
- disabled: true,
triggers: {
generate: {
cls: 'iconCls: x-fa fa-refresh',
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index 2946a2a2..bfb934da 100644
--- a/web/app/view/UserDialogController.js
+++ b/web/app/view/UserDialogController.js
@@ -30,7 +30,7 @@ Ext.define('Traccar.view.UserDialogController', {
this.lookupReference('readonlyField').setHidden(false);
this.lookupReference('disabledField').setHidden(false);
this.lookupReference('expirationTimeField').setDisabled(false);
- this.lookupReference('tokenField').setDisabled(false);
+ this.lookupReference('deviceReadonlyField').setDisabled(false);
}
},
diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js
index 8aaa8397..68e49f83 100644
--- a/web/app/view/UsersController.js
+++ b/web/app/view/UsersController.js
@@ -40,6 +40,12 @@ Ext.define('Traccar.view.UsersController', {
onAddClick: function () {
var user, dialog;
user = Ext.create('Traccar.model.User');
+ if (Traccar.app.getUser().get('admin')) {
+ user.set('deviceLimit', -1);
+ }
+ if (Traccar.app.getUser().get('expirationTime')) {
+ user.set('expirationTime', Traccar.app.getUser().get('expirationTime'));
+ }
dialog = Ext.create('Traccar.view.UserDialog');
dialog.down('form').loadRecord(user);
dialog.show();
diff --git a/web/l10n/en.json b/web/l10n/en.json
index dc7280e7..62f8a225 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -58,6 +58,7 @@
"userExpirationTime": "Expiration",
"userDeviceLimit": "Device Limit",
"userUserLimit": "User Limit",
+ "userDeviceReadonly": "Device Readonly",
"userToken": "Token",
"loginTitle": "Login",
"loginLanguage": "Language",