From fdeeb73587180417cd1524cbf8f1cb94c31fedd4 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 4 Nov 2015 02:27:35 -0800 Subject: [PATCH 1/4] AWS Region as a mandatory field --- public/app/plugins/datasource/cloudwatch/partials/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 60c645c33f9..15d747ac937 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.
  • - +
  • From 4de9ac133a398b4b48585859b0e2cffb10dff916 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 4 Nov 2015 17:21:34 -0800 Subject: [PATCH 2/4] 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.
  • - +
  • From 7612e47aee5424bdca82ec7a7d9b63921b5f607d Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 9 Nov 2015 12:08:40 -0800 Subject: [PATCH 3/4] Select AWS region from dropdown --- pkg/api/cloudwatch/metrics.go | 2 ++ public/app/features/org/datasourceEditCtrl.js | 18 ------------------ .../datasource/cloudwatch/partials/config.html | 9 +++++++-- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 6d6ff10dfb9..ab4df6784c7 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -65,6 +65,8 @@ func init() { } } +// Whenever this list is updated, frontend list should also be updated. +// Please update the region list in public/app/features/org/datasourceEditCtrl.js func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1", diff --git a/public/app/features/org/datasourceEditCtrl.js b/public/app/features/org/datasourceEditCtrl.js index 46b8ab11abc..09dd8606092 100644 --- a/public/app/features/org/datasourceEditCtrl.js +++ b/public/app/features/org/datasourceEditCtrl.js @@ -50,34 +50,16 @@ 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 0d7bf81777f..311ca0ae3dc 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -19,8 +19,13 @@
  • Default RegionSpecify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.
  • -
  • - + +
  • +
  • From 6325635fce4159d632ef21c75ba9bf4eb46b3bb4 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 9 Nov 2015 12:31:35 -0800 Subject: [PATCH 4/4] Corrected the frontend filename --- pkg/api/cloudwatch/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index ab4df6784c7..a5e738a2ae9 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -66,7 +66,7 @@ func init() { } // Whenever this list is updated, frontend list should also be updated. -// Please update the region list in public/app/features/org/datasourceEditCtrl.js +// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1",