mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Changed search result model to be more datasource agnostic
This commit is contained in:
@@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user