collaboratorsCtrl.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('CollaboratorsCtrl', function($scope, $http, backendSrv) {
  8. $scope.collaborator = {
  9. loginOrEmail: '',
  10. role: 'Viewer',
  11. };
  12. $scope.init = function() {
  13. $scope.get();
  14. };
  15. $scope.get = function() {
  16. backendSrv.get('/api/account/collaborators').then(function(collaborators) {
  17. $scope.collaborators = collaborators;
  18. });
  19. };
  20. $scope.removeCollaborator = function(collaborator) {
  21. backendSrv.request({
  22. method: 'DELETE',
  23. url: '/api/account/collaborators/' + collaborator.id,
  24. desc: 'Remove collaborator',
  25. }).then($scope.get);
  26. };
  27. $scope.addCollaborator = function() {
  28. if (!$scope.form.$valid) {
  29. return;
  30. }
  31. backendSrv.request({
  32. method: 'PUT',
  33. url: '/api/account/collaborators',
  34. data: $scope.collaborator,
  35. desc: 'Add collaborator'
  36. }).then($scope.get);
  37. };
  38. $scope.init();
  39. });
  40. });