Updated org creation view, after creating new org user is switched to that org and redirect to org details view, Closes #2198

This commit is contained in:
Torkel Ödegaard 2015-06-22 08:13:21 +02:00
parent d3c6db1ba8
commit 3f917b0af5
2 changed files with 12 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
m "github.com/grafana/grafana/pkg/models" m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
) )
// GET /api/org // GET /api/org
@ -50,7 +51,10 @@ func CreateOrg(c *middleware.Context, cmd m.CreateOrgCommand) Response {
metrics.M_Api_Org_Create.Inc(1) metrics.M_Api_Org_Create.Inc(1)
return ApiSuccess("Organization created") return Json(200, &util.DynMap{
"orgId": cmd.Result.Id,
"message": "Organization created",
})
} }
// PUT /api/org // PUT /api/org

View File

@ -1,7 +1,8 @@
define([ define([
'angular', 'angular',
'config',
], ],
function (angular) { function (angular, config) {
'use strict'; 'use strict';
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
@ -11,7 +12,11 @@ function (angular) {
$scope.newOrg = {name: ''}; $scope.newOrg = {name: ''};
$scope.createOrg = function() { $scope.createOrg = function() {
backendSrv.post('/api/orgs/', $scope.newOrg).then($scope.getUserOrgs); backendSrv.post('/api/orgs/', $scope.newOrg).then(function(result) {
backendSrv.post('/api/user/using/' + result.orgId).then(function() {
window.location.href = config.appSubUrl + '/org';
});
});
}; };
}); });