diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 3537c6a9d1d..6eb18eb21e6 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;