mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	new UI - volumes page - snapshot tab - build action list.
This commit is contained in:
		
							parent
							
								
									96fd242feb
								
							
						
					
					
						commit
						8604f70d71
					
				@ -689,4 +689,53 @@
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>    
 | 
			
		||||
</div>
 | 
			
		||||
<!--  Snapshot tab template (end) -->
 | 
			
		||||
<!--  Snapshot tab template (end) -->
 | 
			
		||||
 | 
			
		||||
<!-- Add Volume Dialog from Snapshot (begin) -->
 | 
			
		||||
<div id="dialog_add_volume_from_snapshot" title="Add Volume from Snapshot" style="display: none">   
 | 
			
		||||
    <div class="dialog_formcontent">
 | 
			
		||||
        <form action="#" method="post" id="form5">
 | 
			
		||||
        <ol>
 | 
			
		||||
            <li>
 | 
			
		||||
                <label>Name:</label>
 | 
			
		||||
                <input class="text" type="text" id="name" />
 | 
			
		||||
                <div id="name_errormsg" class="dialog_formcontent_errormsg" style="display: none;"></div>
 | 
			
		||||
            </li>           
 | 
			
		||||
        </ol>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
<!-- Add Volume Dialog from Snapshot (end) -->
 | 
			
		||||
 | 
			
		||||
<!-- Create template from snapshot (begin) -->
 | 
			
		||||
<div id="dialog_create_template_from_snapshot" title="Create Template from Snapshot" style="display:none">	
 | 
			
		||||
	<div class="dialog_formcontent">
 | 
			
		||||
		<form action="#" method="post" id="form6">
 | 
			
		||||
			<ol>
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>Name:</label>
 | 
			
		||||
					<input class="text" type="text" id="name" style="width:250px"/>
 | 
			
		||||
					<div id="name_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
 | 
			
		||||
				</li>
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>Display Text:</label>
 | 
			
		||||
					<input class="text" type="text" id="display_text" style="width:250px"/>
 | 
			
		||||
					<div id="display_text_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
 | 
			
		||||
				</li>				
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>OS Type:</label>
 | 
			
		||||
					<select class="select" id="os_type">
 | 
			
		||||
					</select>
 | 
			
		||||
				</li>		
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>Password Enabled?:</label>
 | 
			
		||||
					<select class="select" id="password">						
 | 
			
		||||
						<option value="false">No</option>
 | 
			
		||||
						<option value="true">Yes</option>
 | 
			
		||||
					</select>
 | 
			
		||||
				</li>
 | 
			
		||||
			</ol>
 | 
			
		||||
		</form>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
<!-- Create template from snapshot (end) -->
 | 
			
		||||
 | 
			
		||||
