Select AWS region from dropdown

pull/3129/head
utkarshcmu 10 years ago
parent 4de9ac133a
commit 7612e47aee
  1. 2
      pkg/api/cloudwatch/metrics.go
  2. 18
      public/app/features/org/datasourceEditCtrl.js
  3. 9
      public/app/plugins/datasource/cloudwatch/partials/config.html

@ -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",

@ -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() {

@ -19,8 +19,13 @@
<li class="tight-form-item" style="width: 200px">
Default Region<tip>Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.</tip>
</li>
<li>
<select class="tight-form-input input-large last" ng-model="current.jsonData.defaultRegion" ng-options="region for region in current.jsonData.allRegions"></select>
<!--
Whenever this list is updated, backend list should also be updated.
Please update the region list in pkg/api/cloudwatch/metric.go
-->
<li>
<select class="tight-form-input input-large last" ng-model="current.jsonData.defaultRegion" ng-options="region for region in ['us-east-1', 'us-west-2', 'us-west-1', 'eu-west-1',
'eu-central-1', 'ap-southeast-1' ,'ap-southeast-2' ,'ap-northeast-1' ,'sa-east-1' ,'cn-north-1']"></select>
</li>
</ul>
<div class="clearfix"></div>

Loading…
Cancel
Save