select_org_ctrl.ts 713 B

12345678910111213141516171819202122232425262728293031
  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
  24. .module("grafana.controllers")
  25. .controller("SelectOrgCtrl", SelectOrgCtrl);