diff --git a/ui/new/scripts/cloud.core2.init.js b/ui/new/scripts/cloud.core2.init.js index 15a98784438..9aee4bbf3f0 100644 --- a/ui/new/scripts/cloud.core2.init.js +++ b/ui/new/scripts/cloud.core2.init.js @@ -29,12 +29,22 @@ $(document).ready(function() { clearLeftMenu(); clearMidMenu(); - $("#right_panel").load(rightPanelJSP, function(){ - + $("#right_panel").load(rightPanelJSP, function(){ $("#right_panel_content #tab_content_details #action_message_box #close_button").bind("click", function(event){ $(this).parent().hide(); return false; - }); + }); + + var $actionLink = $("#right_panel_content #tab_content_details #action_link"); + $actionLink.bind("mouseover", function(event) { + $(this).find("#action_menu").show(); + return false; + }); + $actionLink.bind("mouseout", function(event) { + $(this).find("#action_menu").hide(); + return false; + }); + afterLoadRightPanelJSP(); $.ajax({ diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index 4cf205dd1d1..f2359742c46 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -515,15 +515,10 @@ var midmenuItemCount = 20; function setBooleanField(value, $field) { if(value == "true") $field.find("#icon").removeClass("cross_icon").addClass("tick_icon").show(); - else // value == "false" + else if(value == "false") $field.find("#icon").removeClass("tick_icon").addClass("cross_icon").show(); -} - -function getBooleanField($field) { - if($field.find("#icon").hasClass("tick_icon")==true) - return "true"; - else // $field.find("#icon").hasClass("cross_icon")==true - return "false"; + else + $field.find("#icon").hide(); } function clearLeftMenu() { diff --git a/ui/new/scripts/cloud.core2.template.js b/ui/new/scripts/cloud.core2.template.js index bbfd14518f9..2a94dc7f886 100644 --- a/ui/new/scripts/cloud.core2.template.js +++ b/ui/new/scripts/cloud.core2.template.js @@ -183,7 +183,30 @@ function templateJsonToDetailsTab(jsonObj) { if(jsonObj.size != null) $detailsTab.find("#size").text(convertBytes(parseInt(jsonObj.size))); - setDateField(jsonObj.created, $detailsTab.find("#created")); + setDateField(jsonObj.created, $detailsTab.find("#created")); + + //actions *** + var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu"); + $actionMenu.find("#action_list").empty(); + + // action Edit, Copy, Create VM + if ((isUser() && jsonObj.ispublic == "true" && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) || jsonObj.id==DomRTemplateId || jsonObj.isready == "false") { + //template.find("#template_edit_container, #template_copy_container, #template_create_vm_container").hide(); + $("edit_button").hide(); + } + else { + $("edit_button").show(); + //buildActionLinkForDetailsTab("Copy Template", templateActionMap, $actionMenu, templateListAPIMap); + //buildActionLinkForDetailsTab("Create VM", templateActionMap, $actionMenu, templateListAPIMap); + } + + // action Delete + if (((isUser() && jsonObj.ispublic == "true" && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) || jsonObj.id==DomRTemplateId) || (jsonObj.isready == "false" && jsonObj.templatestatus != null && jsonObj.templatestatus.indexOf("% Downloaded") != -1)) { + //template.find("#template_delete_container").hide(); + } + else { + buildActionLinkForDetailsTab("Delete Template", templateActionMap, $actionMenu, templateListAPIMap); + } } //setIconByOsType() is shared by template page and ISO page @@ -196,4 +219,60 @@ function setIconByOsType(osType, $field) { $field.attr("src", "images/midmenuicon_template_windows.png"); else $field.attr("src", "images/midmenuicon_template_linux.png"); -} \ No newline at end of file +} + +function templateClearRightPanel() { + var $detailsTab = $("#right_panel_content #tab_content_details"); + $detailsTab.data("jsonObj", null); + $detailsTab.find("#id").text(""); + $detailsTab.find("#zonename").text(""); + + $detailsTab.find("#name").text(""); + $detailsTab.find("#name_edit").val(""); + + $detailsTab.find("#displaytext").text(""); + $detailsTab.find("#displaytext_edit").val(""); + + $detailsTab.find("#status").text(""); + + setBooleanField(null, $detailsTab.find("#passwordenabled")); + $detailsTab.find("#passwordenabled_edit").val(null); + + setBooleanField(null, $detailsTab.find("#ispublic")); + $detailsTab.find("#ispublic_edit").val(null); + + setBooleanField(null, $detailsTab.find("#isfeatured")); + $detailsTab.find("#isfeatured_edit").val(null); + + setBooleanField(null, $detailsTab.find("#crossZones")); + + $detailsTab.find("#ostypename").text(""); + $detailsTab.find("#ostypename_edit").val(null); + + $detailsTab.find("#account").text(""); + $detailsTab.find("#size").text(""); + $detailsTab.find("#created").text(""); +} + +var templateActionMap = { + "Delete Template": { + api: "deleteTemplate", + isAsyncJob: true, + asyncJobResponse: "deletetemplateresponse", + inProcessText: "Deleting Template....", + afterActionSeccessFn: function(jsonObj) { + var $midmenuItem1 = $("#midmenuItem_"+jsonObj.id); + $midmenuItem1.remove(); + clearRightPanel(); + templateClearRightPanel(); + } + } +} + +var templateListAPIMap = { + listAPI: "listTemplates&templatefilter=self", + listAPIResponse: "listtemplatesresponse", + listAPIResponseObj: "template" +}; + +var DomRTemplateId = 1; \ No newline at end of file diff --git a/ui/new/scripts/cloud.core2.volume.js b/ui/new/scripts/cloud.core2.volume.js index dd547bd4baf..ae288759623 100644 --- a/ui/new/scripts/cloud.core2.volume.js +++ b/ui/new/scripts/cloud.core2.volume.js @@ -64,6 +64,7 @@ function volumeJsonToDetailsTab(jsonObj){ setDateField(jsonObj.created, $detailsTab.find("#created")); + /* var $actionLink = $detailsTab.find("#action_link"); $actionLink.bind("mouseover", function(event) { $(this).find("#action_menu").show(); @@ -72,9 +73,11 @@ function volumeJsonToDetailsTab(jsonObj){ $actionLink.bind("mouseout", function(event) { $(this).find("#action_menu").hide(); return false; - }); - - var $actionMenu = $actionLink.find("#action_menu"); + }); + */ + + //actions *** + var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu"); $actionMenu.find("#action_list").empty(); if(jsonObj.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed. if (jsonObj.vmstate == "Stopped") @@ -84,13 +87,7 @@ function volumeJsonToDetailsTab(jsonObj){ buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap); } } - -var volumeListAPIMap = { - listAPI: "listVolumes", - listAPIResponse: "listvolumesresponse", - listAPIResponseObj: "volume" -}; - + var volumeActionMap = { "Detach Disk": { api: "detachVolume", @@ -108,14 +105,19 @@ var volumeActionMap = { } } +var volumeListAPIMap = { + listAPI: "listVolumes", + listAPIResponse: "listvolumesresponse", + listAPIResponseObj: "volume" +}; + function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) { var jsonObj = $detailsTab.data("jsonObj"); $("#dialog_create_template").find("#volume_name").text(jsonObj.name); $("#dialog_create_template") .dialog('option', 'buttons', { - "Create": function() { - //debugger; + "Create": function() { var thisDialog = $(this); thisDialog.dialog("close");