Skip to content

Commit

Permalink
feat: publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 committed Aug 30, 2024
1 parent b37471a commit 1cc884d
Show file tree
Hide file tree
Showing 18 changed files with 1,008 additions and 12 deletions.
6 changes: 5 additions & 1 deletion react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ const EndpointDetailPage = React.lazy(
() => import('./pages/EndpointDetailPage'),
);
// const SummaryPage = React.lazy(() => import('./pages/SummaryPage'));
const StartPage = React.lazy(() => import('./pages/StartPage'));
const EnvironmentPage = React.lazy(() => import('./pages/EnvironmentPage'));
const MyEnvironmentPage = React.lazy(() => import('./pages/MyEnvironmentPage'));
const StorageHostSettingPage = React.lazy(
() => import('./pages/StorageHostSettingPage'),
);
const UserSettingsPage = React.lazy(() => import('./pages/UserSettingsPage'));
const SessionListPage = React.lazy(() => import('./pages/SessionListPage'));
const NeoSessionPage = React.lazy(() => import('./pages/NeoSessionPage'));
const SessionLauncherPage = React.lazy(
() => import('./pages/SessionLauncherPage'),
);
Expand Down Expand Up @@ -134,6 +136,7 @@ const router = createBrowserRouter([
closable
/>
{/* <SummaryPage /> */}
<StartPage />
</>
);
},
Expand Down Expand Up @@ -307,7 +310,8 @@ const router = createBrowserRouter([
{
path: '/session',
handle: { labelKey: 'webui.menu.Sessions' },
Component: SessionListPage,
Component: NeoSessionPage,
// Component: SessionListPage,
},
{
path: '/session/start',
Expand Down
123 changes: 123 additions & 0 deletions react/src/components/AllocatedResourcesCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import Flex from './Flex';
import ResourceGroupSelect from './ResourceGroupSelect';
import ResourceUnit, { ResourceUnitProps } from './ResourceUnit';
import { SyncOutlined } from '@ant-design/icons';
import {
Button,
Card,
CardProps,
ConfigProvider,
Divider,
Switch,
theme,
Typography,
} from 'antd';
import _ from 'lodash';
import React from 'react';
import { useTranslation } from 'react-i18next';

interface AllocatedResourcesCardProps extends CardProps {}

const AllocatedResourcesCard: React.FC<AllocatedResourcesCardProps> = ({
...cardProps
}) => {
const { token } = theme.useToken();
const { t } = useTranslation();

const resourceUnitMockData: Array<ResourceUnitProps> = [
{
name: 'CPU',
displayUnit: 'Core',
value: 12,
percentage: (4 / 12) * 100,
},
{
name: 'RAM',
displayUnit: 'GiB',
value: 256,
percentage: (8 / 12) * 100,
},
{
name: 'FGPU',
displayUnit: 'GiB',
value: 3.5,
percentage: (4 / 12) * 100,
},
{
name: 'ATOM',
displayUnit: 'Unit',
value: 2,
percentage: (2 / 12) * 100,
},
];
return (
<ConfigProvider
theme={{
components: {
Button: {
onlyIconSizeLG: 20,
},
},
}}
>
<Card
{...cardProps}
style={{
width: '100%',
height: 240,
// width: 936,
// height: 192,
}}
>
<Flex justify="between" style={{ marginBottom: 26 }}>
<Flex gap={10}>
<Typography.Title
level={4}
style={{
margin: 0,
}}
>
Allocated Resources
</Typography.Title>
<Switch defaultChecked />
</Flex>
<Flex>
<ResourceGroupSelect
placeholder={t('session.ResourceGroup')}
variant="borderless"
style={{ minWidth: 151, fontSize: token.fontSizeLG, padding: 0 }}
dropdownStyle={{ color: '#999999' }}
/>
<Button
type="link"
size="large"
icon={<SyncOutlined />}
style={{ padding: 0, color: '#5DD2AD' }}
/>
</Flex>
</Flex>
<Flex justify="between" style={{ maxWidth: 630 }}>
{_.map(
resourceUnitMockData,
(resourceUnit: ResourceUnitProps, index) => (
<>
<ResourceUnit
key={index}
name={resourceUnit.name}
displayUnit={resourceUnit.displayUnit}
value={resourceUnit.value}
percentage={resourceUnit.percentage}
/>
{index < resourceUnitMockData.length - 1 && (
<Divider type="vertical" style={{ height: 70 }} />
)}
</>
),
)}
</Flex>
</Card>
</ConfigProvider>
);
};

export default AllocatedResourcesCard;
127 changes: 127 additions & 0 deletions react/src/components/BAIStartBasicCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import Flex from './Flex';
import {
Button,
ButtonProps,
Card,
CardProps,
ConfigProvider,
Divider,
theme,
Typography,
} from 'antd';

export interface BAIStartBasicCardProps extends CardProps {
icon: React.ReactNode;
title: React.ReactNode;
footerButtonProps: ButtonProps;
description?: string;
secondary?: Boolean;
}

const BAIStartBasicCard: React.FC<BAIStartBasicCardProps> = ({
icon,
title,
footerButtonProps,
description,
secondary,
...cardProps
}) => {
const { token } = theme.useToken();

return (
<ConfigProvider
theme={{
components: {
Button: {
defaultBorderColor: 'none',
defaultColor: secondary ? '#E8FAF6' : '#FFF6E8',
defaultBg: secondary ? '#00BD9B' : token.colorPrimary,
defaultHoverColor: secondary ? '#00BD9B' : token.colorPrimary,
defaultHoverBorderColor: secondary ? '#00BD9B' : token.colorPrimary,
},
},
}}
>
<Card
{...cardProps}
styles={{
body: {
paddingTop: token.paddingSM,
paddingBottom: token.paddingSM,
paddingLeft: token.paddingMD,
paddingRight: token.paddingMD,
width: 210,
height: 308,
},
}}
>
<Flex
direction="column"
justify="between"
align="stretch"
style={{ height: '100%' }}
>
<Flex
align="center"
direction="column"
gap={16}
style={{
minHeight: 202,
}}
>
<Flex
align="center"
justify="center"
style={{
width: 50,
height: 50,
padding: 0,
border: 0,
color: secondary ? '#00BD9B' : '#FF7A00',
background: secondary ? '#E8FAF6' : '#FFF6E8',
fontSize: token.sizeLG,
borderRadius: '50%',
}}
>
{icon}
</Flex>
<Typography.Text
strong
style={{
fontSize: token.fontSizeLG,
color: secondary ? '#00BD9B' : token.colorLink,
textAlign: 'center',
}}
>
{title}
</Typography.Text>
{description && (
<Typography.Paragraph
style={{
color: token.colorTextDescription,
fontSize: token.fontSize - 4,
textAlign: 'center',
}}
>
{description}
</Typography.Paragraph>
)}
</Flex>
<Flex direction="column">
<Divider style={{ margin: 0, marginBottom: token.margin }} />
<Button
{...footerButtonProps}
size="large"
block
style={{
borderRadius: token.borderRadiusLG,
}}
/>
</Flex>
</Flex>
</Card>
</ConfigProvider>
);
};

export default BAIStartBasicCard;
111 changes: 111 additions & 0 deletions react/src/components/BAIStartSimpleCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import Flex from './Flex';
import {
Button,
ButtonProps,
Card,
CardProps,
ConfigProvider,
theme,
Typography,
} from 'antd';

export interface BAIStartSimpleCardProps extends CardProps {
icon: React.ReactNode;
title: React.ReactNode;
footerButtonProps: ButtonProps;
description?: string;
secondary?: Boolean;
}

const BAIStartSimpleCard: React.FC<BAIStartSimpleCardProps> = ({
icon,
title,
footerButtonProps,
description,
secondary,
...cardProps
}) => {
const { token } = theme.useToken();

return (
<ConfigProvider
theme={{
components: {
Button: {
defaultBorderColor: 'none',
defaultColor: secondary ? '#E8FAF6' : '#FFF6E8',
defaultBg: secondary ? '#00BD9B' : token.colorPrimary,
defaultHoverColor: secondary ? '#00BD9B' : token.colorPrimary,
defaultHoverBorderColor: secondary ? '#00BD9B' : token.colorPrimary,
},
},
}}
>
<Card
styles={{
body: {
width: 194,
height: 192,
},
}}
{...cardProps}
>
<Flex
direction="column"
justify="center"
align="stretch"
style={{ height: '100%' }}
>
<Flex align="center" direction="column" gap={16}>
<Flex
align="center"
justify="center"
style={{
width: 50,
height: 50,
padding: 0,
border: 0,
color: secondary ? '#00BD9B' : '#FF7A00',
background: secondary ? '#E8FAF6' : '#FFF6E8',
fontSize: token.sizeLG,
borderRadius: '50%',
}}
>
{icon}
</Flex>
<Typography.Text
strong
style={{
fontSize: token.fontSizeSM,
color: '#333333',
textAlign: 'center',
}}
>
{title}
</Typography.Text>
{description && (
<Typography.Paragraph
style={{
color: token.colorTextDescription,
fontSize: token.fontSize - 4,
textAlign: 'center',
}}
>
{description}
</Typography.Paragraph>
)}
<Button
{...footerButtonProps}
block
style={{
borderRadius: token.borderRadiusLG,
}}
/>
</Flex>
</Flex>
</Card>
</ConfigProvider>
);
};

export default BAIStartSimpleCard;
Loading

0 comments on commit 1cc884d

Please sign in to comment.