cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/master to 6a396a9
Date Thu, 07 Nov 2013 19:46:28 GMT
Updated Branches:
  refs/heads/master 62286fcc6 -> 6a396a905


CLOUDSTACK-4793: UI > Infrastructure > Virtual Routers > listView > implement
Advanced Search by name/zone/pod/domain/account.


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

Branch: refs/heads/master
Commit: 6a396a90576c7e29bb3cfa00957fe06b96319d2b
Parents: 62286fc
Author: Jessica Wang <jessicawang@apache.org>
Authored: Thu Nov 7 11:45:53 2013 -0800
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Thu Nov 7 11:46:19 2013 -0800

----------------------------------------------------------------------
 ui/scripts/system.js | 176 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 148 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a396a90/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index e568a6d..8c03e75 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -7394,41 +7394,57 @@
                         },
                         virtualRouters: function() {
                             var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView,
{
-                                dataProvider: function(args) {
-                                    var searchByArgs = args.filterBy.search.value.length
?
-                                        '&keyword=' + args.filterBy.search.value : '';
-
+                                dataProvider: function(args) {                          
     	
+                                	var data = {};
+                                    listViewDataProvider(args, data);
+                                	
                                     var routers = [];
+                                    
+                                    //get account-owned routers
                                     $.ajax({
-                                        url: createURL("listRouters&listAll=true&page="
+ args.page + "&pagesize=" + pageSize + searchByArgs),
-                                        async: true,
+                                        url: createURL('listRouters'),
+                                        data: $.extend(data,{
+                                        	listAll: true
+                                        }), 
+                                        async: false,
                                         success: function(json) {
-                                            var items = json.listroutersresponse.router ?
-                                                json.listroutersresponse.router : [];
-
+                                            var items = json.listroutersresponse.router ?
json.listroutersresponse.router : [];
                                             $(items).map(function(index, item) {
                                                 routers.push(item);
                                             });
-
-                                            // Get project routers
-                                            $.ajax({
-                                                url: createURL("listRouters&listAll=true&page="
+ args.page + "&pagesize=" + pageSize + "&projectid=-1"),
-                                                async: true,
-                                                success: function(json) {
-                                                    var items = json.listroutersresponse.router
?
-                                                        json.listroutersresponse.router :
[];
-
-                                                    $(items).map(function(index, item) {
-                                                        routers.push(item);
-                                                    });
-                                                    args.response.success({
-                                                        actionFilter: routerActionfilter,
-                                                        data: $(routers).map(mapRouterType)
-                                                    });
-                                                }
-                                            });
+                                              
+                                            //get project-owned routers
+                                            var toSearchByProjectid = true;             
                              
+                                            if (args.filterBy != null) {
+                                            	if (args.filterBy.advSearch != null &&
typeof(args.filterBy.advSearch) == "object") { //advanced search
+                                            		if ('account' in args.filterBy.advSearch  &&
args.filterBy.advSearch.account.length > 0) { //if account is specified in advanced search,
don't search project-owned routers
+                                            			toSearchByProjectid = false;  //since account
and projectid can't be specified together
+                                            		}
+                                            	}
+                                            }
+                                            if (toSearchByProjectid) {                  
                          	
+	                                            $.ajax({
+	                                            	url: createURL('listRouters'),            
                                    
+	                                                data: $.extend(data,{
+	                                                	listAll: true,
+	                                                	projectid: -1
+	                                                }), 
+	                                                async: false,
+	                                                success: function(json) {
+	                                                    var items = json.listroutersresponse.router
? json.listroutersresponse.router : [];	
+	                                                    $(items).map(function(index, item) {
+	                                                        routers.push(item);
+	                                                    });
+	                                                }
+	                                            });
+                                            }
                                         }
-                                    });
+                                    });                                    
+
+                                    args.response.success({
+                                        actionFilter: routerActionfilter,
+                                        data: $(routers).map(mapRouterType)
+                                    });                                    
                                 },
 
                                 detailView: {
@@ -7558,6 +7574,110 @@
                             }
                         }
                     },
+                                        
+                    advSearchFields: {
+                        name: {
+                            label: 'Name'
+                        },
+                        zoneid: {
+                            label: 'Zone',
+                            select: function(args) {
+                                $.ajax({
+                                    url: createURL('listZones'),
+                                    data: {
+                                        listAll: true
+                                    },
+                                    success: function(json) {
+                                        var zones = json.listzonesresponse.zone ? json.listzonesresponse.zone
: [];
+
+                                        args.response.success({
+                                            data: $.map(zones, function(zone) {
+                                                return {
+                                                    id: zone.id,
+                                                    description: zone.name
+                                                };
+                                            })
+                                        });
+                                    }
+                                });
+                            }
+                        },                        
+                        podid: {
+                            label: 'Pod',
+                            dependsOn: 'zoneid',
+                            select: function (args) {                            	
+                                $.ajax({
+                                    url: createURL("listPods&zoneid=" + args.zoneid),
+                                    dataType: "json",
+                                    async: true,
+                                    success: function (json) {                          
         
+                                        var pods = json.listpodsresponse.pod ? json.listpodsresponse.pod
: [];
+                                        args.response.success({
+                                            data: $.map(pods, function(pod) {
+                                                return {
+                                                    id: pod.id,
+                                                    description: pod.name
+                                                };
+                                            })
+                                        });                                        
+                                    }
+                                });
+                            }
+                        },                                                
+                        domainid: {
+                            label: 'Domain',
+                            select: function(args) {
+                                if (isAdmin() || isDomainAdmin()) {
+                                    $.ajax({
+                                        url: createURL('listDomains'),
+                                        data: {
+                                            listAll: true,
+                                            details: 'min'
+                                        },
+                                        success: function(json) {
+                                            var array1 = [{
+                                                id: '',
+                                                description: ''
+                                            }];
+                                            var domains = json.listdomainsresponse.domain;
+                                            if (domains != null && domains.length
> 0) {
+                                                for (var i = 0; i < domains.length; i++)
{
+                                                    array1.push({
+                                                        id: domains[i].id,
+                                                        description: domains[i].path
+                                                    });
+                                                }
+                                            }
+                                            args.response.success({
+                                                data: array1
+                                            });
+                                        }
+                                    });
+                                } else {
+                                    args.response.success({
+                                        data: null
+                                    });
+                                }
+                            },
+                            isHidden: function(args) {
+                                if (isAdmin() || isDomainAdmin())
+                                    return false;
+                                else
+                                    return true;
+                            }
+                        },
+
+                        account: {
+                            label: 'Account',
+                            isHidden: function(args) {
+                                if (isAdmin() || isDomainAdmin())
+                                    return false;
+                                else
+                                    return true;
+                            }
+                        }
+                    },                    
+                    
                     dataProvider: function(args) {
                         var array1 = [];
                         if (args.filterBy != null) {


Mime
View raw message