mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
new UI - implement DetachISO action
This commit is contained in:
parent
dd880b62f8
commit
f714fb82a1
@ -240,7 +240,7 @@
|
||||
<div class="midmenu_panel">
|
||||
<div class="midmenu_box" id="midmenu_container">
|
||||
|
||||
|
||||
<!--
|
||||
<div class="midmenu_list">
|
||||
<div class="midmenu_content">
|
||||
<div class="midmenu_icons"><img src="images/status_green.png" alt="Running" /></div>
|
||||
@ -251,6 +251,7 @@
|
||||
<div class="midmenu_defaultloader"></div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<!--
|
||||
<div class="midmenu_list">
|
||||
<div class="midmenu_content">
|
||||
@ -579,6 +580,16 @@
|
||||
<div class="poweredby_box">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dialogs -->
|
||||
<div id="dialog_confirmation" title="Confirmation" style="display:none"></div>
|
||||
<div id="dialog_info" title="Info" style="display:none"></div>
|
||||
<div id="dialog_alert" title="Alert" style="display:none"></div>
|
||||
<div id="dialog_error" title="Error" style="display:none"></div>
|
||||
<div id="dialog_session_expired" title="Session Expired" style="display:none">
|
||||
<p>Your session has expired. Please click 'OK' to return to the login screen.</p>
|
||||
</div>
|
||||
|
||||
<!-- templates starts here-->
|
||||
<div class="leftmenu_content" id="leftmenu_instance_group_template" style="display: none">
|
||||
<div class="leftmenu_thirdindent">
|
||||
|
||||
@ -597,7 +597,7 @@
|
||||
<!-- Attach ISO Dialog -->
|
||||
<div id="dialog_attach_iso" title="Attach ISO" style="display:none">
|
||||
<p>
|
||||
Please specify the ISO you wish to attach to your Virtual Instance: <b><span id="vm_name">
|
||||
Please specify the ISO you wish to attach to your Virtual Instance(s)
|
||||
</span></b>.</p>
|
||||
<div class="dialog_formcontent">
|
||||
<form action="#" method="post" id="form_acquire">
|
||||
|
||||
@ -14,69 +14,62 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
var $actionListItem = $("#action_list_item");
|
||||
|
||||
var noGroupName = "(no group name)";
|
||||
|
||||
var listAPIMap = {
|
||||
API: "listVirtualMachines",
|
||||
APIResponse: "listvirtualmachinesresponse",
|
||||
APIResponseObj: "virtualmachine"
|
||||
};
|
||||
|
||||
var actionMap = {
|
||||
stopVirtualMachine: {
|
||||
label: "Stop Instance",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "stopvirtualmachineresponse",
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu
|
||||
},
|
||||
startVirtualMachine: {
|
||||
label: "Start Instance",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "startvirtualmachineresponse",
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu
|
||||
},
|
||||
rebootVirtualMachine: {
|
||||
label: "Reboot Instance",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "rebootvirtualmachineresponse",
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu
|
||||
},
|
||||
destroyVirtualMachine: {
|
||||
label: "Destroy Instance",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "destroyvirtualmachineresponse",
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu
|
||||
},
|
||||
recoverVirtualMachine: {
|
||||
label: "Restore Instance",
|
||||
isAsyncJob: false,
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
afterActionSeccessFn: updateVirtualMachineStateInMidMenu
|
||||
},
|
||||
attachIso: {
|
||||
label: "Attach ISO",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "attachisoresponse",
|
||||
afterActionSeccessFn: function(){
|
||||
//debugger;
|
||||
},
|
||||
dialogBeforeActionFn : doAttachISO,
|
||||
listAPI: "listVirtualMachines",
|
||||
listAPIResponse: "listvirtualmachinesresponse",
|
||||
listAPIResponseObj: "virtualmachine"
|
||||
}
|
||||
afterActionSeccessFn: function(){},
|
||||
dialogBeforeActionFn : doAttachISO
|
||||
},
|
||||
detachIso: {
|
||||
label: "Detach ISO",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "detachisoresponse",
|
||||
afterActionSeccessFn: function(){},
|
||||
dialogBeforeActionFn : doDetachISO
|
||||
}
|
||||
}
|
||||
|
||||
function doAttachISO($t, selectedItemIds) {
|
||||
function doAttachISO($t, selectedItemIds, listAPIMap) {
|
||||
$.ajax({
|
||||
data: createURL("command=listIsos&isReady=true&response=json"),
|
||||
data: createURL("command=listIsos&isReady=true"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -90,20 +83,20 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
}
|
||||
}
|
||||
});
|
||||
//$("#dialog_attach_iso").find("#vm_name").text(vmName);
|
||||
|
||||
$("#dialog_attach_iso")
|
||||
.dialog('option', 'buttons', {
|
||||
"Confirm": function() {
|
||||
$(this).dialog("close");
|
||||
var isoId = $("#dialog_attach_iso #attach_iso_select").val();
|
||||
if (isoId == "none") {
|
||||
$("#dialog_alert").html("<p>There is no ISO file to attach to the virtual machine.</p>")
|
||||
$("#dialog_alert").html("<p>There is no ISO file to attach to the virtual machine.</p>");
|
||||
$("#dialog_alert").dialog("open");
|
||||
return false;
|
||||
}
|
||||
for(var id in selectedItemIds) {
|
||||
var apiCommand = "command=attachIso&virtualmachineid="+id+"&id="+isoId+"&response=json";
|
||||
doAction(id, $t, apiCommand);
|
||||
var apiCommand = "command=attachIso&virtualmachineid="+id+"&id="+isoId;
|
||||
doAction(id, $t, apiCommand, listAPIMap);
|
||||
}
|
||||
},
|
||||
"Cancel": function() {
|
||||
@ -112,6 +105,23 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
}).dialog("open");
|
||||
}
|
||||
|
||||
function doDetachISO($t, selectedItemIds, listAPIMap) {
|
||||
$("#dialog_confirmation")
|
||||
.html("<p>Please confirm you want to detach an ISO from the virtual machine(s)</p>")
|
||||
.dialog('option', 'buttons', {
|
||||
"Confirm": function() {
|
||||
$(this).dialog("close");
|
||||
for(var id in selectedItemIds) {
|
||||
var apiCommand = "command=detachIso&virtualmachineid="+id;
|
||||
doAction(id, $t, apiCommand, listAPIMap);
|
||||
}
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
|
||||
function updateVirtualMachineStateInRightPanel(state) {
|
||||
if(state == "Running")
|
||||
$rightPanelContent.find("#state").text(state).removeClass("red gray").addClass("green");
|
||||
@ -206,7 +216,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
$arrowIcon.removeClass("close").addClass("open");
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVirtualMachines&response=json"),
|
||||
data: createURL("command=listVirtualMachines"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var instanceGroupMap = {};
|
||||
@ -238,7 +248,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVirtualMachines&response=json"),
|
||||
data: createURL("command=listVirtualMachines"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
@ -271,22 +281,19 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
$link.data("isAsyncJob", apiInfo.isAsyncJob);
|
||||
$link.data("asyncJobResponse", apiInfo.asyncJobResponse);
|
||||
$link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn);
|
||||
$link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn);
|
||||
$link.data("listAPI", apiInfo.listAPI);
|
||||
$link.data("listAPIResponse", apiInfo.listAPIResponse);
|
||||
$link.data("listAPIResponseObj", apiInfo.listAPIResponseObj);
|
||||
$link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn);
|
||||
$link.bind("click", function(event) {
|
||||
$actionMenu.hide();
|
||||
var $t = $(this);
|
||||
var dialogBeforeActionFn = $t.data("dialogBeforeActionFn");
|
||||
if(dialogBeforeActionFn == null) {
|
||||
for(var id in selectedItemIds) {
|
||||
var apiCommand = "command="+$t.data("api")+"&id="+id+"&response=json";
|
||||
doAction(id, $t, apiCommand);
|
||||
var apiCommand = "command="+$t.data("api")+"&id="+id;
|
||||
doAction(id, $t, apiCommand, listAPIMap);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dialogBeforeActionFn($t, selectedItemIds);
|
||||
dialogBeforeActionFn($t, selectedItemIds, listAPIMap);
|
||||
}
|
||||
selectedItemIds = {}; //clear selected items for action
|
||||
return false;
|
||||
@ -321,7 +328,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
$("#add_link").unbind("click").bind("click", function(event) {
|
||||
vmWizardOpen();
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true&response=json"),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
@ -336,7 +343,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listServiceOfferings&response=json"),
|
||||
data: createURL("command=listServiceOfferings"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -369,7 +376,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listDiskOfferings&domainid=1&response=json"),
|
||||
data: createURL("command=listDiskOfferings&domainid=1"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -561,14 +568,14 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
var searchInput = $vmPopup.find("#search_input").val();
|
||||
if (selectedTemplateTypeInVmPopup != "blank") {
|
||||
if (searchInput != null && searchInput.length > 0)
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup+"&response=json";
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
else
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup+"&response=json";
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
} else {
|
||||
if (searchInput != null && searchInput.length > 0)
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup+"&response=json";
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
else
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup+"&response=json";
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
}
|
||||
|
||||
var loading = $vmPopup.find("#wiz_template_loading").show();
|
||||
@ -841,7 +848,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
$("#midmenu_container").append($t.show());
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=deployVirtualMachine"+moreCriteria.join("")+"&response=json"),
|
||||
data: createURL("command=deployVirtualMachine"+moreCriteria.join("")),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var jobId = json.deployvirtualmachineresponse.jobid;
|
||||
@ -854,7 +861,7 @@ function clickInstanceGroupHeader($arrowIcon) {
|
||||
timerKey,
|
||||
function() {
|
||||
$.ajax({
|
||||
data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"),
|
||||
data: createURL("command=queryAsyncJobResult&jobId="+jobId),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var result = json.queryasyncjobresultresponse;
|
||||
|
||||
@ -21,15 +21,15 @@
|
||||
// Version: @VERSION@
|
||||
|
||||
//var jobIdMap;
|
||||
function doAction(id, $t, apiCommand) {
|
||||
function doAction(id, $t, apiCommand, listAPIMap) {
|
||||
var api = $t.data("api");
|
||||
var label = $t.data("label");
|
||||
var isAsyncJob = $t.data("isAsyncJob");
|
||||
var asyncJobResponse = $t.data("asyncJobResponse");
|
||||
var afterActionSeccessFn = $t.data("afterActionSeccessFn");
|
||||
var listAPI = $t.data("listAPI");
|
||||
var listAPIResponse = $t.data("listAPIResponse");
|
||||
var listAPIResponseObj = $t.data("listAPIResponseObj");
|
||||
var listAPI = listAPIMap["listAPI"];
|
||||
var listAPIResponse = listAPIMap["listAPIResponse"];
|
||||
var listAPIResponseObj = listAPIMap["listAPIResponseObj"];
|
||||
|
||||
var $midmenuItem = $("#midmenuItemVm_"+id);
|
||||
$midmenuItem.find("#content").removeClass("selected").addClass("inaction");
|
||||
@ -49,7 +49,7 @@ function doAction(id, $t, apiCommand) {
|
||||
timerKey,
|
||||
function() {
|
||||
$.ajax({
|
||||
data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"),
|
||||
data: createURL("command=queryAsyncJobResult&jobId="+jobId),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var result = json.queryasyncjobresultresponse;
|
||||
@ -67,7 +67,7 @@ function doAction(id, $t, apiCommand) {
|
||||
//Before Bug 6041 get fixed, use the temporary solution below.
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command="+listAPI+"&id="+id+"&response=json"),
|
||||
data: createURL("command="+listAPI+"&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -110,7 +110,7 @@ function doAction(id, $t, apiCommand) {
|
||||
//Sync job (begin) *****
|
||||
else {
|
||||
$.ajax({
|
||||
data: createURL("command="+api+"&id="+id+"&response=json"),
|
||||
data: createURL("command="+api+"&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -121,11 +121,17 @@ function doAction(id, $t, apiCommand) {
|
||||
//Before Bug 6037 get fixed, use the temporary solution below.
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command="+listAPI+"&id="+id+"&response=json"),
|
||||
data: createURL("command="+listAPI+"&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
success: function(json) {
|
||||
$midmenuItem.find("#info_icon").removeClass("error").show();
|
||||
$midmenuItem.data("afterActionInfo", (label + " action succeeded."));
|
||||
afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0], $midmenuItem);
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
$midmenuItem.find("#info_icon").addClass("error").show();
|
||||
$midmenuItem.data("afterActionInfo", (label + " action failed. Reason: " + sanitizeXSS(result.jobresult)));
|
||||
}
|
||||
});
|
||||
//After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
|
||||
@ -136,7 +142,9 @@ function doAction(id, $t, apiCommand) {
|
||||
//Sync job (end) *****
|
||||
}
|
||||
|
||||
|
||||
function createURL(url) {
|
||||
return url +"&response=json&sessionkey=" + g_sessionKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -217,10 +225,6 @@ function isDomainAdmin() {
|
||||
return (g_role == 2);
|
||||
}
|
||||
|
||||
function createURL(url) {
|
||||
return url + "&sessionkey=" + g_sessionKey;
|
||||
}
|
||||
|
||||
function setDateField(dateValue, dateField, htmlMarkup) {
|
||||
if (dateValue != null && dateValue.length > 0) {
|
||||
var disconnected = new Date();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user