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
01ac3a49
Commit
01ac3a49
authored
Jun 23, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashfolders: fix user group picker + cleanup
parent
45622536
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
42 deletions
+51
-42
pkg/api/user_group.go
+1
-0
pkg/models/user_group.go
+1
-0
pkg/services/sqlstore/user_group.go
+5
-1
public/app/features/org/partials/user_group_details.html
+30
-29
public/app/features/org/partials/user_groups.html
+5
-1
public/app/features/org/specs/user_group_details_ctrl_specs.ts
+6
-4
public/app/features/org/user_group_details_ctrl.ts
+3
-7
No files found.
pkg/api/user_group.go
View file @
01ac3a49
...
...
@@ -66,6 +66,7 @@ func SearchUserGroups(c *middleware.Context) Response {
Name
:
c
.
Query
(
"name"
),
Page
:
page
,
Limit
:
perPage
,
OrgId
:
c
.
OrgId
,
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
...
...
pkg/models/user_group.go
View file @
01ac3a49
...
...
@@ -55,6 +55,7 @@ type SearchUserGroupsQuery struct {
Name
string
Limit
int
Page
int
OrgId
int64
Result
SearchUserGroupQueryResult
}
...
...
pkg/services/sqlstore/user_group.go
View file @
01ac3a49
...
...
@@ -119,12 +119,16 @@ func SearchUserGroups(query *m.SearchUserGroupsQuery) error {
queryWithWildcards
:=
"%"
+
query
.
Query
+
"%"
sess
:=
x
.
Table
(
"user_group"
)
sess
.
Where
(
"org_id=?"
,
query
.
OrgId
)
if
query
.
Query
!=
""
{
sess
.
Where
(
"name LIKE ?"
,
queryWithWildcards
)
}
if
query
.
Name
!=
""
{
sess
.
Where
(
"name=?"
,
query
.
Name
)
}
sess
.
Asc
(
"name"
)
offset
:=
query
.
Limit
*
(
query
.
Page
-
1
)
sess
.
Limit
(
query
.
Limit
,
offset
)
sess
.
Cols
(
"id"
,
"name"
)
...
...
@@ -222,7 +226,7 @@ func GetUserGroupMembers(query *m.GetUserGroupMembersQuery) error {
sess
.
Join
(
"INNER"
,
"user"
,
fmt
.
Sprintf
(
"user_group_member.user_id=%s.id"
,
x
.
Dialect
()
.
Quote
(
"user"
)))
sess
.
Where
(
"user_group_member.user_group_id=?"
,
query
.
UserGroupId
)
sess
.
Cols
(
"user.org_id"
,
"user_group_member.user_group_id"
,
"user_group_member.user_id"
,
"user.email"
,
"user.login"
)
sess
.
Asc
(
"user.
email"
,
"user.login
"
)
sess
.
Asc
(
"user.
login"
,
"user.email
"
)
err
:=
sess
.
Find
(
&
query
.
Result
)
return
err
...
...
public/app/features/org/partials/user_group_details.html
View file @
01ac3a49
...
...
@@ -5,44 +5,45 @@
<h1>
Edit User Group
</h1>
</div>
<form
name=
"userGroupDetailsForm"
class=
"gf-form-group"
>
<form
name=
"userGroupDetailsForm"
class=
"gf-form-group
gf-form-inline
"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Name
</span>
<input
type=
"text"
required
ng-model=
"ctrl.userGroup.name"
class=
"gf-form-input max-width-14"
>
</div>
<div
class=
"gf-form
-button-row
"
>
<div
class=
"gf-form"
>
<button
type=
"submit"
class=
"btn btn-success"
ng-click=
"ctrl.update()"
>
Update
</button>
</div>
</form>
<h3
class=
"page-heading"
>
User Group Members
</h3>
<form
name=
"ctrl.addMemberForm"
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Name
</span>
<user-picker
user-id=
"ctrl.userId"
></user-picker>
</div>
<div
class=
"gf-form-group"
>
<h3
class=
"page-heading"
>
User Group Members
</h3>
<div
class=
"gf-form-button-row"
>
<button
type=
"submit"
class=
"btn btn-success"
ng-click=
"ctrl.addMember()"
>
Add
</button>
</div>
</form>
<form
name=
"ctrl.addMemberForm"
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
User
</span>
<user-picker
user-picked=
"ctrl.userPicked($user)"
></user-picker>
</div>
</form>
<table
class=
"grafana-options-table"
>
<tr>
<th>
Username
</th>
<th>
Email
</th>
<th></th>
</tr>
<tr
ng-repeat=
"userGroup in ctrl.userGroupMembers"
>
<td>
{{userGroup.login}}
</td>
<td>
{{userGroup.email}}
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"ctrl.removeUserGroupMember(userGroup)"
class=
"btn btn-danger btn-mini"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
</tr>
</table>
<table
class=
"grafana-options-table"
ng-show=
"ctrl.userGroupMembers.length > 0"
>
<tr>
<th>
Username
</th>
<th>
Email
</th>
<th></th>
</tr>
<tr
ng-repeat=
"member in ctrl.userGroupMembers"
>
<td>
{{member.login}}
</td>
<td>
{{member.email}}
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"ctrl.removeUserGroupMember(member)"
class=
"btn btn-danger btn-mini"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
</tr>
</table>
<div>
<em
class=
"muted"
ng-hide=
"ctrl.userGroupMembers.length > 0"
>
This user group has no members yet.
</em>
</div>
public/app/features/org/partials/user_groups.html
View file @
01ac3a49
...
...
@@ -16,7 +16,7 @@
</span>
</div>
<div
class=
"admin-list-table"
>
<table
class=
"filter-table form-inline"
>
<table
class=
"filter-table form-inline"
ng-show=
"ctrl.userGroups.length > 0"
>
<thead>
<tr>
<th>
Id
</th>
...
...
@@ -54,4 +54,8 @@
</li>
</ol>
</div>
<em
class=
"muted"
ng-hide=
"ctrl.userGroups.length > 0"
>
No User Groups found.
</em>
</div>
public/app/features/org/specs/user_group_details_ctrl_specs.ts
View file @
01ac3a49
...
...
@@ -21,18 +21,20 @@ var backendSrv = {
backendSrv
:
backendSrv
,
$routeParams
:
{
id
:
1
}
});
ctx
.
ctrl
.
userId
=
1
;
}));
describe
(
'when user is chosen to be added to user group'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
ctrl
.
addMemberForm
=
{
$valid
:
true
};
ctx
.
ctrl
.
addMember
();
const
userItem
=
{
id
:
2
,
login
:
'user2'
,
};
ctx
.
ctrl
.
userPicked
(
userItem
);
});
it
(
'should parse the result and save to db'
,
()
=>
{
expect
(
backendSrv
.
post
.
getCall
(
0
).
args
[
0
]).
to
.
eql
(
'/api/user-groups/1/members'
);
expect
(
backendSrv
.
post
.
getCall
(
0
).
args
[
1
].
userId
).
to
.
eql
(
1
);
expect
(
backendSrv
.
post
.
getCall
(
0
).
args
[
1
].
userId
).
to
.
eql
(
2
);
});
it
(
'should refresh the list after saving.'
,
()
=>
{
...
...
public/app/features/org/user_group_details_ctrl.ts
View file @
01ac3a49
...
...
@@ -6,9 +6,7 @@ import _ from 'lodash';
export
default
class
UserGroupDetailsCtrl
{
userGroup
:
UserGroup
;
userGroupMembers
:
User
[]
=
[];
userId
:
number
;
navModel
:
any
;
addMemberForm
:
any
;
constructor
(
private
$scope
,
private
$http
,
private
backendSrv
,
private
$routeParams
,
navModelSrv
)
{
this
.
navModel
=
navModelSrv
.
getOrgNav
(
3
);
...
...
@@ -51,11 +49,9 @@ export default class UserGroupDetailsCtrl {
this
.
backendSrv
.
put
(
'/api/user-groups/'
+
this
.
userGroup
.
id
,
{
name
:
this
.
userGroup
.
name
});
}
addMember
()
{
if
(
!
this
.
addMemberForm
.
$valid
)
{
return
;
}
this
.
backendSrv
.
post
(
`/api/user-groups/
${
this
.
$routeParams
.
id
}
/members`
,
{
userId
:
this
.
userId
}).
then
(()
=>
{
this
.
userId
=
null
;
userPicked
(
user
)
{
this
.
backendSrv
.
post
(
`/api/user-groups/
${
this
.
$routeParams
.
id
}
/members`
,
{
userId
:
user
.
id
}).
then
(()
=>
{
this
.
$scope
.
$broadcast
(
'user-picker-reset'
);
this
.
get
();
});
}
...
...
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