diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 1376a8566d..431985711f 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -84,7 +84,11 @@ var create_host_tmpl = \ \ \ + \ \ +
\ + \ +
\ \
\ \ @@ -94,18 +98,28 @@ var create_host_tmpl = \ \ \ + \ \ +
\ + \ + \ +
\
\
\ \ \ +
\ + \ + \ +
\
\
\ \ @@ -595,9 +609,35 @@ function setupCreateHostDialog(){ $('button',dialog).button(); + $('input[name="custom_vmm_mad"],'+ + 'input[name="custom_im_mad"],'+ + 'input[name="custom_vnm_mad"]',dialog).parent().hide(); + + $('select#vmm_mad',dialog).change(function(){ + if ($(this).val()=="custom") + $('input[name="custom_vmm_mad"]').parent().show(); + else + $('input[name="custom_vmm_mad"]').parent().hide(); + }); + + $('select#im_mad',dialog).change(function(){ + if ($(this).val()=="custom") + $('input[name="custom_im_mad"]').parent().show(); + else + $('input[name="custom_im_mad"]').parent().hide(); + }); + + $('select#vnm_mad',dialog).change(function(){ + if ($(this).val()=="custom") + $('input[name="custom_vnm_mad"]').parent().show(); + else + $('input[name="custom_vnm_mad"]').parent().hide(); + }); + //Handle the form submission $('#create_host_form',dialog).submit(function(){ - if (!($('#name',this).val().length)){ + var name = $('#name',this).val(); + if (!name){ notifyError(tr("Host name missing!")); return false; } @@ -605,12 +645,19 @@ function setupCreateHostDialog(){ var cluster_id = $('#host_cluster_id',this).val(); if (!cluster_id) cluster_id = "-1"; + var vmm_mad = $('select#vmm_mad',this).val(); + vmm_mad = vmm_mad == "custom" ? $('input[name="custom_vmm_mad"]').val() : vmm_mad; + var im_mad = $('select#im_mad',this).val(); + im_mad = im_mad == "custom" ? $('input[name="custom_im_mad"]').val() : im_mad; + var vnm_mad = $('select#vnm_mad',this).val(); + vnm_mad = vnm_mad == "custom" ? $('input[name="custom_vnm_mad"]').val() : vnm_mad; + var host_json = { "host": { - "name": $('#name',this).val(), - "vm_mad": $('#vmm_mad',this).val(), - "vnm_mad": $('#vnm_mad',this).val(), - "im_mad": $('#im_mad',this).val(), + "name": name, + "vm_mad": vmm_mad, + "vnm_mad": vnm_mad, + "im_mad": im_mad, "cluster_id": cluster_id } }; diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 1585513a31..d1f4aa34ab 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -60,7 +60,12 @@ var create_user_tmpl = \ \ \ + \ \ +
\ + \ +
\ +
\
\ \
\ @@ -444,15 +449,25 @@ function setupCreateUserDialog(){ $('button',dialog).button(); + $('input[name="custom_auth"]',dialog).parent().hide(); + $('select#driver').change(function(){ + if ($(this).val() == "custom") + $('input[name="custom_auth"]',dialog).parent().show(); + else + $('input[name="custom_auth"]',dialog).parent().hide(); + }); + $('#create_user_form',dialog).submit(function(){ var user_name=$('#username',this).val(); var user_password=$('#pass',this).val(); var driver = $('#driver', this).val(); + if (driver == 'custom') + driver = $('input[name="custom_auth"]').val(); if (!user_name.length || !user_password.length){ notifyError(tr("User name and password must be filled in")); return false; - } + }; var user_json = { "user" : { "name" : user_name,