new UI - show error message on middle menu item when registerTemplate or registerISO fails.

This commit is contained in:
Jessica Wang 2010-09-17 11:03:09 -07:00
parent 4c78c6304d
commit e0d962a8e4
3 changed files with 36 additions and 25 deletions

View File

@ -7,12 +7,11 @@ function afterLoadIsoJSP() {
//add button ***
$("#midmenu_add_link").show();
$("#midmenu_add_link").bind("click", function(event) {
$("#midmenu_add_link").unbind("click").bind("click", function(event) {
$("#dialog_add_iso")
.dialog('option', 'buttons', {
"Create": function() {
var thisDialog = $(this);
thisDialog.dialog("close");
// validate values
var isValid = true;
@ -21,6 +20,8 @@ function afterLoadIsoJSP() {
isValid &= validateString("URL", thisDialog.find("#add_iso_url"), thisDialog.find("#add_iso_url_errormsg"));
if (!isValid)
return;
thisDialog.dialog("close");
var name = trim(thisDialog.find("#add_iso_name").val());
var desc = trim(thisDialog.find("#add_iso_display_text").val());
@ -37,15 +38,15 @@ function afterLoadIsoJSP() {
data: createURL("command=registerIso&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneId="+zoneId+"&isPublic="+isPublic+"&osTypeId="+osType+"&bootable="+bootable+"&response=json"),
dataType: "json",
success: function(json) {
var result = json.registerisoresponse;
isoToMidmenu(result.iso[0], $midmenuItem1);
var items = json.registerisoresponse.iso;
isoToMidmenu(items[0], $midmenuItem1);
bindClickToMidMenu($midmenuItem1, isoToRigntPanel);
/*
if(result.iso.length > 1) {
for(var i=1; i<result.iso.length; i++) {
if(items.length > 1) {
for(var i=1; i<items.length; i++) {
var template2 = $("#vm_iso_template").clone(true);
isoJSONToTemplate(result.iso[i], template2);
isoJSONToTemplate(items[i], template2);
submenuContent.find("#grid_content").prepend(template2.fadeIn("slow"));
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
}
@ -53,7 +54,10 @@ function afterLoadIsoJSP() {
*/
afterAddingMidMenuItem($midmenuItem1, true);
}
},
error: function(XMLHttpResponse) {
handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1);
}
});
},
"Cancel": function() {

View File

@ -322,10 +322,11 @@ function doActionForMidMenu(id, $actionLink, apiCommand, listAPIMap) {
//Sync job (end) *****
}
function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem) {
$midmenuItem.find("#content").removeClass("inaction");
$midmenuItem.find("#spinning_wheel").hide();
$midmenuItem.find("#info_icon").addClass("error").show();
function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1) {
$midmenuItem1.find("#content").removeClass("inaction");
$midmenuItem1.find("#spinning_wheel").hide();
$midmenuItem1.find("#info_icon").addClass("error").show();
$midmenuItem1.find("#first_row").text("Adding failed");
var errorMsg = "";
if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) {
@ -334,10 +335,10 @@ function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem) {
errorMsg = XMLHttpResponse.responseText.substring(start, end);
}
if(errorMsg.length > 0)
$midmenuItem.data("afterActionInfo", ((label + " action failed. Reason: " + sanitizeXSS(unescape(errorMsg)))));
else
$midmenuItem.data("afterActionInfo", (label + " action failed."));
}
$midmenuItem1.find("#second_row").text(fromdb(errorMsg));
else
$midmenuItem1.find("#second_row").text("");
}
//***** actions for middle menu (end) **************************************************************************
@ -557,9 +558,11 @@ function showMiddleMenu() {
// adding middle menu item ***
function beforeAddingMidMenuItem() {
var $midmenuItem1 = $("#midmenu_item").clone();
$midmenuItem1.find("#first_row").text("Adding....");
$midmenuItem1.find("#first_row").text("Adding....");
$midmenuItem1.find("#second_row").html("&nbsp;");
$midmenuItem1.find("#content").addClass("inaction");
$midmenuItem1.find("#spinning_wheel").show();
$midmenuItem1.find("#info_icon").removeClass("error").hide();
$("#midmenu_container").append($midmenuItem1.show());
return $midmenuItem1;
}

View File

@ -18,19 +18,20 @@ function afterLoadTemplateJSP() {
$("#midmenu_add_link").show();
$("#midmenu_add_link").bind("click", function(event) {
$("#midmenu_add_link").unbind("click").bind("click", function(event) {
$("#dialog_add_template")
.dialog('option', 'buttons', {
"Create": function() {
var thisDialog = $(this);
thisDialog.dialog("close");
// validate values
var isValid = true;
isValid &= validateString("Name", thisDialog.find("#add_template_name"), thisDialog.find("#add_template_name_errormsg"));
isValid &= validateString("Display Text", thisDialog.find("#add_template_display_text"), thisDialog.find("#add_template_display_text_errormsg"));
isValid &= validateString("URL", thisDialog.find("#add_template_url"), thisDialog.find("#add_template_url_errormsg"));
if (!isValid) return;
thisDialog.dialog("close");
var name = trim(thisDialog.find("#add_template_name").val());
var desc = trim(thisDialog.find("#add_template_display_text").val());
@ -53,14 +54,14 @@ function afterLoadTemplateJSP() {
data: createURL("command=registerTemplate&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&response=json"),
dataType: "json",
success: function(json) {
var result = json.registertemplateresponse;
templateToMidmenu(result.template[0], $midmenuItem1);
var items = json.registertemplateresponse.template;
templateToMidmenu(items[0], $midmenuItem1);
bindClickToMidMenu($midmenuItem1, templateToRigntPanel);
/*
if(result.template.length > 1) {
for(var i=1; i<result.template.length; i++) {
if(items.length > 1) {
for(var i=1; i<items.length; i++) {
var template2 = $("#vm_template_template").clone(true);
templateJSONToTemplate(result.template[i], template2);
templateJSONToTemplate(items[i], template2);
submenuContent.find("#grid_content").prepend(template2.fadeIn("slow"));
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
}
@ -68,6 +69,9 @@ function afterLoadTemplateJSP() {
*/
afterAddingMidMenuItem($midmenuItem1, true);
},
error: function(XMLHttpResponse) {
handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1);
}
});
},