config_ctrl.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import _ from 'lodash';
  2. export class ElasticConfigCtrl {
  3. static templateUrl = 'public/app/plugins/datasource/elasticsearch/partials/config.html';
  4. current: any;
  5. /** @ngInject */
  6. constructor($scope) {
  7. this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
  8. this.current.jsonData.esVersion = this.current.jsonData.esVersion || 5;
  9. this.current.jsonData.maxConcurrentShardRequests = this.current.jsonData.maxConcurrentShardRequests || 256;
  10. }
  11. indexPatternTypes = [
  12. {name: 'No pattern', value: undefined},
  13. {name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH'},
  14. {name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD'},
  15. {name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW'},
  16. {name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM'},
  17. {name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY'},
  18. ];
  19. esVersions = [
  20. {name: '2.x', value: 2},
  21. {name: '5.x', value: 5},
  22. {name: '5.6+', value: 56},
  23. ];
  24. indexPatternTypeChanged() {
  25. var def = _.find(this.indexPatternTypes, {value: this.current.jsonData.interval});
  26. this.current.database = def.example || 'es-index-name';
  27. }
  28. }