Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7ce766d9
Commit
7ce766d9
authored
Nov 27, 2017
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashlist: Support for clear all filters
parent
415526ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletions
+64
-1
public/app/features/dashboard/dashboard_list_ctrl.ts
+10
-1
public/app/features/dashboard/partials/dashboardList.html
+12
-0
public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts
+42
-0
No files found.
public/app/features/dashboard/dashboard_list_ctrl.ts
View file @
7ce766d9
...
...
@@ -10,6 +10,7 @@ export class DashboardListCtrl {
navModel
:
any
;
canDelete
=
false
;
canMove
=
false
;
hasFilters
=
false
;
selectAllChecked
=
false
;
starredFilterOptions
=
[{
text
:
'Filter by Starred'
,
disabled
:
true
},
{
text
:
'Yes'
},
{
text
:
'No'
}];
selectedStarredFilter
:
any
;
...
...
@@ -17,7 +18,7 @@ export class DashboardListCtrl {
/** @ngInject */
constructor
(
private
backendSrv
,
navModelSrv
,
private
$q
,
private
searchSrv
:
SearchSrv
)
{
this
.
navModel
=
navModelSrv
.
getNav
(
'dashboards'
,
'dashboards'
);
this
.
query
=
{
query
:
''
,
mode
:
'tree'
,
tag
:
[]};
this
.
query
=
{
query
:
''
,
mode
:
'tree'
,
tag
:
[]
,
starred
:
false
};
this
.
selectedStarredFilter
=
this
.
starredFilterOptions
[
0
];
this
.
getDashboards
().
then
(()
=>
{
...
...
@@ -35,6 +36,7 @@ export class DashboardListCtrl {
this
.
canMove
=
false
;
this
.
canDelete
=
false
;
this
.
selectAllChecked
=
false
;
this
.
hasFilters
=
this
.
query
.
query
.
length
>
0
||
this
.
query
.
tag
.
length
>
0
||
this
.
query
.
starred
;
if
(
!
result
)
{
this
.
sections
=
[];
...
...
@@ -194,4 +196,11 @@ export class DashboardListCtrl {
this
.
selectionChanged
();
}
clearFilters
()
{
this
.
query
.
query
=
''
;
this
.
query
.
tag
=
[];
this
.
query
.
starred
=
false
;
this
.
getDashboards
();
}
}
public/app/features/dashboard/partials/dashboardList.html
View file @
7ce766d9
...
...
@@ -32,6 +32,18 @@
</span>
</div>
<div
class=
"gf-form"
>
<div
class=
"gf-form-button-row"
ng-show=
"ctrl.hasFilters"
>
<button
type=
"button"
class=
"btn gf-form-button btn-inverse btn-small"
ng-click=
"ctrl.clearFilters()"
>
<i
class=
"fa fa-close"
></i>
Clear current search query and filters
</button>
</div>
</div>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-button-row"
>
<button
type=
"button"
...
...
public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts
View file @
7ce766d9
...
...
@@ -124,6 +124,10 @@ describe('DashboardListCtrl', () => {
expect
(
ctrl
.
canDelete
).
toBeFalsy
();
});
it
(
'should have active filters'
,
()
=>
{
expect
(
ctrl
.
hasFilters
).
toBeTruthy
();
});
describe
(
'when select all is checked'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
selectAllChecked
=
true
;
...
...
@@ -143,6 +147,16 @@ describe('DashboardListCtrl', () => {
it
(
'should enable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeTruthy
();
});
describe
(
'when clearing filters'
,
()
=>
{
beforeEach
(()
=>
{
return
ctrl
.
clearFilters
();
});
it
(
'should reset query filter'
,
()
=>
{
expect
(
ctrl
.
query
.
query
).
toEqual
(
''
);
});
});
});
});
...
...
@@ -155,6 +169,20 @@ describe('DashboardListCtrl', () => {
expect
(
ctrl
.
sections
.
length
).
toEqual
(
1
);
expect
(
ctrl
.
query
.
tag
[
0
]).
toEqual
(
'test'
);
});
it
(
'should have active filters'
,
()
=>
{
expect
(
ctrl
.
hasFilters
).
toBeTruthy
();
});
describe
(
'when clearing filters'
,
()
=>
{
beforeEach
(()
=>
{
return
ctrl
.
clearFilters
();
});
it
(
'should reset tag filter'
,
()
=>
{
expect
(
ctrl
.
query
.
tag
.
length
).
toEqual
(
0
);
});
});
});
describe
(
'with starred filter'
,
()
=>
{
...
...
@@ -169,6 +197,20 @@ describe('DashboardListCtrl', () => {
expect
(
ctrl
.
sections
.
length
).
toEqual
(
1
);
expect
(
ctrl
.
query
.
starred
).
toEqual
(
true
);
});
it
(
'should have active filters'
,
()
=>
{
expect
(
ctrl
.
hasFilters
).
toBeTruthy
();
});
describe
(
'when clearing filters'
,
()
=>
{
beforeEach
(()
=>
{
return
ctrl
.
clearFilters
();
});
it
(
'should reset starred filter'
,
()
=>
{
expect
(
ctrl
.
query
.
starred
).
toEqual
(
false
);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment