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
96af051c
Commit
96af051c
authored
Mar 15, 2019
by
Hugo Häggmark
Committed by
Hugo Häggmark
Mar 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: Cleaning up implicit anys in manage_dashboard.ts and manage_dashboard.test.ts
progress: #14714
parent
aa4b593d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
75 deletions
+137
-75
public/app/core/components/manage_dashboards/manage_dashboards.ts
+48
-20
public/app/core/specs/manage_dashboards.test.ts
+89
-55
No files found.
public/app/core/components/manage_dashboards/manage_dashboards.ts
View file @
96af051c
// @ts-ignore
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
appEvents
from
'app/core/app_events'
;
import
appEvents
from
'app/core/app_events'
;
import
{
SearchSrv
}
from
'app/core/services/search_srv'
;
import
{
SearchSrv
}
from
'app/core/services/search_srv'
;
import
{
BackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
NavModelSrv
}
from
'app/core/nav_model_srv'
;
import
{
ContextSrv
}
from
'app/core/services/context_srv'
;
export
interface
Section
{
id
:
number
;
uid
:
string
;
title
:
string
;
expanded
:
false
;
items
:
any
[];
url
:
string
;
icon
:
string
;
score
:
number
;
checked
:
boolean
;
hideHeader
:
boolean
;
toggle
:
Function
;
}
export
interface
FoldersAndDashboardUids
{
folderUids
:
string
[];
dashboardUids
:
string
[];
}
class
Query
{
class
Query
{
query
:
string
;
query
:
string
;
...
@@ -14,7 +37,7 @@ class Query {
...
@@ -14,7 +37,7 @@ class Query {
}
}
export
class
ManageDashboardsCtrl
{
export
class
ManageDashboardsCtrl
{
sections
:
any
[];
sections
:
Section
[];
query
:
Query
;
query
:
Query
;
navModel
:
any
;
navModel
:
any
;
...
@@ -45,7 +68,12 @@ export class ManageDashboardsCtrl {
...
@@ -45,7 +68,12 @@ export class ManageDashboardsCtrl {
hasEditPermissionInFolders
:
boolean
;
hasEditPermissionInFolders
:
boolean
;
/** @ngInject */
/** @ngInject */
constructor
(
private
backendSrv
,
navModelSrv
,
private
searchSrv
:
SearchSrv
,
private
contextSrv
)
{
constructor
(
private
backendSrv
:
BackendSrv
,
navModelSrv
:
NavModelSrv
,
private
searchSrv
:
SearchSrv
,
private
contextSrv
:
ContextSrv
)
{
this
.
isEditor
=
this
.
contextSrv
.
isEditor
;
this
.
isEditor
=
this
.
contextSrv
.
isEditor
;
this
.
hasEditPermissionInFolders
=
this
.
contextSrv
.
hasEditPermissionInFolders
;
this
.
hasEditPermissionInFolders
=
this
.
contextSrv
.
hasEditPermissionInFolders
;
...
@@ -73,7 +101,7 @@ export class ManageDashboardsCtrl {
...
@@ -73,7 +101,7 @@ export class ManageDashboardsCtrl {
refreshList
()
{
refreshList
()
{
return
this
.
searchSrv
return
this
.
searchSrv
.
search
(
this
.
query
)
.
search
(
this
.
query
)
.
then
(
result
=>
{
.
then
(
(
result
:
Section
[])
=>
{
return
this
.
initDashboardList
(
result
);
return
this
.
initDashboardList
(
result
);
})
})
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -81,7 +109,7 @@ export class ManageDashboardsCtrl {
...
@@ -81,7 +109,7 @@ export class ManageDashboardsCtrl {
return
;
return
;
}
}
return
this
.
backendSrv
.
getFolderByUid
(
this
.
folderUid
).
then
(
folder
=>
{
return
this
.
backendSrv
.
getFolderByUid
(
this
.
folderUid
).
then
(
(
folder
:
any
)
=>
{
this
.
canSave
=
folder
.
canSave
;
this
.
canSave
=
folder
.
canSave
;
if
(
!
this
.
canSave
)
{
if
(
!
this
.
canSave
)
{
this
.
hasEditPermissionInFolders
=
false
;
this
.
hasEditPermissionInFolders
=
false
;
...
@@ -90,7 +118,7 @@ export class ManageDashboardsCtrl {
...
@@ -90,7 +118,7 @@ export class ManageDashboardsCtrl {
});
});
}
}
initDashboardList
(
result
:
any
)
{
initDashboardList
(
result
:
Section
[]
)
{
this
.
canMove
=
false
;
this
.
canMove
=
false
;
this
.
canDelete
=
false
;
this
.
canDelete
=
false
;
this
.
selectAllChecked
=
false
;
this
.
selectAllChecked
=
false
;
...
@@ -128,25 +156,25 @@ export class ManageDashboardsCtrl {
...
@@ -128,25 +156,25 @@ export class ManageDashboardsCtrl {
this
.
canDelete
=
selectedDashboards
>
0
||
selectedFolders
>
0
;
this
.
canDelete
=
selectedDashboards
>
0
||
selectedFolders
>
0
;
}
}
getFoldersAndDashboardsToDelete
()
{
getFoldersAndDashboardsToDelete
()
:
FoldersAndDashboardUids
{
const
selectedDashboards
=
{
const
selectedDashboards
:
FoldersAndDashboardUids
=
{
folders
:
[],
folder
Uid
s
:
[],
dashboards
:
[],
dashboard
Uid
s
:
[],
};
};
for
(
const
section
of
this
.
sections
)
{
for
(
const
section
of
this
.
sections
)
{
if
(
section
.
checked
&&
section
.
id
!==
0
)
{
if
(
section
.
checked
&&
section
.
id
!==
0
)
{
selectedDashboards
.
folders
.
push
(
section
.
uid
);
selectedDashboards
.
folder
Uid
s
.
push
(
section
.
uid
);
}
else
{
}
else
{
const
selected
=
_
.
filter
(
section
.
items
,
{
checked
:
true
});
const
selected
=
_
.
filter
(
section
.
items
,
{
checked
:
true
});
selectedDashboards
.
dashboards
.
push
(...
_
.
map
(
selected
,
'uid'
));
selectedDashboards
.
dashboard
Uid
s
.
push
(...
_
.
map
(
selected
,
'uid'
));
}
}
}
}
return
selectedDashboards
;
return
selectedDashboards
;
}
}
getFolderIds
(
sections
)
{
getFolderIds
(
sections
:
Section
[]
)
{
const
ids
=
[];
const
ids
=
[];
for
(
const
s
of
sections
)
{
for
(
const
s
of
sections
)
{
if
(
s
.
checked
)
{
if
(
s
.
checked
)
{
...
@@ -158,8 +186,8 @@ export class ManageDashboardsCtrl {
...
@@ -158,8 +186,8 @@ export class ManageDashboardsCtrl {
delete
()
{
delete
()
{
const
data
=
this
.
getFoldersAndDashboardsToDelete
();
const
data
=
this
.
getFoldersAndDashboardsToDelete
();
const
folderCount
=
data
.
folders
.
length
;
const
folderCount
=
data
.
folder
Uid
s
.
length
;
const
dashCount
=
data
.
dashboards
.
length
;
const
dashCount
=
data
.
dashboard
Uid
s
.
length
;
let
text
=
'Do you want to delete the '
;
let
text
=
'Do you want to delete the '
;
let
text2
;
let
text2
;
...
@@ -179,12 +207,12 @@ export class ManageDashboardsCtrl {
...
@@ -179,12 +207,12 @@ export class ManageDashboardsCtrl {
icon
:
'fa-trash'
,
icon
:
'fa-trash'
,
yesText
:
'Delete'
,
yesText
:
'Delete'
,
onConfirm
:
()
=>
{
onConfirm
:
()
=>
{
this
.
deleteFoldersAndDashboards
(
data
.
folder
s
,
data
.
dashboar
ds
);
this
.
deleteFoldersAndDashboards
(
data
.
folder
Uids
,
data
.
dashboardUi
ds
);
},
},
});
});
}
}
private
deleteFoldersAndDashboards
(
folderUids
,
dashboardUids
)
{
private
deleteFoldersAndDashboards
(
folderUids
:
string
[],
dashboardUids
:
string
[]
)
{
this
.
backendSrv
.
deleteFoldersAndDashboards
(
folderUids
,
dashboardUids
).
then
(()
=>
{
this
.
backendSrv
.
deleteFoldersAndDashboards
(
folderUids
,
dashboardUids
).
then
(()
=>
{
this
.
refreshList
();
this
.
refreshList
();
});
});
...
@@ -219,13 +247,13 @@ export class ManageDashboardsCtrl {
...
@@ -219,13 +247,13 @@ export class ManageDashboardsCtrl {
}
}
initTagFilter
()
{
initTagFilter
()
{
return
this
.
searchSrv
.
getDashboardTags
().
then
(
results
=>
{
return
this
.
searchSrv
.
getDashboardTags
().
then
(
(
results
:
any
)
=>
{
this
.
tagFilterOptions
=
[{
term
:
'Filter By Tag'
,
disabled
:
true
}].
concat
(
results
);
this
.
tagFilterOptions
=
[{
term
:
'Filter By Tag'
,
disabled
:
true
}].
concat
(
results
);
this
.
selectedTagFilter
=
this
.
tagFilterOptions
[
0
];
this
.
selectedTagFilter
=
this
.
tagFilterOptions
[
0
];
});
});
}
}
filterByTag
(
tag
)
{
filterByTag
(
tag
:
any
)
{
if
(
_
.
indexOf
(
this
.
query
.
tag
,
tag
)
===
-
1
)
{
if
(
_
.
indexOf
(
this
.
query
.
tag
,
tag
)
===
-
1
)
{
this
.
query
.
tag
.
push
(
tag
);
this
.
query
.
tag
.
push
(
tag
);
}
}
...
@@ -243,7 +271,7 @@ export class ManageDashboardsCtrl {
...
@@ -243,7 +271,7 @@ export class ManageDashboardsCtrl {
return
res
;
return
res
;
}
}
removeTag
(
tag
,
ev
t
)
{
removeTag
(
tag
:
any
,
evt
:
Even
t
)
{
this
.
query
.
tag
=
_
.
without
(
this
.
query
.
tag
,
tag
);
this
.
query
.
tag
=
_
.
without
(
this
.
query
.
tag
,
tag
);
this
.
refreshList
();
this
.
refreshList
();
if
(
evt
)
{
if
(
evt
)
{
...
@@ -269,7 +297,7 @@ export class ManageDashboardsCtrl {
...
@@ -269,7 +297,7 @@ export class ManageDashboardsCtrl {
section
.
checked
=
this
.
selectAllChecked
;
section
.
checked
=
this
.
selectAllChecked
;
}
}
section
.
items
=
_
.
map
(
section
.
items
,
item
=>
{
section
.
items
=
_
.
map
(
section
.
items
,
(
item
:
any
)
=>
{
item
.
checked
=
this
.
selectAllChecked
;
item
.
checked
=
this
.
selectAllChecked
;
return
item
;
return
item
;
});
});
...
...
public/app/core/specs/manage_dashboards.test.ts
View file @
96af051c
This diff is collapsed.
Click to expand it.
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