You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2012/10/17 10:50:11 UTC

[9/50] [abbrv] git commit: cloudstack UI - advanced search - implement advanced search on instance page which has filter dropdown in listView.

cloudstack UI - advanced search - implement advanced search on instance page which has filter dropdown in listView.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/56496a23
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/56496a23
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/56496a23

Branch: refs/heads/regions
Commit: 56496a235f2234eafbb2f281cf0ac583204264cd
Parents: c9bd605
Author: Jessica Wang <je...@citrix.com>
Authored: Tue Oct 2 16:37:17 2012 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Tue Oct 2 16:38:23 2012 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js |   78 ++++++++++++++++++++++-------------------
 1 files changed, 42 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/56496a23/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 3537c6a..6eb18eb 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -266,44 +266,50 @@
       },
 
       dataProvider: function(args) {
-        var array1 = [];
-        if(args.filterBy != null) {
-          if(args.filterBy.kind != null) {
-            switch(args.filterBy.kind) {
-            case "all":
-              array1.push("&listAll=true");
-              break;
-            case "mine":
-              if (!args.context.projects) array1.push("&domainid=" + g_domainid + "&account=" + g_account);
-              break;
-            case "running":
-              array1.push("&listAll=true&state=Running");
-              break;
-            case "stopped":
-              array1.push("&listAll=true&state=Stopped");
-              break;
-            case "destroyed":
-              array1.push("&listAll=true&state=Destroyed");
-              break;
-            }
-          }
-          if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) {
-            switch(args.filterBy.search.by) {
-            case "name":
-              if(args.filterBy.search.value.length > 0)
-                array1.push("&keyword=" + args.filterBy.search.value);
-              break;
-            }
-          }
-        }
-
-        if("hosts" in args.context)
-          array1.push("&hostid=" + args.context.hosts[0].id);
+			  var data = {};
+				listViewDataProvider(args, data);		
+				        				
+				if(args.filterBy != null) {	//filter dropdown
+					if(args.filterBy.kind != null) {
+						switch(args.filterBy.kind) {
+						case "all":						  						
+							break;
+						case "mine":
+							if (!args.context.projects) {
+							  $.extend(data, {
+								  domainid: g_domainid, 
+									account: g_account
+								});		
+              }								
+							break;
+						case "running":
+						  $.extend(data, {
+							  state: 'Running'
+							});						
+							break;
+						case "stopped":
+						  $.extend(data, {
+							  state: 'Stopped'
+							});	
+							break;
+						case "destroyed":
+						  $.extend(data, {
+							  state: 'Destroyed'
+							});									
+							break;
+						}
+					}					
+				}
+								
+        if("hosts" in args.context) {          
+					$.extend(data, {
+					  hostid: args.context.hosts[0].id
+					});
+				}
 
         $.ajax({
-          url: createURL("listVirtualMachines&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
-          dataType: "json",
-          async: true,
+          url: createURL('listVirtualMachines'),
+          data: data,          
           success: function(json) {
             var items = json.listvirtualmachinesresponse.virtualmachine;