2015-01-19 11:57:25 -06:00
|
|
|
define([
|
|
|
|
'angular',
|
|
|
|
],
|
|
|
|
function (angular) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
|
|
2015-08-11 08:20:50 -05:00
|
|
|
module.controller('AdminListUsersCtrl', function($scope, backendSrv) {
|
2015-01-19 11:57:25 -06:00
|
|
|
|
|
|
|
$scope.init = function() {
|
|
|
|
$scope.getUsers();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getUsers = function() {
|
2015-05-19 04:47:14 -05:00
|
|
|
backendSrv.get('/api/users').then(function(users) {
|
2015-01-19 11:57:25 -06:00
|
|
|
$scope.users = users;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-05 08:53:15 -06:00
|
|
|
$scope.deleteUser = function(user) {
|
|
|
|
$scope.appEvent('confirm-modal', {
|
2015-03-05 13:04:54 -06:00
|
|
|
title: 'Do you want to delete ' + user.login + '?',
|
2015-03-05 14:02:25 -06:00
|
|
|
icon: 'fa-trash',
|
|
|
|
yesText: 'Delete',
|
2015-02-05 08:53:15 -06:00
|
|
|
onConfirm: function() {
|
2015-02-11 09:47:22 -06:00
|
|
|
backendSrv.delete('/api/admin/users/' + user.id).then(function() {
|
|
|
|
$scope.getUsers();
|
|
|
|
});
|
2015-02-05 08:53:15 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-01-19 11:57:25 -06:00
|
|
|
$scope.init();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|