@ -441,19 +441,23 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgrid
 | 
			
		||||
			                            $subgridItem.find("#after_action_info").text(label + " action succeeded.");
 | 
			
		||||
                                        $subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show();   
 | 
			
		||||
			                        
 | 
			
		||||
			                            //DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041)
 | 
			
		||||
	                                    //Before Bug 6041 get fixed, use the temporary solution below.							            
 | 
			
		||||
	                                    $.ajax({
 | 
			
		||||
                                            cache: false,
 | 
			
		||||
                                            data: createURL("command="+listAPI+"&id="+id),
 | 
			
		||||
                                            dataType: "json",                                            
 | 
			
		||||
                                            success: function(json) {		                                                                                  
 | 
			
		||||
                                                afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	                        
 | 
			
		||||
                                            }
 | 
			
		||||
                                        });										
 | 
			
		||||
				                        //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
 | 
			
		||||
			                            //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	   
 | 
			
		||||
			                            
 | 
			
		||||
			                            if(apiCommand.indexOf("command=delete")!=0) { 
 | 
			
		||||
			                                //DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041)
 | 
			
		||||
	                                        //Before Bug 6041 get fixed, use the temporary solution below.							            
 | 
			
		||||
	                                        $.ajax({
 | 
			
		||||
                                                cache: false,
 | 
			
		||||
                                                data: createURL("command="+listAPI+"&id="+id),
 | 
			
		||||
                                                dataType: "json",                                            
 | 
			
		||||
                                                success: function(json) {		                                                                                  
 | 
			
		||||
                                                    afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	                        
 | 
			
		||||
                                                }
 | 
			
		||||
                                            });										
 | 
			
		||||
				                            //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
 | 
			
		||||
			                                //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	 
 | 
			
		||||
			                            }
 | 
			
		||||
				                        else { //apiCommand is deleteXXXXXXX	
 | 
			
		||||
				                            afterActionSeccessFn(id);
 | 
			
		||||
				                        }	
 | 
			
		||||
			                        } else if (result.jobstatus == 2) { // Failed
 | 
			
		||||
			                            $subgridItem.find("#after_action_info").text(label + " action failed. Reason: " + fromdb(result.jobresult));
 | 
			
		||||
                                        $subgridItem.find("#after_action_info_container").removeClass("success").addClass("error").show();			                          
 | 
			
		||||
@ -484,22 +488,26 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgrid
 | 
			
		||||
	        async: false,
 | 
			
		||||
	        success: function(json) {	   
 | 
			
		||||
	            $spinningWheel.hide();      
 | 
			
		||||
														              
 | 
			
		||||
	            //RecoverVirtualMachine API doesn't return an embedded object on success (Bug 6037)
 | 
			
		||||
	            //Before Bug 6037 get fixed, use the temporary solution below.							            
 | 
			
		||||
	            $.ajax({
 | 
			
		||||
                    cache: false,
 | 
			
		||||
                    data: createURL("command="+listAPI+"&id="+id),
 | 
			
		||||
                    dataType: "json",
 | 
			
		||||
                    async: false,
 | 
			
		||||
                    success: function(json) {	
 | 
			
		||||
                        $subgridItem.find("#after_action_info").text(label + " action succeeded.");
 | 
			
		||||
                        $subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show();   
 | 
			
		||||
                        afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	                           
 | 
			
		||||
                    }
 | 
			
		||||
                });										
 | 
			
		||||
				//After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
 | 
			
		||||
				//afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	   
 | 
			
		||||
				if(apiCommand.indexOf("command=delete")!=0) { 											              
 | 
			
		||||
	                //RecoverVirtualMachine API doesn't return an embedded object on success (Bug 6037)
 | 
			
		||||
	                //Before Bug 6037 get fixed, use the temporary solution below.							            
 | 
			
		||||
	                $.ajax({
 | 
			
		||||
                        cache: false,
 | 
			
		||||
                        data: createURL("command="+listAPI+"&id="+id),
 | 
			
		||||
                        dataType: "json",
 | 
			
		||||
                        async: false,
 | 
			
		||||
                        success: function(json) {	
 | 
			
		||||
                            $subgridItem.find("#after_action_info").text(label + " action succeeded.");
 | 
			
		||||
                            $subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show();   
 | 
			
		||||
                            afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	                           
 | 
			
		||||
                        }
 | 
			
		||||
                    });										
 | 
			
		||||
				    //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
 | 
			
		||||
				    //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $subgridItem);	 
 | 
			
		||||
				}
 | 
			
		||||
				else { //apiCommand is deleteXXXXXXX	
 | 
			
		||||
				    afterActionSeccessFn(id);
 | 
			
		||||
				}  
 | 
			
		||||
	        },
 | 
			
		||||
            error: function(XMLHttpResponse) {	             
 | 
			
		||||
		        handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label);    
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,17 @@ function afterLoadVolumeJSP() {
 | 
			
		||||
	    modal: true,
 | 
			
		||||
	    zIndex: 2000
 | 
			
		||||
    }));	
 | 
			
		||||
	     
 | 
			
		||||
	activateDialog($("#dialog_add_volume_from_snapshot").dialog({ 
 | 
			
		||||
	    autoOpen: false,
 | 
			
		||||
	    modal: true,
 | 
			
		||||
	    zIndex: 2000
 | 
			
		||||
    }));
 | 
			
		||||
    activateDialog($("#dialog_create_template_from_snapshot").dialog({ 
 | 
			
		||||
        width: 400,
 | 
			
		||||
        autoOpen: false,
 | 
			
		||||
        modal: true,
 | 
			
		||||
        zIndex: 2000
 | 
			
		||||
    }));    
 | 
			
		||||
	        
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        data: createURL("command=listOsTypes"),
 | 
			
		||||
