select_org_ctrl.ts 707 B

1234567891011121314151617181920212223242526272829
  1. import angular from 'angular';
  2. import config from 'app/core/config';
  3. export class SelectOrgCtrl {
  4. /** @ngInject **/
  5. constructor($scope, backendSrv, contextSrv) {
  6. contextSrv.sidemenu = false;
  7. $scope.init = function() {
  8. $scope.getUserOrgs();
  9. };
  10. $scope.getUserOrgs = function() {
  11. backendSrv.get('/api/user/orgs').then(function(orgs) {
  12. $scope.orgs = orgs;
  13. });
  14. };
  15. $scope.setUsingOrg = function(org) {
  16. backendSrv.post('/api/user/using/' + org.orgId).then(function() {
  17. window.location.href = config.appSubUrl + '/';
  18. });
  19. };
  20. $scope.init();
  21. }
  22. }
  23. angular.module('grafana.controllers').controller('SelectOrgCtrl', SelectOrgCtrl);