cloudstack 3.0 UI - Instance page - detail view - keep polling newest info from server if VM state is Starting or Stopping.

This commit is contained in:
Jessica Wang 2012-05-21 15:36:27 -07:00
parent 737543ce3e
commit 0282f2d8c9
3 changed files with 47 additions and 20 deletions

View File

@ -1549,11 +1549,31 @@
},
fields: [
{
{
displayname: { label: 'label.display.name', isEditable: true },
instancename: { label: 'label.internal.name' },
state: { label: 'label.state' },
state: {
label: 'label.state',
pollAgainIfValueIsIn: {
'Starting': 1,
'Stopping': 1
},
pollAgainFn: function(context) { //???
var toClearInterval = false;
$.ajax({
url: createURL("listVirtualMachines&id=" + context.instances[0].id),
dataType: "json",
async: false,
success: function(json) {
var jsonObj = json.listvirtualmachinesresponse.virtualmachine[0];
if(jsonObj.state != context.instances[0].state) {
toClearInterval = true; //to clear interval
}
}
});
return toClearInterval;
}
},
hypervisor: { label: 'label.hypervisor' },
templatename: { label: 'label.template' },
guestosid: {

View File

@ -950,7 +950,22 @@
label: 'label.state',
pollAgainIfValueIsIn: {
'UploadNotStarted': 1
}
},
pollAgainFn: function(context) { //???
var toClearInterval = false;
$.ajax({
url: createURL("listVolumes&id=" + context.volumes[0].id),
dataType: "json",
async: false,
success: function(json) {
var jsonObj = json.listvolumesresponse.volume[0];
if(jsonObj.state != context.volumes[0].state) {
toClearInterval = true; //to clear interval
}
}
});
return toClearInterval;
}
},
type: { label: 'label.type' },
storagetype: { label: 'label.storage.type' },

View File

@ -685,22 +685,14 @@
//???
if("pollAgainIfValueIsIn" in value) {
if (content in value.pollAgainIfValueIsIn) {
//poll again
var intervalKey = setInterval(function() {
$.ajax({
url: createURL("listVolumes&id=" + context.volumes[0].id),
dataType: "json",
async: true,
success: function(json) {
var jsonObj = json.listvolumesresponse.volume[0];
if(jsonObj[key] != content) {
//if(jsonObj[key] == content) { //for testing, remove it before check in
clearInterval(intervalKey);
$('.detail-view .toolbar .button.refresh').click(); //click Refresh button to refresh detailView
}
}
});
if ((content in value.pollAgainIfValueIsIn) && (value.pollAgainFn != null)) {
//poll again
var intervalKey = setInterval(function() {
var toClearInterval = value.pollAgainFn(context);
if(toClearInterval == true) {
clearInterval(intervalKey);
$('.detail-view .toolbar .button.refresh').click(); //click Refresh button to refresh detailView
}
}, 5000);
}
}