new UI - instance page - volume tab - after detach disk action, remove the volume from volume tab.

This commit is contained in:
Jessica Wang 2010-09-11 21:48:03 -07:00
parent 5fb3bf8b56
commit 41fc9fd8b0
2 changed files with 31 additions and 8 deletions

View File

@ -424,9 +424,30 @@ function clickInstanceGroupHeader($arrowIcon) {
});
}
//***** declaration for volume tab (begin) *********************************************************
var vmVolumeActionMap = {
"Detach Disk": {
api: "detachVolume",
isAsyncJob: true,
asyncJobResponse: "detachvolumeresponse",
afterActionSeccessFn: function(jsonObj, template){
template.slideUp("slow", function(){
$(this).remove();
});
}
},
"Create Template": {
isAsyncJob: true,
asyncJobResponse: "createtemplateresponse",
dialogBeforeActionFn : doCreateTemplate,
afterActionSeccessFn: function(){}
}
}
function vmVolumeJSONToTemplate(json, template) {
template.attr("id","vm_volume_"+json.id);
template.data("id", json.id);
template.data("jsonObj", json);
template.find("#id").text(json.id);
template.find("#name").text(json.name);
if (json.storagetype == "shared")
@ -439,13 +460,15 @@ function clickInstanceGroupHeader($arrowIcon) {
if(json.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed.
if (json.vmstate == "Stopped")
buildActionLinkForSingleObject("Create Template", volumeActionMap, template.find("#volume_action_menu"), volumeListAPIMap, template);
buildActionLinkForSingleObject("Create Template", vmVolumeActionMap, template.find("#volume_action_menu"), volumeListAPIMap, template);
}
else { //json.type=="DATADISK": "detach disk" is allowed, "create template" is disallowed.
buildActionLinkForSingleObject("Detach Disk", volumeActionMap, template.find("#volume_action_menu"), volumeListAPIMap, template);
buildActionLinkForSingleObject("Detach Disk", vmVolumeActionMap, template.find("#volume_action_menu"), volumeListAPIMap, template);
}
}
//***** declaration for volume tab (end) *********************************************************
$("#add_link").show();
if($arrowIcon.hasClass("close") == true) {
$arrowIcon.removeClass("close").addClass("open");
@ -1200,8 +1223,7 @@ function clickInstanceGroupHeader($arrowIcon) {
$(this).find("#volume_action_menu").hide();
return false;
});
$.ajax({
data: createURL("command=listOsTypes&response=json"),
dataType: "json",

View File

@ -58,9 +58,10 @@ var volumeActionMap = {
function doCreateTemplate($actionLink, listAPIMap, $singleObject) {
//debugger;
//$("#dialog_create_template").find("#volume_name").text(volumeName);
function doCreateTemplate($actionLink, listAPIMap, $singleObject) {
var jsonObj = $singleObject.data("jsonObj");
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
$("#dialog_create_template")
.dialog('option', 'buttons', {
"Create": function() {