Commit 7be7b07c by Torkel Ödegaard

Changed search result model to be more datasource agnostic

parent 88c46f46
......@@ -61,7 +61,7 @@ function (angular, _, config, $) {
$scope.searchDashboards = function(queryString) {
return $scope.db.searchDashboards(queryString)
.then(function(results) {
$scope.tagsOnly = results.dashboards.length === 0 && results.tags.length > 0;
$scope.tagsOnly = results.tagsOnly;
$scope.results.dashboards = results.dashboards;
$scope.results.tags = results.tags;
});
......
......@@ -211,7 +211,17 @@ function (angular, _, $, config, kbn, moment) {
return { dashboards: [], tags: [] };
}
return { dashboards: results.hits.hits, tags: results.facets.terms || [] };
var hits = { dashboards: [], tags: results.facets.tags.terms || [] };
for (var i = 0; i < results.hits.hits.length; i++) {
hits.dashboards.push({
id: results.hits.hits[i]._id,
tags: results.hits.hits[i]._source.tags
});
}
hits.tagsOnly = tagsOnly;
return hits;
});
};
......
......@@ -282,11 +282,12 @@ function (angular, _, kbn, InfluxSeries) {
}
return this._seriesQuery(influxQuery).then(function(results) {
var hits = { dashboards: [], tags: [], tagsOnly: false };
if (!results || !results.length) {
return { dashboards: [], tags: [] };
return hits;
}
var dashList = [];
var dashCol = _.indexOf(results[0].columns, 'title');
var tagsCol = _.indexOf(results[0].columns, 'tags');
......@@ -296,9 +297,9 @@ function (angular, _, kbn, InfluxSeries) {
tags: results[i].points[0][tagsCol].split(",")
};
hit.tags = hit.tags[0] ? hit.tags : [];
dashList.push(hit);
hits.dashboards.push(hit);
}
return { dashboards: dashList, tags: [] };
return hits;
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment