new UI - add action message box to actions for subgrid items.

This commit is contained in:
Jessica Wang 2010-09-14 17:40:36 -07:00
parent 64c45588b2
commit c3144e0d76
4 changed files with 963 additions and 898 deletions

File diff suppressed because it is too large Load Diff

View File

@ -433,7 +433,7 @@ function clickInstanceGroupHeader($arrowIcon) {
"Create Template": {
isAsyncJob: true,
asyncJobResponse: "createtemplateresponse",
dialogBeforeActionFn : doCreateTemplate,
dialogBeforeActionFn : doCreateTemplateFromVmVolume,
inProcessText: "Creating template....",
afterActionSeccessFn: function(){}
}
@ -473,6 +473,10 @@ function clickInstanceGroupHeader($arrowIcon) {
buildActionLinkForSubgridItem("Detach Disk", vmVolumeActionMap, $actionMenu, volumeListAPIMap, template);
}
template.find("#action_message_box #close_button").bind("click", function(event){
$(this).parent().hide();
return false;
});
}
//***** declaration for volume tab (end) *********************************************************
@ -1256,5 +1260,37 @@ function clickInstanceGroupHeader($arrowIcon) {
});
}
function doCreateTemplateFromVmVolume($actionLink, listAPIMap, $subgridItem) {
var jsonObj = $subgridItem.data("jsonObj");
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
$("#dialog_create_template")
.dialog('option', 'buttons', {
"Create": function() {
//debugger;
var thisDialog = $(this);
thisDialog.dialog("close");
// validate values
var isValid = true;
isValid &= validateString("Name", thisDialog.find("#create_template_name"), thisDialog.find("#create_template_name_errormsg"));
isValid &= validateString("Display Text", thisDialog.find("#create_template_desc"), thisDialog.find("#create_template_desc_errormsg"));
if (!isValid) return;
var name = trim(thisDialog.find("#create_template_name").val());
var desc = trim(thisDialog.find("#create_template_desc").val());
var osType = thisDialog.find("#create_template_os_type").val();
var isPublic = thisDialog.find("#create_template_public").val();
var password = thisDialog.find("#create_template_password").val();
var id = $subgridItem.data("jsonObj").id;
var apiCommand = "command=createTemplate&volumeId="+id+"&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&osTypeId="+osType+"&isPublic="+isPublic+"&passwordEnabled="+password;
doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgridItem);
},
"Cancel": function() {
$(this).dialog("close");
}
}).dialog("open");
}

View File

@ -406,8 +406,9 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgrid
} else {
$("body").stopTime(timerKey);
$spinningWheel.hide();
if (result.jobstatus == 1) { // Succeeded
$subgridItem.data("afterActionInfo", (label + " action succeeded."));
if (result.jobstatus == 1) { // Succeeded
$subgridItem.find("#action_message_box #description").text(label + " action succeeded.");
$subgridItem.find("#action_message_box").removeClass("error").show();
//DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041)
//Before Bug 6041 get fixed, use the temporary solution below.
@ -422,8 +423,9 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgrid
//After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
//afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);
} else if (result.jobstatus == 2) { // Failed
$subgridItem.data("afterActionInfo", (label + " action failed. Reason: " + sanitizeXSS(result.jobresult)));
} else if (result.jobstatus == 2) { // Failed
$subgridItem.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(result.jobresult));
$subgridItem.find("#action_message_box").addClass("error").show();
}
}
},
@ -459,8 +461,9 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgrid
data: createURL("command="+listAPI+"&id="+id),
dataType: "json",
async: false,
success: function(json) {
$subgridItem.data("afterActionInfo", (label + " action succeeded."));
success: function(json) {
$subgridItem.find("#action_message_box #description").text(label + " action succeeded.");
$subgridItem.find("#action_message_box").removeClass("error").show();
afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);
}
});
@ -484,10 +487,11 @@ function handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label) {
var end = XMLHttpResponse.responseText.indexOf("</h1");
errorMsg = XMLHttpResponse.responseText.substring(start, end);
}
if(errorMsg.length > 0)
$subgridItem.data("afterActionInfo", ((label + " action failed. Reason: " + sanitizeXSS(unescape(errorMsg)))));
else
$subgridItem.data("afterActionInfo", (label + " action failed."));
if(errorMsg.length > 0)
$subgridItem.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(unescape(errorMsg)));
else
$subgridItem.find("#action_message_box #description").text(label + " action failed.");
$subgridItem.find("#action_message_box").addClass("error").show();
}
//***** actions for a subgrid item in right panel (end) **************************************************************************

View File

@ -107,14 +107,14 @@ var volumeActionMap = {
"Create Template": {
isAsyncJob: true,
asyncJobResponse: "createtemplateresponse",
dialogBeforeActionFn : doCreateTemplate,
dialogBeforeActionFn : doCreateTemplateFromVolume,
inProcessText: "Creating template....",
afterActionSeccessFn: function(){}
}
}
function doCreateTemplate($actionLink, listAPIMap, $singleObject) {
var jsonObj = $singleObject.data("jsonObj");
function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) {
var jsonObj = $detailsTab.data("jsonObj");
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
$("#dialog_create_template")
@ -136,7 +136,7 @@ function doCreateTemplate($actionLink, listAPIMap, $singleObject) {
var isPublic = thisDialog.find("#create_template_public").val();
var password = thisDialog.find("#create_template_password").val();
var id = $singleObject.data("jsonObj").id;
var id = $detailsTab.data("jsonObj").id;
var apiCommand = "command=createTemplate&volumeId="+id+"&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&osTypeId="+osType+"&isPublic="+isPublic+"&passwordEnabled="+password;
doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap);
},