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
8905c8e5
Commit
8905c8e5
authored
Dec 15, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'team_member_count' of
https://github.com/bergquist/grafana
into develop
parents
75bfe313
256f7176
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
39 deletions
+67
-39
pkg/api/team_test.go
+1
-1
pkg/models/team.go
+11
-4
pkg/services/sqlstore/team.go
+30
-12
public/app/features/org/partials/team_details.html
+24
-21
public/app/features/org/partials/teams.html
+1
-1
No files found.
pkg/api/team_test.go
View file @
8905c8e5
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
func
TestTeamApiEndpoint
(
t
*
testing
.
T
)
{
func
TestTeamApiEndpoint
(
t
*
testing
.
T
)
{
Convey
(
"Given two teams"
,
t
,
func
()
{
Convey
(
"Given two teams"
,
t
,
func
()
{
mockResult
:=
models
.
SearchTeamQueryResult
{
mockResult
:=
models
.
SearchTeamQueryResult
{
Teams
:
[]
*
models
.
Team
{
Teams
:
[]
*
models
.
SearchTeamDto
{
{
Name
:
"team1"
},
{
Name
:
"team1"
},
{
Name
:
"team2"
},
{
Name
:
"team2"
},
},
},
...
...
pkg/models/team.go
View file @
8905c8e5
...
@@ -60,9 +60,16 @@ type SearchTeamsQuery struct {
...
@@ -60,9 +60,16 @@ type SearchTeamsQuery struct {
Result
SearchTeamQueryResult
Result
SearchTeamQueryResult
}
}
type
SearchTeamDto
struct
{
Id
int64
`json:"id"`
OrgId
int64
`json:"orgId"`
Name
string
`json:"name"`
MemberCount
int64
`json:"memberCount"`
}
type
SearchTeamQueryResult
struct
{
type
SearchTeamQueryResult
struct
{
TotalCount
int64
`json:"totalCount"`
TotalCount
int64
`json:"totalCount"`
Teams
[]
*
Team
`json:"teams"`
Teams
[]
*
SearchTeamDto
`json:"teams"`
Page
int
`json:"page"`
Page
int
`json:"page"`
PerPage
int
`json:"perPage"`
PerPage
int
`json:"perPage"`
}
}
pkg/services/sqlstore/team.go
View file @
8905c8e5
package
sqlstore
package
sqlstore
import
(
import
(
"bytes"
"fmt"
"fmt"
"time"
"time"
...
@@ -114,37 +115,54 @@ func isTeamNameTaken(name string, existingId int64, sess *DBSession) (bool, erro
...
@@ -114,37 +115,54 @@ func isTeamNameTaken(name string, existingId int64, sess *DBSession) (bool, erro
func
SearchTeams
(
query
*
m
.
SearchTeamsQuery
)
error
{
func
SearchTeams
(
query
*
m
.
SearchTeamsQuery
)
error
{
query
.
Result
=
m
.
SearchTeamQueryResult
{
query
.
Result
=
m
.
SearchTeamQueryResult
{
Teams
:
make
([]
*
m
.
Team
,
0
),
Teams
:
make
([]
*
m
.
SearchTeamDto
,
0
),
}
}
queryWithWildcards
:=
"%"
+
query
.
Query
+
"%"
queryWithWildcards
:=
"%"
+
query
.
Query
+
"%"
sess
:=
x
.
Table
(
"team"
)
var
sql
bytes
.
Buffer
sess
.
Where
(
"org_id=?"
,
query
.
OrgId
)
params
:=
make
([]
interface
{},
0
)
sql
.
WriteString
(
`select
team.id as id,
team.name as name,
(select count(*) from team_member where team_member.team_id = team.id) as member_count
from team as team
where team.org_id = ?`
)
params
=
append
(
params
,
query
.
OrgId
)
if
query
.
Query
!=
""
{
if
query
.
Query
!=
""
{
sess
.
Where
(
"name LIKE ?"
,
queryWithWildcards
)
sql
.
WriteString
(
` and team.name `
+
dialect
.
LikeStr
()
+
` ?`
)
params
=
append
(
params
,
queryWithWildcards
)
}
}
if
query
.
Name
!=
""
{
if
query
.
Name
!=
""
{
sess
.
Where
(
"name=?"
,
query
.
Name
)
sql
.
WriteString
(
` and team.name = ?`
)
params
=
append
(
params
,
query
.
Name
)
}
sql
.
WriteString
(
` order by team.name asc`
)
if
query
.
Limit
!=
0
{
sql
.
WriteString
(
` limit ? offset ?`
)
offset
:=
query
.
Limit
*
(
query
.
Page
-
1
)
params
=
append
(
params
,
query
.
Limit
,
offset
)
}
}
sess
.
Asc
(
"name"
)
offset
:=
query
.
Limit
*
(
query
.
Page
-
1
)
if
err
:=
x
.
Sql
(
sql
.
String
(),
params
...
)
.
Find
(
&
query
.
Result
.
Teams
);
err
!=
nil
{
sess
.
Limit
(
query
.
Limit
,
offset
)
sess
.
Cols
(
"id"
,
"name"
)
if
err
:=
sess
.
Find
(
&
query
.
Result
.
Teams
);
err
!=
nil
{
return
err
return
err
}
}
team
:=
m
.
Team
{}
team
:=
m
.
Team
{}
countSess
:=
x
.
Table
(
"team"
)
countSess
:=
x
.
Table
(
"team"
)
if
query
.
Query
!=
""
{
if
query
.
Query
!=
""
{
countSess
.
Where
(
"name LIKE ?"
,
queryWithWildcards
)
countSess
.
Where
(
`name `
+
dialect
.
LikeStr
()
+
` ?`
,
queryWithWildcards
)
}
}
if
query
.
Name
!=
""
{
if
query
.
Name
!=
""
{
countSess
.
Where
(
"name=?"
,
query
.
Name
)
countSess
.
Where
(
"name=?"
,
query
.
Name
)
}
}
count
,
err
:=
countSess
.
Count
(
&
team
)
count
,
err
:=
countSess
.
Count
(
&
team
)
query
.
Result
.
TotalCount
=
count
query
.
Result
.
TotalCount
=
count
...
...
public/app/features/org/partials/team_details.html
View file @
8905c8e5
...
@@ -15,33 +15,36 @@
...
@@ -15,33 +15,36 @@
</form>
</form>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-group"
>
<h3
class=
"page-heading"
>
Team Members
</h3>
<h3
class=
"page-heading"
>
Team Members
</h3>
<form
name=
"ctrl.addMemberForm"
class=
"gf-form-group"
>
<form
name=
"ctrl.addMemberForm"
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Us
er
</span>
<span
class=
"gf-form-label width-10"
>
Add memb
er
</span>
<user-picker
user-picked=
"ctrl.userPicked($user)"
></user-picker>
<user-picker
user-picked=
"ctrl.userPicked($user)"
></user-picker>
</div>
</div>
</form>
</form>
<table
class=
"filter-table"
ng-show=
"ctrl.teamMembers.length > 0"
>
<table
class=
"filter-table"
ng-show=
"ctrl.teamMembers.length > 0"
>
<tr>
<thead>
<th>
Username
</th>
<tr>
<th>
Email
</th>
<th>
Username
</th>
<th></th>
<th>
Email
</th>
</tr>
<th></th>
<tr
ng-repeat=
"member in ctrl.teamMembers"
>
</tr>
<td>
{{member.login}}
</td>
</thead>
<td>
{{member.email}}
</td>
<tr
ng-repeat=
"member in ctrl.teamMembers"
>
<td
style=
"width: 1%"
>
<td>
{{member.login}}
</td>
<a
ng-click=
"ctrl.removeTeamMember(member)"
class=
"btn btn-danger btn-mini"
>
<td>
{{member.email}}
</td>
<i
class=
"fa fa-remove"
></i>
<td
style=
"width: 1%"
>
</a>
<a
ng-click=
"ctrl.removeTeamMember(member)"
class=
"btn btn-danger btn-mini"
>
</td>
<i
class=
"fa fa-remove"
></i>
</tr>
</a>
</table>
</td>
<div>
</tr>
<em
class=
"muted"
ng-hide=
"ctrl.teamMembers.length > 0"
>
</table>
This team has no members yet.
<div>
</em>
<em
class=
"muted"
ng-hide=
"ctrl.teamMembers.length > 0"
>
</div>
This team has no members yet.
</em>
</div>
public/app/features/org/partials/teams.html
View file @
8905c8e5
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<a
href=
"org/teams/edit/{{team.id}}"
>
{{team.name}}
</a>
<a
href=
"org/teams/edit/{{team.id}}"
>
{{team.name}}
</a>
</td>
</td>
<td
class=
"link-td"
>
<td
class=
"link-td"
>
<a
href=
"org/teams/edit/{{team.id}}"
>
#Count
</a>
<a
href=
"org/teams/edit/{{team.id}}"
>
{{team.memberCount}}
</a>
</td>
</td>
<td
class=
"text-right"
>
<td
class=
"text-right"
>
<a
ng-click=
"ctrl.deleteTeam(team)"
class=
"btn btn-danger btn-small"
>
<a
ng-click=
"ctrl.deleteTeam(team)"
class=
"btn btn-danger btn-small"
>
...
...
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