feat(gpu-service): add status column to storage and storage-type lists
This commit is contained in:
@@ -1,6 +1,23 @@
|
|||||||
|
import { StatusMaps } from '@/config';
|
||||||
|
import { StatusType } from '@/config/types';
|
||||||
import { icons } from '@gpustack/core-ui';
|
import { icons } from '@gpustack/core-ui';
|
||||||
import { StorageTypeKind } from './types';
|
import { StorageTypeKind } from './types';
|
||||||
|
|
||||||
|
export const StorageTypePhaseValueMap = {
|
||||||
|
Ready: 'Ready',
|
||||||
|
Deleting: 'Deleting'
|
||||||
|
};
|
||||||
|
|
||||||
|
export const StorageTypePhaseLabelMap: Record<string, string> = {
|
||||||
|
[StorageTypePhaseValueMap.Ready]: 'Ready',
|
||||||
|
[StorageTypePhaseValueMap.Deleting]: 'Deleting'
|
||||||
|
};
|
||||||
|
|
||||||
|
export const status: Record<string, StatusType> = {
|
||||||
|
[StorageTypePhaseValueMap.Ready]: StatusMaps.success,
|
||||||
|
[StorageTypePhaseValueMap.Deleting]: StatusMaps.warning
|
||||||
|
};
|
||||||
|
|
||||||
export const StorageTypeKindValueMap: Record<string, StorageTypeKind> = {
|
export const StorageTypeKindValueMap: Record<string, StorageTypeKind> = {
|
||||||
NFS: 'nfs',
|
NFS: 'nfs',
|
||||||
S3: 's3'
|
S3: 's3'
|
||||||
|
|||||||
@@ -44,4 +44,8 @@ export interface ListItem {
|
|||||||
nfs?: StorageTypeNFS | null;
|
nfs?: StorageTypeNFS | null;
|
||||||
s3?: Omit<StorageTypeS3, 'secretKey'> | null;
|
s3?: Omit<StorageTypeS3, 'secretKey'> | null;
|
||||||
};
|
};
|
||||||
|
status?: {
|
||||||
|
phase?: string | null;
|
||||||
|
phaseMessage?: string | null;
|
||||||
|
} | null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,19 @@ import {
|
|||||||
AutoTooltip,
|
AutoTooltip,
|
||||||
DropdownButtons,
|
DropdownButtons,
|
||||||
IconFont,
|
IconFont,
|
||||||
|
StatusTag,
|
||||||
ThemeTag
|
ThemeTag
|
||||||
} from '@gpustack/core-ui';
|
} from '@gpustack/core-ui';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import type { ColumnsType } from 'antd/lib/table';
|
import type { ColumnsType } from 'antd/lib/table';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { rowActionList, StorageTypeKindLabelMap } from '../config';
|
import {
|
||||||
|
rowActionList,
|
||||||
|
status,
|
||||||
|
StorageTypeKindLabelMap,
|
||||||
|
StorageTypePhaseLabelMap
|
||||||
|
} from '../config';
|
||||||
import { ListItem } from '../config/types';
|
import { ListItem } from '../config/types';
|
||||||
|
|
||||||
interface ColumnsHookProps {
|
interface ColumnsHookProps {
|
||||||
@@ -81,6 +87,24 @@ const useStorageTypeColumns = ({
|
|||||||
sorter: false,
|
sorter: false,
|
||||||
render: (_text, record) => getKindLabel(record)
|
render: (_text, record) => getKindLabel(record)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'common.table.status' }),
|
||||||
|
dataIndex: ['status', 'phase'],
|
||||||
|
key: 'status',
|
||||||
|
sorter: false,
|
||||||
|
render: (value: string, record: ListItem) =>
|
||||||
|
value ? (
|
||||||
|
<StatusTag
|
||||||
|
statusValue={{
|
||||||
|
status: status[value],
|
||||||
|
text: StorageTypePhaseLabelMap[value] || value,
|
||||||
|
message: record?.status?.phaseMessage || ''
|
||||||
|
}}
|
||||||
|
></StatusTag>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
)
|
||||||
|
},
|
||||||
...creatorCols,
|
...creatorCols,
|
||||||
// {
|
// {
|
||||||
// title: intl.formatMessage({ id: 'common.table.description' }),
|
// title: intl.formatMessage({ id: 'common.table.description' }),
|
||||||
|
|||||||
@@ -3,21 +3,18 @@ import { StatusType } from '@/config/types';
|
|||||||
import { icons } from '@gpustack/core-ui';
|
import { icons } from '@gpustack/core-ui';
|
||||||
|
|
||||||
export const StoragePhaseValueMap = {
|
export const StoragePhaseValueMap = {
|
||||||
Available: 'Available',
|
Ready: 'Ready',
|
||||||
Unavailable: 'Unavailable',
|
Deleting: 'Deleting'
|
||||||
Pending: 'Pending'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const StoragePhaseLabelMap: Record<string, string> = {
|
export const StoragePhaseLabelMap: Record<string, string> = {
|
||||||
[StoragePhaseValueMap.Available]: 'Available',
|
[StoragePhaseValueMap.Ready]: 'Ready',
|
||||||
[StoragePhaseValueMap.Unavailable]: 'Unavailable',
|
[StoragePhaseValueMap.Deleting]: 'Deleting'
|
||||||
[StoragePhaseValueMap.Pending]: 'Pending'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const status: Record<string, StatusType> = {
|
export const status: Record<string, StatusType> = {
|
||||||
[StoragePhaseValueMap.Available]: StatusMaps.success,
|
[StoragePhaseValueMap.Ready]: StatusMaps.success,
|
||||||
[StoragePhaseValueMap.Unavailable]: StatusMaps.error,
|
[StoragePhaseValueMap.Deleting]: StatusMaps.warning
|
||||||
[StoragePhaseValueMap.Pending]: StatusMaps.transitioning
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const rowActionList = [
|
export const rowActionList = [
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export interface ListItem {
|
|||||||
};
|
};
|
||||||
status?: {
|
status?: {
|
||||||
phase?: string | null;
|
phase?: string | null;
|
||||||
|
phaseMessage?: string | null;
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import useCreatorColumn from '@/pages/gpu-service/hooks/use-creator-column';
|
import useCreatorColumn from '@/pages/gpu-service/hooks/use-creator-column';
|
||||||
import { usePluginListColumns } from '@/plugins/list-extra-columns';
|
import { usePluginListColumns } from '@/plugins/list-extra-columns';
|
||||||
import { AutoTooltip, DropdownButtons } from '@gpustack/core-ui';
|
import { AutoTooltip, DropdownButtons, StatusTag } from '@gpustack/core-ui';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import type { ColumnsType } from 'antd/lib/table';
|
import type { ColumnsType } from 'antd/lib/table';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { rowActionList } from '../config';
|
import { rowActionList, status, StoragePhaseLabelMap } from '../config';
|
||||||
import { ListItem } from '../config/types';
|
import { ListItem } from '../config/types';
|
||||||
|
|
||||||
interface ColumnsHookProps {
|
interface ColumnsHookProps {
|
||||||
@@ -70,24 +70,25 @@ const useStorageColumns = ({
|
|||||||
sorter: false,
|
sorter: false,
|
||||||
render: (value: string) => (value ? value.replace(/Gi$/, 'GB') : '-')
|
render: (value: string) => (value ? value.replace(/Gi$/, 'GB') : '-')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: intl.formatMessage({ id: 'common.table.status' }),
|
||||||
|
dataIndex: ['status', 'phase'],
|
||||||
|
key: 'status',
|
||||||
|
sorter: false,
|
||||||
|
render: (value: string, record: ListItem) =>
|
||||||
|
value ? (
|
||||||
|
<StatusTag
|
||||||
|
statusValue={{
|
||||||
|
status: status[value],
|
||||||
|
text: StoragePhaseLabelMap[value] || value,
|
||||||
|
message: record?.status?.phaseMessage || ''
|
||||||
|
}}
|
||||||
|
></StatusTag>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
)
|
||||||
|
},
|
||||||
...creatorCols,
|
...creatorCols,
|
||||||
// {
|
|
||||||
// title: intl.formatMessage({ id: 'common.table.status' }),
|
|
||||||
// dataIndex: ['status', 'phase'],
|
|
||||||
// key: 'status',
|
|
||||||
// sorter: false,
|
|
||||||
// render: (value: string) =>
|
|
||||||
// value ? (
|
|
||||||
// <StatusTag
|
|
||||||
// statusValue={{
|
|
||||||
// status: status[value],
|
|
||||||
// text: StoragePhaseLabelMap[value] || value
|
|
||||||
// }}
|
|
||||||
// ></StatusTag>
|
|
||||||
// ) : (
|
|
||||||
// '-'
|
|
||||||
// )
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'common.table.createTime' }),
|
title: intl.formatMessage({ id: 'common.table.createTime' }),
|
||||||
dataIndex: 'created_at',
|
dataIndex: 'created_at',
|
||||||
|
|||||||
Reference in New Issue
Block a user