From 3cb18cde2414ddaee9d1aaae08b85982920dc27a Mon Sep 17 00:00:00 2001 From: phamt Date: Fri, 24 Sep 2010 03:06:44 +0000 Subject: [PATCH] Changed confirm() prompt to dialogs. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7604 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvm.js | 60 ++++++++++++--- xCAT-UI/js/custom/zvmUtils.js | 136 ++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 72 deletions(-) diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js index d957d30ae..f598373e4 100644 --- a/xCAT-UI/js/custom/zvm.js +++ b/xCAT-UI/js/custom/zvm.js @@ -488,9 +488,23 @@ zvmPlugin.prototype.loadInventory = function(data) { */ var contextMenu = [{ 'Remove' : function(menuItem, menu) { - if (confirm('Are you sure?')) { - removeProcessor(node, $(this).text()); - } + var addr = $(this).text(); + + // Open dialog to confirm + var confirmDialog = $('

Are you sure?

'); + confirmDialog.dialog({ + modal: true, + width: 300, + buttons: { + "Cancel": function() { + $(this).dialog("close"); + }, + "Ok": function(){ + removeProcessor(node, addr); + $(this).dialog("close"); + } + } + }); } }]; @@ -582,9 +596,23 @@ zvmPlugin.prototype.loadInventory = function(data) { */ contextMenu = [{ 'Remove' : function(menuItem, menu) { - if (confirm('Are you sure?')) { - removeDisk(node, $(this).text()); - } + var addr = $(this).text(); + + // Open dialog to confirm + var confirmDialog = $('

Are you sure?

'); + confirmDialog.dialog({ + modal: true, + width: 300, + buttons: { + "Cancel": function() { + $(this).dialog("close"); + }, + "Ok": function(){ + removeDisk(node, addr); + $(this).dialog("close"); + } + } + }); } }]; @@ -660,9 +688,23 @@ zvmPlugin.prototype.loadInventory = function(data) { */ contextMenu = [ { 'Remove' : function(menuItem, menu) { - if (confirm('Are you sure?')) { - removeNic(node, $(this).text()); - } + var addr = $(this).text(); + + // Open dialog to confirm + var confirmDialog = $('

Are you sure?

'); + confirmDialog.dialog({ + modal: true, + width: 300, + buttons: { + "Cancel": function() { + $(this).dialog("close"); + }, + "Ok": function(){ + removeNic(node, addr); + $(this).dialog("close"); + } + } + }); } } ]; diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index eb4a41341..d3d7bb860 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -2284,73 +2284,83 @@ function createZProvisionNew(inst) { // If no OS is given, create a virtual server var msg = ''; if (diskRows.length > 0) { - msg = 'Do you want to create a virtual server without an operating system ?'; + msg = 'Do you want to create a virtual server without an operating system?'; + } else { + // If no disks are given, create a virtual server (no disk) + msg = 'Do you want to create a virtual server without an operating system or disks?'; } - // If no disks are given, create a virtual server (no disk) - else { - msg = 'Do you want to create a virtual server without an operating system or disks ?'; - } - - // If user clicks Ok - if (confirm(msg)) { - // Disable provision button - $(this).attr('disabled', 'true'); - - // Show loader - $('#zProvisionStatBar' + inst).show(); - $('#zProvisionLoader' + inst).show(); - - // Disable add disk button - addDiskLink.attr('disabled', 'true'); - - // Disable close button on disk table - $('#' + thisTabId + ' table span').unbind('click'); - - // Disable all inputs - var inputs = $('#' + thisTabId + ' input'); - inputs.attr('disabled', 'disabled'); - - // Disable all selects - var selects = $('#' + thisTabId + ' select'); - selects.attr('disabled', 'disabled'); - - // Add a new line at the end of the user entry - var textarea = $('#' + thisTabId + ' textarea'); - var tmp = jQuery.trim(textarea.val()); - textarea.val(tmp + '\n'); - textarea.attr('readonly', 'readonly'); - textarea.css( { - 'background-color' : '#F2F2F2' - }); - - // Get node name - var node = $('#' + thisTabId + ' input[name=nodeName]').val(); - // Get userId - var userId = $('#' + thisTabId + ' input[name=userId]').val(); - // Get hardware control point - var hcp = $('#' + thisTabId + ' input[name=hcp]').val(); - // Get group - var group = $('#' + thisTabId + ' input[name=group]').val(); - - /** - * (1) Define node - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodeadd', - tgt : '', - args : node + ';zvm.hcp=' + hcp - + ';zvm.userid=' + userId - + ';nodehm.mgt=zvm' + ';groups=' + group, - msg : 'cmd=nodeadd;out=' + inst + // Open dialog to confirm + var confirmDialog = $('

' + msg + '

'); + confirmDialog.dialog({ + modal: true, + width: 400, + buttons: { + "Cancel": function() { + $(this).dialog("close"); }, + "Ok": function(){ + // Disable provision button + provisionBtn.attr('disabled', 'true'); + + // Show loader + $('#zProvisionStatBar' + inst).show(); + $('#zProvisionLoader' + inst).show(); - success : updateZProvisionNewStatus - }); - } + // Disable add disk button + addDiskLink.attr('disabled', 'true'); + + // Disable close button on disk table + $('#' + thisTabId + ' table span').unbind('click'); + + // Disable all inputs + var inputs = $('#' + thisTabId + ' input'); + inputs.attr('disabled', 'disabled'); + + // Disable all selects + var selects = $('#' + thisTabId + ' select'); + selects.attr('disabled', 'disabled'); + + // Add a new line at the end of the user entry + var textarea = $('#' + thisTabId + ' textarea'); + var tmp = jQuery.trim(textarea.val()); + textarea.val(tmp + '\n'); + textarea.attr('readonly', 'readonly'); + textarea.css( { + 'background-color' : '#F2F2F2' + }); + + // Get node name + var node = $('#' + thisTabId + ' input[name=nodeName]').val(); + // Get userId + var userId = $('#' + thisTabId + ' input[name=userId]').val(); + // Get hardware control point + var hcp = $('#' + thisTabId + ' input[name=hcp]').val(); + // Get group + var group = $('#' + thisTabId + ' input[name=group]').val(); + + /** + * (1) Define node + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodeadd', + tgt : '', + args : node + ';zvm.hcp=' + hcp + + ';zvm.userid=' + userId + + ';nodehm.mgt=zvm' + ';groups=' + group, + msg : 'cmd=nodeadd;out=' + inst + }, + + success : updateZProvisionNewStatus + }); + + $(this).dialog("close"); + } // End of function() + } + }); } else { /** * Create a virtual server and install OS