mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
get regions from after datasource save
This commit is contained in:
parent
f6cb01d38a
commit
6564abd5f3
@ -1,19 +1,20 @@
|
||||
import _ from 'lodash';
|
||||
export class CloudWatchConfigCtrl {
|
||||
static templateUrl = 'partials/config.html';
|
||||
current: any;
|
||||
$http: any;
|
||||
datasourceSrv: any;
|
||||
|
||||
accessKeyExist = false;
|
||||
secretKeyExist = false;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $http) {
|
||||
constructor($scope, datasourceSrv) {
|
||||
this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
|
||||
this.current.jsonData.authType = this.current.jsonData.authType || 'credentials';
|
||||
|
||||
this.accessKeyExist = this.current.secureJsonFields.accessKey;
|
||||
this.secretKeyExist = this.current.secureJsonFields.secretKey;
|
||||
this.$http = $http;
|
||||
this.datasourceSrv = datasourceSrv;
|
||||
this.getRegions();
|
||||
}
|
||||
|
||||
@ -40,22 +41,41 @@ export class CloudWatchConfigCtrl {
|
||||
{ name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
|
||||
];
|
||||
|
||||
regions = [];
|
||||
regions = [
|
||||
'ap-northeast-1',
|
||||
'ap-northeast-2',
|
||||
'ap-northeast-3',
|
||||
'ap-south-1',
|
||||
'ap-southeast-1',
|
||||
'ap-southeast-2',
|
||||
'ca-central-1',
|
||||
'cn-north-1',
|
||||
'cn-northwest-1',
|
||||
'eu-central-1',
|
||||
'eu-north-1',
|
||||
'eu-west-1',
|
||||
'eu-west-2',
|
||||
'eu-west-3',
|
||||
'me-south-1',
|
||||
'sa-east-1',
|
||||
'us-east-1',
|
||||
'us-east-2',
|
||||
'us-gov-east-1',
|
||||
'us-gov-west-1',
|
||||
'us-iso-east-1',
|
||||
'us-isob-east-1',
|
||||
'us-west-1',
|
||||
'us-west-2',
|
||||
];
|
||||
|
||||
getRegions() {
|
||||
this.$http.get('https://ip-ranges.amazonaws.com/ip-ranges.json').then(ip_ranges => {
|
||||
let regions = {};
|
||||
ip_ranges.data.prefixes
|
||||
.map(p => {
|
||||
return p.region;
|
||||
})
|
||||
.filter(r => {
|
||||
return r !== 'GLOBAL';
|
||||
})
|
||||
.forEach(r => {
|
||||
regions[r] = true;
|
||||
});
|
||||
this.regions = Object.keys(regions).sort();
|
||||
});
|
||||
this.datasourceSrv
|
||||
.loadDatasource(this.current.name)
|
||||
.then(ds => {
|
||||
return ds.getRegions();
|
||||
})
|
||||
.then(regions => {
|
||||
this.regions = _.uniq(this.regions.concat(_.map(regions, 'value')));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user