mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
minor update to dashboard search
This commit is contained in:
parent
9ace21b689
commit
c1539b90b7
@ -56,14 +56,14 @@
|
|||||||
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
|
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
|
||||||
|
|
||||||
<div ng-repeat="section in ctrl.results" class="search-section">
|
<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>
|
<i class="search-section__header__icon" ng-class="section.icon"></i>
|
||||||
<span class="search-section__header__text">{{::section.title}}</span>
|
<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-minus search-section__header__toggle" ng-show="section.expanded"></i>
|
||||||
<i class="fa fa-plus search-section__header__toggle" ng-show="section.collapsed"></i>
|
<i class="fa fa-plus search-section__header__toggle" ng-hide="section.expanded"></i>
|
||||||
</a>
|
</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}}">
|
<a ng-repeat="item in section.items" class="search-item" ng-class="{'selected': item.selected}" ng-href="{{::item.url}}">
|
||||||
<span class="search-item__icon">
|
<span class="search-item__icon">
|
||||||
<i class="fa fa-th-large"></i>
|
<i class="fa fa-th-large"></i>
|
||||||
|
@ -151,9 +151,9 @@ export class SearchCtrl {
|
|||||||
this.searchDashboards();
|
this.searchDashboards();
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggleFolder(section) {
|
toggleFolder(section) {
|
||||||
// this.searchSrv.toggleFolder(section);
|
this.searchSrv.toggleFolder(section);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function searchDirective() {
|
export function searchDirective() {
|
||||||
|
@ -34,6 +34,7 @@ export class SearchSrv {
|
|||||||
items: [],
|
items: [],
|
||||||
icon: 'fa fa-folder-open',
|
icon: 'fa fa-folder-open',
|
||||||
score: _.keys(sections).length,
|
score: _.keys(sections).length,
|
||||||
|
expanded: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let hit of results) {
|
for (let hit of results) {
|
||||||
@ -54,14 +55,16 @@ export class SearchSrv {
|
|||||||
return this.browse();
|
return this.browse();
|
||||||
}
|
}
|
||||||
|
|
||||||
options.folderIds = [];
|
let query = _.clone(options);
|
||||||
options.type = 'dash-db';
|
query.folderIds = [];
|
||||||
|
query.type = 'dash-db';
|
||||||
|
|
||||||
return this.backendSrv.search(options).then(results => {
|
return this.backendSrv.search(query).then(results => {
|
||||||
|
|
||||||
let section = {
|
let section = {
|
||||||
hideHeader: true,
|
hideHeader: true,
|
||||||
items: [],
|
items: [],
|
||||||
|
expanded: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let hit of results) {
|
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() {
|
getDashboardTags() {
|
||||||
return this.backendSrv.get('/api/dashboards/tags');
|
return this.backendSrv.get('/api/dashboards/tags');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user