2017-12-20 05:33:33 -06:00
|
|
|
import angular from 'angular';
|
|
|
|
import config from 'app/core/config';
|
2015-08-31 02:37:14 -05:00
|
|
|
|
2017-11-23 10:04:50 -06:00
|
|
|
export class SelectOrgCtrl {
|
2018-08-31 09:40:43 -05:00
|
|
|
/** @ngInject */
|
2017-11-23 10:04:50 -06:00
|
|
|
constructor($scope, backendSrv, contextSrv) {
|
2015-08-31 02:37:14 -05:00
|
|
|
contextSrv.sidemenu = false;
|
|
|
|
|
2018-02-20 06:39:16 -06:00
|
|
|
$scope.navModel = {
|
|
|
|
main: {
|
|
|
|
icon: 'gicon gicon-branding',
|
|
|
|
subTitle: 'Preferences',
|
|
|
|
text: 'Select active organization',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-09-05 00:47:30 -05:00
|
|
|
$scope.init = () => {
|
2015-08-31 02:37:14 -05:00
|
|
|
$scope.getUserOrgs();
|
|
|
|
};
|
|
|
|
|
2018-09-05 00:47:30 -05:00
|
|
|
$scope.getUserOrgs = () => {
|
|
|
|
backendSrv.get('/api/user/orgs').then(orgs => {
|
2015-08-31 02:37:14 -05:00
|
|
|
$scope.orgs = orgs;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-09-05 00:47:30 -05:00
|
|
|
$scope.setUsingOrg = org => {
|
|
|
|
backendSrv.post('/api/user/using/' + org.orgId).then(() => {
|
2017-12-20 05:33:33 -06:00
|
|
|
window.location.href = config.appSubUrl + '/';
|
2015-08-31 02:37:14 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.init();
|
2017-11-23 10:04:50 -06:00
|
|
|
}
|
|
|
|
}
|
2015-08-31 02:37:14 -05:00
|
|
|
|
2017-12-21 01:39:31 -06:00
|
|
|
angular.module('grafana.controllers').controller('SelectOrgCtrl', SelectOrgCtrl);
|