adminListUsersCtrl.js 828 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('AdminListUsersCtrl', function($scope, backendSrv) {
  8. $scope.init = function() {
  9. $scope.getUsers();
  10. };
  11. $scope.getUsers = function() {
  12. backendSrv.get('/api/users').then(function(users) {
  13. $scope.users = users;
  14. });
  15. };
  16. $scope.deleteUser = function(user) {
  17. $scope.appEvent('confirm-modal', {
  18. title: 'Delete',
  19. text: 'Do you want to delete ' + user.login + '?',
  20. icon: 'fa-trash',
  21. yesText: 'Delete',
  22. onConfirm: function() {
  23. backendSrv.delete('/api/admin/users/' + user.id).then(function() {
  24. $scope.getUsers();
  25. });
  26. }
  27. });
  28. };
  29. $scope.init();
  30. });
  31. });