selectOrgCtrl.js 690 B

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