cloudstack UI - add advanced search on Event page.

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

Branch: refs/heads/javelin
Commit: a2a1e19e70a94d0121a0e844ed54f9168c5ed235
Parents: 9e1b5b5
Author: Jessica Wang <[email protected]>
Authored: Thu Oct 4 15:33:15 2012 -0700
Committer: Jessica Wang <[email protected]>
Committed: Thu Oct 4 15:36:25 2012 -0700

----------------------------------------------------------------------
 ui/scripts/events.js |   75 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 61 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2a1e19e/ui/scripts/events.js
----------------------------------------------------------------------
diff --git a/ui/scripts/events.js b/ui/scripts/events.js
index ab7a667..a8e7085 100644
--- a/ui/scripts/events.js
+++ b/ui/scripts/events.js
@@ -36,27 +36,74 @@
           label: 'label.menu.events',
           fields: {            
             description: { label: 'label.description' },
+                                               level: { label: 'label.level' },
             domain: { label: 'label.domain' },
                                                account: { label: 
'label.account' },
             created: { label: 'label.date', converter: 
cloudStack.converters.toLocalDate }
           },
-          dataProvider: function(args) {                                       
  
-                                               var array1 = [];  
-                                               if(args.filterBy != null) {     
     
-                                                       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;
-                                                               }
+                                                                               
+                                       advSearchFields: {      
+            level: {
+                                                 label: 'label.level',
+                                                       select: function(args) {
+                                                         
args.response.success({
+                                                                       data: [
+                                                                         {id: 
'', description: ''}, 
+                                                                         {id: 
'INFO', description: 'INFO'}, 
+                                                                               
{id: 'WARN', description: 'WARN'}, 
+                                                                               
{id: 'ERROR', description: 'ERROR'}
+                                                                       ]
+                                                               });
                                                        }
-                                               }
+                                               },                              
        
+                                               domainid: {                     
                
+                                                       label: 'Domain',        
                                
+                                                       select: function(args) {
+                                                               $.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
+                                                                               
});
+                                                                       }
+                                                               });
+                                                       },
+                                                       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 data = {};
+                                               listViewDataProvider(args, 
data);                                               
                                                
             $.ajax({
-              url: createURL("listEvents&listAll=true&page=" + args.page + 
"&pagesize=" + pageSize + array1.join("")),
-              dataType: "json",
-              async: true,
+              url: createURL('listEvents'),
+              data: data,              
               success: function(json) {
                 var items = json.listeventsresponse.event;
                 args.response.success({data:items});

Reply via email to