SagarRajput-7 e83e691ef5
feat: added celery task feature - with task graphs and details (#6840)
* feat: added celery task feature - with task garphs and details

* feat: added celery bar graph toggle states UI

* feat: added histogram charts and right panel

* feat: added task latency graph with different states

* feat: added right panel trace navigation

* feat: added navigateToTrace logic

* feat: added value graph and global filter logic

* feat: added dynamic stepinterval based on timerange

* feat: changed histogram occurences to bar

* feat: onclick right panels for celery state bar graphs

* feat: pagesetup and tabs with kafka setup

* feat: custom series for bar for color generation

* feat: fixed test cases

* feat: update styles
2025-01-27 08:53:19 +05:30

93 lines
2.2 KiB
TypeScript

import { QueryParams } from 'constants/query';
import { History, Location } from 'history';
import getRenderer from 'lib/uPlotLib/utils/getRenderer';
import { Widgets } from 'types/api/dashboard/getAll';
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import { v4 as uuidv4 } from 'uuid';
export function getValuesFromQueryParams(
queryParams: QueryParams,
urlQuery: URLSearchParams,
): string[] {
const value = urlQuery.get(queryParams);
return value ? value.split(',') : [];
}
export function setQueryParamsFromOptions(
value: string[],
urlQuery: URLSearchParams,
history: History<unknown>,
location: Location<unknown>,
queryParams: QueryParams,
): void {
urlQuery.set(queryParams, value.join(','));
const generatedUrl = `${location.pathname}?${urlQuery.toString()}`;
history.replace(generatedUrl);
}
export function getFiltersFromQueryParams(
queryParams: QueryParams,
urlQuery: URLSearchParams,
key: string,
): TagFilterItem[] {
const value = urlQuery.get(queryParams);
const filters = value ? value.split(',') : [];
return filters.map((value) => ({
id: uuidv4(),
key: {
key,
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: `${key}--string--tag--false`,
},
op: '=',
value: value.toString(),
}));
}
export function applyCeleryFilterOnWidgetData(
filters: TagFilterItem[],
widgetData: Widgets,
): Widgets {
return {
...widgetData,
query: {
...widgetData.query,
builder: {
...widgetData.query.builder,
queryData: widgetData.query.builder.queryData.map((queryItem, index) =>
index === 0
? {
...queryItem,
filters: {
...queryItem.filters,
items: [...queryItem.filters.items, ...filters],
},
}
: queryItem,
),
},
},
};
}
export const paths = (
u: any,
seriesIdx: number,
idx0: number,
idx1: number,
extendGap: boolean,
buildClip: boolean,
): uPlot.Series.PathBuilder => {
const s = u.series[seriesIdx];
const style = s.drawStyle;
const interp = s.lineInterpolation;
const renderer = getRenderer(style, interp);
return renderer(u, seriesIdx, idx0, idx1, extendGap, buildClip);
};