'+
@@ -681,6 +721,7 @@ var provision_content = provision_user_info +
if (Config.isTabPanelEnabled("provision-tab", "users")) {
provision_content += provision_list_users;
+ provision_content += provision_create_user;
}
var provision_header = '

'+
@@ -767,6 +808,21 @@ var povision_actions = {
error: onError
},
+ "Provision.User.create" : {
+ type: "create",
+ call: OpenNebula.User.create,
+ callback: function() {
+ OpenNebula.Helper.clear_cache("USER");
+ show_provision_user_list(0);
+ var context = $("#provision_create_user");
+ $("#username", context).val('');
+ $("#password", context).val('');
+ $("#repeat_password", context).val('');
+ $(".alert-box-error", context).hide();
+ },
+ error: onError
+ },
+
"Provision.show" : {
type: "single",
call: OpenNebula.VM.show,
@@ -1013,6 +1069,11 @@ function show_provision_create_vm() {
$("#provision_create_vm").fadeIn();
}
+function show_provision_create_user() {
+ $(".section_content").hide();
+ $("#provision_create_user").fadeIn();
+}
+
function show_provision_vm_list(timeout) {
$(".section_content").hide();
$("#provision_list_vms").fadeIn();
@@ -2388,6 +2449,48 @@ $(document).ready(function(){
show_provision_user_list(0);
});
+ $(".provision_create_user_button").on("click", function(){
+ show_provision_create_user();
+ });
+
+ //
+ // Create User
+ //
+
+
+ $("#provision_create_user").submit(function(){
+ var context = $(this);
+
+ var username = $("#username", context).val();
+ var password = $("#password", context).val();
+ var repeat_password = $("#repeat_password", context).val();
+
+ // TODO driver
+ var driver = 'core';
+
+ if (!username.length || !password.length){
+ $(".alert-box-error", context).fadeOut();
+ $(".alert-box-error", context).fadeIn().html(tr("You have to provide a username and password"));
+ return false;
+ }
+
+ if (password !== repeat_password){
+ $(".alert-box-error", context).fadeOut();
+ $(".alert-box-error", context).fadeIn().html(tr("Passwords do not match"));
+ return false;
+ }
+
+ var user_json = { "user" :
+ { "name" : username,
+ "password" : password,
+ "auth_driver" : driver
+ }
+ };
+
+ Sunstone.runAction("Provision.User.create",user_json);
+ return false;
+ });
+
//
// Info VM
//