@ -34,9 +44,11 @@ function afterLoadVolumeJSP() {
 | 
			
		||||
	    success: function(json) {
 | 
			
		||||
		    types = json.listostypesresponse.ostype;
 | 
			
		||||
		    if (types != null && types.length > 0) {
 | 
			
		||||
			    var select = $("#dialog_create_template #create_template_os_type").empty();
 | 
			
		||||
			    var osTypeField1 = $("#dialog_create_template #create_template_os_type").empty();
 | 
			
		||||
			    var osTypeField2 = $("#dialog_create_template_from_snapshot #os_type").empty();	
 | 
			
		||||
			    for (var i = 0; i < types.length; i++) {
 | 
			
		||||
				    select.append("<option value='" + types[i].id + "'>" + types[i].description + "</option>");
 | 
			
		||||
				    osTypeField1.append("<option value='" + types[i].id + "'>" + types[i].description + "</option>");
 | 
			
		||||
				    osTypeField2.append("<option value='" + types[i].id + "'>" + types[i].description + "</option>");
 | 
			
		||||
			    }
 | 
			
		||||
		    }	
 | 
			
		||||
	    }
 | 
			
		||||
@ -487,7 +499,10 @@ function volumeSnapshotJSONToTemplate(jsonObj, template) {
 | 
			
		||||
	
 | 
			
		||||
	var $actionMenu = $actionLink.find("#snapshot_action_menu");
 | 
			
		||||
    $actionMenu.find("#action_list").empty();	
 | 
			
		||||
	//buildActionLinkForSubgridItem("Create Template", vmSnapshotActionMap, $actionMenu, snapshotListAPIMap, template);		
 | 
			
		||||
    
 | 
			
		||||
    buildActionLinkForSubgridItem("Create Volume", volumeSnapshotActionMap, $actionMenu, snapshotListAPIMap, template);	
 | 
			
		||||
    buildActionLinkForSubgridItem("Delete Snapshot", volumeSnapshotActionMap, $actionMenu, snapshotListAPIMap, template);	
 | 
			
		||||
    buildActionLinkForSubgridItem("Create Template", volumeSnapshotActionMap, $actionMenu, snapshotListAPIMap, template);	
 | 
			
		||||
} 
 | 
			
		||||
 
 | 
			
		||||
function volumeClearRightPanel() {       
 | 
			
		||||
@ -824,4 +839,97 @@ function doAttachDisk($actionLink, listAPIMap, $detailsTab) {
 | 
			
		||||
		    $(this).dialog("close"); 
 | 
			
		||||
	    } 
 | 
			
		||||
    }).dialog("open");
 | 
			
		||||
}	
 | 
			
		||||
}	
 | 
			
		||||
 | 
			
		||||
//Snapshot tab actions
 | 
			
		||||
var volumeSnapshotActionMap = {  
 | 
			
		||||
    "Create Volume": {              
 | 
			
		||||
        isAsyncJob: true,
 | 
			
		||||
        asyncJobResponse: "createvolumeresponse",
 | 
			
		||||
        dialogBeforeActionFn : doCreateVolumeFromSnapshotInVolumePage,
 | 
			
		||||
        inProcessText: "Creating Volume....",
 | 
			
		||||
        afterActionSeccessFn: function(jsonObj) {}
 | 
			
		||||
    }   
 | 
			
		||||
    , 
 | 
			
		||||
    "Delete Snapshot": {              
 | 
			
		||||
        api: "deleteSnapshot",     
 | 
			
		||||
        isAsyncJob: true,
 | 
			
		||||
        asyncJobResponse: "deletesnapshotresponse",        
 | 
			
		||||
        inProcessText: "Deleting snapshot....",
 | 
			
		||||
        afterActionSeccessFn: function(id) { 
 | 
			
		||||
//            var $midmenuItem1 = $("#midmenuItem_"+id); 
 | 
			
		||||
//            $midmenuItem1.remove();
 | 
			
		||||
//            clearRightPanel();
 | 
			
		||||
//            snapshotClearRightPanel();
 | 
			
		||||
        }
 | 
			
		||||
    } 
 | 
			
		||||
    ,
 | 
			
		||||
    "Create Template": {              
 | 
			
		||||
        isAsyncJob: true,
 | 
			
		||||
        asyncJobResponse: "createtemplateresponse",
 | 
			
		||||
        dialogBeforeActionFn : doCreateTemplateFromSnapshotInVolumePage,
 | 
			
		||||
        inProcessText: "Creating Template....",
 | 
			
		||||
        afterActionSeccessFn: function(jsonObj) {}
 | 
			
		||||
    }
 | 
			
		||||
}  
 | 
			
		||||
                                              
 | 
			
		||||
