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