mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 01:28:59 +08:00
feat: add autocomplete to groupBy filters (#2156)
* feat: add autocomplete to groupBy filters * chore: handle none groupby in frontend --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
This commit is contained in:
parent
2c973adf0b
commit
02ef1744b4
@ -37,7 +37,7 @@ const getSpans = async (
|
|||||||
start: String(props.start),
|
start: String(props.start),
|
||||||
end: String(props.end),
|
end: String(props.end),
|
||||||
function: props.function,
|
function: props.function,
|
||||||
groupBy: props.groupBy,
|
groupBy: props.groupBy === 'none' ? '' : props.groupBy,
|
||||||
step: props.step,
|
step: props.step,
|
||||||
tags: updatedSelectedTags,
|
tags: updatedSelectedTags,
|
||||||
...nonDuration,
|
...nonDuration,
|
||||||
|
@ -22,7 +22,7 @@ function TraceGraph(): JSX.Element {
|
|||||||
|
|
||||||
const ChartData = useMemo(
|
const ChartData = useMemo(
|
||||||
() =>
|
() =>
|
||||||
selectedGroupBy.length === 0
|
selectedGroupBy.length === 0 || selectedGroupBy === 'none'
|
||||||
? getChartData(payload)
|
? getChartData(payload)
|
||||||
: getChartDataforGroupBy(payload),
|
: getChartDataforGroupBy(payload),
|
||||||
[payload, selectedGroupBy],
|
[payload, selectedGroupBy],
|
||||||
|
@ -9,13 +9,12 @@ interface Dropdown {
|
|||||||
export const groupBy: DefaultOptionType[] = [
|
export const groupBy: DefaultOptionType[] = [
|
||||||
{
|
{
|
||||||
label: 'None',
|
label: 'None',
|
||||||
value: '',
|
value: 'none',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Service Name',
|
label: 'Service Name',
|
||||||
value: 'serviceName',
|
value: 'serviceName',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
label: 'Operation',
|
label: 'Operation',
|
||||||
value: 'name',
|
value: 'name',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { AutoComplete, Input, Space } from 'antd';
|
import { AutoComplete, Input, Space } from 'antd';
|
||||||
import getTagFilters from 'api/trace/getTagFilter';
|
import getTagFilters from 'api/trace/getTagFilter';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
@ -10,6 +10,7 @@ import { TraceReducer } from 'types/reducer/trace';
|
|||||||
import { functions } from './config';
|
import { functions } from './config';
|
||||||
import { SelectComponent } from './styles';
|
import { SelectComponent } from './styles';
|
||||||
import {
|
import {
|
||||||
|
filterGroupBy,
|
||||||
getSelectedValue,
|
getSelectedValue,
|
||||||
initOptions,
|
initOptions,
|
||||||
onClickSelectedFunctionHandler,
|
onClickSelectedFunctionHandler,
|
||||||
@ -24,6 +25,9 @@ function TraceGraphFilter(): JSX.Element {
|
|||||||
AppState,
|
AppState,
|
||||||
TraceReducer
|
TraceReducer
|
||||||
>((state) => state.traces);
|
>((state) => state.traces);
|
||||||
|
const [selectedGroupByLocal, setSelectedGroupByLocal] = useState<string>(
|
||||||
|
selectedGroupBy,
|
||||||
|
);
|
||||||
const globalTime = useSelector<AppState, GlobalReducer>(
|
const globalTime = useSelector<AppState, GlobalReducer>(
|
||||||
(state) => state.globalTime,
|
(state) => state.globalTime,
|
||||||
);
|
);
|
||||||
@ -75,8 +79,12 @@ function TraceGraphFilter(): JSX.Element {
|
|||||||
id="selectedGroupBy"
|
id="selectedGroupBy"
|
||||||
data-testid="selectedGroupBy"
|
data-testid="selectedGroupBy"
|
||||||
options={options}
|
options={options}
|
||||||
value={selectedGroupByValue(selectedGroupBy, options)}
|
value={selectedGroupByValue(selectedGroupByLocal, options)}
|
||||||
onChange={onClickSelectedGroupByHandler(options)}
|
onChange={(e): void => setSelectedGroupByLocal(e.toString())}
|
||||||
|
onSelect={onClickSelectedGroupByHandler(options)}
|
||||||
|
filterOption={(inputValue, option): boolean =>
|
||||||
|
filterGroupBy(inputValue, option)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Input disabled={isLoading} placeholder="Please select" />
|
<Input disabled={isLoading} placeholder="Please select" />
|
||||||
</AutoComplete>
|
</AutoComplete>
|
||||||
|
@ -61,13 +61,28 @@ export function onClickSelectedFunctionHandler(value: unknown): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectedGroupByValue(
|
export function selectedGroupByValue(
|
||||||
selectedGroupBy: string,
|
selectedGroupBy: string,
|
||||||
options: DefaultOptionType[],
|
options: DefaultOptionType[],
|
||||||
): ReactNode {
|
): ReactNode {
|
||||||
return options.find((e) => selectedGroupBy === e.value)?.label;
|
const optionValue = options.find((e) => selectedGroupBy === e.value)?.label;
|
||||||
|
if (optionValue) {
|
||||||
|
return optionValue;
|
||||||
|
}
|
||||||
|
return selectedGroupBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectedValue(selectedFunction: string): unknown {
|
export function getSelectedValue(selectedFunction: string): unknown {
|
||||||
return functions.find((e) => selectedFunction === e.key)?.displayValue;
|
return functions.find((e) => selectedFunction === e.key)?.displayValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function filterGroupBy(
|
||||||
|
inputValue: string,
|
||||||
|
option: DefaultOptionType | undefined,
|
||||||
|
): boolean {
|
||||||
|
return (
|
||||||
|
option?.label?.toString().toUpperCase().indexOf(inputValue.toUpperCase()) !==
|
||||||
|
-1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user