config_ctrl.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import _ from 'lodash';
  2. export class CloudWatchConfigCtrl {
  3. static templateUrl = 'partials/config.html';
  4. current: any;
  5. datasourceSrv: any;
  6. accessKeyExist = false;
  7. secretKeyExist = false;
  8. /** @ngInject */
  9. constructor($scope, datasourceSrv) {
  10. this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
  11. this.current.jsonData.authType = this.current.jsonData.authType || 'credentials';
  12. this.accessKeyExist = this.current.secureJsonFields.accessKey;
  13. this.secretKeyExist = this.current.secureJsonFields.secretKey;
  14. this.datasourceSrv = datasourceSrv;
  15. this.getRegions();
  16. }
  17. resetAccessKey() {
  18. this.accessKeyExist = false;
  19. }
  20. resetSecretKey() {
  21. this.secretKeyExist = false;
  22. }
  23. authTypes = [
  24. { name: 'Access & secret key', value: 'keys' },
  25. { name: 'Credentials file', value: 'credentials' },
  26. { name: 'ARN', value: 'arn' },
  27. ];
  28. indexPatternTypes = [
  29. { name: 'No pattern', value: undefined },
  30. { name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },
  31. { name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },
  32. { name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },
  33. { name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },
  34. { name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
  35. ];
  36. regions = [
  37. 'ap-northeast-1',
  38. 'ap-northeast-2',
  39. 'ap-northeast-3',
  40. 'ap-south-1',
  41. 'ap-southeast-1',
  42. 'ap-southeast-2',
  43. 'ca-central-1',
  44. 'cn-north-1',
  45. 'cn-northwest-1',
  46. 'eu-central-1',
  47. 'eu-north-1',
  48. 'eu-west-1',
  49. 'eu-west-2',
  50. 'eu-west-3',
  51. 'me-south-1',
  52. 'sa-east-1',
  53. 'us-east-1',
  54. 'us-east-2',
  55. 'us-gov-east-1',
  56. 'us-gov-west-1',
  57. 'us-iso-east-1',
  58. 'us-isob-east-1',
  59. 'us-west-1',
  60. 'us-west-2',
  61. ];
  62. getRegions() {
  63. this.datasourceSrv
  64. .loadDatasource(this.current.name)
  65. .then(ds => {
  66. return ds.getRegions();
  67. })
  68. .then(
  69. regions => {
  70. this.regions = _.map(regions, 'value');
  71. },
  72. err => {
  73. console.error('failed to get latest regions');
  74. }
  75. );
  76. }
  77. }