aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-01-13 09:26:24 +0500
committerAbyss777 <abyss@fox5.ru>2017-01-16 16:58:52 +0500
commit34c878d014a065981d56859cb73564bfa2bc478e (patch)
treea303aa2f2671faf2c0a4c0870e0aafea5e430ba4
parentede04a679525bb95fcc5ca0a327e8e915f58564e (diff)
downloadetbsa-traccar-web-34c878d014a065981d56859cb73564bfa2bc478e.tar.gz
etbsa-traccar-web-34c878d014a065981d56859cb73564bfa2bc478e.tar.bz2
etbsa-traccar-web-34c878d014a065981d56859cb73564bfa2bc478e.zip
Initial manager implementation
-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/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
12 files changed, 122 insertions, 35 deletions
diff --git a/web/app/model/User.js b/web/app/model/User.js
index 6df6afc..a88b944 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 367a32a..1cbb735 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 7f109fd..b6f0444 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 66d6809..a9edee9 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'
@@ -118,7 +118,8 @@ Ext.define('Traccar.view.MapController', {
});
},
- 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
@@ -128,15 +129,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/SettingsMenuController.js b/web/app/view/SettingsMenuController.js
index 2f1685f..1f5907d 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 f9be113..f84caac 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 02e7b2f..8ab3f6b 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 f07031e..2946a2a 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 0000000..265acc8
--- /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 09a03cc..2c0bbef 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 af9d47b..8aaa839 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 e7b0574..dc7280e 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",