Commit c1539b90 by Torkel Ödegaard

minor update to dashboard search

parent 9ace21b6
......@@ -56,14 +56,14 @@
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
<div ng-repeat="section in ctrl.results" class="search-section">
<a class="search-section__header pointer" ng-show="::section.title" ng-click="ctrl.toggleFolder(section)">
<a class="search-section__header pointer" ng-hide="section.hideHeader" ng-click="ctrl.toggleFolder(section)">
<i class="search-section__header__icon" ng-class="section.icon"></i>
<span class="search-section__header__text">{{::section.title}}</span>
<i class="fa fa-minus search-section__header__toggle" ng-hide="section.collapsed"></i>
<i class="fa fa-plus search-section__header__toggle" ng-show="section.collapsed"></i>
<i class="fa fa-minus search-section__header__toggle" ng-show="section.expanded"></i>
<i class="fa fa-plus search-section__header__toggle" ng-hide="section.expanded"></i>
</a>
<div ng-if="!section.collapsed">
<div ng-if="section.expanded">
<a ng-repeat="item in section.items" class="search-item" ng-class="{'selected': item.selected}" ng-href="{{::item.url}}">
<span class="search-item__icon">
<i class="fa fa-th-large"></i>
......
......@@ -151,9 +151,9 @@ export class SearchCtrl {
this.searchDashboards();
}
// toggleFolder(section) {
// this.searchSrv.toggleFolder(section);
// }
toggleFolder(section) {
this.searchSrv.toggleFolder(section);
}
}
export function searchDirective() {
......
......@@ -34,6 +34,7 @@ export class SearchSrv {
items: [],
icon: 'fa fa-folder-open',
score: _.keys(sections).length,
expanded: true,
};
for (let hit of results) {
......@@ -54,14 +55,16 @@ export class SearchSrv {
return this.browse();
}
options.folderIds = [];
options.type = 'dash-db';
let query = _.clone(options);
query.folderIds = [];
query.type = 'dash-db';
return this.backendSrv.search(options).then(results => {
return this.backendSrv.search(query).then(results => {
let section = {
hideHeader: true,
items: [],
expanded: true,
};
for (let hit of results) {
......@@ -76,6 +79,25 @@ export class SearchSrv {
});
}
toggleFolder(section) {
section.expanded = !section.expanded;
if (section.items.length) {
return;
}
let query = {
folderIds: [section.id]
};
return this.backendSrv.search(query).then(results => {
for (let hit of results) {
hit.url = 'dashboard/' + hit.uri;
section.items.push(hit);
}
});
}
getDashboardTags() {
return this.backendSrv.get('/api/dashboards/tags');
}
......
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