The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/cloud-monitoring/components/GraphPeriod.tsx

49 lines
1.5 KiB

import React from 'react';
import { SelectableValue } from '@grafana/data';
import { EditorField, EditorRow } from '@grafana/experimental';
import { HorizontalGroup, Switch } from '@grafana/ui';
import { GRAPH_PERIODS } from '../constants';
import { PeriodSelect } from './index';
export interface Props {
refId: string;
onChange: (period: string) => void;
variableOptionGroup: SelectableValue<string>;
graphPeriod?: string;
}
export const GraphPeriod = ({ refId, onChange, graphPeriod, variableOptionGroup }: Props) => {
return (
<EditorRow>
<EditorField
label="Graph period"
htmlFor={`${refId}-graph-period`}
tooltip={
<>
Set <code>graph_period</code> which forces a preferred period between points. Automatically set to the
current interval if left blank.
</>
}
>
<HorizontalGroup>
<Switch
data-testid={`${refId}-switch-graph-period`}
value={graphPeriod !== 'disabled'}
onChange={(e) => onChange(e.currentTarget.checked ? '' : 'disabled')}
/>
<PeriodSelect
inputId={`${refId}-graph-period`}
templateVariableOptions={variableOptionGroup.options}
current={graphPeriod}
onChange={onChange}
disabled={graphPeriod === 'disabled'}
aligmentPeriods={GRAPH_PERIODS}
/>
</HorizontalGroup>
</EditorField>
</EditorRow>
);
};