2025-05-13 16:31:37 +05:30
|
|
|
import './QueryAggregation.styles.scss';
|
2025-05-11 17:47:30 +05:30
|
|
|
|
|
|
|
|
import InputWithLabel from 'components/InputWithLabel/InputWithLabel';
|
2025-06-07 12:45:01 +05:30
|
|
|
import { PANEL_TYPES } from 'constants/queryBuilder';
|
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { DataSource } from 'types/common/queryBuilder';
|
2025-05-11 17:47:30 +05:30
|
|
|
|
2025-05-13 16:31:37 +05:30
|
|
|
import QueryAggregationSelect from './QueryAggregationSelect';
|
|
|
|
|
|
2025-06-07 12:45:01 +05:30
|
|
|
function QueryAggregationOptions({
|
|
|
|
|
dataSource,
|
|
|
|
|
panelType,
|
|
|
|
|
}: {
|
|
|
|
|
dataSource: DataSource;
|
|
|
|
|
panelType?: string;
|
|
|
|
|
}): JSX.Element {
|
|
|
|
|
const showAggregationInterval = useMemo(() => {
|
|
|
|
|
// eslint-disable-next-line sonarjs/prefer-single-boolean-return
|
|
|
|
|
if (panelType === PANEL_TYPES.VALUE) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataSource === DataSource.TRACES || dataSource === DataSource.LOGS) {
|
|
|
|
|
return !(panelType === PANEL_TYPES.TABLE || panelType === PANEL_TYPES.PIE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}, [dataSource, panelType]);
|
|
|
|
|
|
2025-05-11 17:47:30 +05:30
|
|
|
return (
|
|
|
|
|
<div className="query-aggregation-container">
|
2025-05-14 16:43:28 +05:30
|
|
|
<QueryAggregationSelect />
|
2025-05-11 17:47:30 +05:30
|
|
|
|
2025-06-07 12:45:01 +05:30
|
|
|
{showAggregationInterval && (
|
|
|
|
|
<div className="query-aggregation-interval">
|
|
|
|
|
<div className="query-aggregation-interval-label">every</div>
|
|
|
|
|
<div className="query-aggregation-interval-input-container">
|
|
|
|
|
<InputWithLabel
|
|
|
|
|
initialValue="60"
|
|
|
|
|
label="Seconds"
|
|
|
|
|
placeholder="60"
|
|
|
|
|
type="number"
|
|
|
|
|
labelAfter
|
|
|
|
|
onClose={(): void => {}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-05-11 17:47:30 +05:30
|
|
|
</div>
|
2025-06-07 12:45:01 +05:30
|
|
|
)}
|
2025-05-11 17:47:30 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 12:45:01 +05:30
|
|
|
QueryAggregationOptions.defaultProps = {
|
|
|
|
|
panelType: null,
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-11 17:47:30 +05:30
|
|
|
export default QueryAggregationOptions;
|