Commit e9e2fa29 by Torkel Ödegaard

Started Account -> Organization rename

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