mirror of
https://github.com/nasa/openmct.git
synced 2025-02-01 08:48:28 +00:00
[Search] Cleanup
Added and removed some comments, for clarity
This commit is contained in:
parent
d7dd53c2da
commit
c92d15ba42
@ -30,13 +30,14 @@ define(function () {
|
|||||||
// JSLint doesn't like underscore-prefixed properties,
|
// JSLint doesn't like underscore-prefixed properties,
|
||||||
// so hide them here.
|
// so hide them here.
|
||||||
var ID = "_id",
|
var ID = "_id",
|
||||||
SOURCE = "_source";
|
SOURCE = "_source"; // TODO: Do we need this one?
|
||||||
|
|
||||||
function SearchController($scope, $http, objectService, queryService, ROOT) {
|
function SearchController($scope, $http, objectService, queryService, ROOT) {
|
||||||
|
|
||||||
/*
|
// Search through items for items manually
|
||||||
// Search through items for items which contain the search term in the name
|
// This is a fallback if other search services aren't avaliable
|
||||||
function search() {
|
// ... currently only searches 1 layer down (TODO)
|
||||||
|
function searchFallback() {
|
||||||
var term,
|
var term,
|
||||||
searchResults = [],
|
searchResults = [],
|
||||||
itemsLength,
|
itemsLength,
|
||||||
@ -70,14 +71,14 @@ define(function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.results = searchResults; // Some redundancy
|
//$scope.results = searchResults; // Some redundancy
|
||||||
return searchResults;
|
return searchResults;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
function search2() {
|
// Use elasticsearch's search to search through all the objects
|
||||||
var term = document.getElementById("searchinput").value;
|
function searchElastic() {
|
||||||
|
var searchTerm = document.getElementById("searchinput").value;
|
||||||
|
|
||||||
// Get the data...
|
// Get the data...
|
||||||
return $http({
|
return $http({
|
||||||
@ -86,7 +87,7 @@ define(function () {
|
|||||||
data: {
|
data: {
|
||||||
query: {
|
query: {
|
||||||
term: {
|
term: {
|
||||||
name: term
|
name: searchTerm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,12 +98,14 @@ define(function () {
|
|||||||
ids = [],
|
ids = [],
|
||||||
i;
|
i;
|
||||||
|
|
||||||
|
//console.log('raw results', rawResults);
|
||||||
|
|
||||||
// Get the result objects' IDs
|
// Get the result objects' IDs
|
||||||
for (i = 0; i < resultsLength; i++) {
|
for (i = 0; i < resultsLength; i++) {
|
||||||
ids.push(results[i][ID]);
|
ids.push(results[i][ID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the objects themselves from their IDs
|
// Get the domain objects from their IDs
|
||||||
return objectService.getObjects(ids).then(function (objects) {
|
return objectService.getObjects(ids).then(function (objects) {
|
||||||
var output = [],
|
var output = [],
|
||||||
id,
|
id,
|
||||||
@ -120,16 +123,16 @@ define(function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('final output', output);
|
//console.log('final output', output);
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Search the database using the user input from id "searchinput"
|
// Search the database using the user input of id "searchinput"
|
||||||
search: function () {
|
search: function () {
|
||||||
search2().then( function (c) {
|
searchElastic().then( function (c) {
|
||||||
$scope.results = c;
|
$scope.results = c;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -146,37 +149,3 @@ define(function () {
|
|||||||
}
|
}
|
||||||
return SearchController;
|
return SearchController;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
///// Old stuff to look at later
|
|
||||||
|
|
||||||
// Recursive search
|
|
||||||
/*
|
|
||||||
var subList = [current],
|
|
||||||
i;
|
|
||||||
console.log('children ', children);
|
|
||||||
for (i = 0; i < children.length; i += 1) {
|
|
||||||
console.log('children[', i, ']', children[i]);
|
|
||||||
subList.push(listHelper(children[i]));
|
|
||||||
console.log('subList', subList, 'index', i);
|
|
||||||
}
|
|
||||||
console.log('sublist ', subList);
|
|
||||||
return subList;
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
var array = [current].concat(children.forEach(listHelper));
|
|
||||||
console.log('array ', array);
|
|
||||||
return array;
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
var subList = [];//= Promise.all([]);
|
|
||||||
subList.push(current);
|
|
||||||
for (var i = 0, len = children.length; i < len; i++) {
|
|
||||||
listHelper(children[i]).then(function (c) {
|
|
||||||
subList.concat(c);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return subList;//.then(function (c) {
|
|
||||||
// return c;
|
|
||||||
//});
|
|
||||||
*/
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user