Skip to content

Commit c62f09f

Browse files
RI-7687: adjust statistics page
1 parent 3c4202a commit c62f09f

File tree

13 files changed

+322
-299
lines changed

13 files changed

+322
-299
lines changed

redisinsight/ui/src/components/auto-refresh/AutoRefresh.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727

2828
import styles from './styles.module.scss'
2929

30-
const AutoRefreshInterval = styled.span<
30+
const AutoRefreshInterval = styled(ColorText)<
3131
HTMLAttributes<HTMLSpanElement> & {
3232
enableAutoRefresh: boolean
3333
disabled?: boolean
@@ -247,26 +247,34 @@ const AutoRefresh = ({
247247
[styles.enable]: !disabled && enableAutoRefresh,
248248
})}
249249
data-testid={getDataTestid('auto-refresh-container')}
250+
// TODO: fix properly
251+
style={{ lineHeight: 1 }}
250252
>
251-
<FlexItem>
252-
<ColorText size="s">
253-
{displayText && (
254-
<span data-testid={getDataTestid('refresh-message-label')}>
255-
{enableAutoRefresh ? 'Auto refresh:' : 'Last refresh:'}
256-
</span>
257-
)}
258-
{displayLastRefresh && (
259-
<AutoRefreshInterval
260-
disabled={disabled}
261-
enableAutoRefresh={enableAutoRefresh}
262-
className={cx('refresh-message-time')}
263-
data-testid={getDataTestid('refresh-message')}
264-
>
265-
{` ${enableAutoRefresh ? refreshRateMessage : refreshMessage}`}
266-
</AutoRefreshInterval>
267-
)}
268-
</ColorText>
269-
</FlexItem>
253+
{displayText && (
254+
<FlexItem>
255+
<ColorText
256+
size="s"
257+
component="span"
258+
data-testid={getDataTestid('refresh-message-label')}
259+
>
260+
{enableAutoRefresh ? 'Auto refresh:' : 'Last refresh:'}
261+
</ColorText>
262+
</FlexItem>
263+
)}
264+
{displayLastRefresh && (
265+
<FlexItem>
266+
<AutoRefreshInterval
267+
disabled={disabled}
268+
enableAutoRefresh={enableAutoRefresh}
269+
className={cx('refresh-message-time')}
270+
data-testid={getDataTestid('refresh-message')}
271+
component="span"
272+
size="s"
273+
>
274+
{` ${enableAutoRefresh ? refreshRateMessage : refreshMessage}`}
275+
</AutoRefreshInterval>
276+
</FlexItem>
277+
)}
270278
<FlexItem>
271279
<Row align="center" gap="none">
272280
<FlexItem>

