From 3b51b1865fb44cd2fde3d7796ea53541cb6e403c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 21 May 2012 14:02:48 -0700 Subject: [PATCH 1/4] CS-15015: cloudstack 3.0 UI - detailView widget - add new property "pollAgainIfValueIsIn" to keep polling newest info from server when a column has a specific value (e.g. volume state column has value 'UploadNotStarted') --- ui/scripts/storage.js | 16 ++++++++++++---- ui/scripts/ui/widgets/detailView.js | 24 +++++++++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 36d4464595f..730267dcf94 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -33,14 +33,17 @@ fields: { name: { label: 'label.name' }, type: { label: 'label.type' }, - //hypervisor: { label: 'label.hypervisor' }, - //vmdisplayname: { label: 'label.vm.display.name' }, - state: { + hypervisor: { label: 'label.hypervisor' }, + vmdisplayname: { label: 'label.vm.display.name' }, + + /* + state: { label: 'State', indicator: { 'Ready': 'on' } } + */ }, // List view actions @@ -943,7 +946,12 @@ { id: { label: 'ID' }, zonename: { label: 'label.zone' }, - state: { label: 'label.state' }, + state: { + label: 'label.state', + pollAgainIfValueIsIn: { + 'UploadNotStarted': 1 + } + }, type: { label: 'label.type' }, storagetype: { label: 'label.storage.type' }, hypervisor: { label: 'label.hypervisor' }, diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 860983252d6..14a472f8278 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -680,7 +680,29 @@ } else if (key != 'name') { isOddRow = true; } - + + //??? + 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 + } + } + }); + }, 5000); + } + } + $name.html(_l(value.label)); $value.html(_s(content)); From 5501e85c2e2fc246dce75a8b299fb5c55f41ba7f Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 21 May 2012 15:36:27 -0700 Subject: [PATCH 2/4] cloudstack 3.0 UI - Instance page - detail view - keep polling newest info from server if VM state is Starting or Stopping. --- ui/scripts/instances.js | 26 +++++++++++++++++++++++--- ui/scripts/storage.js | 17 ++++++++++++++++- ui/scripts/ui/widgets/detailView.js | 24 ++++++++---------------- 3 files changed, 47 insertions(+), 20 deletions(-) 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 14a472f8278..6e40826ae8a 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -683,22 +683,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); } } From 0e306c9a05c5dbdc22335b9255f2cc35435d3b5c Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 21 May 2012 15:33:53 -0700 Subject: [PATCH 3/4] CS-15025 listTemplates: made executable filters to work for regular user --- server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java | 3 ++- server/src/com/cloud/user/AccountManagerImpl.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index 5a16a932be0..3b66e3bd287 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -542,7 +542,8 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem } } - if (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community) && !isAdmin(caller.getType()) ) { + if (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.featured || + templateFilter == TemplateFilter.community || templateFilter == TemplateFilter.executable) && !isAdmin(caller.getType()) ) { whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")"; } diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index fd9c9c2099e..35fbfe01077 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -269,7 +269,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag @Override public boolean isAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); + return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) + || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); } @Override From 851e152dac2e34d4e916beb90701049548b567b9 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 21 May 2012 16:10:38 -0700 Subject: [PATCH 4/4] CS-15015: cloudstack 3.0 UI - detailView widget - disable "pollAgainIfValueIsIn" function for now. --- ui/scripts/ui/widgets/detailView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 6e40826ae8a..a1d7eaa01e4 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -682,6 +682,7 @@ } //??? + /* if("pollAgainIfValueIsIn" in value) { if ((content in value.pollAgainIfValueIsIn) && (value.pollAgainFn != null)) { //poll again @@ -691,9 +692,10 @@ clearInterval(intervalKey); $('.detail-view .toolbar .button.refresh').click(); //click Refresh button to refresh detailView } - }, 5000); + }, 2000); } } + */ $name.html(_l(value.label)); $value.html(_s(content));