import { convertFileSize } from '@/utils'; import { AutoTooltip } from '@gpustack/core-ui'; import { useIntl } from '@umijs/max'; import React from 'react'; import styled from 'styled-components'; import '../style/gpu-card.less'; const CardWrapper = styled.div` display: flex; gap: 8px; flex-direction: column; align-items: flex-start; justify-content: center; width: 100%; border-bottom: 1px solid var(--ant-color-split); padding-bottom: 5px; `; const Header = styled.div` width: 100%; `; const ItemInfo = styled.div` display: flex; flex-wrap: wrap; white-space: break-spaces; font-size: 13px; `; const Description = styled.div` display: flex; flex-direction: column; align-items: flex-start; gap: 8px; color: var(--ant-color-text-tertiary); `; export const CardContainer: React.FC<{ header?: React.ReactNode; description?: React.ReactNode; }> = ({ header, description }) => { return (
{header}
{description && {description}}
); }; const GPUCard: React.FC<{ data: any; header?: React.ReactNode; info?: React.ReactNode; }> = ({ data, header, info }) => { const intl = useIntl(); return ( [{data.index}] {data.label} ) } description={ info || ( <> {intl.formatMessage({ id: 'resources.table.vram' })}( {intl.formatMessage({ id: 'resources.table.used' })}/ {intl.formatMessage({ id: 'resources.table.total' })}):{' '} {convertFileSize( data?.memory?.used || data?.memory?.allocated || 0 )}{' '} / {convertFileSize(data?.memory?.total || 0)} {/* {intl.formatMessage({ id: 'resources.table.gpuutilization' })} :{' '} {data?.memory?.used ? _.round(data?.memory?.utilization_rate || 0, 2) : _.round(data.memory?.allocated / data.memory?.total, 2) * 100} % */} ) } > ); }; export default GPUCard;