Adapt UI logic to get user/group configuration for each user/group
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/* global Clipboard:false */
|
||||
+/* global asyncForEach:false */
|
||||
|
||||
angular.module('Application').controller('UsersController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.hasScope('users')) $location.path('/'); });
|
||||
@@ -415,8 +416,48 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
document.execCommand('copy');
|
||||
};
|
||||
|
||||
function getUsers(callback) {
|
||||
var users = [ ];
|
||||
|
||||
Client.getUsers(function (error, results) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
asyncForEach(results, function (result, iteratorDone) {
|
||||
Client.getUser(result.id, function (error, user) {
|
||||
if (error) return iteratorDone(error);
|
||||
|
||||
users.push(user);
|
||||
|
||||
iteratorDone();
|
||||
});
|
||||
}, function (error) {
|
||||
callback(error, users);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getGroups(callback) {
|
||||
var groups = [ ];
|
||||
|
||||
Client.getGroups(function (error, results) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
asyncForEach(results, function (result, iteratorDone) {
|
||||
Client.getGroup(result.id, function (error, group) {
|
||||
if (error) return iteratorDone(error);
|
||||
|
||||
groups.push(group);
|
||||
|
||||
iteratorDone();
|
||||
});
|
||||
}, function (error) {
|
||||
callback(error, groups);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
Client.getGroups(function (error, result) {
|
||||
getGroups(function (error, result) {
|
||||
if (error) return console.error('Unable to get group listing.', error);
|
||||
|
||||
$scope.groups = result;
|
||||
@@ -425,7 +466,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$scope.groupsById[result[i].id] = result[i];
|
||||
}
|
||||
|
||||
Client.getUsers(function (error, result) {
|
||||
getUsers(function (error, result) {
|
||||
if (error) return console.error('Unable to get user listing.', error);
|
||||
|
||||
$scope.users = result;
|
||||
|
||||
Reference in New Issue
Block a user