parent
d63ec8c6b0
commit
fe735b8048
25 changed files with 784 additions and 614 deletions
|
@ -13,11 +13,13 @@
|
|||
function UserViewCtrl($scope, $routeParams, $timeout, ApiService, UserService, UIService, AvatarService, Config, ExternalLoginService) {
|
||||
var username = $routeParams.username;
|
||||
|
||||
$scope.showInvoicesCounter = 0;
|
||||
$scope.showAppsCounter = 0;
|
||||
$scope.showRobotsCounter = 0;
|
||||
$scope.changeEmailInfo = {};
|
||||
$scope.changePasswordInfo = {};
|
||||
$scope.showBillingCounter = 0;
|
||||
$scope.showLogsCounter = 0;
|
||||
|
||||
$scope.changeEmailInfo = null;
|
||||
$scope.changePasswordInfo = null;
|
||||
$scope.hasSingleSignin = ExternalLoginService.hasSingleSignin();
|
||||
$scope.context = {};
|
||||
|
||||
|
@ -54,37 +56,32 @@
|
|||
$scope.showRobotsCounter++;
|
||||
};
|
||||
|
||||
$scope.showInvoices = function() {
|
||||
$scope.showInvoicesCounter++;
|
||||
$scope.showLogs = function() {
|
||||
$scope.showLogsCounter++;
|
||||
};
|
||||
|
||||
$scope.showApplications = function() {
|
||||
$scope.showAppsCounter++;
|
||||
};
|
||||
|
||||
$scope.changePassword = function() {
|
||||
if (Config.AUTHENTICATION_TYPE != 'Database') { return; }
|
||||
$scope.showChangePassword = function() {
|
||||
$scope.changePasswordInfo = {};
|
||||
};
|
||||
|
||||
UIService.hidePopover('#changePasswordForm');
|
||||
$scope.changePasswordInfo.state = 'changing';
|
||||
$scope.changePassword = function(info, callback) {
|
||||
if (Config.AUTHENTICATION_TYPE != 'Database') { return; }
|
||||
|
||||
var data = {
|
||||
'password': $scope.changePasswordInfo.password
|
||||
};
|
||||
|
||||
var errorDisplay = ApiService.errorDisplay('Could not change password', callback);
|
||||
|
||||
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);
|
||||
});
|
||||
callback(true);
|
||||
}, errorDisplay);
|
||||
};
|
||||
|
||||
$scope.generateClientToken = function() {
|
||||
|
@ -102,21 +99,32 @@
|
|||
UIService.showPasswordDialog('Enter your password to generate an encrypted version:', generateToken);
|
||||
};
|
||||
|
||||
$scope.changeEmail = function() {
|
||||
UIService.hidePopover('#changeEmailForm');
|
||||
$scope.showChangeEmail = function() {
|
||||
$scope.changeEmailInfo = {
|
||||
'email': $scope.context.viewuser.email
|
||||
};
|
||||
};
|
||||
|
||||
$scope.changeEmail = function(info, callback) {
|
||||
var details = {
|
||||
'email': $scope.changeEmailInfo.email
|
||||
};
|
||||
|
||||
$scope.changeEmailInfo.state = 'sending';
|
||||
var errorDisplay = ApiService.errorDisplay('Could not change email address', callback);
|
||||
|
||||
ApiService.changeUserDetails(details).then(function() {
|
||||
$scope.changeEmailInfo.state = 'sent';
|
||||
delete $scope.changeEmailInfo['email'];
|
||||
}, function(result) {
|
||||
$scope.changeEmailInfo.state = 'send-error';
|
||||
UIService.showFormError('#changeEmailForm', result);
|
||||
});
|
||||
callback(true);
|
||||
}, errorDisplay);
|
||||
};
|
||||
|
||||
$scope.showChangeAccount = function() {
|
||||
$scope.convertAccountInfo = {
|
||||
'user': $scope.context.viewuser
|
||||
};
|
||||
};
|
||||
|
||||
$scope.showBilling = function() {
|
||||
$scope.showBillingCounter++;
|
||||
};
|
||||
}
|
||||
})();
|
Reference in a new issue