2015-04-02 20:34:41 +00:00
|
|
|
(function() {
|
|
|
|
/**
|
|
|
|
* Page that displays details about an user.
|
|
|
|
*/
|
|
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
|
|
|
pages.create('user-view', 'user-view.html', UserViewCtrl, {
|
|
|
|
'newLayout': true,
|
|
|
|
'title': 'User {{ user.username }}',
|
|
|
|
'description': 'User {{ user.username }}'
|
2015-06-29 09:33:00 +00:00
|
|
|
})
|
2015-04-02 20:34:41 +00:00
|
|
|
}]);
|
|
|
|
|
2015-09-04 20:14:46 +00:00
|
|
|
function UserViewCtrl($scope, $routeParams, $timeout, ApiService, UserService, UIService, AvatarService, Config, ExternalLoginService) {
|
2015-04-02 20:34:41 +00:00
|
|
|
var username = $routeParams.username;
|
|
|
|
|
|
|
|
$scope.showInvoicesCounter = 0;
|
|
|
|
$scope.showAppsCounter = 0;
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobotsCounter = 0;
|
2015-04-02 20:34:41 +00:00
|
|
|
$scope.changeEmailInfo = {};
|
|
|
|
$scope.changePasswordInfo = {};
|
2015-09-04 20:14:46 +00:00
|
|
|
$scope.hasSingleSignin = ExternalLoginService.hasSingleSignin();
|
2015-04-02 20:34:41 +00:00
|
|
|
|
|
|
|
UserService.updateUserIn($scope);
|
|
|
|
|
|
|
|
var loadRepositories = function() {
|
|
|
|
var options = {
|
2015-08-06 18:11:32 +00:00
|
|
|
'public': true,
|
2015-04-02 20:34:41 +00:00
|
|
|
'namespace': username,
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.repositoriesResource = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadUser = function() {
|
|
|
|
$scope.userResource = ApiService.getUserInformationAsResource({'username': username}).get(function(user) {
|
2015-04-07 22:33:43 +00:00
|
|
|
$scope.viewuser = user;
|
2015-04-02 20:34:41 +00:00
|
|
|
|
|
|
|
// Load the repositories.
|
|
|
|
$timeout(function() {
|
|
|
|
loadRepositories();
|
|
|
|
}, 10);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load the user.
|
|
|
|
loadUser();
|
|
|
|
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobots = function() {
|
|
|
|
$scope.showRobotsCounter++;
|
|
|
|
};
|
|
|
|
|
2015-04-02 20:34:41 +00:00
|
|
|
$scope.showInvoices = function() {
|
|
|
|
$scope.showInvoicesCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showApplications = function() {
|
|
|
|
$scope.showAppsCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changePassword = function() {
|
2015-08-11 17:53:09 +00:00
|
|
|
if (Config.AUTHENTICATION_TYPE != 'Database') { return; }
|
|
|
|
|
2015-04-02 20:34:41 +00:00
|
|
|
UIService.hidePopover('#changePasswordForm');
|
|
|
|
$scope.changePasswordInfo.state = 'changing';
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'password': $scope.changePasswordInfo.password
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeUserDetails(data).then(function(resp) {
|
|
|
|
$scope.changePasswordInfo.state = 'changed';
|
|
|
|
|
|
|
|
// Reset the form
|
|
|
|
delete $scope.changePasswordInfo['password']
|
|
|
|
delete $scope.changePasswordInfo['repeatPassword']
|
|
|
|
|
|
|
|
// Reload the user.
|
|
|
|
UserService.load();
|
|
|
|
}, function(result) {
|
|
|
|
$scope.changePasswordInfo.state = 'change-error';
|
|
|
|
UIService.showFormError('#changePasswordForm', result);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.generateClientToken = function() {
|
|
|
|
var generateToken = function(password) {
|
|
|
|
var data = {
|
|
|
|
'password': password
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.generateUserClientKey(data).then(function(resp) {
|
|
|
|
$scope.generatedClientToken = resp['key'];
|
|
|
|
$('#clientTokenModal').modal({});
|
|
|
|
}, ApiService.errorDisplay('Could not generate token'));
|
|
|
|
};
|
|
|
|
|
2015-05-27 16:06:38 +00:00
|
|
|
UIService.showPasswordDialog('Enter your password to generate an encrypted version:', generateToken);
|
2015-04-02 20:34:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeEmail = function() {
|
|
|
|
UIService.hidePopover('#changeEmailForm');
|
|
|
|
|
|
|
|
var details = {
|
|
|
|
'email': $scope.changeEmailInfo.email
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeEmailInfo.state = 'sending';
|
|
|
|
ApiService.changeUserDetails(details).then(function() {
|
|
|
|
$scope.changeEmailInfo.state = 'sent';
|
|
|
|
delete $scope.changeEmailInfo['email'];
|
|
|
|
}, function(result) {
|
|
|
|
$scope.changeEmailInfo.state = 'send-error';
|
|
|
|
UIService.showFormError('#changeEmailForm', result);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
})();
|