Added Tree Explorer Search
Change-Id: I3de5ec2ad84526b6308f37f4a6df7396175d183a
diff --git a/client/catalog/js/catalog.js b/client/catalog/js/catalog.js
index 347366e..3f703cb 100644
--- a/client/catalog/js/catalog.js
+++ b/client/catalog/js/catalog.js
@@ -81,11 +81,23 @@
this.filterSetup();
this.searchInput.autoComplete(function(field, callback){
- scope.autoComplete(field, callback);
+ scope.autoComplete(field, function(list){
+ callback(list.map(function(element){
+ return field + element + "/";
+ }));
+ });
});
this.searchBar.submit(function(e){
e.preventDefault();
+ if (scope.searchInput.val().length === 0){
+ if (!scope.searchBar.hasClass('has-error')){
+ scope.searchBar.addClass('has-error').append('<span class="help-block">Search path is required!</span>');
+ }
+ return;
+ } else {
+ scope.searchBar.removeClass('has-error').find('.help-block').fadeOut(function(){$(this).remove()});
+ }
scope.pathSearch();
});
@@ -120,6 +132,16 @@
});
+ $('#treeSearch div').treeExplorer(function(path, callback){
+ console.log("Tree Explorer request", path);
+ scope.autoComplete(path, function(list){
+ console.log("Autocomplete response", list);
+ callback(list.map(function(element){
+ return (path == "/"?"/":"") + element + "/";
+ }));
+ })
+ });
+
}
Atmos.prototype.clearResults = function(){
@@ -182,15 +204,6 @@
Atmos.prototype.autoComplete = function(field, callback){
- if (this.searchInput.val().length === 0 && !filters.hasOwnProperty()){
- if (!this.searchBar.hasClass('has-error')){
- this.searchBar.addClass('has-error').append('<span class="help-block">A filter or search value is required!</span>');
- }
- return;
- } else {
- this.searchBar.removeClass('has-error').find('.help-block').fadeOut(function(){$(this).remove()});
- }
-
var scope = this;
this.query(this.catalog, {"?": field},
@@ -206,10 +219,9 @@
function(interest, data){
if (data.getContent().length !== 0){
- var options = JSON.parse(data.getContent().toString().replace(/[\n\0]/g, "")).next.map(function(element){
- return field + element + "/";
- });
- callback(options);
+ callback(JSON.parse(data.getContent().toString().replace(/[\n\0]/g, "")).next);
+ } else {
+ callback([]);
}
}, function(interest){