Support filtering volumes by name (in a case-insensitive fashion)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9ecc358a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9ecc358a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9ecc358a Branch: refs/heads/sf-plugins Commit: 9ecc358a2d99740fda1cdd2107453d77305a8519 Parents: 6456534 Author: Mike Tutkowski <[email protected]> Authored: Fri Jul 10 13:49:02 2015 -0600 Committer: Mike Tutkowski <[email protected]> Committed: Fri Sep 18 19:28:20 2015 -0600 ---------------------------------------------------------------------- ui/plugins/sfSharedVolume/sfSharedVolume.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ecc358a/ui/plugins/sfSharedVolume/sfSharedVolume.js ---------------------------------------------------------------------- diff --git a/ui/plugins/sfSharedVolume/sfSharedVolume.js b/ui/plugins/sfSharedVolume/sfSharedVolume.js index f2182f6..6d4c791 100644 --- a/ui/plugins/sfSharedVolume/sfSharedVolume.js +++ b/ui/plugins/sfSharedVolume/sfSharedVolume.js @@ -19,9 +19,24 @@ dataProvider: function(args) { plugin.ui.apiCall('listSolidFireVolumes', { success: function(json) { + var sfvolumesfiltered = []; var sfvolumes = json.listsolidfirevolumesresponse.sfvolume; + var search = args.filterBy.search.value == null ? "" : args.filterBy.search.value.toLowerCase(); - args.response.success({ data: sfvolumes }); + if (search == "") { + sfvolumesfiltered = sfvolumes; + } + else { + for (i = 0; i < sfvolumes.length; i++) { + sfvolume = sfvolumes[i]; + + if (sfvolume.name.toLowerCase().indexOf(search) > -1 ) { + sfvolumesfiltered.push(sfvolume); + } + } + } + + args.response.success({ data: sfvolumesfiltered }); }, error: function(errorMessage) { args.response.error(errorMessage);
