import React, { SFC } from 'react'; import _ from 'lodash'; import kbn from 'app/core/utils/kbn'; import { MetricSelect } from 'app/core/components/Select/MetricSelect'; import { alignmentPeriods, alignOptions } from '../constants'; import { TemplateSrv } from 'app/features/templating/template_srv'; export interface Props { onChange: (alignmentPeriod) => void; templateSrv: TemplateSrv; alignmentPeriod: string; perSeriesAligner: string; usedAlignmentPeriod: string; } export const AlignmentPeriods: SFC = ({ alignmentPeriod, templateSrv, onChange, perSeriesAligner, usedAlignmentPeriod, }) => { const alignment = alignOptions.find(ap => ap.value === templateSrv.replace(perSeriesAligner)); const formatAlignmentText = `${kbn.secondsToHms(usedAlignmentPeriod)} interval (${alignment ? alignment.text : ''})`; return ( <>
({ ...ap, label: ap.text, })), }, ]} placeholder="Select Alignment" className="width-15" />
{usedAlignmentPeriod && }
); };