From 2f992b18affccc7b769ec2291497224ec22c14d7 Mon Sep 17 00:00:00 2001 From: amlannandy Date: Sun, 22 Dec 2024 21:38:54 +0530 Subject: [PATCH] feat: implement cluster details page --- .../ClusterDetails.interfaces.ts | 7 + .../ClusterDetails/ClusterDetails.styles.scss | 247 +++ .../ClusterDetails/ClusterDetails.tsx | 542 ++++++ .../Events/ClusterEvents.styles.scss | 289 +++ .../ClusterDetails/Events/ClusterEvents.tsx | 259 +++ .../Events/NoEventsContainer.tsx | 16 + .../ClusterDetails/Events/constants.ts | 65 + .../Clusters/ClusterDetails/Events/index.ts | 3 + .../Logs/ClusterLogs.styles.scss | 133 ++ .../ClusterDetails/Logs/ClusterLogs.tsx | 211 +++ .../Logs/ClusterLogsDetailedView.tsx | 95 + .../ClusterDetails/Logs/NoLogsContainer.tsx | 16 + .../Clusters/ClusterDetails/Logs/constants.ts | 65 + .../Clusters/ClusterDetails/Logs/index.ts | 3 + .../Metrics/ClusterMetrics.styles.scss | 45 + .../ClusterDetails/Metrics/ClusterMetrics.tsx | 140 ++ .../ClusterDetails/Metrics/constants.ts | 1634 +++++++++++++++++ .../Clusters/ClusterDetails/Metrics/index.ts | 3 + .../Traces/ClusterTraces.styles.scss | 193 ++ .../ClusterDetails/Traces/ClusterTraces.tsx | 195 ++ .../ClusterDetails/Traces/constants.ts | 200 ++ .../Clusters/ClusterDetails/Traces/index.ts | 3 + .../Clusters/ClusterDetails/Traces/utils.tsx | 84 + .../Clusters/ClusterDetails/constants.ts | 18 + .../Clusters/ClusterDetails/index.ts | 3 + 25 files changed, 4469 insertions(+) create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.interfaces.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.styles.scss create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Events/ClusterEvents.styles.scss create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Events/ClusterEvents.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Events/NoEventsContainer.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Events/constants.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Events/index.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/ClusterLogs.styles.scss create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/ClusterLogs.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/ClusterLogsDetailedView.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/NoLogsContainer.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/constants.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Logs/index.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Metrics/ClusterMetrics.styles.scss create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Metrics/ClusterMetrics.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Metrics/constants.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Metrics/index.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Traces/ClusterTraces.styles.scss create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Traces/ClusterTraces.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Traces/constants.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Traces/index.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/Traces/utils.tsx create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/constants.ts create mode 100644 frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/index.ts diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.interfaces.ts b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.interfaces.ts new file mode 100644 index 0000000000..8126d50fba --- /dev/null +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.interfaces.ts @@ -0,0 +1,7 @@ +import { K8sClustersData } from 'api/infraMonitoring/getK8sClustersList'; + +export type ClusterDetailsProps = { + cluster: K8sClustersData | null; + isModalTimeSelection: boolean; + onClose: () => void; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.styles.scss b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.styles.scss new file mode 100644 index 0000000000..52309b5da5 --- /dev/null +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.styles.scss @@ -0,0 +1,247 @@ +.cluster-detail-drawer { + border-left: 1px solid var(--bg-slate-500); + background: var(--bg-ink-400); + box-shadow: -4px 10px 16px 2px rgba(0, 0, 0, 0.2); + + .ant-drawer-header { + padding: 8px 16px; + border-bottom: none; + + align-items: stretch; + + border-bottom: 1px solid var(--bg-slate-500); + background: var(--bg-ink-400); + } + + .ant-drawer-close { + margin-inline-end: 0px; + } + + .ant-drawer-body { + display: flex; + flex-direction: column; + padding: 16px; + } + + .title { + color: var(--text-vanilla-400); + font-family: 'Geist Mono'; + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: 20px; /* 142.857% */ + letter-spacing: -0.07px; + } + + .radio-button { + display: flex; + align-items: center; + justify-content: center; + padding-top: var(--padding-1); + border: 1px solid var(--bg-slate-400); + background: var(--bg-ink-300); + box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1); + } + + .cluster-detail-drawer__cluster { + .cluster-details-grid { + .labels-row, + .values-row { + display: grid; + grid-template-columns: 1fr 1.5fr 1.5fr 1.5fr; + gap: 30px; + align-items: center; + } + + .labels-row { + margin-bottom: 8px; + } + + .cluster-details-metadata-label { + color: var(--text-vanilla-400); + font-family: Inter; + font-size: 11px; + font-style: normal; + font-weight: 500; + line-height: 18px; /* 163.636% */ + letter-spacing: 0.44px; + text-transform: uppercase; + } + + .cluster-details-metadata-value { + color: var(--text-vanilla-400); + font-family: 'Geist Mono'; + font-size: 12px; + font-style: normal; + font-weight: 500; + line-height: 20px; /* 142.857% */ + letter-spacing: -0.07px; + + width: 100%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + .status-tag { + margin: 0; + + &.active { + color: var(--success-500); + background: var(--success-100); + border-color: var(--success-500); + } + + &.inactive { + color: var(--error-500); + background: var(--error-100); + border-color: var(--error-500); + } + } + + .progress-container { + width: 158px; + .ant-progress { + margin: 0; + + .ant-progress-text { + font-weight: 600; + } + } + } + + .ant-card { + &.ant-card-bordered { + border: 1px solid var(--bg-slate-500) !important; + } + } + } + } + + .tabs-and-search { + display: flex; + justify-content: space-between; + align-items: center; + margin: 16px 0; + + .action-btn { + border-radius: 2px; + border: 1px solid var(--bg-slate-400); + background: var(--bg-ink-300); + box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1); + display: flex; + align-items: center; + justify-content: center; + } + } + + .views-tabs-container { + margin-top: 1.5rem; + display: flex; + justify-content: space-between; + align-items: center; + + .views-tabs { + color: var(--text-vanilla-400); + + .view-title { + display: flex; + gap: var(--margin-2); + align-items: center; + justify-content: center; + font-size: var(--font-size-xs); + font-style: normal; + font-weight: var(--font-weight-normal); + } + + .tab { + border: 1px solid var(--bg-slate-400); + width: 114px; + } + + .tab::before { + background: var(--bg-slate-400); + } + + .selected_view { + background: var(--bg-slate-300); + color: var(--text-vanilla-100); + border: 1px solid var(--bg-slate-400); + } + + .selected_view::before { + background: var(--bg-slate-400); + } + } + + .compass-button { + width: 30px; + height: 30px; + + border-radius: 2px; + border: 1px solid var(--bg-slate-400); + background: var(--bg-ink-300); + box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1); + } + } + .ant-drawer-close { + padding: 0px; + } +} + +.lightMode { + .ant-drawer-header { + border-bottom: 1px solid var(--bg-vanilla-400); + background: var(--bg-vanilla-100); + } + + .cluster-detail-drawer { + .title { + color: var(--text-ink-300); + } + + .cluster-detail-drawer__cluster { + .ant-typography { + color: var(--text-ink-300); + background: transparent; + } + } + + .radio-button { + border: 1px solid var(--bg-vanilla-400); + background: var(--bg-vanilla-100); + color: var(--text-ink-300); + } + + .views-tabs { + .tab { + background: var(--bg-vanilla-100); + } + + .selected_view { + background: var(--bg-vanilla-300); + border: 1px solid var(--bg-slate-300); + color: var(--text-ink-400); + } + + .selected_view::before { + background: var(--bg-vanilla-300); + border-left: 1px solid var(--bg-slate-300); + } + } + + .compass-button { + border: 1px solid var(--bg-vanilla-300); + background: var(--bg-vanilla-100); + box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1); + } + + .tabs-and-search { + .action-btn { + border: 1px solid var(--bg-vanilla-400); + background: var(--bg-vanilla-100); + color: var(--text-ink-300); + } + } + } +} diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.tsx b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.tsx new file mode 100644 index 0000000000..184aa8bdd2 --- /dev/null +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/ClusterDetails.tsx @@ -0,0 +1,542 @@ +import './ClusterDetails.styles.scss'; + +import { Color, Spacing } from '@signozhq/design-tokens'; +import { Button, Divider, Drawer, Radio, Tooltip, Typography } from 'antd'; +import { RadioChangeEvent } from 'antd/lib'; +import logEvent from 'api/common/logEvent'; +import { QueryParams } from 'constants/query'; +import { + initialQueryBuilderFormValuesMap, + initialQueryState, +} from 'constants/queryBuilder'; +import ROUTES from 'constants/routes'; +import { + CustomTimeType, + Time, +} from 'container/TopNav/DateTimeSelectionV2/config'; +import { useIsDarkMode } from 'hooks/useDarkMode'; +import useUrlQuery from 'hooks/useUrlQuery'; +import GetMinMax from 'lib/getMinMax'; +import { + BarChart2, + ChevronsLeftRight, + Compass, + DraftingCompass, + ScrollText, + X, +} from 'lucide-react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { AppState } from 'store/reducers'; +import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse'; +import { + IBuilderQuery, + TagFilterItem, +} from 'types/api/queryBuilder/queryBuilderData'; +import { + LogsAggregatorOperator, + TracesAggregatorOperator, +} from 'types/common/queryBuilder'; +import { GlobalReducer } from 'types/reducer/globalTime'; +import { v4 as uuidv4 } from 'uuid'; + +import { ClusterDetailsProps } from './ClusterDetails.interfaces'; +import { QUERY_KEYS, VIEW_TYPES, VIEWS } from './constants'; +import ClusterEvents from './Events'; +import ClusterLogs from './Logs'; +import ClusterMetrics from './Metrics'; +import ClusterTraces from './Traces'; + +function ClusterDetails({ + cluster, + onClose, + isModalTimeSelection, +}: ClusterDetailsProps): JSX.Element { + const { maxTime, minTime, selectedTime } = useSelector< + AppState, + GlobalReducer + >((state) => state.globalTime); + + const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [ + minTime, + ]); + const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [ + maxTime, + ]); + + const urlQuery = useUrlQuery(); + + const [modalTimeRange, setModalTimeRange] = useState(() => ({ + startTime: startMs, + endTime: endMs, + })); + + const [selectedInterval, setSelectedInterval] = useState