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
b60e71c2
Commit
b60e71c2
authored
Mar 13, 2019
by
Hugo Häggmark
Committed by
Leonard Gram
Mar 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: moved logic for searchteams to backend
parent
782b5b6a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
pkg/api/api.go
+1
-1
pkg/api/team.go
+2
-2
pkg/api/team_test.go
+8
-2
public/app/features/teams/state/actions.ts
+2
-4
No files found.
pkg/api/api.go
View file @
b60e71c2
...
@@ -168,7 +168,7 @@ func (hs *HTTPServer) registerRoutes() {
...
@@ -168,7 +168,7 @@ func (hs *HTTPServer) registerRoutes() {
// team without requirement of user to be org admin
// team without requirement of user to be org admin
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
teamsRoute
.
Get
(
"/:teamId"
,
Wrap
(
GetTeamByID
))
teamsRoute
.
Get
(
"/:teamId"
,
Wrap
(
GetTeamByID
))
teamsRoute
.
Get
(
"/search"
,
Wrap
(
SearchTeams
))
teamsRoute
.
Get
(
"/search"
,
Wrap
(
hs
.
SearchTeams
))
})
})
// org information available to all users.
// org information available to all users.
...
...
pkg/api/team.go
View file @
b60e71c2
...
@@ -81,7 +81,7 @@ func DeleteTeamByID(c *m.ReqContext) Response {
...
@@ -81,7 +81,7 @@ func DeleteTeamByID(c *m.ReqContext) Response {
}
}
// GET /api/teams/search
// GET /api/teams/search
func
SearchTeams
(
c
*
m
.
ReqContext
)
Response
{
func
(
hs
*
HTTPServer
)
SearchTeams
(
c
*
m
.
ReqContext
)
Response
{
perPage
:=
c
.
QueryInt
(
"perpage"
)
perPage
:=
c
.
QueryInt
(
"perpage"
)
if
perPage
<=
0
{
if
perPage
<=
0
{
perPage
=
1000
perPage
=
1000
...
@@ -92,7 +92,7 @@ func SearchTeams(c *m.ReqContext) Response {
...
@@ -92,7 +92,7 @@ func SearchTeams(c *m.ReqContext) Response {
}
}
var
userIdFilter
int64
var
userIdFilter
int64
if
c
.
QueryBool
(
"showMine"
)
{
if
hs
.
Cfg
.
EditorsCanAdmin
&&
c
.
OrgRole
!=
m
.
ROLE_ADMIN
{
userIdFilter
=
c
.
SignedInUser
.
UserId
userIdFilter
=
c
.
SignedInUser
.
UserId
}
}
...
...
pkg/api/team_test.go
View file @
b60e71c2
...
@@ -3,6 +3,8 @@ package api
...
@@ -3,6 +3,8 @@ package api
import
(
import
(
"testing"
"testing"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
...
@@ -20,6 +22,10 @@ func TestTeamApiEndpoint(t *testing.T) {
...
@@ -20,6 +22,10 @@ func TestTeamApiEndpoint(t *testing.T) {
TotalCount
:
2
,
TotalCount
:
2
,
}
}
hs
:=
&
HTTPServer
{
Cfg
:
setting
.
NewCfg
(),
}
Convey
(
"When searching with no parameters"
,
func
()
{
Convey
(
"When searching with no parameters"
,
func
()
{
loggedInUserScenario
(
"When calling GET on"
,
"/api/teams/search"
,
func
(
sc
*
scenarioContext
)
{
loggedInUserScenario
(
"When calling GET on"
,
"/api/teams/search"
,
func
(
sc
*
scenarioContext
)
{
var
sentLimit
int
var
sentLimit
int
...
@@ -33,7 +39,7 @@ func TestTeamApiEndpoint(t *testing.T) {
...
@@ -33,7 +39,7 @@ func TestTeamApiEndpoint(t *testing.T) {
return
nil
return
nil
})
})
sc
.
handlerFunc
=
SearchTeams
sc
.
handlerFunc
=
hs
.
SearchTeams
sc
.
fakeReqWithParams
(
"GET"
,
sc
.
url
,
map
[
string
]
string
{})
.
exec
()
sc
.
fakeReqWithParams
(
"GET"
,
sc
.
url
,
map
[
string
]
string
{})
.
exec
()
So
(
sentLimit
,
ShouldEqual
,
1000
)
So
(
sentLimit
,
ShouldEqual
,
1000
)
...
@@ -60,7 +66,7 @@ func TestTeamApiEndpoint(t *testing.T) {
...
@@ -60,7 +66,7 @@ func TestTeamApiEndpoint(t *testing.T) {
return
nil
return
nil
})
})
sc
.
handlerFunc
=
SearchTeams
sc
.
handlerFunc
=
hs
.
SearchTeams
sc
.
fakeReqWithParams
(
"GET"
,
sc
.
url
,
map
[
string
]
string
{
"perpage"
:
"10"
,
"page"
:
"2"
})
.
exec
()
sc
.
fakeReqWithParams
(
"GET"
,
sc
.
url
,
map
[
string
]
string
{
"perpage"
:
"10"
,
"page"
:
"2"
})
.
exec
()
So
(
sentLimit
,
ShouldEqual
,
10
)
So
(
sentLimit
,
ShouldEqual
,
10
)
...
...
public/app/features/teams/state/actions.ts
View file @
b60e71c2
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
OrgRole
,
StoreState
,
Team
,
TeamGroup
,
TeamMember
}
from
'app/types'
;
import
{
StoreState
,
Team
,
TeamGroup
,
TeamMember
}
from
'app/types'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
{
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
{
buildNavModel
}
from
'./navModel'
;
import
{
buildNavModel
}
from
'./navModel'
;
import
{
contextSrv
}
from
'../../../core/services/context_srv'
;
export
enum
ActionTypes
{
export
enum
ActionTypes
{
LoadTeams
=
'LOAD_TEAMS'
,
LoadTeams
=
'LOAD_TEAMS'
,
...
@@ -86,8 +85,7 @@ export const setSearchQuery = (searchQuery: string): SetSearchQueryAction => ({
...
@@ -86,8 +85,7 @@ export const setSearchQuery = (searchQuery: string): SetSearchQueryAction => ({
export
function
loadTeams
():
ThunkResult
<
void
>
{
export
function
loadTeams
():
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
return
async
dispatch
=>
{
const
showMine
=
contextSrv
.
user
.
orgRole
===
OrgRole
.
Editor
;
const
response
=
await
getBackendSrv
().
get
(
'/api/teams/search'
,
{
perpage
:
1000
,
page
:
1
});
const
response
=
await
getBackendSrv
().
get
(
'/api/teams/search'
,
{
perpage
:
1000
,
page
:
1
,
showMine
});
dispatch
(
teamsLoaded
(
response
.
teams
));
dispatch
(
teamsLoaded
(
response
.
teams
));
};
};
}
}
...
...
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