-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathStatisticsPage.tsx
More file actions
74 lines (68 loc) · 2.02 KB
/
StatisticsPage.tsx
File metadata and controls
74 lines (68 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import AllocationHistory from '../components/AllocationHistory';
import BAICard from '../components/BAICard';
import UserSessionsMetrics from '../components/UserSessionsMetrics';
import { filterEmptyItem } from '../helper';
import { useSuspendedBackendaiClient } from '../hooks';
import { Skeleton, theme } from 'antd';
import React, { Suspense } from 'react';
import { useTranslation } from 'react-i18next';
import { StringParam, useQueryParam, withDefault } from 'use-query-params';
interface ResourcesPageProps {}
const tabParam = withDefault(StringParam, 'allocation-history');
const ResourcesPage: React.FC<ResourcesPageProps> = (props) => {
const { t } = useTranslation();
const { token } = theme.useToken();
const baiClient = useSuspendedBackendaiClient();
const [curTabKey, setCurTabKey] = useQueryParam('tab', tabParam, {
updateType: 'replace',
});
return (
<BAICard
activeTabKey={curTabKey}
onTabChange={(key) => setCurTabKey(key)}
tabList={filterEmptyItem([
{
key: 'allocation-history',
tab: t('webui.menu.UsageHistory'),
},
baiClient?.supports('user-metrics') && {
key: 'user-session-history',
tab: t('webui.menu.UserSessionHistory'),
},
])}
styles={{
body: {
padding: 0,
paddingTop: 1,
overflow: 'hidden',
},
}}
>
{curTabKey === 'allocation-history' ? (
<Suspense
fallback={
<Skeleton
active
style={{ padding: token.paddingContentVerticalLG }}
/>
}
>
<AllocationHistory />
</Suspense>
) : null}
{curTabKey === 'user-session-history' ? (
<Suspense
fallback={
<Skeleton
active
style={{ padding: token.paddingContentVerticalLG }}
/>
}
>
<UserSessionsMetrics />
</Suspense>
) : null}
</BAICard>
);
};
export default ResourcesPage;