From 43577c7ead5ee1b7a1586ec39c66f5850e17389e Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Fri, 13 Sep 2024 13:47:08 +0530 Subject: [PATCH] feat: group by severity logs explorer page by default (#5772) * feat: initial setup for group by severity logs explorer page * chore: reduce the height of the histogram * chore: pr cleanup * chore: minor color update * chore: clean the PR * chore: clean the PR * chore: better base handling * fix: append query names to the legends in case of multiple queries * feat: make the changes only for list view and add back legends --- frontend/src/components/Graph/utils.ts | 5 ++- .../LogsExplorerChart.interfaces.ts | 1 + .../src/container/LogsExplorerChart/index.tsx | 13 +++++-- .../src/container/LogsExplorerChart/utils.ts | 36 +++++++++++++++++++ .../LogsExplorerViews.styles.scss | 7 ++++ .../src/container/LogsExplorerViews/index.tsx | 12 +++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 frontend/src/container/LogsExplorerChart/utils.ts diff --git a/frontend/src/components/Graph/utils.ts b/frontend/src/components/Graph/utils.ts index db30b6a8cefe..f002d1402fa1 100644 --- a/frontend/src/components/Graph/utils.ts +++ b/frontend/src/components/Graph/utils.ts @@ -139,6 +139,7 @@ export const getGraphOptions = ( }, scales: { x: { + stacked: isStacked, grid: { display: true, color: getGridColor(), @@ -165,6 +166,7 @@ export const getGraphOptions = ( ticks: { color: getAxisLabelColor(currentTheme) }, }, y: { + stacked: isStacked, display: true, grid: { display: true, @@ -178,9 +180,6 @@ export const getGraphOptions = ( }, }, }, - stacked: { - display: isStacked === undefined ? false : 'auto', - }, }, elements: { line: { diff --git a/frontend/src/container/LogsExplorerChart/LogsExplorerChart.interfaces.ts b/frontend/src/container/LogsExplorerChart/LogsExplorerChart.interfaces.ts index a19a41d77807..ee447242eb0c 100644 --- a/frontend/src/container/LogsExplorerChart/LogsExplorerChart.interfaces.ts +++ b/frontend/src/container/LogsExplorerChart/LogsExplorerChart.interfaces.ts @@ -3,6 +3,7 @@ import { QueryData } from 'types/api/widgets/getQuery'; export type LogsExplorerChartProps = { data: QueryData[]; isLoading: boolean; + isLogsExplorerViews?: boolean; isLabelEnabled?: boolean; className?: string; }; diff --git a/frontend/src/container/LogsExplorerChart/index.tsx b/frontend/src/container/LogsExplorerChart/index.tsx index 7f4d6485292c..7ac1934bb7a6 100644 --- a/frontend/src/container/LogsExplorerChart/index.tsx +++ b/frontend/src/container/LogsExplorerChart/index.tsx @@ -16,12 +16,14 @@ import { UpdateTimeInterval } from 'store/actions'; import { LogsExplorerChartProps } from './LogsExplorerChart.interfaces'; import { CardStyled } from './LogsExplorerChart.styled'; +import { getColorsForSeverityLabels } from './utils'; function LogsExplorerChart({ data, isLoading, isLabelEnabled = true, className, + isLogsExplorerViews = false, }: LogsExplorerChartProps): JSX.Element { const dispatch = useDispatch(); const urlQuery = useUrlQuery(); @@ -29,15 +31,19 @@ function LogsExplorerChart({ const handleCreateDatasets: Required['createDataset'] = useCallback( (element, index, allLabels) => ({ data: element, - backgroundColor: colors[index % colors.length] || themeColors.red, - borderColor: colors[index % colors.length] || themeColors.red, + backgroundColor: isLogsExplorerViews + ? getColorsForSeverityLabels(allLabels[index], index) + : colors[index % colors.length] || themeColors.red, + borderColor: isLogsExplorerViews + ? getColorsForSeverityLabels(allLabels[index], index) + : colors[index % colors.length] || themeColors.red, ...(isLabelEnabled ? { label: allLabels[index], } : {}), }), - [isLabelEnabled], + [isLabelEnabled, isLogsExplorerViews], ); const onDragSelect = useCallback( @@ -112,6 +118,7 @@ function LogsExplorerChart({ )}