From 4de9ac133a398b4b48585859b0e2cffb10dff916 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 4 Nov 2015 17:21:34 -0800 Subject: [PATCH] Set default AWS region from dropdown now --- public/app/features/org/datasourceEditCtrl.js | 18 ++++++++++++++++++ .../datasource/cloudwatch/partials/config.html | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/app/features/org/datasourceEditCtrl.js b/public/app/features/org/datasourceEditCtrl.js index 09dd8606092..46b8ab11abc 100644 --- a/public/app/features/org/datasourceEditCtrl.js +++ b/public/app/features/org/datasourceEditCtrl.js @@ -50,16 +50,34 @@ function (angular, config, _) { }); }; + $scope.loadAWSRegions = function() { + var options = { + method: 'POST', + url: '/api/datasources/proxy/' + $scope.current.id, + data: { action: '__GetRegions' } + }; + + return backendSrv.datasourceRequest(options).then(function(result) { + $scope.current.jsonData.allRegions = result.data.map(function(region) { + return region.text; + }); + }); + }; + $scope.getDatasourceById = function(id) { backendSrv.get('/api/datasources/' + id).then(function(ds) { $scope.isNew = false; $scope.current = ds; + console.log($scope.current); $scope.typeChanged(); }); }; $scope.typeChanged = function() { $scope.datasourceMeta = $scope.types[$scope.current.type]; + if ($scope.current.type === 'cloudwatch') { + $scope.loadAWSRegions(); + } }; $scope.updateFrontendSettings = function() { diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 15d747ac937..0d7bf81777f 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -20,7 +20,7 @@ Default RegionSpecify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
  • - +