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
2724cf5d
Commit
2724cf5d
authored
Jul 17, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(invite): small progress
parent
0ffcce1b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
12 deletions
+36
-12
pkg/api/org_invite.go
+1
-0
pkg/models/temp_user.go
+3
-1
pkg/services/sqlstore/sqlstore.goconvey
+1
-1
pkg/services/sqlstore/temp_user.go
+15
-3
public/app/features/org/orgUsersCtrl.js
+6
-1
public/app/features/org/partials/orgUsers.html
+3
-3
public/app/features/org/userInviteCtrl.js
+7
-3
No files found.
pkg/api/org_invite.go
View file @
2724cf5d
...
...
@@ -30,6 +30,7 @@ func AddOrgInvite(c *middleware.Context, inviteDto dtos.AddInviteForm) Response
cmd
.
IsInvite
=
true
cmd
.
InvitedByUserId
=
c
.
UserId
cmd
.
Code
=
util
.
GetRandomString
(
30
)
cmd
.
Role
=
inviteDto
.
Role
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to save invite to database"
,
err
)
...
...
pkg/models/temp_user.go
View file @
2724cf5d
...
...
@@ -17,7 +17,7 @@ type TempUser struct {
Version
int
Email
string
Name
string
Role
string
Role
RoleType
IsInvite
bool
InvitedByUserId
int64
...
...
@@ -39,6 +39,7 @@ type CreateTempUserCommand struct {
IsInvite
bool
InvitedByUserId
int64
Code
string
Role
RoleType
Result
*
TempUser
}
...
...
@@ -54,6 +55,7 @@ type TempUserDTO struct {
Name
string
`json:"name"`
Email
string
`json:"email"`
Role
string
`json:"role"`
InvitedBy
string
`json:"invitedBy"`
EmailSent
bool
`json:"emailSent"`
EmailSentOn
time
.
Time
`json:"emailSentOn"`
Created
time
.
Time
`json:"createdOn"`
...
...
pkg/services/sqlstore/sqlstore.goconvey
View file @
2724cf5d
-timeout=
1
0s
-timeout=
2
0s
pkg/services/sqlstore/temp_user.go
View file @
2724cf5d
...
...
@@ -21,6 +21,7 @@ func CreateTempUser(cmd *m.CreateTempUserCommand) error {
Name
:
cmd
.
Name
,
OrgId
:
cmd
.
OrgId
,
Code
:
cmd
.
Code
,
Role
:
cmd
.
Role
,
IsInvite
:
cmd
.
IsInvite
,
InvitedByUserId
:
cmd
.
InvitedByUserId
,
Created
:
time
.
Now
(),
...
...
@@ -39,10 +40,21 @@ func CreateTempUser(cmd *m.CreateTempUserCommand) error {
}
func
GetTempUsersForOrg
(
query
*
m
.
GetTempUsersForOrgQuery
)
error
{
query
.
Result
=
make
([]
*
m
.
TempUserDTO
,
0
)
sess
:=
x
.
Table
(
"temp_user"
)
sess
.
Where
(
"org_id=?"
,
query
.
OrgId
)
var
rawSql
=
`SELECT
tu.id as id,
tu.email as email,
tu.name as name,
tu.role as role,
tu.email_sent as email_sent,
tu.email_sent_on as email_sent_on,
tu.created as created,
u.login as invited_by
FROM `
+
dialect
.
Quote
(
"temp_user"
)
+
` as tu
LEFT OUTER JOIN `
+
dialect
.
Quote
(
"user"
)
+
` as u on u.id = tu.invited_by_user_id
WHERE tu.org_id=? ORDER BY tu.created desc`
query
.
Result
=
make
([]
*
m
.
TempUserDTO
,
0
)
sess
:=
x
.
Sql
(
rawSql
,
query
.
OrgId
)
err
:=
sess
.
Find
(
&
query
.
Result
)
return
err
}
public/app/features/org/orgUsersCtrl.js
View file @
2724cf5d
...
...
@@ -44,10 +44,15 @@ function (angular) {
};
$scope
.
openInviteModal
=
function
()
{
var
modalScope
=
$scope
.
$new
();
modalScope
.
invitesSent
=
function
()
{
$scope
.
get
();
};
$scope
.
appEvent
(
'show-modal'
,
{
src
:
'./app/features/org/partials/invite.html'
,
modalClass
:
'modal-no-header invite-modal'
,
scope
:
$scope
.
$new
()
scope
:
modalScope
});
};
...
...
public/app/features/org/partials/orgUsers.html
View file @
2724cf5d
...
...
@@ -45,15 +45,15 @@
<th>
Email
</th>
<th>
Name
</th>
<th>
Role
</th>
<th>
Crea
ted on
</th>
<th>
Invited b
y
</th>
<th>
Invi
ted on
</th>
<th>
B
y
</th>
<th></th>
</tr>
<tr
ng-repeat=
"invite in pendingInvites"
>
<td>
{{invite.email}}
</td>
<td>
{{invite.name}}
</td>
<td>
{{invite.role}}
</td>
<td>
{{invite.createdOn | date:'
medium
'}}
</td>
<td>
{{invite.createdOn | date:'
shortDate
'}}
</td>
<td>
{{invite.invitedBy}}
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"removeInvite(invite)"
class=
"btn btn-danger btn-mini"
>
...
...
public/app/features/org/userInviteCtrl.js
View file @
2724cf5d
...
...
@@ -7,7 +7,7 @@ function (angular, _) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'UserInviteCtrl'
,
function
(
$scope
,
backendSrv
)
{
module
.
controller
(
'UserInviteCtrl'
,
function
(
$scope
,
backendSrv
,
$q
)
{
$scope
.
invites
=
[
{
name
:
''
,
email
:
''
,
role
:
'Editor'
},
...
...
@@ -27,8 +27,12 @@ function (angular, _) {
$scope
.
sendInvites
=
function
()
{
if
(
!
$scope
.
inviteForm
.
$valid
)
{
return
;
}
_
.
each
(
$scope
.
invites
,
function
(
invite
)
{
backendSrv
.
post
(
'/api/org/invites'
,
invite
);
var
promises
=
_
.
map
(
$scope
.
invites
,
function
(
invite
)
{
return
backendSrv
.
post
(
'/api/org/invites'
,
invite
);
});
$q
.
all
(
promises
).
then
(
function
()
{
$scope
.
invitesSent
();
});
$scope
.
dismiss
();
...
...
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