Skip to content

Commit 099ed36

Browse files
authored
FE: Fix statistics timer, update theming (#228)
1 parent 51adeb7 commit 099ed36

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

frontend/src/components/Topics/Topic/Statistics/Metrics.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import * as S from './Statistics.styles';
2121
import Total from './Indicators/Total';
2222
import SizeStats from './Indicators/SizeStats';
2323
import PartitionTable from './PartitionTable';
24+
import { LabelValue } from './Statistics.styles';
2425

2526
const Metrics: React.FC = () => {
2627
const params = useAppParams<RouteParamsClusterTopic>();
@@ -67,21 +68,23 @@ const Metrics: React.FC = () => {
6768
</ActionButton>
6869
<List>
6970
<Label>Started at</Label>
70-
<span>
71+
<LabelValue>
7172
{formatTimestamp(data.progress.startedAt, {
7273
hour: 'numeric',
7374
minute: 'numeric',
7475
second: 'numeric',
7576
})}
76-
</span>
77+
</LabelValue>
7778
<Label>Passed since start</Label>
78-
<span>{calculateTimer(data.progress.startedAt as number)}</span>
79+
<LabelValue>
80+
{calculateTimer(data.progress.startedAt as number)}
81+
</LabelValue>
7982
<Label>Scanned messages</Label>
80-
<span>{data.progress.msgsScanned}</span>
83+
<LabelValue>{data.progress.msgsScanned}</LabelValue>
8184
<Label>Scanned size</Label>
82-
<span>
85+
<LabelValue>
8386
<BytesFormatted value={data.progress.bytesScanned} />
84-
</span>
87+
</LabelValue>
8588
</List>
8689
</S.ProgressContainer>
8790
);

frontend/src/components/Topics/Topic/Statistics/PartitionInfoRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const PartitionInfoRow: React.FC<{ row: Row<TopicAnalysisStats> }> = ({
5151
<div>
5252
<Heading level={4}>Keys sizes</Heading>
5353
<List>
54-
<Label>Total keys size</Label>
54+
<Label>Total key size</Label>
5555
<BytesFormatted value={keySize?.sum} />
5656
<Label>Min key size</Label>
5757
<BytesFormatted value={keySize?.min} />
@@ -74,7 +74,7 @@ const PartitionInfoRow: React.FC<{ row: Row<TopicAnalysisStats> }> = ({
7474
<div>
7575
<Heading level={4}>Values sizes</Heading>
7676
<List>
77-
<Label>Total keys size</Label>
77+
<Label>Total key size</Label>
7878
<BytesFormatted value={valueSize?.sum} />
7979
<Label>Min key size</Label>
8080
<BytesFormatted value={valueSize?.min} />

frontend/src/components/Topics/Topic/Statistics/Statistics.styles.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const ActionsBar = styled.div`
2727
export const CreatedAt = styled.div`
2828
font-size: 12px;
2929
line-height: 1.5;
30-
color: ${({ theme }) => theme.statictics.createdAtColor};
30+
color: ${({ theme }) => theme.statistics.createdAtColor};
3131
`;
3232

3333
export const PartitionInfo = styled.div`
@@ -47,5 +47,9 @@ export const ProgressPct = styled.span`
4747
font-size: 15px;
4848
font-weight: bold;
4949
line-height: 1.5;
50-
color: ${({ theme }) => theme.statictics.progressPctColor};
50+
color: ${({ theme }) => theme.statistics.progressPctColor};
51+
`;
52+
53+
export const LabelValue = styled.span`
54+
color: ${({ theme }) => theme.statistics.createdAtColor};
5155
`;

frontend/src/lib/dateTimeHelpers.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ export const formatMilliseconds = (input = 0) => {
4343
export const passedTime = (value: number) => (value < 10 ? `0${value}` : value);
4444

4545
export const calculateTimer = (startedAt: number) => {
46-
const nowDate = new Date();
47-
const now = nowDate.getTime();
48-
const newDate = now - startedAt;
49-
const minutes = nowDate.getMinutes();
50-
const second = nowDate.getSeconds();
46+
const now = new Date().getTime();
47+
const elapsedMillis = now - startedAt;
5148

52-
return newDate > 0 ? `${passedTime(minutes)}:${passedTime(second)}` : '00:00';
49+
if (elapsedMillis < 0) {
50+
return '00:00';
51+
}
52+
53+
const seconds = Math.floor(elapsedMillis / 1000) % 60;
54+
const minutes = Math.floor(elapsedMillis / 60000);
55+
56+
return `${passedTime(minutes)}:${passedTime(seconds)}`;
5357
};

frontend/src/theme/theme.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,17 @@ const baseTheme = {
263263
color: Colors.neutral[90],
264264
},
265265
switch: {
266-
unchecked: Colors.neutral[20],
266+
unchecked: Colors.brand[30],
267267
hover: Colors.neutral[40],
268-
checked: Colors.brand[50],
268+
checked: Colors.brand[90],
269269
circle: Colors.neutral[0],
270-
disabled: Colors.neutral[10],
270+
disabled: Colors.brand[10],
271271
checkedIcon: {
272272
backgroundColor: Colors.neutral[10],
273273
},
274274
},
275275
pageLoader: {
276-
borderColor: Colors.brand[50],
276+
borderColor: Colors.brand[90],
277277
borderBottomColor: Colors.neutral[0],
278278
},
279279
topicFormLabel: {
@@ -304,7 +304,7 @@ const baseTheme = {
304304
active: Colors.neutral[10],
305305
},
306306
},
307-
statictics: {
307+
statistics: {
308308
createdAtColor: Colors.neutral[50],
309309
progressPctColor: Colors.neutral[100],
310310
},
@@ -1044,6 +1044,16 @@ export const darkTheme: ThemeType = {
10441044
active: Colors.neutral[0],
10451045
},
10461046
},
1047+
switch: {
1048+
unchecked: Colors.brand[30],
1049+
hover: Colors.neutral[40],
1050+
checked: Colors.brand[70],
1051+
circle: Colors.neutral[0],
1052+
disabled: Colors.brand[10],
1053+
checkedIcon: {
1054+
backgroundColor: Colors.neutral[10],
1055+
},
1056+
},
10471057
select: {
10481058
backgroundColor: {
10491059
normal: Colors.neutral[85],

0 commit comments

Comments
 (0)