diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index e7767f6442b..3af5761eaaa 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -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: { diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 730267dcf94..2f70ef8cb32 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -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' }, diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index f31756eed9a..17292ffa2a4 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -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); } }