LokiQueryEditor.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Libraries
  2. import React, { PureComponent } from 'react';
  3. // Components
  4. // import { Select, SelectOptionItem } from '@grafana/ui';
  5. // Types
  6. import { QueryEditorProps } from '@grafana/ui/src/types';
  7. import { LokiDatasource } from '../datasource';
  8. import { LokiQuery } from '../types';
  9. // import { LokiQueryField } from './LokiQueryField';
  10. type Props = QueryEditorProps<LokiDatasource, LokiQuery>;
  11. // interface State {
  12. // query: LokiQuery;
  13. // }
  14. export class LokiQueryEditor extends PureComponent<Props> {
  15. // state: State = {
  16. // query: this.props.query,
  17. // };
  18. //
  19. // onRunQuery = () => {
  20. // const { query } = this.state;
  21. //
  22. // this.props.onChange(query);
  23. // this.props.onRunQuery();
  24. // };
  25. //
  26. // onFieldChange = (query: LokiQuery, override?) => {
  27. // this.setState({
  28. // query: {
  29. // ...this.state.query,
  30. // expr: query.expr,
  31. // },
  32. // });
  33. // };
  34. //
  35. // onFormatChanged = (option: SelectOptionItem) => {
  36. // this.props.onChange({
  37. // ...this.state.query,
  38. // resultFormat: option.value,
  39. // });
  40. // };
  41. render() {
  42. // const { query } = this.state;
  43. // const { datasource } = this.props;
  44. // const formatOptions: SelectOptionItem[] = [
  45. // { label: 'Time Series', value: 'time_series' },
  46. // { label: 'Table', value: 'table' },
  47. // ];
  48. //
  49. // query.resultFormat = query.resultFormat || 'time_series';
  50. // const currentFormat = formatOptions.find(item => item.value === query.resultFormat);
  51. return (
  52. <div>
  53. <div className="gf-form">
  54. <div className="gf-form-label">
  55. Loki is currently not supported as dashboard data source. We are working on it!
  56. </div>
  57. </div>
  58. {/*
  59. <LokiQueryField
  60. datasource={datasource}
  61. query={query}
  62. onQueryChange={this.onFieldChange}
  63. onExecuteQuery={this.onRunQuery}
  64. history={[]}
  65. />
  66. <div className="gf-form-inline">
  67. <div className="gf-form">
  68. <div className="gf-form-label">Format as</div>
  69. <Select
  70. isSearchable={false}
  71. options={formatOptions}
  72. onChange={this.onFormatChanged}
  73. value={currentFormat}
  74. />
  75. </div>
  76. <div className="gf-form gf-form--grow">
  77. <div className="gf-form-label gf-form-label--grow" />
  78. </div>
  79. </div>
  80. */}
  81. </div>
  82. );
  83. }
  84. }
  85. export default LokiQueryEditor;