diff --git a/ui/new/scripts/cloud.core2.init.js b/ui/new/scripts/cloud.core2.init.js index 854c184897e..d2d69e6729c 100644 --- a/ui/new/scripts/cloud.core2.init.js +++ b/ui/new/scripts/cloud.core2.init.js @@ -59,19 +59,8 @@ $(document).ready(function() { for(var i=0; i 0) - $("#"+selected_midmenu_id).find("#content").removeClass("selected"); - selected_midmenu_id = ("midmenuItem_"+thisMidmenuItem.data("jsonObj").id); - - thisMidmenuItem.find("#content").addClass("selected"); - clearRightPanel(); - toRightPanel(thisMidmenuItem); - return false; - }); + toMidmenu(items[i], $midmenuItem1); + bindClickToMidMenu($midmenuItem1, toRightPanel); $("#midmenu_container").append($midmenuItem1.show()); } } diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index 1dcfbeddd1e..a7acb16f9df 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -1218,8 +1218,7 @@ function clickInstanceGroupHeader($arrowIcon) { } else if (result.jobstatus == 2) { // Failed - afterAddingMidMenuItem($midmenuItem1, false); - $("#dialog_error").html("

Adding Instance failed


"+fromdb(result.jobresult)+"

").dialog("open"); + afterAddingMidMenuItem($midmenuItem1, false, fromdb(result.jobresult)); } } }, diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index 1b53ff4f131..2f3306b749f 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -563,7 +563,7 @@ function beforeAddingMidMenuItem() { $("#midmenu_container").append($midmenuItem1.show()); return $midmenuItem1; } -function afterAddingMidMenuItem($midmenuItem1, isSuccessful) { +function afterAddingMidMenuItem($midmenuItem1, isSuccessful, extraMessage) { $midmenuItem1.find("#content").removeClass("inaction"); $midmenuItem1.find("#spinning_wheel").hide(); @@ -574,9 +574,40 @@ function afterAddingMidMenuItem($midmenuItem1, isSuccessful) { else { $midmenuItem1.find("#info_icon").addClass("error").show(); $midmenuItem1.find("#first_row").text("Adding failed"); + if(extraMessage != null) + $midmenuItem1.find("#second_row").text(extraMessage); } } +function bindClickToMidMenu($midmenuItem1, toRightPanel) { + $midmenuItem1.bind("click", function(event){ + var thisMidmenuItem = $(this); + + if(selected_midmenu_id != null && selected_midmenu_id.length > 0) + $("#"+selected_midmenu_id).find("#content").removeClass("selected"); + selected_midmenu_id = ("midmenuItem_"+thisMidmenuItem.data("jsonObj").id); + + thisMidmenuItem.find("#content").addClass("selected"); + clearRightPanel(); + toRightPanel(thisMidmenuItem); + return false; + }); +} + + + + + + + + + + + + + + + diff --git a/ui/new/scripts/cloud.core2.template.js b/ui/new/scripts/cloud.core2.template.js index bb4ebef3427..19317db8c09 100644 --- a/ui/new/scripts/cloud.core2.template.js +++ b/ui/new/scripts/cloud.core2.template.js @@ -4,16 +4,27 @@ var g_zoneNames = []; function afterLoadTemplateJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); - //add button *** + //add button *** + var formatSelect = $("#dialog_add_template #add_template_format").empty(); + if (getHypervisorType() == "kvm") + formatSelect.append(""); + else if (getHypervisorType() == "xenserver") + formatSelect.append(""); + + if(isAdmin()) + $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").show(); + else + $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").hide(); + $("#midmenu_add_link").show(); + $("#midmenu_add_link").bind("click", function(event) { $("#dialog_add_template") .dialog('option', 'buttons', { "Create": function() { var thisDialog = $(this); thisDialog.dialog("close"); - - debugger; + // validate values var isValid = true; isValid &= validateString("Name", thisDialog.find("#add_template_name"), thisDialog.find("#add_template_name_errormsg")); @@ -36,20 +47,28 @@ function afterLoadTemplateJSP() { moreCriteria.push("&isfeatured="+isFeatured); } - //middle menu spinning wheel.... + var $midmenuItem1 = beforeAddingMidMenuItem() ; $.ajax({ 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; - debugger; - //spinning wheel disappear - }, - error: function(XMLHttpResponse) { - debugger; - - } + success: function(json) { + var result = json.registertemplateresponse; + templateToMidmenu(result.template[0], $midmenuItem1); + bindClickToMidMenu($midmenuItem1, templateToRigntPanel); + /* + if(result.template.length > 1) { + for(var i=1; i