adminListOrgsCtrl.js 958 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('AdminListOrgsCtrl', function($scope, backendSrv, navModelSrv) {
  8. $scope.init = function() {
  9. $scope.navModel = navModelSrv.getAdminNav();
  10. $scope.getOrgs();
  11. };
  12. $scope.getOrgs = function() {
  13. backendSrv.get('/api/orgs').then(function(orgs) {
  14. $scope.orgs = orgs;
  15. });
  16. };
  17. $scope.deleteOrg = function(org) {
  18. $scope.appEvent('confirm-modal', {
  19. title: 'Delete',
  20. text: 'Do you want to delete organization ' + org.name + '?',
  21. text2: 'All dashboards for this organization will be removed!',
  22. icon: 'fa-trash',
  23. yesText: 'Delete',
  24. onConfirm: function() {
  25. backendSrv.delete('/api/orgs/' + org.id).then(function() {
  26. $scope.getOrgs();
  27. });
  28. }
  29. });
  30. };
  31. $scope.init();
  32. });
  33. });