select_org_ctrl.js 718 B

1234567891011121314151617181920212223242526272829303132333435
  1. define([
  2. 'angular',
  3. 'app/core/config',
  4. ],
  5. function (angular, config) {
  6. 'use strict';
  7. config = config.default;
  8. var module = angular.module('grafana.controllers');
  9. module.controller('SelectOrgCtrl', function($scope, backendSrv, contextSrv) {
  10. contextSrv.sidemenu = false;
  11. $scope.init = function() {
  12. $scope.getUserOrgs();
  13. };
  14. $scope.getUserOrgs = function() {
  15. backendSrv.get('/api/user/orgs').then(function(orgs) {
  16. $scope.orgs = orgs;
  17. });
  18. };
  19. $scope.setUsingOrg = function(org) {
  20. backendSrv.post('/api/user/using/' + org.orgId).then(function() {
  21. window.location.href = config.appSubUrl + '/';
  22. });
  23. };
  24. $scope.init();
  25. });
  26. });