2017-11-23 17:04:50 +01:00
|
|
|
import angular from 'angular';
|
|
|
|
|
import config from 'app/core/config';
|
2015-08-31 09:37:14 +02:00
|
|
|
|
2017-11-23 17:04:50 +01:00
|
|
|
export class SelectOrgCtrl {
|
2015-08-31 09:37:14 +02:00
|
|
|
|
2017-11-23 17:04:50 +01:00
|
|
|
/** @ngInject **/
|
|
|
|
|
constructor($scope, backendSrv, contextSrv) {
|
2015-08-31 09:37:14 +02:00
|
|
|
contextSrv.sidemenu = false;
|
|
|
|
|
|
|
|
|
|
$scope.init = function() {
|
|
|
|
|
$scope.getUserOrgs();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.getUserOrgs = function() {
|
|
|
|
|
backendSrv.get('/api/user/orgs').then(function(orgs) {
|
|
|
|
|
$scope.orgs = orgs;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.setUsingOrg = function(org) {
|
|
|
|
|
backendSrv.post('/api/user/using/' + org.orgId).then(function() {
|
|
|
|
|
window.location.href = config.appSubUrl + '/';
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.init();
|
2017-11-23 17:04:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-08-31 09:37:14 +02:00
|
|
|
|
2017-11-23 17:04:50 +01:00
|
|
|
angular.module('grafana.controllers').controller('SelectOrgCtrl', SelectOrgCtrl);
|