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
9cbaf072
Commit
9cbaf072
authored
Apr 19, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: add some TS types
parent
cbbe90ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
12 deletions
+33
-12
public/app/features/org/partials/edit_user_group.html
+1
-1
public/app/features/org/specs/user_group_details_ctrl_specs.ts
+1
-1
public/app/features/org/user_group_details_ctrl.ts
+31
-10
No files found.
public/app/features/org/partials/edit_user_group.html
View file @
9cbaf072
...
...
@@ -26,7 +26,7 @@
<form
name=
"addMemberForm"
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Name
</span>
<input
type=
"text"
bs-typeahead=
"ctrl.searchUsers"
required
ng-model=
"ctrl.user
.n
ame"
class=
"gf-form-input max-width-14"
>
<input
type=
"text"
bs-typeahead=
"ctrl.searchUsers"
required
ng-model=
"ctrl.user
N
ame"
class=
"gf-form-input max-width-14"
>
</div>
<div
class=
"gf-form-button-row"
>
...
...
public/app/features/org/specs/user_group_details_ctrl_specs.ts
View file @
9cbaf072
...
...
@@ -21,7 +21,7 @@ var backendSrv = {
backendSrv
:
backendSrv
,
$routeParams
:
{
id
:
1
}
});
ctx
.
ctrl
.
user
=
{
name
:
'login - user@email.com'
}
;
ctx
.
ctrl
.
user
Name
=
'login - user@email.com'
;
}));
describe
(
'when user is chosen to be added to user group'
,
()
=>
{
...
...
public/app/features/org/user_group_details_ctrl.ts
View file @
9cbaf072
...
...
@@ -4,10 +4,10 @@ import coreModule from 'app/core/core_module';
import
_
from
'lodash'
;
export
default
class
UserGroupDetailsCtrl
{
userGroup
:
any
;
userGroupMembers
=
[];
user
:
any
;
usersSearchCache
=
[];
userGroup
:
UserGroup
;
userGroupMembers
:
User
[]
=
[];
user
Name
=
''
;
usersSearchCache
:
User
[]
=
[];
searchUsers
:
any
;
constructor
(
private
$scope
,
private
$http
,
private
backendSrv
,
private
$routeParams
)
{
...
...
@@ -15,17 +15,21 @@ export default class UserGroupDetailsCtrl {
this
.
usersSearchCache
=
[];
this
.
searchUsers
=
(
queryStr
,
callback
)
=>
{
if
(
this
.
usersSearchCache
.
length
>
0
)
{
callback
(
_
.
map
(
this
.
usersSearchCache
,
(
user
)
=>
{
return
user
.
login
+
' - '
+
user
.
email
;
}
));
callback
(
_
.
map
(
this
.
usersSearchCache
,
this
.
userKey
));
return
;
}
this
.
backendSrv
.
get
(
'/api/users/search?perpage=10&page=1&query='
+
queryStr
).
then
(
result
=>
{
this
.
usersSearchCache
=
result
.
users
;
callback
(
_
.
map
(
result
.
users
,
(
user
)
=>
{
return
user
.
login
+
' - '
+
user
.
email
;
}
));
callback
(
_
.
map
(
result
.
users
,
this
.
userKey
));
});
};
}
private
userKey
(
user
:
User
)
{
return
user
.
login
+
' - '
+
user
.
email
;
}
get
()
{
if
(
this
.
$routeParams
&&
this
.
$routeParams
.
id
)
{
this
.
backendSrv
.
get
(
`/api/user-groups/
${
this
.
$routeParams
.
id
}
`
)
...
...
@@ -39,7 +43,7 @@ export default class UserGroupDetailsCtrl {
}
}
removeUserGroupMember
(
userGroupMember
)
{
removeUserGroupMember
(
userGroupMember
:
UserGroupMember
)
{
this
.
$scope
.
appEvent
(
'confirm-modal'
,
{
title
:
'Remove Member'
,
text
:
'Are you sure you want to remove '
+
userGroupMember
.
name
+
' from this group?'
,
...
...
@@ -51,7 +55,7 @@ export default class UserGroupDetailsCtrl {
});
}
removeMemberConfirmed
(
userGroupMember
)
{
removeMemberConfirmed
(
userGroupMember
:
UserGroupMember
)
{
this
.
backendSrv
.
delete
(
`/api/user-groups/
${
this
.
$routeParams
.
id
}
/members/
${
userGroupMember
.
userId
}
`
)
.
then
(
this
.
get
.
bind
(
this
));
}
...
...
@@ -65,14 +69,31 @@ export default class UserGroupDetailsCtrl {
addMember
()
{
if
(
!
this
.
$scope
.
addMemberForm
.
$valid
)
{
return
;
}
const
login
=
this
.
user
.
n
ame
.
split
(
' - '
)[
0
];
const
login
=
this
.
user
N
ame
.
split
(
' - '
)[
0
];
const
memberToAdd
=
_
.
find
(
this
.
usersSearchCache
,
[
'login'
,
login
]);
this
.
backendSrv
.
post
(
`/api/user-groups/
${
this
.
$routeParams
.
id
}
/members`
,
{
userId
:
memberToAdd
.
id
}).
then
(()
=>
{
this
.
user
.
n
ame
=
''
;
this
.
user
N
ame
=
''
;
this
.
get
();
});
}
}
export
interface
UserGroup
{
id
:
number
;
name
:
string
;
}
export
interface
User
{
id
:
number
;
name
:
string
;
login
:
string
;
email
:
string
;
}
export
interface
UserGroupMember
{
userId
:
number
;
name
:
string
;
}
coreModule
.
controller
(
'UserGroupDetailsCtrl'
,
UserGroupDetailsCtrl
);
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