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.showAppsCounter = 0;
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobotsCounter = 0;
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.showBillingCounter = 0;
|
|
|
|
$scope.showLogsCounter = 0;
|
|
|
|
|
|
|
|
$scope.changeEmailInfo = null;
|
|
|
|
$scope.changePasswordInfo = null;
|
2015-09-04 20:14:46 +00:00
|
|
|
$scope.hasSingleSignin = ExternalLoginService.hasSingleSignin();
|
2015-12-28 21:29:17 +00:00
|
|
|
$scope.context = {};
|
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,
|
2015-12-28 21:29:17 +00:00
|
|
|
'last_modified': true,
|
|
|
|
'popularity': true
|
2015-04-02 20:34:41 +00:00
|
|
|
};
|
|
|
|
|
2015-12-28 21:29:17 +00:00
|
|
|
$scope.context.viewuser.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
2015-04-02 20:34:41 +00:00
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadUser = function() {
|
|
|
|
$scope.userResource = ApiService.getUserInformationAsResource({'username': username}).get(function(user) {
|
2015-12-28 21:29:17 +00:00
|
|
|
$scope.context.viewuser = user;
|
2016-05-12 21:59:49 +00:00
|
|
|
$scope.viewuser = user;
|
2015-04-02 20:34:41 +00:00
|
|
|
|
|
|
|
$timeout(function() {
|
2016-11-28 23:59:01 +00:00
|
|
|
// Load the repositories.
|
2015-04-02 20:34:41 +00:00
|
|
|
loadRepositories();
|
2016-11-28 23:59:01 +00:00
|
|
|
|
|
|
|
// Show the password change dialog if immediately after an account recovery.
|
|
|
|
if ($routeParams.action == 'password' && UserService.isNamespaceAdmin(username)) {
|
|
|
|
$scope.showChangePassword();
|
|
|
|
}
|
2015-04-02 20:34:41 +00:00
|
|
|
}, 10);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load the user.
|
|
|
|
loadUser();
|
|
|
|
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobots = function() {
|
|
|
|
$scope.showRobotsCounter++;
|
|
|
|
};
|
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.showLogs = function() {
|
|
|
|
$scope.showLogsCounter++;
|
2015-04-02 20:34:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showApplications = function() {
|
|
|
|
$scope.showAppsCounter++;
|
|
|
|
};
|
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.showChangePassword = function() {
|
|
|
|
$scope.changePasswordInfo = {};
|
|
|
|
};
|
2015-08-11 17:53:09 +00:00
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.changePassword = function(info, callback) {
|
|
|
|
if (Config.AUTHENTICATION_TYPE != 'Database') { return; }
|
2015-04-02 20:34:41 +00:00
|
|
|
|
|
|
|
var data = {
|
|
|
|
'password': $scope.changePasswordInfo.password
|
|
|
|
};
|
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
var errorDisplay = ApiService.errorDisplay('Could not change password', callback);
|
2015-04-02 20:34:41 +00:00
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
ApiService.changeUserDetails(data).then(function(resp) {
|
2015-04-02 20:34:41 +00:00
|
|
|
// Reload the user.
|
|
|
|
UserService.load();
|
2016-04-25 19:17:18 +00:00
|
|
|
callback(true);
|
|
|
|
}, errorDisplay);
|
2015-04-02 20:34:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.generateClientToken = function() {
|
|
|
|
var generateToken = function(password) {
|
2016-06-14 22:09:42 +00:00
|
|
|
if (!password) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-02 20:34:41 +00:00
|
|
|
var data = {
|
|
|
|
'password': password
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.generateUserClientKey(data).then(function(resp) {
|
2016-04-29 23:37:35 +00:00
|
|
|
$scope.context.encryptedPasswordCredentials = {
|
2016-06-14 22:09:42 +00:00
|
|
|
'username': UserService.getCLIUsername(),
|
|
|
|
'password': resp['key'],
|
|
|
|
'namespace': UserService.currentUser().username
|
2016-04-29 23:37:35 +00:00
|
|
|
};
|
2015-04-02 20:34:41 +00:00
|
|
|
}, 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
|
|
|
};
|
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.showChangeEmail = function() {
|
|
|
|
$scope.changeEmailInfo = {
|
|
|
|
'email': $scope.context.viewuser.email
|
|
|
|
};
|
|
|
|
};
|
2015-04-02 20:34:41 +00:00
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
$scope.changeEmail = function(info, callback) {
|
2015-04-02 20:34:41 +00:00
|
|
|
var details = {
|
|
|
|
'email': $scope.changeEmailInfo.email
|
|
|
|
};
|
|
|
|
|
2016-04-25 19:17:18 +00:00
|
|
|
var errorDisplay = ApiService.errorDisplay('Could not change email address', callback);
|
|
|
|
|
2015-04-02 20:34:41 +00:00
|
|
|
ApiService.changeUserDetails(details).then(function() {
|
2016-08-16 17:13:52 +00:00
|
|
|
$scope.context.emailAwaitingChange = $scope.changeEmailInfo.email;
|
2016-04-25 19:17:18 +00:00
|
|
|
callback(true);
|
|
|
|
}, errorDisplay);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showChangeAccount = function() {
|
|
|
|
$scope.convertAccountInfo = {
|
|
|
|
'user': $scope.context.viewuser
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showBilling = function() {
|
|
|
|
$scope.showBillingCounter++;
|
2015-04-02 20:34:41 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
})();
|