2018-07-24 22:09:33 +09:00
|
|
|
import _ from 'lodash';
|
2016-11-24 08:39:36 +01:00
|
|
|
export class CloudWatchConfigCtrl {
|
2017-12-20 12:33:33 +01:00
|
|
|
static templateUrl = 'partials/config.html';
|
2016-11-24 08:39:36 +01:00
|
|
|
current: any;
|
2018-07-24 22:09:33 +09:00
|
|
|
datasourceSrv: any;
|
2016-11-24 08:39:36 +01:00
|
|
|
|
2017-01-30 15:04:55 +01:00
|
|
|
accessKeyExist = false;
|
|
|
|
|
secretKeyExist = false;
|
2016-11-24 16:24:47 +01:00
|
|
|
|
2016-11-24 08:39:36 +01:00
|
|
|
/** @ngInject */
|
2018-07-24 22:09:33 +09:00
|
|
|
constructor($scope, datasourceSrv) {
|
2017-12-21 08:39:31 +01:00
|
|
|
this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
|
|
|
|
|
this.current.jsonData.authType = this.current.jsonData.authType || 'credentials';
|
2016-11-24 16:24:47 +01:00
|
|
|
|
2016-12-14 21:05:12 +01:00
|
|
|
this.accessKeyExist = this.current.secureJsonFields.accessKey;
|
|
|
|
|
this.secretKeyExist = this.current.secureJsonFields.secretKey;
|
2018-07-24 22:09:33 +09:00
|
|
|
this.datasourceSrv = datasourceSrv;
|
2018-06-19 17:41:26 +09:00
|
|
|
this.getRegions();
|
2016-11-24 16:24:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetAccessKey() {
|
|
|
|
|
this.accessKeyExist = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetSecretKey() {
|
|
|
|
|
this.secretKeyExist = false;
|
2016-11-24 08:39:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
authTypes = [
|
2017-12-20 12:33:33 +01:00
|
|
|
{ name: 'Access & secret key', value: 'keys' },
|
|
|
|
|
{ name: 'Credentials file', value: 'credentials' },
|
|
|
|
|
{ name: 'ARN', value: 'arn' },
|
2016-11-24 08:39:36 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
indexPatternTypes = [
|
2017-12-20 12:33:33 +01:00
|
|
|
{ name: 'No pattern', value: undefined },
|
|
|
|
|
{ name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },
|
|
|
|
|
{ name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },
|
|
|
|
|
{ name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },
|
|
|
|
|
{ name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },
|
|
|
|
|
{ name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
|
2016-11-24 08:39:36 +01:00
|
|
|
];
|
2018-06-19 17:41:26 +09:00
|
|
|
|
2018-10-17 14:02:02 +09:00
|
|
|
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',
|
|
|
|
|
];
|
2018-06-19 17:41:26 +09:00
|
|
|
|
|
|
|
|
getRegions() {
|
2018-07-24 22:09:33 +09:00
|
|
|
this.datasourceSrv
|
|
|
|
|
.loadDatasource(this.current.name)
|
|
|
|
|
.then(ds => {
|
|
|
|
|
return ds.getRegions();
|
|
|
|
|
})
|
2018-10-16 12:06:57 +09:00
|
|
|
.then(
|
|
|
|
|
regions => {
|
|
|
|
|
this.regions = _.map(regions, 'value');
|
|
|
|
|
},
|
|
|
|
|
err => {
|
|
|
|
|
console.error('failed to get latest regions');
|
|
|
|
|
}
|
|
|
|
|
);
|
2018-06-19 17:41:26 +09:00
|
|
|
}
|
2016-11-24 08:39:36 +01:00
|
|
|
}
|