aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/model/User.js5
-rw-r--r--web/app/view/AttributeAliasesController.js12
-rw-r--r--web/app/view/Map.js2
-rw-r--r--web/app/view/MapController.js16
-rw-r--r--web/app/view/MapMarkerController.js2
-rw-r--r--web/app/view/SettingsMenuController.js9
-rw-r--r--web/app/view/StateController.js4
-rw-r--r--web/app/view/UserDialog.js12
-rw-r--r--web/app/view/UserDialogController.js10
-rw-r--r--web/app/view/UserUsers.js49
-rw-r--r--web/app/view/Users.js11
-rw-r--r--web/app/view/UsersController.js26
-rw-r--r--web/l10n/en.json1
13 files changed, 123 insertions, 36 deletions
diff --git a/web/app/model/User.js b/web/app/model/User.js
index 6df6afc0..a88b9440 100644
--- a/web/app/model/User.js
+++ b/web/app/model/User.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -72,6 +72,9 @@ Ext.define('Traccar.model.User', {
name: 'deviceLimit',
type: 'int'
}, {
+ name: 'userLimit',
+ type: 'int'
+ }, {
name: 'token',
type: 'string'
}, {
diff --git a/web/app/view/AttributeAliasesController.js b/web/app/view/AttributeAliasesController.js
index 367a32a3..1cbb735f 100644
--- a/web/app/view/AttributeAliasesController.js
+++ b/web/app/view/AttributeAliasesController.js
@@ -1,6 +1,6 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
- * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
+ * 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
@@ -26,8 +26,8 @@ Ext.define('Traccar.view.AttributeAliasesController', {
],
init: function () {
- var admin = Traccar.app.getUser().get('admin');
- this.lookupReference('deviceField').setStore(admin ? 'AllDevices' : 'Devices');
+ 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);
@@ -88,11 +88,11 @@ Ext.define('Traccar.view.AttributeAliasesController', {
},
onDeviceChange: function (combobox, newValue, oldValue) {
- var admin = Traccar.app.getUser().get('admin');
+ var manager = Traccar.app.getUser().get('admin') || Traccar.app.getUser().get('userLimit') > 0;
this.onSelectionChange('');
if (newValue !== null) {
this.getView().getStore().filter('deviceId', newValue);
- if (admin && this.getView().getStore().getCount() === 0) {
+ if (manager && this.getView().getStore().getCount() === 0) {
Ext.getStore('AttributeAliases').getProxy().setExtraParam('deviceId', newValue);
Ext.getStore('AttributeAliases').load({
addRecords: true
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index 33fa8bb7..88bdf8b4 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -44,7 +44,7 @@ Ext.define('Traccar.view.Map', {
}, {
xtype: 'button',
tooltipType: 'title',
- handler: 'showGeofences',
+ handler: 'updateGeofences',
reference: 'showGeofencesButton',
glyph: 'xf21d@FontAwesome',
enableToggle: true,
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index 43d86d97..95296f14 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -33,7 +33,7 @@ Ext.define('Traccar.view.MapController', {
},
store: {
'#Geofences': {
- load: 'showGeofences',
+ load: 'updateGeofences',
add: 'updateGeofences',
update: 'updateGeofences',
remove: 'updateGeofences'
@@ -86,7 +86,8 @@ Ext.define('Traccar.view.MapController', {
this.fireEvent('togglestate', state);
},
- showGeofences: function () {
+ updateGeofences: function () {
+ this.getView().getGeofencesSource().clear();
if (this.lookupReference('showGeofencesButton').pressed) {
Ext.getStore('Geofences').each(function (geofence) {
var feature = new ol.Feature(Traccar.GeofenceConverter
@@ -96,15 +97,6 @@ Ext.define('Traccar.view.MapController', {
this.getView().getGeofencesSource().addFeature(feature);
return true;
}, this);
- } else {
- this.getView().getGeofencesSource().clear();
- }
- },
-
- updateGeofences: function () {
- if (this.lookupReference('showGeofencesButton').pressed) {
- this.getView().getGeofencesSource().clear();
- this.showGeofences();
}
}
});
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js
index 80a16a30..5e1861c4 100644
--- a/web/app/view/MapMarkerController.js
+++ b/web/app/view/MapMarkerController.js
@@ -173,7 +173,7 @@ Ext.define('Traccar.view.MapMarkerController', {
},
updateAccuracy: function (position) {
- var center, feature, mapView, projection, pointResolution;
+ var center, radius, feature, mapView, projection, pointResolution;
mapView = this.getView().getMapView();
feature = this.accuracyCircles[position.get('deviceId')];
diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index 2f1685f0..1f5907d1 100644
--- a/web/app/view/SettingsMenuController.js
+++ b/web/app/view/SettingsMenuController.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -35,15 +35,18 @@ Ext.define('Traccar.view.SettingsMenuController', {
],
init: function () {
- var admin, readonly;
+ var admin, manager, readonly;
admin = Traccar.app.getUser().get('admin');
+ manager = Traccar.app.getUser().get('userLimit') > 0;
readonly = Traccar.app.getPreference('readonly', false);
if (admin) {
this.lookupReference('settingsServerButton').setHidden(false);
- this.lookupReference('settingsUsersButton').setHidden(false);
this.lookupReference('settingsStatisticsButton').setHidden(false);
this.lookupReference('settingsDeviceDistanceButton').setHidden(false);
}
+ if (admin || manager) {
+ this.lookupReference('settingsUsersButton').setHidden(false);
+ }
if (admin || !readonly) {
this.lookupReference('settingsGroupsButton').setHidden(false);
this.lookupReference('settingsGeofencesButton').setHidden(false);
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index f9be1135..f84caac2 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -194,7 +194,7 @@ Ext.define('Traccar.view.StateController', {
},
updateAliases: function () {
- if (this.position !== null) {
+ if (this.position) {
this.updatePosition();
}
}
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index 02e7b2fc..8ab3f6b2 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -139,6 +139,12 @@ Ext.define('Traccar.view.UserDialog', {
disabled: true,
reference: 'deviceLimitField'
}, {
+ xtype: 'numberfield',
+ name: 'userLimit',
+ fieldLabel: Strings.userUserLimit,
+ disabled: true,
+ reference: 'userLimitField'
+ }, {
xtype: 'textfield',
name: 'token',
reference: 'tokenField',
@@ -153,6 +159,10 @@ Ext.define('Traccar.view.UserDialog', {
}]
},
+ listeners: {
+ show: 'onShow'
+ },
+
buttons: [{
text: Strings.sharedAttributes,
handler: 'showAttributesView'
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index f07031e3..2946a2a2 100644
--- a/web/app/view/UserDialogController.js
+++ b/web/app/view/UserDialogController.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@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
@@ -19,13 +19,17 @@ Ext.define('Traccar.view.UserDialogController', {
extend: 'Traccar.view.MapPickerDialogController',
alias: 'controller.userDialog',
- init: function () {
+ onShow: function () {
if (Traccar.app.getUser().get('admin')) {
this.lookupReference('adminField').setHidden(false);
+ this.lookupReference('deviceLimitField').setDisabled(false);
+ this.lookupReference('userLimitField').setDisabled(false);
+ }
+ if (Traccar.app.getUser().get('admin') ||
+ Traccar.app.getUser().getId() !== this.getView().down('form').getRecord().getId()) {
this.lookupReference('readonlyField').setHidden(false);
this.lookupReference('disabledField').setHidden(false);
this.lookupReference('expirationTimeField').setDisabled(false);
- this.lookupReference('deviceLimitField').setDisabled(false);
this.lookupReference('tokenField').setDisabled(false);
}
},
diff --git a/web/app/view/UserUsers.js b/web/app/view/UserUsers.js
new file mode 100644
index 00000000..265acc87
--- /dev/null
+++ b/web/app/view/UserUsers.js
@@ -0,0 +1,49 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+Ext.define('Traccar.view.UserUsers', {
+ extend: 'Ext.grid.Panel',
+ xtype: 'userUsersView',
+
+ requires: [
+ 'Traccar.view.BasePermissionsController'
+ ],
+
+ controller: 'basePermissionsController',
+
+ selModel: {
+ selType: 'checkboxmodel',
+ checkOnly: true,
+ showHeaderCheckbox: false
+ },
+
+ listeners: {
+ beforedeselect: 'onBeforeDeselect',
+ beforeselect: 'onBeforeSelect'
+ },
+
+ forceFit: true,
+
+ columns: {
+ items: [{
+ text: Strings.sharedName,
+ minWidth: Traccar.Style.columnWidthNormal,
+ dataIndex: 'name'
+ }]
+ }
+});
diff --git a/web/app/view/Users.js b/web/app/view/Users.js
index 09a03cc2..2c0bbefa 100644
--- a/web/app/view/Users.js
+++ b/web/app/view/Users.js
@@ -1,6 +1,6 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
- * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2015 - 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
@@ -55,6 +55,13 @@ Ext.define('Traccar.view.Users', {
tooltipType: 'title'
}, {
disabled: true,
+ handler: 'onUsersClick',
+ reference: 'userUsersButton',
+ glyph: 'xf0c0@FontAwesome',
+ tooltip: Strings.settingsUsers,
+ tooltipType: 'title'
+ }, {
+ disabled: true,
handler: 'onNotificationsClick',
reference: 'userNotificationsButton',
glyph: 'xf003@FontAwesome',
diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js
index af9d47b2..8aaa8397 100644
--- a/web/app/view/UsersController.js
+++ b/web/app/view/UsersController.js
@@ -1,6 +1,6 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
- * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2015 - 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
@@ -26,6 +26,7 @@ Ext.define('Traccar.view.UsersController', {
'Traccar.view.UserGroups',
'Traccar.view.UserGeofences',
'Traccar.view.UserCalendars',
+ 'Traccar.view.UserUsers',
'Traccar.view.Notifications',
'Traccar.view.BaseWindow',
'Traccar.model.User'
@@ -33,6 +34,7 @@ Ext.define('Traccar.view.UsersController', {
init: function () {
Ext.getStore('Users').load();
+ this.lookupReference('userUsersButton').setHidden(!Traccar.app.getUser().get('admin'));
},
onAddClick: function () {
@@ -147,8 +149,23 @@ Ext.define('Traccar.view.UsersController', {
}).show();
},
- onSelectionChange: function (selected) {
- var disabled = selected.length > 0;
+ onUsersClick: function () {
+ var user = this.getView().getSelectionModel().getSelection()[0];
+ Ext.create('Traccar.view.BaseWindow', {
+ title: Strings.settingsUsers,
+ items: {
+ xtype: 'userUsersView',
+ baseObjectName: 'userId',
+ linkObjectName: 'managedUserId',
+ storeName: 'Users',
+ urlApi: 'api/permissions/users',
+ baseObject: user.getId()
+ }
+ }).show();
+ },
+
+ onSelectionChange: function (selection, selected) {
+ var disabled = selected.length === 0;
this.lookupReference('toolbarEditButton').setDisabled(disabled);
this.lookupReference('toolbarRemoveButton').setDisabled(disabled);
this.lookupReference('userDevicesButton').setDisabled(disabled);
@@ -156,5 +173,6 @@ Ext.define('Traccar.view.UsersController', {
this.lookupReference('userGeofencesButton').setDisabled(disabled);
this.lookupReference('userNotificationsButton').setDisabled(disabled);
this.lookupReference('userCalendarsButton').setDisabled(disabled);
+ this.lookupReference('userUsersButton').setDisabled(disabled || selected[0].get('userLimit') === 0);
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index e7b05740..dc7280e7 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -57,6 +57,7 @@
"userDisabled": "Disabled",
"userExpirationTime": "Expiration",
"userDeviceLimit": "Device Limit",
+ "userUserLimit": "User Limit",
"userToken": "Token",
"loginTitle": "Login",
"loginLanguage": "Language",