Commit e9e2fa29 by Torkel Ödegaard

Started Account -> Organization rename

parent 5b271551
......@@ -6,7 +6,7 @@ import (
m "github.com/grafana/grafana/pkg/models"
)
func GetAccount(c *middleware.Context) {
func GetOrg(c *middleware.Context) {
query := m.GetAccountByIdQuery{Id: c.AccountId}
if err := bus.Dispatch(&query); err != nil {
......@@ -27,7 +27,7 @@ func GetAccount(c *middleware.Context) {
c.JSON(200, &account)
}
func CreateAccount(c *middleware.Context, cmd m.CreateAccountCommand) {
func CreateOrg(c *middleware.Context, cmd m.CreateAccountCommand) {
cmd.UserId = c.UserId
if err := bus.Dispatch(&cmd); err != nil {
......@@ -38,7 +38,7 @@ func CreateAccount(c *middleware.Context, cmd m.CreateAccountCommand) {
c.JsonOK("Account created")
}
func UpdateAccount(c *middleware.Context, cmd m.UpdateAccountCommand) {
func UpdateOrg(c *middleware.Context, cmd m.UpdateAccountCommand) {
cmd.AccountId = c.AccountId
if err := bus.Dispatch(&cmd); err != nil {
......
......@@ -6,7 +6,7 @@ import (
m "github.com/grafana/grafana/pkg/models"
)
func AddAccountUser(c *middleware.Context, cmd m.AddAccountUserCommand) {
func AddOrgUser(c *middleware.Context, cmd m.AddAccountUserCommand) {
if !cmd.Role.IsValid() {
c.JsonApiErr(400, "Invalid role specified", nil)
return
......@@ -37,7 +37,7 @@ func AddAccountUser(c *middleware.Context, cmd m.AddAccountUserCommand) {
c.JsonOK("User added to account")
}
func GetAccountUsers(c *middleware.Context) {
func GetOrgUsers(c *middleware.Context) {
query := m.GetAccountUsersQuery{AccountId: c.AccountId}
if err := bus.Dispatch(&query); err != nil {
......@@ -48,7 +48,7 @@ func GetAccountUsers(c *middleware.Context) {
c.JSON(200, query.Result)
}
func RemoveAccountUser(c *middleware.Context) {
func RemoveOrgUser(c *middleware.Context) {
userId := c.ParamsInt64(":id")
cmd := m.RemoveAccountUserCommand{AccountId: c.AccountId, UserId: userId}
......
......@@ -54,13 +54,13 @@ func Register(r *macaron.Macaron) {
})
// account
r.Group("/account", func() {
r.Get("/", GetAccount)
r.Post("/", bind(m.CreateAccountCommand{}), CreateAccount)
r.Put("/", bind(m.UpdateAccountCommand{}), UpdateAccount)
r.Post("/users", bind(m.AddAccountUserCommand{}), AddAccountUser)
r.Get("/users", GetAccountUsers)
r.Delete("/users/:id", RemoveAccountUser)
r.Group("/org", func() {
r.Get("/", GetOrg)
r.Post("/", bind(m.CreateAccountCommand{}), CreateOrg)
r.Put("/", bind(m.UpdateAccountCommand{}), UpdateOrg)
r.Post("/users", bind(m.AddAccountUserCommand{}), AddOrgUser)
r.Get("/users", GetOrgUsers)
r.Delete("/users/:id", RemoveOrgUser)
}, reqAccountAdmin)
// auth api keys
......
......@@ -26,10 +26,10 @@ function (angular, _, $, config) {
$scope.menu.push({
text: "Data Sources",
icon: "fa fa-fw fa-database",
href: $scope.getUrl("/account/datasources"),
href: $scope.getUrl("/datasources"),
});
$scope.menu.push({
text: "Organization", href: $scope.getUrl("/account"),
text: "Organization", href: $scope.getUrl("/org"),
icon: "fa fa-fw fa-users",
});
}
......
......@@ -10,7 +10,7 @@ define([
'./panel/all',
'./profile/profileCtrl',
'./profile/changePasswordCtrl',
'./account/all',
'./org/all',
'./admin/all',
'./grafanaDatasource/datasource',
], function () {});
define([
'./accountUsersCtrl',
'./datasourcesCtrl',
'./datasourceEditCtrl',
'./apiKeysCtrl',
'./accountCtrl',
'./orgUsersCtrl',
'./orgApiKeysCtrl',
'./orgDetailsCtrl',
], function () {});
......@@ -6,7 +6,7 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('ApiKeysCtrl', function($scope, $http, backendSrv) {
module.controller('OrgApiKeysCtrl', function($scope, $http, backendSrv) {
$scope.roleTypes = ['Viewer', 'Editor', 'Admin'];
$scope.token = { role: 'Viewer' };
......
......@@ -6,21 +6,21 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('AccountCtrl', function($scope, $http, backendSrv) {
module.controller('OrgDetailsCtrl', function($scope, $http, backendSrv) {
$scope.init = function() {
$scope.getAccount();
$scope.getOrgInfo();
};
$scope.getAccount = function() {
backendSrv.get('/api/account').then(function(account) {
$scope.account = account;
$scope.getOrgInfo = function() {
backendSrv.get('/api/org').then(function(account) {
$scope.org = account;
});
};
$scope.update = function() {
if (!$scope.accountForm.$valid) { return; }
backendSrv.put('/api/account', $scope.account).then($scope.getAccount);
if (!$scope.orgForm.$valid) { return; }
backendSrv.put('/api/org', $scope.org).then($scope.getOrgInfo);
};
$scope.init();
......
......@@ -6,7 +6,7 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('AccountUsersCtrl', function($scope, $http, backendSrv) {
module.controller('OrgUsersCtrl', function($scope, $http, backendSrv) {
$scope.user = {
loginOrEmail: '',
......@@ -18,18 +18,18 @@ function (angular) {
};
$scope.get = function() {
backendSrv.get('/api/account/users').then(function(users) {
backendSrv.get('/api/org/users').then(function(users) {
$scope.users = users;
});
};
$scope.removeUser = function(user) {
backendSrv.delete('/api/account/users/' + user.userId).then($scope.get);
backendSrv.delete('/api/org/users/' + user.userId).then($scope.get);
};
$scope.addUser = function() {
if (!$scope.form.$valid) { return; }
backendSrv.post('/api/account/users', $scope.user).then($scope.get);
backendSrv.post('/api/org/users', $scope.user).then($scope.get);
};
$scope.init();
......
<topnav title="Data sources" icon="fa fa-fw fa-database" subnav="true">
<ul class="nav">
<li class="active" ><a href="account/datasources">Overview</a></li>
<li><a href="account/datasources/new">Add new</a></li>
<li class="active" ><a href="datasources">Overview</a></li>
<li><a href="datasources/new">Add new</a></li>
</ul>
</topnav>
......
<topnav icon="fa fa-fw fa-users" title="Organization" subnav="true">
<ul class="nav">
<li class="active"><a href="account">Overview</a></li>
<li><a href="account/users">Users</a></li>
<li class="active"><a href="org">Overview</a></li>
<li><a href="org/users">Users</a></li>
</ul>
</topnav>
......@@ -15,10 +15,10 @@
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 100px">
<strong>Account name</strong>
<strong>Name</strong>
</li>
<li>
<input type="text" required ng-model="account.name" class="input-xxlarge tight-form-input last" >
<input type="text" required ng-model="org.name" class="input-xxlarge tight-form-input last" >
</li>
</ul>
<div class="clearfix"></div>
......@@ -33,7 +33,7 @@
</h2>
<div ng-controller="ApiKeysCtrl">
<form name="addTokenrForm" class="form-inline tight-form">
<form name="addTokenrForm" class="form-inline tight-form last">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 100px">
Add a key
......
<topnav title="Organization" icon="fa fa-users" subnav="true">
<topnav title="Organization" icon="fa fa-fw fa-users" subnav="true">
<ul class="nav">
<li><a href="account">Overview</a></li>
<li class="active"><a href="account/users">Users</a></li>
<li><a href="account/import">Import</a></li>
<li><a href="org">Overview</a></li>
<li class="active"><a href="org/users">Users</a></li>
</ul>
</topnav>
......
......@@ -34,28 +34,28 @@ define([
templateUrl: 'app/features/dashboard/partials/import.html',
controller : 'DashboardImportCtrl',
})
.when('/account', {
templateUrl: 'app/features/account/partials/account.html',
controller : 'AccountCtrl',
})
.when('/account/datasources', {
templateUrl: 'app/features/account/partials/datasources.html',
.when('/datasources', {
templateUrl: 'app/features/org/partials/datasources.html',
controller : 'DataSourcesCtrl',
})
.when('/account/datasources/edit/:id', {
templateUrl: 'app/features/account/partials/datasourceEdit.html',
.when('/datasources/edit/:id', {
templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl',
})
.when('/account/datasources/new', {
templateUrl: 'app/features/account/partials/datasourceEdit.html',
.when('/datasources/new', {
templateUrl: 'app/features/org/partials/datasourceEdit.html',
controller : 'DataSourceEditCtrl',
})
.when('/account/users', {
templateUrl: 'app/features/account/partials/users.html',
controller : 'AccountUsersCtrl',
.when('/org', {
templateUrl: 'app/features/org/partials/orgDetails.html',
controller : 'OrgDetailsCtrl',
})
.when('/org/users', {
templateUrl: 'app/features/org/partials/orgUsers.html',
controller : 'OrgUsersCtrl',
})
.when('/account/apikeys', {
templateUrl: 'app/features/account/partials/apikeys.html',
.when('/org/apikeys', {
templateUrl: 'app/features/org/partials/orgApiKeys.html',
controller : 'ApiKeysCtrl',
})
.when('/profile', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment