config_ctrl.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. import _ from 'lodash';
  4. export class ElasticConfigCtrl {
  5. static templateUrl = 'public/app/plugins/datasource/elasticsearch/partials/config.html';
  6. current: any;
  7. /** @ngInject */
  8. constructor($scope) {
  9. this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
  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. ];
  23. indexPatternTypeChanged() {
  24. var def = _.find(this.indexPatternTypes, {value: this.current.jsonData.interval});
  25. this.current.database = def.example || 'es-index-name';
  26. }
  27. }