From 04aaa728103c5ff184a89e8b69bca3f196c52224 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 12 Dec 2014 10:21:50 +0100 Subject: [PATCH] Show user backend in user management * add switch to settings to show user backend * user classes for headers and rows to unify the show/hide statement * add user backend to response of user create request * proper markup in settings area --- settings/controller/userscontroller.php | 3 +- settings/css/settings.css | 7 +++-- settings/js/users/users.js | 31 ++++++++++++------- settings/templates/users/main.php | 22 +++++++++---- settings/templates/users/part.userlist.php | 6 ++-- .../controller/userscontrollertest.php | 14 +++++++-- 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index 589b0a888cb..dd3aa72890e 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -185,7 +185,8 @@ class UsersController extends Controller { array( 'username' => $username, 'groups' => $this->groupManager->getUserGroupIds($user), - 'storageLocation' => $user->getHome() + 'storageLocation' => $user->getHome(), + 'backend' => $user->getBackendClassName() ), Http::STATUS_CREATED ); diff --git a/settings/css/settings.css b/settings/css/settings.css index 4594a22c6d0..fa699e50a4b 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -94,8 +94,11 @@ td.password>img,td.displayName>img, td.remove>a, td.quota>img { visibility:hidde td.password, td.quota, td.displayName { width:12em; cursor:pointer; } td.password>span, td.quota>span, rd.displayName>span { margin-right: 1.2em; color: #C7C7C7; } span.usersLastLoginTooltip { white-space: nowrap; } -th#headerLastLogin, td.lastLogin { display : none; } -th#headerStorageLocation, td.storageLocation { display : none; } +#userlist .storageLocation, +#userlist .userBackend, +#userlist .lastLogin { + display : none; +} td.remove { width:1em; padding-right:1em; } tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; } diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 70dd115396d..62e18d1be04 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -28,7 +28,7 @@ var UserList = { this.$el.find('.quota-user').singleSelect().on('change', this.onQuotaSelect); }, - add: function (username, displayname, groups, subadmin, quota, storageLocation, lastLogin, sort) { + add: function (username, displayname, groups, subadmin, quota, storageLocation, lastLogin, sort, backend) { var $tr = $userListBody.find('tr:first-child').clone(); // this removes just the `display:none` of the template row $tr.removeAttr('style'); @@ -116,6 +116,11 @@ var UserList = { */ $tr.find('td.storageLocation').text(storageLocation); + /** + * user backend + */ + $tr.find('td.userBackend').text(backend); + /** * last login */ @@ -372,7 +377,7 @@ var UserList = { if(UserList.has(user.name)) { return true; } - var $tr = UserList.add(user.name, user.displayname, user.groups, user.subadmin, user.quota, user.storageLocation, user.lastLogin, false); + var $tr = UserList.add(user.name, user.displayname, user.groups, user.subadmin, user.quota, user.storageLocation, user.lastLogin, false, user.backend); $tr.addClass('appear transparent'); trs.push($tr); loadedUsers++; @@ -731,7 +736,7 @@ $(document).ready(function () { }, 10000); } if(!UserList.has(username)) { - UserList.add(username, username, result.groups, null, 'default', result.storageLocation, 0, true); + UserList.add(username, username, result.groups, null, 'default', result.storageLocation, 0, true, result.backend); } $('#newusername').focus(); GroupList.incEveryoneCount(); @@ -743,21 +748,25 @@ $(document).ready(function () { // Option to display/hide the "Storage location" column $('#CheckboxStorageLocation').click(function() { if ($('#CheckboxStorageLocation').is(':checked')) { - $("#headerStorageLocation").show(); - $("#userlist td.storageLocation").show(); + $("#userlist .storageLocation").show(); } else { - $("#headerStorageLocation").hide(); - $("#userlist td.storageLocation").hide(); + $("#userlist .storageLocation").hide(); } }); // Option to display/hide the "Last Login" column $('#CheckboxLastLogin').click(function() { if ($('#CheckboxLastLogin').is(':checked')) { - $("#headerLastLogin").show(); - $("#userlist td.lastLogin").show(); + $("#userlist .lastLogin").show(); + } else { + $("#userlist .lastLogin").hide(); + } + }); + // Option to display/hide the "Last Login" column + $('#CheckboxUserBackend').click(function() { + if ($('#CheckboxUserBackend').is(':checked')) { + $("#userlist .userBackend").show(); } else { - $("#headerLastLogin").hide(); - $("#userlist td.lastLogin").hide(); + $("#userlist .userBackend").hide(); } }); diff --git a/settings/templates/users/main.php b/settings/templates/users/main.php index 1923f4b0493..c32c8df6809 100644 --- a/settings/templates/users/main.php +++ b/settings/templates/users/main.php @@ -44,14 +44,24 @@ translation('settings'); inc('users/part.setquota')); ?>
-

+ +

-

+

+

- t('Show last log in')) ?> -

+ +

+

+ + +

diff --git a/settings/templates/users/part.userlist.php b/settings/templates/users/part.userlist.php index c531323a2fa..6a6b0b69fa2 100644 --- a/settings/templates/users/part.userlist.php +++ b/settings/templates/users/part.userlist.php @@ -12,8 +12,9 @@ t('Group Admin for')); ?> t('Quota')); ?> - t('Storage Location')); ?> - t('Last Login')); ?> + t('Storage Location')); ?> + t('User Backend')); ?> + t('Last Login')); ?>   @@ -55,6 +56,7 @@ + diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index eb48babadc8..26ca6f7e5f3 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -182,6 +182,10 @@ class UsersControllerTest extends \Test\TestCase { $user ->method('getHome') ->will($this->returnValue('/home/user')); + $user + ->expects($this->once()) + ->method('getBackendClassName') + ->will($this->returnValue('bar')); $this->container['UserManager'] ->expects($this->once()) @@ -193,7 +197,8 @@ class UsersControllerTest extends \Test\TestCase { array( 'username' => 'foo', 'groups' => null, - 'storageLocation' => '/home/user' + 'storageLocation' => '/home/user', + 'backend' => 'bar' ), Http::STATUS_CREATED ); @@ -214,6 +219,10 @@ class UsersControllerTest extends \Test\TestCase { $user ->method('getHome') ->will($this->returnValue('/home/user')); + $user + ->expects($this->once()) + ->method('getBackendClassName') + ->will($this->returnValue('bar')); $existingGroup = $this->getMockBuilder('\OCP\IGroup') ->disableOriginalConstructor()->getMock(); $existingGroup @@ -250,7 +259,8 @@ class UsersControllerTest extends \Test\TestCase { array( 'username' => 'foo', 'groups' => array('NewGroup', 'ExistingGroup'), - 'storageLocation' => '/home/user' + 'storageLocation' => '/home/user', + 'backend' => 'bar' ), Http::STATUS_CREATED ); -- 2.39.5