config_ctrl.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. }
  10. indexPatternTypes = [
  11. {name: 'No pattern', value: undefined},
  12. {name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH'},
  13. {name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD'},
  14. {name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW'},
  15. {name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM'},
  16. {name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY'},
  17. ];
  18. esVersions = [
  19. {name: '2.x', value: 2},
  20. {name: '5.x', value: 5},
  21. ];
  22. indexPatternTypeChanged() {
  23. var def = _.find(this.indexPatternTypes, {value: this.current.jsonData.interval});
  24. this.current.database = def.example || 'es-index-name';
  25. }
  26. }