Files
grafana/public/app/plugins/datasource/cloudwatch/config_ctrl.ts

62 lines
1.7 KiB
TypeScript
Raw Normal View History

2018-07-24 22:09:33 +09:00
import _ from 'lodash';
export class CloudWatchConfigCtrl {
2017-12-20 12:33:33 +01:00
static templateUrl = 'partials/config.html';
current: any;
2018-07-24 22:09:33 +09:00
datasourceSrv: any;
2017-01-30 15:04:55 +01:00
accessKeyExist = false;
secretKeyExist = false;
/** @ngInject */
2018-07-24 22:09:33 +09:00
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;
2018-07-24 22:09:33 +09:00
this.datasourceSrv = datasourceSrv;
2018-06-19 17:41:26 +09:00
this.getRegions();
}
resetAccessKey() {
this.accessKeyExist = false;
}
resetSecretKey() {
this.secretKeyExist = false;
}
authTypes = [
2017-12-20 12:33:33 +01:00
{ name: 'Access & secret key', value: 'keys' },
{ name: 'Credentials file', value: 'credentials' },
{ name: 'ARN', value: 'arn' },
];
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' },
];
2018-06-19 17:41:26 +09:00
regions = [];
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();
})
.then(
regions => {
this.regions = _.map(regions, 'value');
},
err => {
console.error('failed to get latest regions');
}
);
2018-06-19 17:41:26 +09:00
}
}