|
|
|
@ -1,8 +1,8 @@
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { Button, Space, Table, TableColumnProps, Tag } from '@arco-design/web-react';
|
|
|
|
import { Button, Space, Table, TableColumnProps, Tag, Message } from '@arco-design/web-react';
|
|
|
|
import styles from '@/pages/componentDevelopment/componentDeployment/style/collapseList.module.less';
|
|
|
|
import styles from '@/pages/componentDevelopment/componentDeployment/style/collapseList.module.less';
|
|
|
|
import { getInstanceList } from '@/api/componentInstance';
|
|
|
|
import { getInstanceList, startInstance, stopInstance } from '@/api/componentInstance';
|
|
|
|
import { runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy';
|
|
|
|
import { runStatusConstant, runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
|
|
interface ListNodeProps {
|
|
|
|
interface ListNodeProps {
|
|
|
|
@ -39,6 +39,40 @@ const ListNode: React.FC<ListNodeProps> = ({ componentData }) => {
|
|
|
|
fetchInstanceList();
|
|
|
|
fetchInstanceList();
|
|
|
|
}, [componentData]);
|
|
|
|
}, [componentData]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理启动实例
|
|
|
|
|
|
|
|
const handleStart = async (record) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const res: any = await startInstance(record.id);
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
Message.success('启动成功');
|
|
|
|
|
|
|
|
fetchInstanceList(); // 刷新列表
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Message.error(res.msg || '启动失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('启动实例失败:', error);
|
|
|
|
|
|
|
|
Message.error('启动失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理停止实例
|
|
|
|
|
|
|
|
const handleStop = async (record) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const res: any = await stopInstance(record.id);
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
Message.success('停止成功');
|
|
|
|
|
|
|
|
fetchInstanceList(); // 刷新列表
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Message.error(res.msg || '停止失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('停止实例失败:', error);
|
|
|
|
|
|
|
|
Message.error('停止失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const columns: TableColumnProps[] = [
|
|
|
|
const columns: TableColumnProps[] = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
title: '#',
|
|
|
|
title: '#',
|
|
|
|
@ -86,7 +120,11 @@ const ListNode: React.FC<ListNodeProps> = ({ componentData }) => {
|
|
|
|
title: '操作',
|
|
|
|
title: '操作',
|
|
|
|
dataIndex: '',
|
|
|
|
dataIndex: '',
|
|
|
|
align: 'center',
|
|
|
|
align: 'center',
|
|
|
|
render: (col, record, index) => (
|
|
|
|
render: (col, record, index) => {
|
|
|
|
|
|
|
|
// 根据运行状态判断显示启动还是停止按钮
|
|
|
|
|
|
|
|
const isRunning = record.runStatus === runStatusConstant.RUN || record.runStatus === runStatusConstant.HEALTHY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles['table-handle-box']}>
|
|
|
|
<div className={styles['table-handle-box']}>
|
|
|
|
<Space size={20}>
|
|
|
|
<Space size={20}>
|
|
|
|
<Button type="text">运行日志</Button>
|
|
|
|
<Button type="text">运行日志</Button>
|
|
|
|
@ -94,21 +132,41 @@ const ListNode: React.FC<ListNodeProps> = ({ componentData }) => {
|
|
|
|
<Button type="text"
|
|
|
|
<Button type="text"
|
|
|
|
icon={<img
|
|
|
|
icon={<img
|
|
|
|
src={'/icons/editIcon.png'}
|
|
|
|
src={'/icons/editIcon.png'}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5 }} />}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5, verticalAlign: 'middle' }} />}
|
|
|
|
>编辑</Button>
|
|
|
|
>编辑</Button>
|
|
|
|
<Button type="text"
|
|
|
|
{isRunning ? (
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
style={{ color: 'rgb(var(--danger-6))' }}
|
|
|
|
|
|
|
|
icon={<img
|
|
|
|
|
|
|
|
src={'/icons/powerUpIcon.png'}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
width: 16,
|
|
|
|
|
|
|
|
height: 16,
|
|
|
|
|
|
|
|
marginRight: 5,
|
|
|
|
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
|
|
|
|
filter: 'invert(27%) sepia(96%) saturate(4392%) hue-rotate(348deg) brightness(95%) contrast(95%)'
|
|
|
|
|
|
|
|
}} />}
|
|
|
|
|
|
|
|
onClick={() => handleStop(record)}
|
|
|
|
|
|
|
|
>停止</Button>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
icon={<img
|
|
|
|
icon={<img
|
|
|
|
src={'/icons/powerUpIcon.png'}
|
|
|
|
src={'/icons/powerUpIcon.png'}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5 }} />}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5, verticalAlign: 'middle' }} />}
|
|
|
|
>启用</Button>
|
|
|
|
onClick={() => handleStart(record)}
|
|
|
|
|
|
|
|
>启动</Button>
|
|
|
|
|
|
|
|
)}
|
|
|
|
<Button type="text"
|
|
|
|
<Button type="text"
|
|
|
|
icon={<img
|
|
|
|
icon={<img
|
|
|
|
src={'/icons/deleteIcon.png'}
|
|
|
|
src={'/icons/deleteIcon.png'}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5 }} />}
|
|
|
|
style={{ width: 16, height: 16, marginRight: 5, verticalAlign: 'middle' }} />}
|
|
|
|
>删除</Button>
|
|
|
|
>删除</Button>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|