From c1539b90b74b4d27b2a058f5b158f2a874b70f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 20 Nov 2017 15:46:16 +0100 Subject: [PATCH] minor update to dashboard search --- public/app/core/components/search/search.html | 8 +++--- public/app/core/components/search/search.ts | 6 ++-- public/app/core/services/search_srv.ts | 28 +++++++++++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) 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.
- + {{::section.title}} - - + + -
+
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'); }