Skip to content

Commit 5dc1d46

Browse files
author
Jessica Wang
committed
cloudstack UI - advanced search - implement advanced search on template page.
1 parent 2a0f2e0 commit 5dc1d46

1 file changed

Lines changed: 51 additions & 20 deletions

File tree

‎ui/scripts/templates.js‎

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@
4848
zonename: { label: 'label.zone' },
4949
hypervisor: { label: 'label.hypervisor' }
5050
},
51+
52+
advSearchFields: {
53+
name: { label: 'Name' },
54+
zoneid: {
55+
label: 'Zone',
56+
select: function(args) {
57+
$.ajax({
58+
url: createURL('listZones'),
59+
data: {
60+
listAll: true
61+
},
62+
success: function(json) {
63+
var zones = json.listzonesresponse.zone;
64+
65+
args.response.success({
66+
data: $.map(zones, function(zone) {
67+
return {
68+
id: zone.id,
69+
description: zone.name
70+
};
71+
})
72+
});
73+
}
74+
});
75+
}
76+
},
77+
tagKey: { label: 'Tag Key' },
78+
tagValue: { label: 'Tag Value' }
79+
},
80+
5181
reorder: cloudStack.api.actions.sort('updateTemplate', 'templates'),
5282
actions: {
5383
add: {
@@ -301,43 +331,44 @@
301331
}
302332
},
303333

304-
dataProvider: function(args) {
305-
var array1 = [];
334+
dataProvider: function(args) {
335+
var data = {};
336+
listViewDataProvider(args, data);
337+
306338
var ignoreProject = false;
307-
if(args.filterBy != null) {
339+
if(args.filterBy != null) { //filter dropdown
308340
if(args.filterBy.kind != null) {
309341
switch(args.filterBy.kind) {
310342
case "all":
311343
ignoreProject = true;
312-
array1.push("&templatefilter=all");
344+
$.extend(data, {
345+
templatefilter: 'all'
346+
});
313347
break;
314348
case "mine":
315-
array1.push("&templatefilter=self");
349+
$.extend(data, {
350+
templatefilter: 'self'
351+
});
316352
break;
317353
case "featured":
318354
ignoreProject = true;
319-
array1.push("&templatefilter=featured");
355+
$.extend(data, {
356+
templatefilter: 'featured'
357+
});
320358
break;
321359
case "community":
322360
ignoreProject = true;
323-
array1.push("&templatefilter=community");
324-
break;
325-
}
326-
}
327-
if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) {
328-
switch(args.filterBy.search.by) {
329-
case "name":
330-
if(args.filterBy.search.value.length > 0)
331-
array1.push("&keyword=" + args.filterBy.search.value);
361+
$.extend(data, {
362+
templatefilter: 'community'
363+
});
332364
break;
333365
}
334-
}
366+
}
335367
}
368+
336369
$.ajax({
337-
url: createURL("listTemplates&page=" + args.page + "&pagesize=" + pageSize + array1.join(""),
338-
{ ignoreProject: ignoreProject }),
339-
dataType: "json",
340-
async: true,
370+
url: createURL('listTemplates', { ignoreProject: ignoreProject }),
371+
data: data,
341372
success: function(json) {
342373
var items = json.listtemplatesresponse.template;
343374
args.response.success({

0 commit comments

Comments
 (0)