mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'develop' of github.com:grafana/grafana into develop
This commit is contained in:
commit
b7a8db4937
@ -381,10 +381,11 @@ func TestDashboardDataAccess(t *testing.T) {
|
|||||||
childDash2 := insertTestDashboard("child dash 2", 1, folder2.Id, false, "prod")
|
childDash2 := insertTestDashboard("child dash 2", 1, folder2.Id, false, "prod")
|
||||||
|
|
||||||
currentUser := createUser("viewer", "Viewer", false)
|
currentUser := createUser("viewer", "Viewer", false)
|
||||||
|
var rootFolderId int64 = 0
|
||||||
|
|
||||||
Convey("and one folder is expanded, the other collapsed", func() {
|
Convey("and one folder is expanded, the other collapsed", func() {
|
||||||
Convey("should return dashboards in root and expanded folder", func() {
|
Convey("should return dashboards in root and expanded folder", func() {
|
||||||
query := &search.FindPersistedDashboardsQuery{FolderIds: []int64{folder1.Id}, SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1}
|
query := &search.FindPersistedDashboardsQuery{FolderIds: []int64{rootFolderId, folder1.Id}, SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1}
|
||||||
err := SearchDashboards(query)
|
err := SearchDashboards(query)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(len(query.Result), ShouldEqual, 4)
|
So(len(query.Result), ShouldEqual, 4)
|
||||||
|
@ -52,7 +52,7 @@ export class SearchSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
search(options) {
|
search(options) {
|
||||||
if (!options.query) {
|
if (!options.query && !options.tag) {
|
||||||
return this.browse();
|
return this.browse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,14 +16,28 @@ 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() {
|
||||||
|
if (this.query.query.length === 0 && this.query.tag.length === 0) {
|
||||||
return this.searchSrv.browse().then((result) => {
|
return this.searchSrv.browse().then((result) => {
|
||||||
|
return this.initDashboardList(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.searchSrv.search(this.query).then((result) => {
|
||||||
|
return this.initDashboardList(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initDashboardList(result: any) {
|
||||||
|
if (!result) {
|
||||||
|
this.sections = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.sections = result;
|
this.sections = result;
|
||||||
|
|
||||||
@ -33,7 +48,6 @@ export class DashboardListCtrl {
|
|||||||
dashboard.checked = false;
|
dashboard.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionChanged() {
|
selectionChanged() {
|
||||||
@ -119,11 +133,16 @@ export class DashboardListCtrl {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTags() {
|
toggleFolder(section) {
|
||||||
// return this.backendSrv.get('/api/dashboards/tags').then((results) => {
|
return this.searchSrv.toggleFolder(section);
|
||||||
// this.tags = results;
|
}
|
||||||
// });
|
|
||||||
// }
|
getTags() {
|
||||||
|
return this.searchSrv.getDashboardTags().then((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);
|
||||||
@ -134,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,23 +54,31 @@
|
|||||||
<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">
|
||||||
<gf-form-switch
|
<gf-form-switch
|
||||||
switch-class="gf-form-switch--table-cell"
|
switch-class="gf-form-switch--table-cell"
|
||||||
on-change="ctrl.selectionChanged()"
|
on-change="ctrl.selectionChanged()"
|
||||||
checked="section.checked">
|
checked="section.checked">
|
||||||
</gf-form-switch>
|
</gf-form-switch>
|
||||||
<a class="search-section__header pointer" ng-show="::section.title" ng-click="section.collapsed = !section.collapsed">
|
<a 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>
|
||||||
|
|
||||||
<div ng-if="!section.collapsed">
|
<div ng-if="section.expanded">
|
||||||
<div ng-repeat="item in section.items" class="search-item" ng-class="{'selected': item.selected}">
|
<div ng-repeat="item in section.items" class="search-item" ng-class="{'selected': item.selected}">
|
||||||
<gf-form-switch
|
<gf-form-switch
|
||||||
switch-class="gf-form-switch--table-cell"
|
switch-class="gf-form-switch--table-cell"
|
||||||
@ -124,7 +132,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<em class="muted" ng-hide="ctrl.dashboards.length > 0">
|
<em class="muted" ng-hide="ctrl.sections.length > 0">
|
||||||
No Dashboards or Folders found.
|
No Dashboards or Folders found.
|
||||||
</em>
|
</em>
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,6 +61,63 @@ describe('DashboardListCtrl', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when searching dashboards', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const response = [
|
||||||
|
{
|
||||||
|
id: 410,
|
||||||
|
title: "afolder",
|
||||||
|
type: "dash-folder",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
id: 399,
|
||||||
|
title: "Dashboard Test",
|
||||||
|
url: "dashboard/db/dashboard-test",
|
||||||
|
icon: 'fa fa-folder',
|
||||||
|
tags: [],
|
||||||
|
isStarred: false,
|
||||||
|
folderId: 410,
|
||||||
|
folderTitle: "afolder",
|
||||||
|
folderSlug: "afolder"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
tags: [],
|
||||||
|
isStarred: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 0,
|
||||||
|
title: "Root",
|
||||||
|
icon: 'fa fa-folder-open',
|
||||||
|
uri: "db/something-else",
|
||||||
|
type: "dash-db",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
id: 500,
|
||||||
|
title: "Dashboard Test",
|
||||||
|
url: "dashboard/db/dashboard-test",
|
||||||
|
icon: 'fa fa-folder',
|
||||||
|
tags: [],
|
||||||
|
isStarred: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
tags: [],
|
||||||
|
isStarred: false,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
ctrl = createCtrlWithStubs(response);
|
||||||
|
ctrl.query.query = 'd';
|
||||||
|
return ctrl.getDashboards();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set checked to false on all sections and children', () => {
|
||||||
|
expect(ctrl.sections.length).toEqual(2);
|
||||||
|
expect(ctrl.sections[0].checked).toEqual(false);
|
||||||
|
expect(ctrl.sections[0].items[0].checked).toEqual(false);
|
||||||
|
expect(ctrl.sections[1].checked).toEqual(false);
|
||||||
|
expect(ctrl.sections[1].items[0].checked).toEqual(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when selecting dashboards', () => {
|
describe('when selecting dashboards', () => {
|
||||||
let ctrl;
|
let ctrl;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user