diff --git a/public/app/core/components/search/search.html b/public/app/core/components/search/search.html
index 00ee6cc9b20..76b2436ea35 100644
--- a/public/app/core/components/search/search.html
+++ b/public/app/core/components/search/search.html
@@ -56,14 +56,14 @@
No dashboards matching your query were found.
-
-
+
diff --git a/public/app/core/components/search/search.ts b/public/app/core/components/search/search.ts
index 2bf19b75108..7d68820dd42 100644
--- a/public/app/core/components/search/search.ts
+++ b/public/app/core/components/search/search.ts
@@ -151,9 +151,9 @@ export class SearchCtrl {
this.searchDashboards();
}
- // toggleFolder(section) {
- // this.searchSrv.toggleFolder(section);
- // }
+ toggleFolder(section) {
+ this.searchSrv.toggleFolder(section);
+ }
}
export function searchDirective() {
diff --git a/public/app/core/services/search_srv.ts b/public/app/core/services/search_srv.ts
index f282ee57f34..b7717a826f3 100644
--- a/public/app/core/services/search_srv.ts
+++ b/public/app/core/services/search_srv.ts
@@ -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');
}