mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* cloud monitoring mql support * reduce nesting * remove resource type from deep link since. its removed for two reasons. first of all it is not needed for the link to work. secondly, by adding the resource type, the the link will differ from the query in grafana which I think is misleading * use frame.meta.executedQueryString instead of legacy meta Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
85 lines
2.9 KiB
TypeScript
85 lines
2.9 KiB
TypeScript
import React from 'react';
|
|
import { Aggregations, Metrics, LabelFilter, GroupBys, Alignments, AlignmentPeriods } from '.';
|
|
import { MetricQuery, MetricDescriptor } from '../types';
|
|
import { getAlignmentPickerData } from '../functions';
|
|
import CloudMonitoringDatasource from '../datasource';
|
|
import { SelectableValue } from '@grafana/data';
|
|
|
|
export interface Props {
|
|
usedAlignmentPeriod?: number;
|
|
variableOptionGroup: SelectableValue<string>;
|
|
onMetricTypeChange: (query: MetricDescriptor) => void;
|
|
onChange: (query: MetricQuery) => void;
|
|
query: MetricQuery;
|
|
datasource: CloudMonitoringDatasource;
|
|
labels: any;
|
|
}
|
|
|
|
function Editor({
|
|
query,
|
|
labels,
|
|
datasource,
|
|
onChange,
|
|
onMetricTypeChange,
|
|
usedAlignmentPeriod,
|
|
variableOptionGroup,
|
|
}: React.PropsWithChildren<Props>) {
|
|
const { perSeriesAligner, alignOptions } = getAlignmentPickerData(query, datasource.templateSrv);
|
|
|
|
return (
|
|
<Metrics
|
|
templateSrv={datasource.templateSrv}
|
|
projectName={query.projectName}
|
|
metricType={query.metricType}
|
|
templateVariableOptions={variableOptionGroup.options}
|
|
datasource={datasource}
|
|
onChange={onMetricTypeChange}
|
|
>
|
|
{metric => (
|
|
<>
|
|
<LabelFilter
|
|
labels={labels}
|
|
filters={query.filters!}
|
|
onChange={filters => onChange({ ...query, filters })}
|
|
variableOptionGroup={variableOptionGroup}
|
|
/>
|
|
<GroupBys
|
|
groupBys={Object.keys(labels)}
|
|
values={query.groupBys!}
|
|
onChange={groupBys => onChange({ ...query, groupBys })}
|
|
variableOptionGroup={variableOptionGroup}
|
|
/>
|
|
<Aggregations
|
|
metricDescriptor={metric}
|
|
templateVariableOptions={variableOptionGroup.options}
|
|
crossSeriesReducer={query.crossSeriesReducer}
|
|
groupBys={query.groupBys!}
|
|
onChange={crossSeriesReducer => onChange({ ...query, crossSeriesReducer })}
|
|
>
|
|
{displayAdvancedOptions =>
|
|
displayAdvancedOptions && (
|
|
<Alignments
|
|
alignOptions={alignOptions}
|
|
templateVariableOptions={variableOptionGroup.options}
|
|
perSeriesAligner={perSeriesAligner || ''}
|
|
onChange={perSeriesAligner => onChange({ ...query, perSeriesAligner })}
|
|
/>
|
|
)
|
|
}
|
|
</Aggregations>
|
|
<AlignmentPeriods
|
|
templateSrv={datasource.templateSrv}
|
|
templateVariableOptions={variableOptionGroup.options}
|
|
alignmentPeriod={query.alignmentPeriod || ''}
|
|
perSeriesAligner={query.perSeriesAligner || ''}
|
|
usedAlignmentPeriod={usedAlignmentPeriod}
|
|
onChange={alignmentPeriod => onChange({ ...query, alignmentPeriod })}
|
|
/>
|
|
</>
|
|
)}
|
|
</Metrics>
|
|
);
|
|
}
|
|
|
|
export const VisualMetricQueryEditor = React.memo(Editor);
|