mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
dashlist: adds tag filter select (GitHub style)
This commit is contained in:
parent
121d48ec26
commit
ba511f3e24
@ -5,6 +5,7 @@ import { SearchSrv } from 'app/core/services/search_srv';
|
|||||||
export class DashboardListCtrl {
|
export class DashboardListCtrl {
|
||||||
public sections: any [];
|
public sections: any [];
|
||||||
tags: any [];
|
tags: any [];
|
||||||
|
selectedTagFilter: any;
|
||||||
query: any;
|
query: any;
|
||||||
navModel: any;
|
navModel: any;
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
@ -15,10 +16,9 @@ export class DashboardListCtrl {
|
|||||||
this.navModel = navModelSrv.getNav('dashboards', 'dashboards');
|
this.navModel = navModelSrv.getNav('dashboards', 'dashboards');
|
||||||
this.query = {query: '', mode: 'tree', tag: []};
|
this.query = {query: '', mode: 'tree', tag: []};
|
||||||
|
|
||||||
this.getDashboards();
|
this.getDashboards().then(() => {
|
||||||
// this.getDashboards().then(() => {
|
this.getTags();
|
||||||
// this.getTags();
|
});
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDashboards() {
|
getDashboards() {
|
||||||
@ -137,11 +137,12 @@ export class DashboardListCtrl {
|
|||||||
return this.searchSrv.toggleFolder(section);
|
return this.searchSrv.toggleFolder(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTags() {
|
getTags() {
|
||||||
// return this.backendSrv.get('/api/dashboards/tags').then((results) => {
|
return this.searchSrv.getDashboardTags().then((results) => {
|
||||||
// this.tags = results;
|
this.tags = [{ term: 'Filter By Tag', disabled: true }].concat(results);
|
||||||
// });
|
this.selectedTagFilter = this.tags[0];
|
||||||
// }
|
});
|
||||||
|
}
|
||||||
|
|
||||||
filterByTag(tag, evt) {
|
filterByTag(tag, evt) {
|
||||||
this.query.tag.push(tag);
|
this.query.tag.push(tag);
|
||||||
@ -152,6 +153,12 @@ export class DashboardListCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterChange() {
|
||||||
|
this.query.tag.push(this.selectedTagFilter.term);
|
||||||
|
this.selectedTagFilter = this.tags[0];
|
||||||
|
this.getDashboards();
|
||||||
|
}
|
||||||
|
|
||||||
removeTag(tag, evt) {
|
removeTag(tag, evt) {
|
||||||
this.query.tag = _.without(this.query.tag, tag);
|
this.query.tag = _.without(this.query.tag, tag);
|
||||||
this.getDashboards();
|
this.getDashboards();
|
||||||
|
@ -54,9 +54,14 @@
|
|||||||
<div class="admin-list-table" style="height: 80%">
|
<div class="admin-list-table" style="height: 80%">
|
||||||
<div gemini-scrollbar>
|
<div gemini-scrollbar>
|
||||||
<div ng-show="ctrl.sections.length > 0">
|
<div ng-show="ctrl.sections.length > 0">
|
||||||
<!-- <div>
|
<div>
|
||||||
<select class="gf-form-input" ng-model="ctrl.query.tags" ng-options="t.term for t in ctrl.tags" />
|
<select
|
||||||
</div> -->
|
class="gf-form-input"
|
||||||
|
ng-model="ctrl.selectedTagFilter"
|
||||||
|
ng-options="t.term disable when t.disabled for t in ctrl.tags"
|
||||||
|
ng-change="ctrl.filterChange(tag, $index)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div ng-repeat="section in ctrl.sections" class="search-section">
|
<div ng-repeat="section in ctrl.sections" class="search-section">
|
||||||
|
|
||||||
<div class="search-section__header pointer" ng-show="::section.title">
|
<div class="search-section__header pointer" ng-show="::section.title">
|
||||||
|
Loading…
Reference in New Issue
Block a user