mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
new UI - when applying actions to multiple-selection middle menu items (e.g. StartVM, StopVM, RebootVM, DestroyVM), display spinning wheel on details tab action menu.
This commit is contained in:
parent
170ad91011
commit
c4a31f0d0d
@ -108,6 +108,7 @@ function initStartVMButton() {
|
||||
var apiInfo = {
|
||||
label: "Start Instance",
|
||||
isAsyncJob: true,
|
||||
inProcessText: "Starting Instance....",
|
||||
asyncJobResponse: "startvirtualmachineresponse",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
var jsonObj = json.queryasyncjobresultresponse.jobresult.startvirtualmachineresponse;
|
||||
@ -157,6 +158,7 @@ function initStopVMButton() {
|
||||
var apiInfo = {
|
||||
label: "Stop Instance",
|
||||
isAsyncJob: true,
|
||||
inProcessText: "Stopping Instance....",
|
||||
asyncJobResponse: "stopvirtualmachineresponse",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
//call listVirtualMachine to get embedded object until bug 6486 ("StopVirtualMachine API should return an embedded object on success") is fixed.
|
||||
@ -215,6 +217,7 @@ function initRebootVMButton() {
|
||||
var apiInfo = {
|
||||
label: "Reboot Instance",
|
||||
isAsyncJob: true,
|
||||
inProcessText: "Rebooting Instance....",
|
||||
asyncJobResponse: "rebootvirtualmachineresponse",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
//call listVirtualMachine to get embedded object until Bug 6751("rebootVirtualMachine API should return an embedded object") is fixed.
|
||||
@ -273,6 +276,7 @@ function initDestroyVMButton() {
|
||||
var apiInfo = {
|
||||
label: "Destroy Instance",
|
||||
isAsyncJob: true,
|
||||
inProcessText: "Destroying Instance....",
|
||||
asyncJobResponse: "destroyvirtualmachineresponse",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
//call listVirtualMachine to get embedded object until bug 6041 ("DestroyVirtualMachine API should return an embedded object on success") is fixed.
|
||||
|
||||
@ -342,14 +342,20 @@ function buildActionLinkForMidMenu(label, actionMap, $actionMenu) {
|
||||
function doActionForMidMenu(id, apiInfo, apiCommand) {
|
||||
var label = apiInfo.label;
|
||||
var isAsyncJob = apiInfo.isAsyncJob;
|
||||
var inProcessText = apiInfo.inProcessText;
|
||||
var asyncJobResponse = apiInfo.asyncJobResponse;
|
||||
var afterActionSeccessFn = apiInfo.afterActionSeccessFn;
|
||||
var afterActionSeccessFn = apiInfo.afterActionSeccessFn;
|
||||
|
||||
var $midmenuItem1 = $("#midmenuItem_"+id);
|
||||
$midmenuItem1.find("#content").removeClass("selected").addClass("inaction");
|
||||
$midmenuItem1.find("#spinning_wheel").addClass("midmenu_addingloader").show();
|
||||
$midmenuItem1.find("#info_icon").hide();
|
||||
|
||||
var $detailsTab = $("#right_panel_content #tab_content_details");
|
||||
var $spinningWheel = $detailsTab.find("#spinning_wheel");
|
||||
$spinningWheel.find("#description").text(inProcessText);
|
||||
$spinningWheel.show();
|
||||
|
||||
//Async job (begin) *****
|
||||
if(isAsyncJob == true) {
|
||||
$.ajax({
|
||||
@ -372,7 +378,8 @@ function doActionForMidMenu(id, apiInfo, apiCommand) {
|
||||
} else {
|
||||
$("body").stopTime(timerKey);
|
||||
$midmenuItem1.find("#content").removeClass("inaction");
|
||||
$midmenuItem1.find("#spinning_wheel").hide();
|
||||
$midmenuItem1.find("#spinning_wheel").hide();
|
||||
hideDetailsTabActionSpinningWheel(id, inProcessText);
|
||||
if (result.jobstatus == 1) { // Succeeded
|
||||
$midmenuItem1.find("#info_icon").removeClass("error").show();
|
||||
$midmenuItem1.data("afterActionInfo", (label + " action succeeded."));
|
||||
@ -409,7 +416,8 @@ function doActionForMidMenu(id, apiInfo, apiCommand) {
|
||||
$midmenuItem1.find("#content").removeClass("inaction");
|
||||
$midmenuItem1.find("#spinning_wheel").hide();
|
||||
$midmenuItem1.find("#info_icon").removeClass("error").show();
|
||||
$midmenuItem1.data("afterActionInfo", (label + " action succeeded."));
|
||||
$midmenuItem1.data("afterActionInfo", (label + " action succeeded."));
|
||||
hideDetailsTabActionSpinningWheel(id, inProcessText);
|
||||
afterActionSeccessFn(json, $midmenuItem1, id);
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
@ -424,7 +432,8 @@ function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1) {
|
||||
$midmenuItem1.find("#content").removeClass("inaction");
|
||||
$midmenuItem1.find("#spinning_wheel").hide();
|
||||
$midmenuItem1.find("#info_icon").addClass("error").show();
|
||||
$midmenuItem1.find("#first_row").text("Action failed");
|
||||
$midmenuItem1.find("#first_row").text("Action failed");
|
||||
hideDetailsTabActionSpinningWheel(id, inProcessText);
|
||||
|
||||
var errorMsg = "";
|
||||
if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) {
|
||||
@ -438,6 +447,15 @@ function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1) {
|
||||
$midmenuItem1.find("#second_row").html(" ");
|
||||
}
|
||||
|
||||
function hideDetailsTabActionSpinningWheel(id, inProcessText) {
|
||||
var $detailsTab = $("#right_panel_content #tab_content_details");
|
||||
var jsonObj = $detailsTab.data("jsonObj");
|
||||
var $spinningWheel = $detailsTab.find("#spinning_wheel");
|
||||
if(jsonObj != null && ("id" in jsonObj) && jsonObj.id == id && ($spinningWheel.find("#description").text() == inProcessText)) {
|
||||
$spinningWheel.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function handleAsyncJobFailInMidMenu(errorMsg, $midmenuItem1) {
|
||||
$midmenuItem1.find("#content").removeClass("inaction");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user