mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	new UI - template page - implement delete action.
This commit is contained in:
		
							parent
							
								
									40db8f60e0
								
							
						
					
					
						commit
						b7d6ae6406
					
				@ -30,11 +30,21 @@ $(document).ready(function() {
 | 
			
		||||
            clearMidMenu();
 | 
			
		||||
            
 | 
			
		||||
            $("#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({
 | 
			
		||||
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
@ -184,6 +184,29 @@ function templateJsonToDetailsTab(jsonObj) {
 | 
			
		||||
	    $detailsTab.find("#size").text(convertBytes(parseInt(jsonObj.size)));        
 | 
			
		||||
    
 | 
			
		||||
    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
 | 
			
		||||
@ -197,3 +220,59 @@ function setIconByOsType(osType, $field) {
 | 
			
		||||
	else 
 | 
			
		||||
		$field.attr("src", "images/midmenuicon_template_linux.png");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
@ -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();    
 | 
			
		||||
@ -73,8 +74,10 @@ function volumeJsonToDetailsTab(jsonObj){
 | 
			
		||||
        $(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") 
 | 
			
		||||
@ -85,12 +88,6 @@ function volumeJsonToDetailsTab(jsonObj){
 | 
			
		||||
	}	
 | 
			
		||||
} 
 | 
			
		||||
   
 | 
			
		||||
var volumeListAPIMap = {
 | 
			
		||||
    listAPI: "listVolumes",
 | 
			
		||||
    listAPIResponse: "listvolumesresponse",
 | 
			
		||||
    listAPIResponseObj: "volume"
 | 
			
		||||
};           
 | 
			
		||||
  
 | 
			
		||||
var volumeActionMap = {  
 | 
			
		||||
    "Detach Disk": {
 | 
			
		||||
        api: "detachVolume",            
 | 
			
		||||
@ -108,6 +105,12 @@ 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);
 | 
			
		||||
@ -115,7 +118,6 @@ function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) {
 | 
			
		||||
	$("#dialog_create_template")
 | 
			
		||||
	.dialog('option', 'buttons', { 						
 | 
			
		||||
		"Create": function() { 		   
 | 
			
		||||
		    //debugger;
 | 
			
		||||
		    var thisDialog = $(this);
 | 
			
		||||
		    thisDialog.dialog("close"); 
 | 
			
		||||
									
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user