datasourcesCtrl.js 814 B

123456789101112131415161718192021222324252627282930313233343536
  1. define([
  2. 'angular',
  3. 'lodash',
  4. ],
  5. function (angular) {
  6. 'use strict';
  7. var module = angular.module('grafana.controllers');
  8. module.controller('DataSourcesCtrl', function($scope, $http, backendSrv, datasourceSrv) {
  9. $scope.init = function() {
  10. $scope.datasources = [];
  11. $scope.getDatasources();
  12. };
  13. $scope.getDatasources = function() {
  14. backendSrv.get('/api/datasources').then(function(results) {
  15. $scope.datasources = results;
  16. });
  17. };
  18. $scope.remove = function(ds) {
  19. backendSrv.delete('/api/datasources/' + ds.id).then(function() {
  20. $scope.getDatasources();
  21. backendSrv.get('/api/frontend/settings').then(function(settings) {
  22. datasourceSrv.init(settings.datasources);
  23. });
  24. });
  25. };
  26. $scope.init();
  27. });
  28. });