function doCreateVolumeFromSnapshotInVolumePage($actionLink, listAPIMap, $subgridItem) { 
 | 
			
		||||
    var jsonObj = $subgridItem.data("jsonObj");
 | 
			
		||||
       
 | 
			
		||||
    $("#dialog_add_volume_from_snapshot")
 | 
			
		||||
    .dialog("option", "buttons", {	                    
 | 
			
		||||
     "Add": function() {	
 | 
			
		||||
         var thisDialog = $(this);	 
 | 
			
		||||
                                        
 | 
			
		||||
         var isValid = true;					
 | 
			
		||||
         isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"));					          		
 | 
			
		||||
         if (!isValid) return;   
 | 
			
		||||
         
 | 
			
		||||
         thisDialog.dialog("close");       	                                             
 | 
			
		||||
         
 | 
			
		||||
         var name = thisDialog.find("#name").val();	                
 | 
			
		||||
         
 | 
			
		||||
         var id = jsonObj.id;
 | 
			
		||||
         var apiCommand = "command=createVolume&snapshotid="+id+"&name="+name;    	
 | 
			
		||||
    	 doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgridItem);			
 | 
			
		||||
     },
 | 
			
		||||
     "Cancel": function() {	                         
 | 
			
		||||
         $(this).dialog("close");
 | 
			
		||||
     }
 | 
			
		||||
    }).dialog("open");     
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function doCreateTemplateFromSnapshotInVolumePage($actionLink, listAPIMap, $subgridItem) { 
 | 
			
		||||
    var jsonObj = $subgridItem.data("jsonObj");
 | 
			
		||||
       
 | 
			
		||||
    $("#dialog_create_template_from_snapshot")
 | 
			
		||||
    .dialog("option", "buttons", {
 | 
			
		||||
     "Add": function() {	
 | 
			
		||||
         var thisDialog = $(this);	 	                                                                        
 | 
			
		||||
         var isValid = true;					
 | 
			
		||||
         isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"), false);		
 | 
			
		||||
         isValid &= validateString("Display Text", thisDialog.find("#display_text"), thisDialog.find("#display_text_errormsg"), false);				         		          		
 | 
			
		||||
         if (!isValid) return;                  	                                             
 | 
			
		||||
         
 | 
			
		||||
         thisDialog.dialog("close");	
 | 
			
		||||
         
 | 
			
		||||
         var name = thisDialog.find("#name").val();	 
 | 
			
		||||
         var displayText = thisDialog.find("#display_text").val();	 
 | 
			
		||||
         var osTypeId = thisDialog.find("#os_type").val(); 	  
 | 
			
		||||
         var password = thisDialog.find("#password").val();	                                         
 | 
			
		||||
       
 | 
			
		||||
         var id = jsonObj.id;
 | 
			
		||||
         var apiCommand = "command=createTemplate&snapshotid="+id+"&name="+name+"&displaytext="+displayText+"&ostypeid="+osTypeId+"&passwordEnabled="+password;    	 
 | 
			
		||||
    	 doActionToSubgridItem(id, $actionLink, apiCommand, listAPIMap, $subgridItem);				
 | 
			
		||||
     },
 | 
			
		||||
     "Cancel": function() {	                         
 | 
			
		||||
         $(this).dialog("close");
 | 
			
		||||
     }	                     
 | 
			
		||||
    }).dialog("open");	     
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var snapshotListAPIMap = {
 | 
			
		||||
    listAPI: "listSnapshots",
 | 
			
		||||
    listAPIResponse: "listsnapshotsresponse",
 | 
			
		||||
    listAPIResponseObj: "snapshot"
 | 
			
		||||
}; 
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user