diff --git a/public/app/features/dashboard/dashboard_list_ctrl.ts b/public/app/features/dashboard/dashboard_list_ctrl.ts index 4522a53e81d..a8479de92e0 100644 --- a/public/app/features/dashboard/dashboard_list_ctrl.ts +++ b/public/app/features/dashboard/dashboard_list_ctrl.ts @@ -11,12 +11,12 @@ export class DashboardListCtrl { /** @ngInject */ constructor(private backendSrv, navModelSrv, private $q) { this.navModel = navModelSrv.getNav('cfg', 'dashboards'); - this.query = ''; + this.query = {query: '', mode: 'tree', tag: []}; this.getDashboards(); } getDashboards() { - return this.backendSrv.get(`/api/search?query=${this.query}&mode=tree`).then((result) => { + return this.backendSrv.search(this.query).then((result) => { this.dashboards = this.groupDashboardsInFolders(result); @@ -134,4 +134,22 @@ export class DashboardListCtrl { model: {dashboards: selectedDashboards, afterSave: this.getDashboards.bind(this)} }); } + + filterByTag(tag, evt) { + this.query.tag.push(tag); + this.getDashboards(); + if (evt) { + evt.stopPropagation(); + evt.preventDefault(); + } + } + + removeTag(tag, evt) { + this.query.tag = _.without(this.query.tag, tag); + this.getDashboards(); + if (evt) { + evt.stopPropagation(); + evt.preventDefault(); + } + } } diff --git a/public/app/features/dashboard/partials/dashboardList.html b/public/app/features/dashboard/partials/dashboardList.html index aca798ebf32..313ec2337b7 100644 --- a/public/app/features/dashboard/partials/dashboardList.html +++ b/public/app/features/dashboard/partials/dashboardList.html @@ -14,11 +14,24 @@ Create Folder -
- - - +
+
+
+ + + +
+
+ Filtered by Tags: + + + + {{tagName}} + + +
+
@@ -68,7 +81,7 @@ - + diff --git a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts index 9a0218a2a4b..c4cd538b6ac 100644 --- a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts @@ -21,7 +21,7 @@ describe('DashboardListCtrl', () => { } ]; - ctrl = new DashboardListCtrl({get: () => q.resolve(response)}, {getNav: () => {}}, q); + ctrl = new DashboardListCtrl({search: () => q.resolve(response)}, {getNav: () => {}}, q); return ctrl.getDashboards(); }); @@ -62,7 +62,7 @@ describe('DashboardListCtrl', () => { folderSlug: "afolder" } ]; - ctrl = new DashboardListCtrl({get: () => q.resolve(response)}, {getNav: () => {}}, null); + ctrl = new DashboardListCtrl({search: () => q.resolve(response)}, {getNav: () => {}}, null); return ctrl.getDashboards(); }); @@ -78,7 +78,7 @@ describe('DashboardListCtrl', () => { let ctrl; beforeEach(() => { - ctrl = new DashboardListCtrl({get: () => q.resolve([])}, {getNav: () => {}}, null); + ctrl = new DashboardListCtrl({search: () => q.resolve([])}, {getNav: () => {}}, null); }); describe('and no dashboards are selected', () => { @@ -174,7 +174,7 @@ describe('DashboardListCtrl', () => { describe('when deleting dashboards', () => { beforeEach(() => { - ctrl = new DashboardListCtrl({get: () => q.resolve([])}, {getNav: () => {}}, q); + ctrl = new DashboardListCtrl({search: () => q.resolve([])}, {getNav: () => {}}, q); ctrl.dashboards = [ {id: 1, type: 'dash-folder', checked: true}, {id: 2, type: 'dash-child', checked: true, folderId: 1},