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
43ef9f90
Commit
43ef9f90
authored
Aug 11, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(admin): admin page for all grafana organizations (list / edit view), #2457
parent
e01c68dc
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
191 additions
and
5 deletions
+191
-5
CHANGELOG.md
+6
-0
pkg/api/api.go
+3
-0
public/app/features/admin/adminEditOrgCtrl.js
+52
-0
public/app/features/admin/adminListOrgsCtrl.js
+38
-0
public/app/features/admin/adminListUsersCtrl.js
+1
-1
public/app/features/admin/all.js
+3
-1
public/app/features/admin/partials/edit_org.html
+60
-0
public/app/features/admin/partials/orgs.html
+22
-2
public/app/routes/all.js
+6
-1
No files found.
CHANGELOG.md
View file @
43ef9f90
# 2.2 (unreleased)
**New Features && Enhancements**
-
[
Issue #2457
](
https://github.com/grafana/grafana/issues/2457
)
. Admin: admin page for all grafana organizations (list / edit view)
# 2.1.1 (2015-08-11)
**Fixes**
...
...
pkg/api/api.go
View file @
43ef9f90
...
...
@@ -37,6 +37,8 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/admin/users"
,
reqGrafanaAdmin
,
Index
)
r
.
Get
(
"/admin/users/create"
,
reqGrafanaAdmin
,
Index
)
r
.
Get
(
"/admin/users/edit/:id"
,
reqGrafanaAdmin
,
Index
)
r
.
Get
(
"/admin/orgs"
,
reqGrafanaAdmin
,
Index
)
r
.
Get
(
"/admin/orgs/edit/:id"
,
reqGrafanaAdmin
,
Index
)
r
.
Get
(
"/dashboard/*"
,
reqSignedIn
,
Index
)
// sign up
...
...
@@ -109,6 +111,7 @@ func Register(r *macaron.Macaron) {
// orgs (admin routes)
r
.
Group
(
"/orgs/:orgId"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetOrgById
))
r
.
Put
(
"/"
,
bind
(
m
.
UpdateOrgCommand
{}),
wrap
(
UpdateOrg
))
r
.
Get
(
"/users"
,
wrap
(
GetOrgUsers
))
r
.
Post
(
"/users"
,
bind
(
m
.
AddOrgUserCommand
{}),
wrap
(
AddOrgUser
))
...
...
public/app/features/admin/adminEditOrgCtrl.js
0 → 100644
View file @
43ef9f90
define
([
'angular'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'AdminEditOrgCtrl'
,
function
(
$scope
,
$routeParams
,
backendSrv
,
$location
)
{
$scope
.
init
=
function
()
{
if
(
$routeParams
.
id
)
{
$scope
.
getOrg
(
$routeParams
.
id
);
$scope
.
getOrgUsers
(
$routeParams
.
id
);
}
};
$scope
.
getOrg
=
function
(
id
)
{
backendSrv
.
get
(
'/api/orgs/'
+
id
).
then
(
function
(
org
)
{
$scope
.
org
=
org
;
});
};
$scope
.
getOrgUsers
=
function
(
id
)
{
backendSrv
.
get
(
'/api/orgs/'
+
id
+
'/users'
).
then
(
function
(
orgUsers
)
{
$scope
.
orgUsers
=
orgUsers
;
});
};
$scope
.
update
=
function
()
{
if
(
!
$scope
.
orgDetailsForm
.
$valid
)
{
return
;
}
backendSrv
.
put
(
'/api/orgs/'
+
$scope
.
org
.
id
,
$scope
.
org
).
then
(
function
()
{
$location
.
path
(
'/admin/orgs'
);
});
};
$scope
.
updateOrgUser
=
function
(
orgUser
)
{
backendSrv
.
patch
(
'/api/orgs/'
+
orgUser
.
orgId
+
'/users/'
+
orgUser
.
userId
,
orgUser
);
};
$scope
.
removeOrgUser
=
function
(
orgUser
)
{
backendSrv
.
delete
(
'/api/orgs/'
+
orgUser
.
orgId
+
'/users/'
+
orgUser
.
userId
).
then
(
function
()
{
$scope
.
getOrgUsers
(
$scope
.
org
.
id
);
});
};
$scope
.
init
();
});
});
public/app/features/admin/adminListOrgsCtrl.js
0 → 100644
View file @
43ef9f90
define
([
'angular'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'AdminListOrgsCtrl'
,
function
(
$scope
,
backendSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
getOrgs
();
};
$scope
.
getOrgs
=
function
()
{
backendSrv
.
get
(
'/api/orgs'
).
then
(
function
(
orgs
)
{
$scope
.
orgs
=
orgs
;
});
};
$scope
.
deleteOrg
=
function
(
org
)
{
$scope
.
appEvent
(
'confirm-modal'
,
{
title
:
'Do you want to delete organization '
+
org
.
name
+
'?'
,
icon
:
'fa-trash'
,
yesText
:
'Delete'
,
onConfirm
:
function
()
{
backendSrv
.
delete
(
'/api/orgs/'
+
org
.
id
).
then
(
function
()
{
$scope
.
getOrgs
();
});
}
});
};
$scope
.
init
();
});
});
public/app/features/admin/adminUsersCtrl.js
→
public/app/features/admin/admin
List
UsersCtrl.js
View file @
43ef9f90
...
...
@@ -6,7 +6,7 @@ function (angular) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'AdminUsersCtrl'
,
function
(
$scope
,
backendSrv
)
{
module
.
controller
(
'Admin
List
UsersCtrl'
,
function
(
$scope
,
backendSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
getUsers
();
...
...
public/app/features/admin/all.js
View file @
43ef9f90
define
([
'./adminUsersCtrl'
,
'./adminListUsersCtrl'
,
'./adminListOrgsCtrl'
,
'./adminEditOrgCtrl'
,
'./adminEditUserCtrl'
,
'./adminSettingsCtrl'
,
],
function
()
{});
public/app/features/admin/partials/edit_org.html
0 → 100644
View file @
43ef9f90
<topnav
icon=
"fa fa-fw fa-user"
title=
"Global Users"
subnav=
"true"
>
<ul
class=
"nav"
>
<li><a
href=
"admin/orgs"
>
List
</a></li>
<li
class=
"active"
><a
href=
"admin/orgs/edit/{{org.id}}"
>
Edit Org
</a></li>
</ul>
</topnav>
<div
class=
"page-container"
>
<div
class=
"page"
>
<h2>
Organization Details
</h2>
<form
name=
"orgDetailsForm"
>
<div>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 100px"
>
Name
</li>
<li>
<input
type=
"text"
required
ng-model=
"org.name"
class=
"input-xxlarge tight-form-input last"
>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
</div>
<br>
<button
type=
"submit"
class=
"pull-right btn btn-success"
ng-click=
"update()"
ng-show=
"!createMode"
>
Update
</button>
</form>
<h3>
Organization Users
</h3>
<table
class=
"grafana-options-table form-inline"
>
<tr>
<th>
Username
</th>
<th>
Email
</th>
<th>
Role
</th>
<th></th>
</tr>
<tr
ng-repeat=
"orgUser in orgUsers"
>
<td>
{{orgUser.login}}
</td>
<td>
{{orgUser.email}}
</td>
<td>
<select
type=
"text"
ng-model=
"orgUser.role"
class=
"input-small"
ng-options=
"f for f in ['Viewer', 'Editor', 'Read Only Editor', 'Admin']"
ng-change=
"updateOrgUser(orgUser)"
>
</select>
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"removeOrgUser(orgUser)"
class=
"btn btn-danger btn-mini"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
</tr>
</table>
</div>
</div>
public/app/features/admin/partials/orgs.html
View file @
43ef9f90
<topnav
icon=
"fa fa-fw fa-users"
title=
"Global Orgs"
subnav=
"true"
>
<ul
class=
"nav"
>
<li
class=
"active"
><a
href=
"admin/
users"
>
Overview
</a></li>
<li
class=
"active"
><a
href=
"admin/
orgs"
>
List
</a></li>
</ul>
</topnav>
...
...
@@ -10,6 +10,26 @@
Organizations
</h2>
View not implemented yet...
<table
class=
"grafana-options-table"
>
<tr>
<th
style=
"text-align:left"
>
Id
</th>
<th>
Name
</th>
<th></th>
</tr>
<tr
ng-repeat=
"org in orgs"
>
<td>
{{org.name}}
</td>
<td
style=
"width: 1%"
>
<a
href=
"admin/orgs/edit/{{org.id}}"
class=
"btn btn-inverse btn-small"
>
<i
class=
"fa fa-edit"
></i>
Edit
</a>
<a
ng-click=
"deleteOrg(org)"
class=
"btn btn-danger btn-small"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
</tr>
</table>
</div>
</div>
public/app/routes/all.js
View file @
43ef9f90
...
...
@@ -80,7 +80,7 @@ define([
})
.
when
(
'/admin/users'
,
{
templateUrl
:
'app/features/admin/partials/users.html'
,
controller
:
'AdminUsersCtrl'
,
controller
:
'Admin
List
UsersCtrl'
,
})
.
when
(
'/admin/users/create'
,
{
templateUrl
:
'app/features/admin/partials/new_user.html'
,
...
...
@@ -92,6 +92,11 @@ define([
})
.
when
(
'/admin/orgs'
,
{
templateUrl
:
'app/features/admin/partials/orgs.html'
,
controller
:
'AdminListOrgsCtrl'
,
})
.
when
(
'/admin/orgs/edit/:id'
,
{
templateUrl
:
'app/features/admin/partials/edit_org.html'
,
controller
:
'AdminEditOrgCtrl'
,
})
.
when
(
'/login'
,
{
templateUrl
:
'app/partials/login.html'
,
...
...
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