Skip to content

Commit

Permalink
Merge pull request #15346 from grafana/logs-graph-series-names
Browse files Browse the repository at this point in the history
Fix for logs graph series names (level names)
  • Loading branch information
torkelo committed Feb 11, 2019
2 parents 784d4fb + e75e69a commit 8f6ccce
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 81 deletions.
1 change: 0 additions & 1 deletion public/app/core/core.ts
@@ -1,4 +1,3 @@
import './directives/dash_class';
import './directives/dropdown_typeahead';
import './directives/autofill_event_fix';
import './directives/metric_segment';
Expand Down
39 changes: 0 additions & 39 deletions public/app/core/directives/dash_class.ts

This file was deleted.

7 changes: 6 additions & 1 deletion public/app/core/logs_model.ts
Expand Up @@ -340,6 +340,11 @@ export function makeSeriesForLogs(rows: LogRowModel[], intervalMs: number): Time
return a[1] - b[1];
});

return { datapoints: series.datapoints, target: series.alias, color: series.color };
return {
datapoints: series.datapoints,
target: series.alias,
alias: series.alias,
color: series.color
};
});
}
85 changes: 45 additions & 40 deletions public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx
Expand Up @@ -2,61 +2,65 @@
import React, { PureComponent } from 'react';

// Components
import { Select, SelectOptionItem } from '@grafana/ui';
// import { Select, SelectOptionItem } from '@grafana/ui';

// Types
import { QueryEditorProps } from '@grafana/ui/src/types';
import { LokiDatasource } from '../datasource';
import { LokiQuery } from '../types';
import { LokiQueryField } from './LokiQueryField';
// import { LokiQueryField } from './LokiQueryField';

type Props = QueryEditorProps<LokiDatasource, LokiQuery>;

interface State {
query: LokiQuery;
}
// interface State {
// query: LokiQuery;
// }

export class LokiQueryEditor extends PureComponent<Props> {
state: State = {
query: this.props.query,
};

onRunQuery = () => {
const { query } = this.state;

this.props.onChange(query);
this.props.onRunQuery();
};

onFieldChange = (query: LokiQuery, override?) => {
this.setState({
query: {
...this.state.query,
expr: query.expr,
},
});
};

onFormatChanged = (option: SelectOptionItem) => {
this.props.onChange({
...this.state.query,
resultFormat: option.value,
});
};
// state: State = {
// query: this.props.query,
// };
//
// onRunQuery = () => {
// const { query } = this.state;
//
// this.props.onChange(query);
// this.props.onRunQuery();
// };
//
// onFieldChange = (query: LokiQuery, override?) => {
// this.setState({
// query: {
// ...this.state.query,
// expr: query.expr,
// },
// });
// };
//
// onFormatChanged = (option: SelectOptionItem) => {
// this.props.onChange({
// ...this.state.query,
// resultFormat: option.value,
// });
// };

render() {
const { query } = this.state;
const { datasource } = this.props;
const formatOptions: SelectOptionItem[] = [
{ label: 'Time Series', value: 'time_series' },
{ label: 'Table', value: 'table' },
];

query.resultFormat = query.resultFormat || 'time_series';
const currentFormat = formatOptions.find(item => item.value === query.resultFormat);
// const { query } = this.state;
// const { datasource } = this.props;
// const formatOptions: SelectOptionItem[] = [
// { label: 'Time Series', value: 'time_series' },
// { label: 'Table', value: 'table' },
// ];
//
// query.resultFormat = query.resultFormat || 'time_series';
// const currentFormat = formatOptions.find(item => item.value === query.resultFormat);

return (
<div>
<div className="gf-form">
<div className="gf-form-label">Loki is currently not supported as dashboard data source. We are working on it!</div>
</div>
{/*
<LokiQueryField
datasource={datasource}
query={query}
Expand All @@ -78,6 +82,7 @@ export class LokiQueryEditor extends PureComponent<Props> {
<div className="gf-form-label gf-form-label--grow" />
</div>
</div>
*/}
</div>
);
}
Expand Down

0 comments on commit 8f6ccce

Please sign in to comment.