2017-12-20 12:33:33 +01:00
|
|
|
import angular from 'angular';
|
|
|
|
|
import config from 'app/core/config';
|
2019-07-18 08:03:04 +02:00
|
|
|
import { BackendSrv } from 'app/core/services/backend_srv';
|
|
|
|
|
import { NavModelSrv } from 'app/core/core';
|
2015-02-26 13:01:34 +01:00
|
|
|
|
2017-11-23 17:04:50 +01:00
|
|
|
export class NewOrgCtrl {
|
2018-08-31 16:40:43 +02:00
|
|
|
/** @ngInject */
|
2019-07-18 08:03:04 +02:00
|
|
|
constructor($scope: any, $http: any, backendSrv: BackendSrv, navModelSrv: NavModelSrv) {
|
2019-03-05 13:02:41 +01:00
|
|
|
$scope.navModel = navModelSrv.getNav('admin', 'global-orgs', 0);
|
2017-12-20 12:33:33 +01:00
|
|
|
$scope.newOrg = { name: '' };
|
2015-02-26 13:01:34 +01:00
|
|
|
|
2018-09-05 07:47:30 +02:00
|
|
|
$scope.createOrg = () => {
|
2019-07-18 08:03:04 +02:00
|
|
|
backendSrv.post('/api/orgs/', $scope.newOrg).then((result: any) => {
|
2018-09-05 07:47:30 +02:00
|
|
|
backendSrv.post('/api/user/using/' + result.orgId).then(() => {
|
2017-12-20 12:33:33 +01:00
|
|
|
window.location.href = config.appSubUrl + '/org';
|
2015-06-22 08:13:21 +02:00
|
|
|
});
|
|
|
|
|
});
|
2015-02-26 13:01:34 +01:00
|
|
|
};
|
2017-11-23 17:04:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-26 13:01:34 +01:00
|
|
|
|
2017-12-20 12:33:33 +01:00
|
|
|
angular.module('grafana.controllers').controller('NewOrgCtrl', NewOrgCtrl);
|