redisinsight/ui/src/components/base/text/text.styles.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ export const Indicator = styled.div<
106106
background-color: ${({ $color }) => $color || 'inherit'};
107107
`
108108

109+
const useStatusColorStyles = ({ $color }: MapProps = {}) => {
110+
const theme = useTheme()
111+
const colors = theme.semantic.color
112+
113+
const getColorValue = (color?: ColorType) => {
114+
switch (color) {
115+
case 'danger':
116+
return colors.text.danger500
117+
case 'warning':
118+
return colors.text.attention500
119+
case 'success':
120+
return colors.text.success500
121+
default:
122+
return color // any supported color value e.g #fff
123+
}
124+
}
125+
126+
return css`
127+
background-color: ${getColorValue($color)};
128+
`
129+
}
130+
131+
export const StatusIndicator = styled.div<
132+
{
133+
$color: ColorType
134+
} & CommonProps
135+
>`
136+
${useStatusColorStyles};
137+
width: 1rem;
138+
height: 1rem;
139+
border-radius: 50%;
140+
`
109141
export const mapSize = (size: TextSizeType): BodyProps['size'] => {
110142
if (size === 'm') {
111143
return 'M'

redisinsight/ui/src/pages/rdi/statistics/StatisticsPage.tsx

Lines changed: 37 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ import Status from './status'
2929
import TargetConnections from './target-connections'
3030

3131
import styles from './styles.module.scss'
32+
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
33+
import { AutoRefresh } from 'uiSrc/components'
3234

3335
const shouldShowStatistics = (data: Nullable<IRdiStatistics>) =>
3436
data?.status === RdiPipelineStatus.Success && !!data?.data
3537

3638
const StatisticsPage = () => {
3739
const [pageLoading, setPageLoading] = useState(true)
3840
const { rdiInstanceId } = useParams<{ rdiInstanceId: string }>()
41+
const [lastRefreshTime, setLastRefreshTime] = React.useState(Date.now())
3942

4043
const dispatch = useDispatch()
4144

@@ -120,9 +123,10 @@ const StatisticsPage = () => {
120123

121124
const { data: statisticsData } = statisticsResults
122125

126+
123127
return (
124128
<div className={styles.pageContainer}>
125-
<div className={styles.bodyContainer}>
129+
<Col gap="xxl" style={{ padding: 16 }}>
126130
{pageLoading && (
127131
<div className={styles.cover}>
128132
<Loader size="xl" />
@@ -133,61 +137,45 @@ const StatisticsPage = () => {
133137
<Empty rdiInstanceId={rdiInstanceId} />
134138
) : (
135139
<>
140+
<Row justify="end">
141+
<FlexItem>
142+
<AutoRefresh
143+
postfix="processing-performance-info"
144+
displayText
145+
loading={isStatisticsLoading}
146+
lastRefreshTime={lastRefreshTime}
147+
enableAutoRefreshDefault
148+
testid="processing-performance-info"
149+
onRefresh={() => {
150+
setLastRefreshTime(Date.now())
151+
onRefresh('processing_performance')
152+
}}
153+
onRefreshClicked={() =>
154+
onRefreshClicked('processing_performance')
155+
}
156+
onEnableAutoRefresh={(
157+
enableAutoRefresh: boolean,
158+
refreshRate: string,
159+
) =>
160+
onChangeAutoRefresh(
161+
'processing_performance',
162+
enableAutoRefresh,
163+
refreshRate,
164+
)
165+
}
166+
/>
167+
</FlexItem>
168+
</Row>
136169
<Status data={statisticsData.rdiPipelineStatus} />
137170
<ProcessingPerformance
138171
data={statisticsData.processingPerformance}
139-
loading={isStatisticsLoading}
140-
onRefresh={() => onRefresh('processing_performance')}
141-
onRefreshClicked={() =>
142-
onRefreshClicked('processing_performance')
143-
}
144-
onChangeAutoRefresh={(
145-
enableAutoRefresh: boolean,
146-
refreshRate: string,
147-
) =>
148-
onChangeAutoRefresh(
149-
'processing_performance',
150-
enableAutoRefresh,
151-
refreshRate,
152-
)
153-
}
154172
/>
155173
<TargetConnections data={statisticsData.connections} />
156-
<DataStreams
157-
data={statisticsData.dataStreams}
158-
loading={isStatisticsLoading}
159-
onRefresh={() => {
160-
dispatch(fetchRdiStatistics(rdiInstanceId, 'data_streams'))
161-
}}
162-
onRefreshClicked={() => onRefreshClicked('data_streams')}
163-
onChangeAutoRefresh={(
164-
enableAutoRefresh: boolean,
165-
refreshRate: string,
166-
) =>
167-
onChangeAutoRefresh(
168-
'data_streams',
169-
enableAutoRefresh,
170-
refreshRate,
171-
)
172-
}
173-
/>
174-
<Clients
175-
data={statisticsData.clients}
176-
loading={isStatisticsLoading}
177-
onRefresh={() => {
178-
dispatch(fetchRdiStatistics(rdiInstanceId, 'clients'))
179-
}}
180-
onRefreshClicked={() => onRefreshClicked('clients')}
181-
onChangeAutoRefresh={(
182-
enableAutoRefresh: boolean,
183-
refreshRate: string,
184-
) =>
185-
onChangeAutoRefresh('clients', enableAutoRefresh, refreshRate)
186-
}
187-
/>
174+
<DataStreams data={statisticsData.dataStreams} />
175+
<Clients data={statisticsData.clients} />
188176
</>
189177
)}
190-
</div>
178+
</Col>
191179
</div>
192180
)
193181
}

redisinsight/ui/src/pages/rdi/statistics/clients/Clients.tsx

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import React from 'react'
22

33
import { IClients } from 'uiSrc/slices/interfaces'
44
import { Table, ColumnDefinition } from 'uiSrc/components/base/layout/table'
5-
import Accordion from '../components/accordion'
6-
import Panel from '../components/panel'
5+
import { Section } from '@redis-ui/components'
6+
import {
7+
StyledRdiAnalyticsTable,
8+
StyledRdiStatisticsSectionBody,
9+
} from 'uiSrc/pages/rdi/statistics/styles'
710

811
type ClientsData = {
912
id: string
@@ -55,19 +58,9 @@ const columns: ColumnDefinition<ClientsData>[] = [
5558

5659
interface Props {
5760
data: IClients
58-
loading: boolean
59-
onRefresh: () => void
60-
onRefreshClicked: () => void
61-
onChangeAutoRefresh: (enableAutoRefresh: boolean, refreshRate: string) => void
6261
}
6362

64-
const Clients = ({
65-
data,
66-
loading,
67-
onRefresh,
68-
onRefreshClicked,
69-
onChangeAutoRefresh,
70-
}: Props) => {
63+
const Clients = ({ data }: Props) => {
7164
const clients: ClientsData[] = Object.keys(data).map((key) => {
7265
const client = data[key]
7366
return {
@@ -77,23 +70,21 @@ const Clients = ({
7770
})
7871

7972
return (
80-
<Panel>
81-
<Accordion
82-
id="clients"
83-
title="Clients"
84-
hideAutoRefresh
85-
loading={loading}
86-
onRefresh={onRefresh}
87-
onRefreshClicked={onRefreshClicked}
88-
onChangeAutoRefresh={onChangeAutoRefresh}
89-
>
90-
<Table
91-
columns={columns}
92-
data={clients}
93-
defaultSorting={[{ id: 'id', desc: false }]}
94-
/>
95-
</Accordion>
96-
</Panel>
73+
<Section.Compose collapsible defaultOpen id="clients">
74+
<Section.Header label="Clients" />
75+
<StyledRdiStatisticsSectionBody
76+
content={
77+
<StyledRdiAnalyticsTable
78+
columns={columns}
79+
data={clients}
80+
defaultSorting={[{ id: 'id', desc: false }]}
81+
>
82+
<Table.Header />
83+
<Table.Body />
84+
</StyledRdiAnalyticsTable>
85+
}
86+
/>
87+
</Section.Compose>
9788
)
9889
}
9990

redisinsight/ui/src/pages/rdi/statistics/data-streams/DataStreams.tsx

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { IDataStreams } from 'uiSrc/slices/interfaces'
44
import { formatLongName } from 'uiSrc/utils'
55
import { FormatedDate, RiTooltip } from 'uiSrc/components'
66
import { Table, ColumnDefinition } from 'uiSrc/components/base/layout/table'
7-
import Accordion from '../components/accordion'
8-
import Panel from '../components/panel'
7+
import { Section } from '@redis-ui/components'
8+
import {
9+
StyledRdiAnalyticsTable,
10+
StyledRdiStatisticsSectionBody,
11+
} from 'uiSrc/pages/rdi/statistics/styles'
912

1013
type DataStreamsData = {
1114
name: string
@@ -22,10 +25,6 @@ type DataStreamsData = {
2225

2326
interface Props {
2427
data: IDataStreams
25-
loading: boolean
26-
onRefresh: () => void
27-
onRefreshClicked: () => void
28-
onChangeAutoRefresh: (enableAutoRefresh: boolean, refreshRate: string) => void
2928
}
3029

3130
const columns: ColumnDefinition<DataStreamsData>[] = [
@@ -99,10 +98,6 @@ const columns: ColumnDefinition<DataStreamsData>[] = [
9998

10099
const DataStreams = ({
101100
data,
102-
loading,
103-
onRefresh,
104-
onRefreshClicked,
105-
onChangeAutoRefresh,
106101
}: Props) => {
107102
const dataStreams: DataStreamsData[] = Object.keys(data?.streams || {}).map(
108103
(key) => {
@@ -128,23 +123,21 @@ const DataStreams = ({
128123
}
129124

130125
return (
131-
<Panel>
132-
<Accordion
133-
id="data-streams"
134-
title="Data streams overview"
135-
hideAutoRefresh
136-
loading={loading}
137-
onRefresh={onRefresh}
138-
onRefreshClicked={onRefreshClicked}
139-
onChangeAutoRefresh={onChangeAutoRefresh}
140-
>
141-
<Table
142-
columns={columns}
143-
data={[...dataStreams, totalsRow]}
144-
defaultSorting={[{ id: 'name', desc: false }]}
145-
/>
146-
</Accordion>
147-
</Panel>
126+
<Section.Compose collapsible defaultOpen id="data-streams">
127+
<Section.Header label="Data streams overview" />
128+
<StyledRdiStatisticsSectionBody
129+
content={
130+
<StyledRdiAnalyticsTable
131+
columns={columns}
132+
data={[...dataStreams, totalsRow]}
133+
defaultSorting={[{ id: 'name', desc: false }]}
134+
>
135+
<Table.Header />
136+
<Table.Body />
137+
</StyledRdiAnalyticsTable>
138+
}
139+
/>
140+
</Section.Compose>
148141
)
149142
}
150143

0 commit comments

Comments
 (0)