fix: delete worker
This commit is contained in:
@@ -31,7 +31,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
|
|||||||
>
|
>
|
||||||
{copied ? (
|
{copied ? (
|
||||||
<CheckCircleFilled
|
<CheckCircleFilled
|
||||||
style={{ color: 'var(--ant-color-primary)', fontSize: '14px' }}
|
style={{ color: 'var(--ant-color-success)', fontSize: '14px' }}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CopyOutlined
|
<CopyOutlined
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isFunction } from 'lodash';
|
||||||
const chartColorMap = {
|
const chartColorMap = {
|
||||||
tickLineColor: 'rgba(217,217,217,0.5)',
|
tickLineColor: 'rgba(217,217,217,0.5)',
|
||||||
axislabelColor: 'rgba(0, 0, 0, 0.4)'
|
axislabelColor: 'rgba(0, 0, 0, 0.4)'
|
||||||
@@ -8,15 +9,18 @@ export const tooltip = {
|
|||||||
// axisPointer: {
|
// axisPointer: {
|
||||||
// type: 'shadow'
|
// type: 'shadow'
|
||||||
// }
|
// }
|
||||||
formatter(params: any) {
|
formatter(params: any, callback?: (val: any) => any) {
|
||||||
let result = `<span class="tooltip-x-name">${params[0].axisValue}</span>`;
|
let result = `<span class="tooltip-x-name">${params[0].axisValue}</span>`;
|
||||||
params.forEach((item: any) => {
|
params.forEach((item: any) => {
|
||||||
|
let value = isFunction(callback)
|
||||||
|
? callback?.(item.data.value)
|
||||||
|
: item.data.value;
|
||||||
result += `<span class="tooltip-item">
|
result += `<span class="tooltip-item">
|
||||||
<span class="tooltip-item-name">
|
<span class="tooltip-item-name">
|
||||||
<span style="display:inline-block;margin-right:5px;border-radius:8px;width:8px;height:8px;background-color:${item.color};"></span>
|
<span style="display:inline-block;margin-right:5px;border-radius:8px;width:8px;height:8px;background-color:${item.color};"></span>
|
||||||
<span class="tooltip-title">${item.seriesName}</span>:
|
<span class="tooltip-title">${item.seriesName}</span>:
|
||||||
</span>
|
</span>
|
||||||
<span class="tooltip-value">${item.data.value}</span>
|
<span class="tooltip-value">${value}</span>
|
||||||
</span>`;
|
</span>`;
|
||||||
});
|
});
|
||||||
return `<div class="tooltip-wrapper">${result}</div>`;
|
return `<div class="tooltip-wrapper">${result}</div>`;
|
||||||
@@ -55,6 +59,9 @@ export const xAxis = {
|
|||||||
export const yAxis = {
|
export const yAxis = {
|
||||||
// max: 100,
|
// max: 100,
|
||||||
// min: 0,
|
// min: 0,
|
||||||
|
nameTextStyle: {
|
||||||
|
padding: [0, 0, 0, -25]
|
||||||
|
},
|
||||||
splitLine: {
|
splitLine: {
|
||||||
show: true,
|
show: true,
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
const {
|
const {
|
||||||
seriesData,
|
seriesData,
|
||||||
xAxisData,
|
xAxisData,
|
||||||
|
yAxisName,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
labelFormatter,
|
labelFormatter,
|
||||||
|
tooltipValueFormatter = null,
|
||||||
legendData = [],
|
legendData = [],
|
||||||
smooth,
|
smooth,
|
||||||
title
|
title
|
||||||
@@ -34,7 +36,12 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
},
|
},
|
||||||
grid,
|
grid,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
...tooltip
|
...tooltip,
|
||||||
|
formatter(params: any) {
|
||||||
|
return tooltipValueFormatter
|
||||||
|
? tooltip.formatter(params, tooltipValueFormatter)
|
||||||
|
: tooltip.formatter(params);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
...xAxis,
|
...xAxis,
|
||||||
@@ -76,7 +83,8 @@ const LineChart: React.FC<ChartProps> = (props) => {
|
|||||||
text: title
|
text: title
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
...options.yAxis
|
...options.yAxis,
|
||||||
|
name: yAxisName
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
...options.xAxis,
|
...options.xAxis,
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ export interface ChartProps {
|
|||||||
xAxisData: string[];
|
xAxisData: string[];
|
||||||
legendData?: string[];
|
legendData?: string[];
|
||||||
labelFormatter?: (val?: any) => string;
|
labelFormatter?: (val?: any) => string;
|
||||||
|
tooltipValueFormatter?: (val?: any) => string;
|
||||||
height: string | number;
|
height: string | number;
|
||||||
width?: string | number;
|
width?: string | number;
|
||||||
title?: string;
|
title?: string;
|
||||||
value?: number;
|
value?: number;
|
||||||
smooth?: boolean;
|
smooth?: boolean;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
yAxisName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AreaChartItemProps {
|
export interface AreaChartItemProps {
|
||||||
|
|||||||
@@ -170,8 +170,6 @@ const TableRow: React.FC<
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!firstLoad && expanded) {
|
if (!firstLoad && expanded) {
|
||||||
createChunkRequest();
|
createChunkRequest();
|
||||||
} else {
|
|
||||||
chunkRequestRef.current?.current?.cancel?.();
|
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
chunkRequestRef.current?.current?.cancel?.();
|
chunkRequestRef.current?.current?.cancel?.();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { StatusColorMap } from '@/config';
|
import { StatusColorMap } from '@/config';
|
||||||
import { StatusType } from '@/config/types';
|
import { StatusType } from '@/config/types';
|
||||||
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||||
|
import { Tooltip } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
@@ -16,6 +18,7 @@ type StatusTagProps = {
|
|||||||
statusValue: {
|
statusValue: {
|
||||||
status: StatusType;
|
status: StatusType;
|
||||||
text: string;
|
text: string;
|
||||||
|
message?: string;
|
||||||
};
|
};
|
||||||
download?: {
|
download?: {
|
||||||
percent: number;
|
percent: number;
|
||||||
@@ -56,7 +59,16 @@ const StatusTag: React.FC<StatusTagProps> = ({ statusValue, download }) => {
|
|||||||
border: `1px solid ${statusColor?.text}`
|
border: `1px solid ${statusColor?.text}`
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{renderContent()}
|
{statusValue.message ? (
|
||||||
|
<Tooltip title={statusValue.message}>
|
||||||
|
<span className="m-r-5">
|
||||||
|
<InfoCircleOutlined />
|
||||||
|
</span>
|
||||||
|
{renderContent()}
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
renderContent()
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ export default {
|
|||||||
'resources.table.gpuutilization': 'GPU Utilization',
|
'resources.table.gpuutilization': 'GPU Utilization',
|
||||||
'resources.table.vramutilization': 'VRAM Utilization',
|
'resources.table.vramutilization': 'VRAM Utilization',
|
||||||
'resources.table.total': 'Total',
|
'resources.table.total': 'Total',
|
||||||
'resources.table.used': 'Used'
|
'resources.table.used': 'Used',
|
||||||
|
'resources.table.wokers': 'workers'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ export default {
|
|||||||
'resources.table.gpuutilization': 'GPU 利用率',
|
'resources.table.gpuutilization': 'GPU 利用率',
|
||||||
'resources.table.vramutilization': '显存利用率',
|
'resources.table.vramutilization': '显存利用率',
|
||||||
'resources.table.total': '总量',
|
'resources.table.total': '总量',
|
||||||
'resources.table.used': '已用'
|
'resources.table.used': '已用',
|
||||||
|
'resources.table.wokers': 'workers'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ const UtilizationOvertime: React.FC = () => {
|
|||||||
|
|
||||||
const typeList = ['gpu', 'cpu', 'memory', 'gpu_memory'];
|
const typeList = ['gpu', 'cpu', 'memory', 'gpu_memory'];
|
||||||
|
|
||||||
|
const tooltipValueFormatter = (value: any) => {
|
||||||
|
return !value ? value : `${value}%`;
|
||||||
|
};
|
||||||
const generateData = () => {
|
const generateData = () => {
|
||||||
const legendData: string[] = [];
|
const legendData: string[] = [];
|
||||||
const xAxisData: string[] = [];
|
const xAxisData: string[] = [];
|
||||||
@@ -154,8 +157,10 @@ const UtilizationOvertime: React.FC = () => {
|
|||||||
seriesData={seriesData}
|
seriesData={seriesData}
|
||||||
legendData={legendData}
|
legendData={legendData}
|
||||||
xAxisData={xAxisData}
|
xAxisData={xAxisData}
|
||||||
|
tooltipValueFormatter={tooltipValueFormatter}
|
||||||
smooth={true}
|
smooth={true}
|
||||||
width="100%"
|
width="100%"
|
||||||
|
yAxisName="(%)"
|
||||||
></LineChart>
|
></LineChart>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
}
|
}
|
||||||
statusValue={{
|
statusValue={{
|
||||||
status: status[item.state] as any,
|
status: status[item.state] as any,
|
||||||
text: item.state
|
text: item.state,
|
||||||
|
message: item.state_message
|
||||||
}}
|
}}
|
||||||
></StatusTag>
|
></StatusTag>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const status: any = {
|
|||||||
[InstanceStatusMap.Running]: StatusMaps.success,
|
[InstanceStatusMap.Running]: StatusMaps.success,
|
||||||
[InstanceStatusMap.Pending]: StatusMaps.transitioning,
|
[InstanceStatusMap.Pending]: StatusMaps.transitioning,
|
||||||
[InstanceStatusMap.Initializing]: StatusMaps.transitioning,
|
[InstanceStatusMap.Initializing]: StatusMaps.transitioning,
|
||||||
[InstanceStatusMap.Scheduled]: StatusMaps.success,
|
[InstanceStatusMap.Scheduled]: StatusMaps.transitioning,
|
||||||
[InstanceStatusMap.Error]: StatusMaps.error,
|
[InstanceStatusMap.Error]: StatusMaps.error,
|
||||||
[InstanceStatusMap.Downloading]: StatusMaps.transitioning,
|
[InstanceStatusMap.Downloading]: StatusMaps.transitioning,
|
||||||
[InstanceStatusMap.Unknown]: StatusMaps.inactive,
|
[InstanceStatusMap.Unknown]: StatusMaps.inactive,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export interface ModelInstanceListItem {
|
|||||||
port: number;
|
port: number;
|
||||||
name: string;
|
name: string;
|
||||||
state: string;
|
state: string;
|
||||||
|
state_message: string;
|
||||||
download_progress: number;
|
download_progress: number;
|
||||||
model_id: number;
|
model_id: number;
|
||||||
model_name: string;
|
model_name: string;
|
||||||
|
|||||||
@@ -27,3 +27,9 @@ export async function queryGPUDeviceItem(id: string) {
|
|||||||
methos: 'GET'
|
methos: 'GET'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deleteWorker(id: string | number) {
|
||||||
|
return request(`${WORKERS_API}/${id}`, {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import PageTools from '@/components/page-tools';
|
import PageTools from '@/components/page-tools';
|
||||||
import ProgressBar from '@/components/progress-bar';
|
import ProgressBar from '@/components/progress-bar';
|
||||||
import StatusTag from '@/components/status-tag';
|
import StatusTag from '@/components/status-tag';
|
||||||
|
import useTableRowSelection from '@/hooks/use-table-row-selection';
|
||||||
import useTableSort from '@/hooks/use-table-sort';
|
import useTableSort from '@/hooks/use-table-sort';
|
||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize, handleBatchRequest } from '@/utils';
|
||||||
import { SyncOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, SyncOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Input, Space, Table } from 'antd';
|
import { Button, Input, Modal, Space, Table, Tooltip, message } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import { queryWorkersList } from '../apis';
|
import { deleteWorker, queryWorkersList } from '../apis';
|
||||||
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
|
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
|
||||||
const { Column } = Table;
|
const { Column } = Table;
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ const Resources: React.FC = () => {
|
|||||||
const { sortOrder, setSortOrder } = useTableSort({
|
const { sortOrder, setSortOrder } = useTableSort({
|
||||||
defaultSortOrder: 'descend'
|
defaultSortOrder: 'descend'
|
||||||
});
|
});
|
||||||
|
const rowSelection = useTableRowSelection();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -90,6 +92,44 @@ const Resources: React.FC = () => {
|
|||||||
return mountRoot ? formateUtilazation(mountRoot.used, mountRoot.total) : 0;
|
return mountRoot ? formateUtilazation(mountRoot.used, mountRoot.total) : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDelete = (row: ListItem) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '',
|
||||||
|
content: intl.formatMessage(
|
||||||
|
{ id: 'common.delete.confirm' },
|
||||||
|
{ type: ' worker ' }
|
||||||
|
),
|
||||||
|
async onOk() {
|
||||||
|
console.log('OK');
|
||||||
|
await deleteWorker(row.id);
|
||||||
|
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||||
|
fetchData();
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
console.log('Cancel');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteBatch = () => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '',
|
||||||
|
content: intl.formatMessage(
|
||||||
|
{ id: 'common.delete.confirm' },
|
||||||
|
{ type: ` wokers ` }
|
||||||
|
),
|
||||||
|
async onOk() {
|
||||||
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
|
||||||
|
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||||
|
rowSelection.clearSelections();
|
||||||
|
fetchData();
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
console.log('Cancel');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const renderStorageTooltip = (files: Filesystem[]) => {
|
const renderStorageTooltip = (files: Filesystem[]) => {
|
||||||
const mountRoot = _.find(
|
const mountRoot = _.find(
|
||||||
files,
|
files,
|
||||||
@@ -137,12 +177,23 @@ const Resources: React.FC = () => {
|
|||||||
></Button>
|
></Button>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
|
right={
|
||||||
|
<Button
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
danger
|
||||||
|
onClick={handleDeleteBatch}
|
||||||
|
disabled={!rowSelection.selectedRowKeys.length}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'common.button.delete' })}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
></PageTools>
|
></PageTools>
|
||||||
<Table
|
<Table
|
||||||
dataSource={dataSource}
|
dataSource={dataSource}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
|
rowSelection={rowSelection}
|
||||||
pagination={{
|
pagination={{
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
pageSize: queryParams.perPage,
|
pageSize: queryParams.perPage,
|
||||||
@@ -307,6 +358,26 @@ const Resources: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Column
|
||||||
|
title={intl.formatMessage({ id: 'common.table.operation' })}
|
||||||
|
key="operation"
|
||||||
|
render={(text, record: ListItem) => {
|
||||||
|
return (
|
||||||
|
<Space size={20}>
|
||||||
|
<Tooltip
|
||||||
|
title={intl.formatMessage({ id: 'common.button.delete' })}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => handleDelete(record)}
|
||||||
|
size="small"
|
||||||
|
danger
|
||||||
|
icon={<DeleteOutlined></DeleteOutlined>}
|
||||||
|
></Button>
|
||||||
|
</Tooltip>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Table>
|
</Table>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user