diff --git a/src/app/controllers/pro/datasourcesCtrl.js b/src/app/controllers/pro/datasourcesCtrl.js index d836b945e5a..2086cb2a0a3 100644 --- a/src/app/controllers/pro/datasourcesCtrl.js +++ b/src/app/controllers/pro/datasourcesCtrl.js @@ -9,13 +9,29 @@ function (angular) { module.controller('DataSourcesCtrl', function($scope, $http, backendSrv) { - $scope.init = function() { + var defaults = { + name: '', + type: 'graphite', + url: '', + access: 'proxy' }; - $scope.getAccount = function() { - backendSrv.get('/api/account/').then(function(account) { - $scope.account = account; - $scope.collaborators = account.collaborators; + $scope.init = function() { + $scope.current = angular.copy(defaults); + }; + + $scope.addDatasource = function() { + if (!$scope.editForm.$valid) { + return; + } + + backendSrv.request({ + method: 'POST', + url: '/api/admin/datasource/add', + data: $scope.current, + desc: 'Add data source' + }).then(function(result) { + console.log('add datasource result', result); }); }; diff --git a/src/app/partials/pro/datasources.html b/src/app/partials/pro/datasources.html index fa2acfa6554..71aa1c536d3 100644 --- a/src/app/partials/pro/datasources.html +++ b/src/app/partials/pro/datasources.html @@ -1,2 +1,49 @@ -
+ +
+
+
+ +
+
+ + Add data source +
+
+ +
+ +
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/app/services/pro/backendSrv.js b/src/app/services/pro/backendSrv.js index 9b8607c6127..02762a80104 100644 --- a/src/app/services/pro/backendSrv.js +++ b/src/app/services/pro/backendSrv.js @@ -13,6 +13,10 @@ function (angular, _) { return this.request({ method: 'GET', url: url }); }; + this.post = function(url, data) { + return this.request({ method: 'POST', url: url, data: data }); + }; + this.request = function(options) { var httpOptions = { url: options.url,