2015-02-20 23:15:48 +00:00
|
|
|
(function() {
|
|
|
|
/**
|
2016-05-02 19:29:31 +00:00
|
|
|
* The superuser admin page provides a new management UI for Quay Enterprise.
|
2015-02-20 23:15:48 +00:00
|
|
|
*/
|
|
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
|
|
|
pages.create('superuser', 'super-user.html', SuperuserCtrl,
|
|
|
|
{
|
2015-02-23 19:23:54 +00:00
|
|
|
'newLayout': true,
|
2016-02-05 10:16:23 +00:00
|
|
|
'title': 'Quay Enterprise Management'
|
2015-06-29 09:33:00 +00:00
|
|
|
})
|
2015-02-20 23:15:48 +00:00
|
|
|
}]);
|
|
|
|
|
2016-06-07 22:12:11 +00:00
|
|
|
function SuperuserCtrl($scope, $timeout, $location, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog) {
|
2015-02-20 23:15:48 +00:00
|
|
|
if (!Features.SUPER_USERS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Monitor any user changes and place the current user into the scope.
|
|
|
|
UserService.updateUserIn($scope);
|
|
|
|
|
|
|
|
$scope.configStatus = null;
|
|
|
|
$scope.requiresRestart = null;
|
|
|
|
$scope.logsCounter = 0;
|
|
|
|
$scope.newUser = {};
|
|
|
|
$scope.createdUser = null;
|
2015-06-28 05:27:39 +00:00
|
|
|
$scope.changeLog = null;
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.debugServices = null;
|
|
|
|
$scope.debugLogs = null;
|
|
|
|
$scope.pollChannel = null;
|
|
|
|
$scope.logsScrolled = false;
|
|
|
|
$scope.csrf_token = encodeURIComponent(window.__token);
|
|
|
|
$scope.dashboardActive = false;
|
2015-09-02 21:21:38 +00:00
|
|
|
$scope.currentConfig = null;
|
2016-04-01 17:55:29 +00:00
|
|
|
$scope.serviceKeysActive = false;
|
2016-06-07 22:12:11 +00:00
|
|
|
$scope.takeOwnershipInfo = null;
|
2015-02-20 23:15:48 +00:00
|
|
|
|
|
|
|
$scope.setDashboardActive = function(active) {
|
|
|
|
$scope.dashboardActive = active;
|
|
|
|
};
|
|
|
|
|
2015-09-02 21:21:38 +00:00
|
|
|
$scope.configurationSaved = function(config) {
|
|
|
|
$scope.currentConfig = config;
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.requiresRestart = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showCreateUser = function() {
|
|
|
|
$scope.createdUser = null;
|
|
|
|
$('#createUserModal').modal('show');
|
|
|
|
};
|
|
|
|
|
2016-04-01 17:55:29 +00:00
|
|
|
$scope.loadServiceKeys = function() {
|
|
|
|
$scope.serviceKeysActive = true;
|
|
|
|
};
|
|
|
|
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.viewSystemLogs = function(service) {
|
|
|
|
if ($scope.pollChannel) {
|
|
|
|
$scope.pollChannel.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.debugService = service;
|
|
|
|
$scope.debugLogs = null;
|
|
|
|
|
|
|
|
$scope.pollChannel = AngularPollChannel.create($scope, $scope.loadServiceLogs, 2 * 1000 /* 2s */);
|
|
|
|
$scope.pollChannel.start();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadServiceLogs = function(callback) {
|
|
|
|
if (!$scope.debugService) { return; }
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'service': $scope.debugService
|
|
|
|
};
|
|
|
|
|
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot load system logs. Please contact support.',
|
|
|
|
function() {
|
|
|
|
callback(false);
|
|
|
|
})
|
|
|
|
|
|
|
|
ApiService.getSystemLogs(null, params, /* background */true).then(function(resp) {
|
|
|
|
$scope.debugLogs = resp['logs'];
|
|
|
|
callback(true);
|
|
|
|
}, errorHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadDebugServices = function() {
|
|
|
|
if ($scope.pollChannel) {
|
|
|
|
$scope.pollChannel.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.debugService = null;
|
|
|
|
|
|
|
|
ApiService.listSystemLogServices().then(function(resp) {
|
|
|
|
$scope.debugServices = resp['services'];
|
|
|
|
}, ApiService.errorDisplay('Cannot load system logs. Please contact support.'))
|
|
|
|
};
|
|
|
|
|
2015-06-28 05:27:39 +00:00
|
|
|
$scope.getChangeLog = function() {
|
|
|
|
if ($scope.changeLog) { return; }
|
2015-02-20 23:15:48 +00:00
|
|
|
|
2015-06-28 05:27:39 +00:00
|
|
|
ApiService.getChangeLog().then(function(resp) {
|
|
|
|
$scope.changeLog = resp;
|
|
|
|
}, ApiService.errorDisplay('Cannot load change log. Please contact support.'))
|
2015-02-20 23:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.loadUsageLogs = function() {
|
|
|
|
$scope.logsCounter++;
|
|
|
|
};
|
|
|
|
|
2015-05-11 22:03:25 +00:00
|
|
|
$scope.loadOrganizations = function() {
|
|
|
|
if ($scope.organizations) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.loadOrganizationsInternal();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadOrganizationsInternal = function() {
|
|
|
|
$scope.organizationsResource = ApiService.listAllOrganizationsAsResource().get(function(resp) {
|
|
|
|
$scope.organizations = resp['organizations'];
|
|
|
|
return $scope.organizations;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.loadUsers = function() {
|
|
|
|
if ($scope.users) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadUsersInternal = function() {
|
|
|
|
ApiService.listAllUsers().then(function(resp) {
|
|
|
|
$scope.users = resp['users'];
|
|
|
|
$scope.showInterface = true;
|
|
|
|
}, function(resp) {
|
|
|
|
$scope.users = [];
|
2016-04-12 20:54:58 +00:00
|
|
|
$scope.usersError = ApiService.getErrorMessage(resp);
|
2015-02-20 23:15:48 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showChangePassword = function(user) {
|
|
|
|
$scope.userToChange = user;
|
|
|
|
$('#changePasswordModal').modal({});
|
|
|
|
};
|
|
|
|
|
2015-05-11 18:38:10 +00:00
|
|
|
$scope.showChangeEmail = function(user) {
|
|
|
|
$scope.userToChange = user;
|
|
|
|
$('#changeEmailModal').modal({});
|
|
|
|
};
|
|
|
|
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.createUser = function() {
|
|
|
|
$scope.creatingUser = true;
|
|
|
|
$scope.createdUser = null;
|
|
|
|
|
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot create user', function() {
|
|
|
|
$scope.creatingUser = false;
|
|
|
|
$('#createUserModal').modal('hide');
|
|
|
|
});
|
|
|
|
|
|
|
|
ApiService.createInstallUser($scope.newUser, null).then(function(resp) {
|
|
|
|
$scope.creatingUser = false;
|
|
|
|
$scope.newUser = {};
|
|
|
|
$scope.createdUser = resp;
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
}, errorHandler)
|
|
|
|
};
|
|
|
|
|
2015-10-16 19:38:06 +00:00
|
|
|
$scope.setSuperuser = function(user, status) {
|
|
|
|
var setSuperuser = function() {
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'superuser': status
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeInstallUser(data, params).then(function(resp) {
|
|
|
|
$scope.requiresRestart = true;
|
|
|
|
}, ApiService.errorDisplay('Could not change user'));
|
|
|
|
};
|
|
|
|
|
|
|
|
var msg = 'Note: This change, once applied, will require your installation ' +
|
|
|
|
'to be restarted to take effect';
|
|
|
|
|
|
|
|
bootbox.confirm(msg, function(status) {
|
|
|
|
if (status) {
|
|
|
|
setSuperuser();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.showDeleteUser = function(user) {
|
|
|
|
if (user.username == UserService.currentUser().username) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": 'Cannot delete yourself!',
|
|
|
|
"title": "Cannot delete user",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.userToDelete = user;
|
|
|
|
$('#confirmDeleteUserModal').modal({});
|
|
|
|
};
|
|
|
|
|
2015-05-11 18:38:10 +00:00
|
|
|
$scope.changeUserEmail = function(user) {
|
|
|
|
$('#changeEmailModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'email': user.newemail
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeInstallUser(data, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
user.email = user.newemail;
|
|
|
|
delete user.newemail;
|
|
|
|
}, ApiService.errorDisplay('Could not change user'));
|
|
|
|
};
|
|
|
|
|
2015-05-11 22:03:25 +00:00
|
|
|
$scope.askDeleteOrganization = function(org) {
|
|
|
|
bootbox.confirm('Are you sure you want to delete this organization? Its data will be deleted with it.',
|
|
|
|
function(result) {
|
|
|
|
if (!result) { return; }
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'name': org.name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteOrganization(null, params).then(function(resp) {
|
|
|
|
$scope.loadOrganizationsInternal();
|
|
|
|
}, ApiService.errorDisplay('Could not delete organization'));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.askRenameOrganization = function(org) {
|
|
|
|
bootbox.prompt('Enter a new name for the organization:', function(newName) {
|
|
|
|
if (!newName) { return; }
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'name': org.name
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'name': newName
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeOrganization(data, params).then(function(resp) {
|
|
|
|
$scope.loadOrganizationsInternal();
|
|
|
|
org.name = newName;
|
|
|
|
}, ApiService.errorDisplay('Could not rename organization'));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-06-07 22:12:11 +00:00
|
|
|
$scope.askTakeOwnership = function(entity, is_org) {
|
|
|
|
$scope.takeOwnershipInfo = {
|
|
|
|
'entity': entity,
|
|
|
|
'is_org': is_org
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.takeOwnership = function(info, callback) {
|
|
|
|
var errorDisplay = ApiService.errorDisplay('Could not take ownership of namespace', callback);
|
|
|
|
var params = {
|
|
|
|
'namespace': info.entity.username || info.entity.name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.takeOwnership(null, params).then(function() {
|
|
|
|
callback(true);
|
|
|
|
$location.path('/organization/' + params.namespace);
|
|
|
|
}, errorDisplay)
|
|
|
|
};
|
|
|
|
|
2015-05-11 21:13:42 +00:00
|
|
|
$scope.askDisableUser = function(user) {
|
|
|
|
var message = 'Are you sure you want to disable this user? ' +
|
|
|
|
'They will be unable to login, pull or push.'
|
|
|
|
|
|
|
|
if (!user.enabled) {
|
|
|
|
message = 'Are you sure you want to reenable this user? ' +
|
|
|
|
'They will be able to login, pull or push.'
|
|
|
|
}
|
|
|
|
|
|
|
|
bootbox.confirm(message, function(resp) {
|
|
|
|
if (resp) {
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'enabled': !user.enabled
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeInstallUser(data, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.changeUserPassword = function(user) {
|
|
|
|
$('#changePasswordModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'password': user.password
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeInstallUser(data, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
}, ApiService.errorDisplay('Could not change user'));
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteUser = function(user) {
|
|
|
|
$('#confirmDeleteUserModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteInstallUser(null, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
}, ApiService.errorDisplay('Cannot delete user'));
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.sendRecoveryEmail = function(user) {
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.sendInstallUserRecoveryEmail(null, params).then(function(resp) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": "A recovery email has been sent to " + resp['email'],
|
|
|
|
"title": "Recovery email sent",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}, ApiService.errorDisplay('Cannot send recovery email'))
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.restartContainer = function() {
|
|
|
|
$('#restartingContainerModal').modal({
|
|
|
|
keyboard: false,
|
|
|
|
backdrop: 'static'
|
|
|
|
});
|
|
|
|
|
|
|
|
ContainerService.restartContainer(function() {
|
|
|
|
$scope.checkStatus()
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.checkStatus = function() {
|
|
|
|
ContainerService.checkStatus(function(resp) {
|
|
|
|
$('#restartingContainerModal').modal('hide');
|
|
|
|
$scope.configStatus = resp['status'];
|
|
|
|
$scope.requiresRestart = resp['requires_restart'];
|
|
|
|
|
|
|
|
if ($scope.configStatus == 'ready') {
|
2015-09-02 21:21:38 +00:00
|
|
|
$scope.currentConfig = null;
|
2015-02-20 23:15:48 +00:00
|
|
|
$scope.loadUsers();
|
|
|
|
} else {
|
|
|
|
var message = "Installation of this product has not yet been completed." +
|
|
|
|
"<br><br>Please read the " +
|
|
|
|
"<a href='https://coreos.com/docs/enterprise-registry/initial-setup/'>" +
|
|
|
|
"Setup Guide</a>"
|
|
|
|
|
|
|
|
var title = "Installation Incomplete";
|
|
|
|
CoreDialog.fatal(title, message);
|
|
|
|
}
|
2015-09-02 21:21:38 +00:00
|
|
|
}, $scope.currentConfig);
|
2015-02-20 23:15:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Load the initial status.
|
|
|
|
$scope.checkStatus();
|
|
|
|
}
|
2016-04-12 20:54:58 +00:00
|
|
|
}());
|