mirror of
https://github.com/nasa/openmct.git
synced 2025-03-28 14:48:42 +00:00
[Search] Changed variable names
Because of the async funtion, changed variable names in serach2 to make more clear.
This commit is contained in:
parent
b994b2a862
commit
75ce5cd0e9
@ -29,7 +29,8 @@ 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";
|
||||||
|
|
||||||
function SearchController($scope, $http, objectService, queryService, ROOT) {
|
function SearchController($scope, $http, objectService, queryService, ROOT) {
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ define(function () {
|
|||||||
var term = document.getElementById("searchinput").value;
|
var term = document.getElementById("searchinput").value;
|
||||||
|
|
||||||
// Get the data...
|
// Get the data...
|
||||||
$http({
|
$scope.results = $http({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: ROOT + "/_search",
|
url: ROOT + "/_search",
|
||||||
data: {
|
data: {
|
||||||
@ -87,38 +88,38 @@ define(function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(function (raw) {
|
}).then(function (rawResults) {
|
||||||
// ...then process the data
|
// ...then process the data
|
||||||
var output = raw.data.hits.hits,
|
var results = rawResults.data.hits.hits,
|
||||||
outputLength = output.length,
|
resultsLength = results.length,
|
||||||
|
output,
|
||||||
id,
|
id,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
console.log('raw', raw);
|
console.log('raw', rawResults);
|
||||||
console.log('output, pre', output);
|
console.log('results, pre', results);
|
||||||
|
|
||||||
for (i = 0; i < outputLength; i++) {
|
for (i = 0; i < resultsLength; i++) {
|
||||||
// Get the object's ID
|
// Get the object's ID
|
||||||
output[i] = output[i][ID];
|
results[i] = results[i][ID];
|
||||||
console.log('output [', i, ']', output[i]);
|
console.log('output [', i, ']', output[i]);
|
||||||
|
|
||||||
// Get the object itself from its ID
|
// Get the object itself from its ID
|
||||||
objectService.getObjects([ output[i] ]).then(function (obj) {
|
objectService.getObjects([ results[i] ]).then(function (obj) {
|
||||||
output[i] = obj;
|
|
||||||
// Manually get the member name to get to the actual object
|
// Manually get the member name to get to the actual object
|
||||||
for (var prop in output[i]) {
|
for (var prop in obj) {
|
||||||
console.log('prop [', i, ']', output[i][prop]);
|
console.log('prop [', i, ']', obj[prop]);
|
||||||
output[i] = output[i][prop];
|
output.push(obj[prop]);
|
||||||
debugger;
|
debugger;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('results [', i, ']', results[i]);
|
||||||
console.log('output [', i, ']', output[i]);
|
console.log('output [', i, ']', output[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log('results, post', results);
|
||||||
console.log('output, post', output);
|
console.log('output, post', output);
|
||||||
|
|
||||||
// Don't need to return, just set scope's version
|
return output;
|
||||||
$scope.results = output;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user