From 0b6c9fed5e80d22acef62ad8760e338d7274fa6a Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 30 Mar 2012 16:15:06 -0700 Subject: [PATCH] bug 12421: cloudstack 3.0 UI - infrastructure page - cluster section - add an extra property ("state" property) to cluster object from API call. "state" property is not returned by API call. "state" property's value is determined by "managestate" property and "allocation" property returned by API call. --- ui/scripts/system.js | 48 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 1a9aede675e..88a4b79a4fb 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -4791,13 +4791,8 @@ async: true, success: function(json) { var items = json.listclustersresponse.cluster; - $(items).each(function(){ - if(this.managedstate == "Managed") { - this.state = this.allocationstate; //this.state == Enabled, Disabled - } - else { - this.state = this.managedstate; //this.state == Unmanaged, PrepareUnmanaged, PrepareUnmanagedError - } + $(items).each(function(){ + addExtraPropertiesToClusterObject(this); }); args.response.success({ @@ -4989,7 +4984,8 @@ dataType: "json", async: true, success: function(json) { - var item = json.updateclusterresponse.cluster; + var item = json.updateclusterresponse.cluster; + addExtraPropertiesToClusterObject(item); args.response.success({ actionFilter: clusterActionfilter, data:item @@ -5020,7 +5016,8 @@ dataType: "json", async: true, success: function(json) { - var item = json.updateclusterresponse.cluster; + var item = json.updateclusterresponse.cluster; + addExtraPropertiesToClusterObject(item); args.response.success({ actionFilter: clusterActionfilter, data:item @@ -5051,7 +5048,8 @@ dataType: "json", async: true, success: function(json) { - var item = json.updateclusterresponse.cluster; + var item = json.updateclusterresponse.cluster; + addExtraPropertiesToClusterObject(item); args.response.success({ actionFilter: clusterActionfilter, data:item @@ -5082,7 +5080,8 @@ dataType: "json", async: true, success: function(json) { - var item = json.updateclusterresponse.cluster; + var item = json.updateclusterresponse.cluster; + addExtraPropertiesToClusterObject(item); args.response.success({ actionFilter: clusterActionfilter, data:item @@ -5141,11 +5140,19 @@ state: { label: 'label.state' } } ], - dataProvider: function(args) { - args.response.success({ - actionFilter: clusterActionfilter, - data: args.context.clusters[0] - }); + dataProvider: function(args) { + $.ajax({ + url: createURL("listClusters&id=" + args.context.clusters[0].id), + dataType: "json", + success: function(json) { + var item = json.listclustersresponse.cluster[0]; + addExtraPropertiesToClusterObject(item); + args.response.success({ + actionFilter: clusterActionfilter, + data: item + }); + } + }); } } } @@ -7463,4 +7470,13 @@ } }; + var addExtraPropertiesToClusterObject = function(jsonObj) { + if(jsonObj.managedstate == "Managed") { + jsonObj.state = jsonObj.allocationstate; //jsonObj.state == Enabled, Disabled + } + else { + jsonObj.state = jsonObj.managedstate; //jsonObj.state == Unmanaged, PrepareUnmanaged, PrepareUnmanagedError + } + } + })($, cloudStack);