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
d9ecb59d
Commit
d9ecb59d
authored
Nov 23, 2017
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashlist: Support for check/uncheck all
parent
99e52143
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
41 deletions
+172
-41
public/app/features/dashboard/dashboard_list_ctrl.ts
+17
-0
public/app/features/dashboard/partials/dashboardList.html
+20
-16
public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts
+112
-25
public/sass/_grafana.scss
+1
-0
public/sass/components/_dash_list.scss
+0
-0
public/sass/components/_dashboard_list.scss
+22
-0
No files found.
public/app/features/dashboard/dashboard_list_ctrl.ts
View file @
d9ecb59d
...
...
@@ -10,6 +10,7 @@ export class DashboardListCtrl {
navModel
:
any
;
canDelete
=
false
;
canMove
=
false
;
selectAllChecked
=
false
;
starredFilterOptions
=
[{
text
:
'Filter by Starred'
,
disabled
:
true
},
{
text
:
'Yes'
},
{
text
:
'No'
}];
selectedStarredFilter
:
any
;
...
...
@@ -41,6 +42,7 @@ export class DashboardListCtrl {
initDashboardList
(
result
:
any
)
{
this
.
canMove
=
false
;
this
.
canDelete
=
false
;
this
.
selectAllChecked
=
false
;
if
(
!
result
)
{
this
.
sections
=
[];
...
...
@@ -185,4 +187,19 @@ export class DashboardListCtrl {
this
.
query
.
starred
=
this
.
selectedStarredFilter
.
text
===
'Yes'
;
return
this
.
getDashboards
();
}
onSelectAllChanged
()
{
for
(
let
section
of
this
.
sections
)
{
if
(
!
section
.
hideHeader
)
{
section
.
checked
=
this
.
selectAllChecked
;
}
section
.
items
=
_
.
map
(
section
.
items
,
(
item
)
=>
{
item
.
checked
=
this
.
selectAllChecked
;
return
item
;
});
}
this
.
selectionChanged
();
}
}
public/app/features/dashboard/partials/dashboardList.html
View file @
d9ecb59d
...
...
@@ -50,22 +50,26 @@
</div>
</div>
<div
style=
"height: 75%"
>
<div
style=
"display: flex; justify-content: flex-end"
>
<select
style=
"width: 150px;"
class=
"gf-form-input"
ng-model=
"ctrl.selectedStarredFilter"
ng-options=
"t.text disable when t.disabled for t in ctrl.starredFilterOptions"
ng-change=
"ctrl.onStarredFilterChange()"
/>
<select
style=
"width: 150px;"
class=
"gf-form-input"
ng-model=
"ctrl.selectedTagFilter"
ng-options=
"t.term disable when t.disabled for t in ctrl.tagFilterOptions"
ng-change=
"ctrl.onTagFilterChange()"
/>
<div
class=
"dashboard-list"
>
<div
class=
"search-results-filter-row"
>
<gf-form-switch
on-change=
"ctrl.onSelectAllChanged()"
checked=
"ctrl.selectAllChecked"
/>
<div
class=
"search-results-filter-row__filters"
>
<select
class=
"search-results-filter-row__filters-item gf-form-input"
ng-model=
"ctrl.selectedStarredFilter"
ng-options=
"t.text disable when t.disabled for t in ctrl.starredFilterOptions"
ng-change=
"ctrl.onStarredFilterChange()"
/>
<select
class=
"search-results-filter-row__filters-item gf-form-input"
ng-model=
"ctrl.selectedTagFilter"
ng-options=
"t.term disable when t.disabled for t in ctrl.tagFilterOptions"
ng-change=
"ctrl.onTagFilterChange()"
/>
</div>
</div>
<div
class=
"search-results-container"
ng-show=
"ctrl.sections.length > 0"
grafana-scrollbar
>
<div
ng-repeat=
"section in ctrl.sections"
class=
"search-section"
>
...
...
public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts
View file @
d9ecb59d
...
...
@@ -65,9 +65,9 @@ describe('DashboardListCtrl', () => {
beforeEach
(()
=>
{
const
response
=
[
{
id
:
410
,
title
:
"afolder"
,
type
:
"dash-folder"
,
checked
:
false
,
expanded
:
true
,
hideHeader
:
true
,
items
:
[
{
id
:
399
,
...
...
@@ -79,48 +79,41 @@ describe('DashboardListCtrl', () => {
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
:
[],
folderId
:
499
,
isStarred
:
false
}
],
tags
:
[],
isStarred
:
false
,
]
}
];
ctrl
=
createCtrlWithStubs
([],
response
);
});
describe
(
'with
no
filter'
,
()
=>
{
describe
(
'with
query
filter'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
query
.
query
=
'd'
;
ctrl
.
canMove
=
true
;
ctrl
.
canDelete
=
true
;
ctrl
.
selectAllChecked
=
true
;
return
ctrl
.
getDashboards
();
});
it
(
'should set checked to false on all sections and children'
,
()
=>
{
expect
(
ctrl
.
sections
.
length
).
toEqual
(
2
);
expect
(
ctrl
.
sections
.
length
).
toEqual
(
1
);
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
);
expect
(
ctrl
.
sections
[
0
].
items
[
1
].
checked
).
toEqual
(
false
);
});
it
(
'should uncheck select all'
,
()
=>
{
expect
(
ctrl
.
selectAllChecked
).
toBeFalsy
();
});
it
(
'should disable Move To button'
,
()
=>
{
...
...
@@ -130,6 +123,27 @@ describe('DashboardListCtrl', () => {
it
(
'should disable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeFalsy
();
});
describe
(
'when select all is checked'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
selectAllChecked
=
true
;
ctrl
.
onSelectAllChanged
();
});
it
(
'should select all dashboards'
,
()
=>
{
expect
(
ctrl
.
sections
[
0
].
checked
).
toBeFalsy
();
expect
(
ctrl
.
sections
[
0
].
items
[
0
].
checked
).
toBeTruthy
();
expect
(
ctrl
.
sections
[
0
].
items
[
1
].
checked
).
toBeTruthy
();
});
it
(
'should enable Move To button'
,
()
=>
{
expect
(
ctrl
.
canMove
).
toBeTruthy
();
});
it
(
'should enable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeTruthy
();
});
});
});
describe
(
'with tag filter'
,
()
=>
{
...
...
@@ -138,7 +152,7 @@ describe('DashboardListCtrl', () => {
});
it
(
'should set tag filter'
,
()
=>
{
expect
(
ctrl
.
sections
.
length
).
toEqual
(
2
);
expect
(
ctrl
.
sections
.
length
).
toEqual
(
1
);
expect
(
ctrl
.
query
.
tag
[
0
]).
toEqual
(
'test'
);
});
});
...
...
@@ -152,13 +166,12 @@ describe('DashboardListCtrl', () => {
});
it
(
'should set starred filter'
,
()
=>
{
expect
(
ctrl
.
sections
.
length
).
toEqual
(
2
);
expect
(
ctrl
.
sections
.
length
).
toEqual
(
1
);
expect
(
ctrl
.
query
.
starred
).
toEqual
(
true
);
});
});
});
describe
(
'when selecting dashboards'
,
()
=>
{
let
ctrl
;
...
...
@@ -194,6 +207,80 @@ describe('DashboardListCtrl', () => {
it
(
'should disable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeFalsy
();
});
describe
(
'when select all is checked'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
selectAllChecked
=
true
;
ctrl
.
onSelectAllChanged
();
});
it
(
'should select all folders and dashboards'
,
()
=>
{
expect
(
ctrl
.
sections
[
0
].
checked
).
toBeTruthy
();
expect
(
ctrl
.
sections
[
0
].
items
[
0
].
checked
).
toBeTruthy
();
expect
(
ctrl
.
sections
[
1
].
checked
).
toBeTruthy
();
expect
(
ctrl
.
sections
[
1
].
items
[
0
].
checked
).
toBeTruthy
();
});
it
(
'should disable Move To button'
,
()
=>
{
expect
(
ctrl
.
canMove
).
toBeFalsy
();
});
it
(
'should enable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeTruthy
();
});
});
});
describe
(
'and all folders and dashboards are selected'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
sections
=
[
{
id
:
1
,
items
:
[
{
id
:
2
,
checked
:
true
}
],
checked
:
true
},
{
id
:
0
,
items
:
[
{
id
:
3
,
checked
:
true
}
],
checked
:
true
}
];
ctrl
.
selectionChanged
();
});
it
(
'should disable Move To button'
,
()
=>
{
expect
(
ctrl
.
canMove
).
toBeFalsy
();
});
it
(
'should enable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeTruthy
();
});
describe
(
'when select all is unchecked'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
.
selectAllChecked
=
false
;
ctrl
.
onSelectAllChanged
();
});
it
(
'should uncheck all checked folders and dashboards'
,
()
=>
{
expect
(
ctrl
.
sections
[
0
].
checked
).
toBeFalsy
();
expect
(
ctrl
.
sections
[
0
].
items
[
0
].
checked
).
toBeFalsy
();
expect
(
ctrl
.
sections
[
1
].
checked
).
toBeFalsy
();
expect
(
ctrl
.
sections
[
1
].
items
[
0
].
checked
).
toBeFalsy
();
});
it
(
'should disable Move To button'
,
()
=>
{
expect
(
ctrl
.
canMove
).
toBeFalsy
();
});
it
(
'should disable delete button'
,
()
=>
{
expect
(
ctrl
.
canDelete
).
toBeFalsy
();
});
});
});
describe
(
'and one dashboard in root is selected'
,
()
=>
{
...
...
public/sass/_grafana.scss
View file @
d9ecb59d
...
...
@@ -84,6 +84,7 @@
@import
"components/json_explorer"
;
@import
"components/code_editor"
;
@import
"components/dashboard_grid"
;
@import
"components/dashboard_list"
;
// PAGES
...
...
public/sass/components/_dash_list.scss
deleted
100644 → 0
View file @
99e52143
public/sass/components/_dashboard_list.scss
0 → 100644
View file @
d9ecb59d
.dashboard-list
{
height
:
75%
;
.search-results-container
{
padding-left
:
0
;
}
}
.search-results-filter-row
{
display
:
flex
;
justify-content
:
space-between
;
}
.search-results-filter-row__filters
{
display
:
flex
;
width
:
300px
;
}
.search-results-filter-row__filters-item
{
width
:
150px
;
}
\ No newline at end of file
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