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
ccfcf02e
Commit
ccfcf02e
authored
Oct 10, 2018
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactors ds permissions to a filter.
parent
f150f351
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
pkg/api/datasources.go
+10
-14
pkg/models/datasource.go
+6
-0
No files found.
pkg/api/datasources.go
View file @
ccfcf02e
...
...
@@ -17,18 +17,21 @@ func GetDataSources(c *m.ReqContext) Response {
return
Error
(
500
,
"Failed to query datasources"
,
err
)
}
permissions
:=
map
[
int64
]
m
.
DsPermissionType
{}
permissionsQuery
:=
m
.
GetDataSourcePermissionsForUserQuery
{
User
:
c
.
SignedInUser
}
if
err
:=
bus
.
Dispatch
(
&
permissionsQuery
);
err
!=
nil
{
dsFilterQuery
:=
m
.
DatasourcesPermissionFilterQuery
{
User
:
c
.
SignedInUser
,
Datasources
:
query
.
Result
,
}
if
err
:=
bus
.
Dispatch
(
&
dsFilterQuery
);
err
!=
nil
{
if
err
!=
bus
.
ErrHandlerNotFound
{
return
Error
(
500
,
"
failed to read datasource permission
s"
,
err
)
return
Error
(
500
,
"
Could not get datasource
s"
,
err
)
}
}
else
{
permissions
=
permissionsQ
uery
.
Result
dsFilterQuery
.
Result
=
q
uery
.
Result
}
result
:=
make
(
dtos
.
DataSourceList
,
0
)
for
_
,
ds
:=
range
q
uery
.
Result
{
for
_
,
ds
:=
range
dsFilterQ
uery
.
Result
{
dsItem
:=
dtos
.
DataSourceListItemDTO
{
OrgId
:
ds
.
OrgId
,
Id
:
ds
.
Id
,
...
...
@@ -45,13 +48,6 @@ func GetDataSources(c *m.ReqContext) Response {
ReadOnly
:
ds
.
ReadOnly
,
}
if
permission
,
ok
:=
permissions
[
ds
.
Id
];
ok
{
c
.
Logger
.
Info
(
"Found permission"
,
"permission"
,
permission
)
if
permission
==
m
.
DsPermissionNoAccess
{
continue
}
}
if
plugin
,
exists
:=
plugins
.
DataSources
[
ds
.
Type
];
exists
{
dsItem
.
TypeLogoUrl
=
plugin
.
Info
.
Logos
.
Small
}
else
{
...
...
pkg/models/datasource.go
View file @
ccfcf02e
...
...
@@ -217,3 +217,9 @@ type GetDataSourcePermissionsForUserQuery struct {
User
*
SignedInUser
Result
map
[
int64
]
DsPermissionType
}
type
DatasourcesPermissionFilterQuery
struct
{
User
*
SignedInUser
Datasources
[]
*
DataSource
Result
[]
*
DataSource
}
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