2021-05-19 08:16:05 +02:00
import { SelectableValue } from '@grafana/data' ;
2022-01-25 17:28:59 +01:00
import React , { FC } from 'react' ;
2021-05-19 08:16:05 +02:00
import { AlignmentFunction , AlignmentPeriod , AlignmentPeriodLabel , QueryEditorField , QueryEditorRow } from '.' ;
2022-01-25 17:28:59 +01:00
import { SELECT_WIDTH } from '../constants' ;
2021-05-19 08:16:05 +02:00
import CloudMonitoringDatasource from '../datasource' ;
2022-01-25 17:28:59 +01:00
import { CustomMetaData , MetricQuery , SLOQuery } from '../types' ;
2021-05-19 08:16:05 +02:00
export interface Props {
2022-01-25 17:28:59 +01:00
refId : string ;
2021-10-20 09:49:49 +02:00
onChange : ( query : MetricQuery | SLOQuery ) = > void ;
2021-05-19 08:16:05 +02:00
query : MetricQuery ;
templateVariableOptions : Array < SelectableValue < string > > ;
customMetaData : CustomMetaData ;
datasource : CloudMonitoringDatasource ;
}
2022-01-25 17:28:59 +01:00
export const Alignment : FC < Props > = ( {
refId ,
templateVariableOptions ,
onChange ,
query ,
customMetaData ,
datasource ,
} ) = > {
2021-05-19 08:16:05 +02:00
return (
< QueryEditorRow
label = "Alignment function"
tooltip = "The process of alignment consists of collecting all data points received in a fixed length of time, applying a function to combine those data points, and assigning a timestamp to the result."
fillComponent = { < AlignmentPeriodLabel datasource = { datasource } customMetaData = { customMetaData } / > }
2022-01-25 17:28:59 +01:00
htmlFor = { ` ${ refId } -alignment-function ` }
2021-05-19 08:16:05 +02:00
>
2022-01-25 17:28:59 +01:00
< AlignmentFunction
inputId = { ` ${ refId } -alignment-function ` }
templateVariableOptions = { templateVariableOptions }
query = { query }
onChange = { onChange }
/ >
< QueryEditorField label = "Alignment period" htmlFor = { ` ${ refId } -alignment-period ` } >
2021-05-19 08:16:05 +02:00
< AlignmentPeriod
2022-01-25 17:28:59 +01:00
inputId = { ` ${ refId } -alignment-period ` }
2021-05-19 08:16:05 +02:00
selectWidth = { SELECT_WIDTH }
templateVariableOptions = { templateVariableOptions }
query = { query }
onChange = { onChange }
/ >
< / QueryEditorField >
< / QueryEditorRow >
) ;
} ;