mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 00:16:06 +08:00
修改依赖操作状态判断
This commit is contained in:
parent
14cb1f7788
commit
c47896e787
|
@ -153,11 +153,18 @@ export default class DependenceService {
|
||||||
const docs = await DependenceModel.findAll({ where: { id: ids } });
|
const docs = await DependenceModel.findAll({ where: { id: ids } });
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
taskLimit.removeQueuedDependency(doc);
|
taskLimit.removeQueuedDependency(doc);
|
||||||
const depRunCommand = InstallDependenceCommandTypes[doc.type];
|
const depInstallCommand = InstallDependenceCommandTypes[doc.type];
|
||||||
const cmd = `${depRunCommand} ${doc.name.trim()}`;
|
const depUnInstallCommand = unInstallDependenceCommandTypes[doc.type];
|
||||||
const pid = await getPid(cmd);
|
const installCmd = `${depInstallCommand} ${doc.name.trim()}`;
|
||||||
|
const unInstallCmd = `${depUnInstallCommand} ${doc.name.trim()}`;
|
||||||
|
const pids = await Promise.all([
|
||||||
|
getPid(installCmd),
|
||||||
|
getPid(unInstallCmd),
|
||||||
|
]);
|
||||||
|
for (const pid of pids) {
|
||||||
pid && (await killTask(pid));
|
pid && (await killTask(pid));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await this.removeDb(ids);
|
await this.removeDb(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,22 +36,12 @@ import { SharedContext } from '@/layouts';
|
||||||
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import WebSocketManager from '@/utils/websocket';
|
import WebSocketManager from '@/utils/websocket';
|
||||||
import { DependenceStatus } from './type';
|
import { DependenceStatus, Status } from './type';
|
||||||
import IconFont from '@/components/iconfont';
|
import IconFont from '@/components/iconfont';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
|
||||||
enum Status {
|
|
||||||
'安装中',
|
|
||||||
'已安装',
|
|
||||||
'安装失败',
|
|
||||||
'删除中',
|
|
||||||
'已删除',
|
|
||||||
'删除失败',
|
|
||||||
'队列中',
|
|
||||||
}
|
|
||||||
|
|
||||||
enum StatusColor {
|
enum StatusColor {
|
||||||
'processing',
|
'processing',
|
||||||
'success',
|
'success',
|
||||||
|
@ -186,6 +176,7 @@ const Dependence = () => {
|
||||||
const isPc = !isPhone;
|
const isPc = !isPhone;
|
||||||
return (
|
return (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
|
{![Status.队列中].includes(record.status) && (
|
||||||
<Tooltip title={isPc ? intl.get('日志') : ''}>
|
<Tooltip title={isPc ? intl.get('日志') : ''}>
|
||||||
<a
|
<a
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -195,14 +186,14 @@ const Dependence = () => {
|
||||||
<FileTextOutlined />
|
<FileTextOutlined />
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{[Status.队列中, Status.安装中].includes(record.status) && (
|
)}
|
||||||
|
{[Status.队列中, Status.安装中, Status.删除中].includes(record.status) ? (
|
||||||
<Tooltip title={isPc ? intl.get('取消安装') : ''}>
|
<Tooltip title={isPc ? intl.get('取消安装') : ''}>
|
||||||
<a onClick={() => cancelDependence(record)}>
|
<a onClick={() => cancelDependence(record)}>
|
||||||
<IconFont type="ql-icon-quxiaoanzhuang" />
|
<IconFont type="ql-icon-quxiaoanzhuang" />
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
) : (
|
||||||
{![Status.安装中, Status.删除中].includes(record.status) && (
|
|
||||||
<>
|
<>
|
||||||
<Tooltip title={isPc ? intl.get('重新安装') : ''}>
|
<Tooltip title={isPc ? intl.get('重新安装') : ''}>
|
||||||
<a onClick={() => reInstallDependence(record, index)}>
|
<a onClick={() => reInstallDependence(record, index)}>
|
||||||
|
@ -487,7 +478,7 @@ const Dependence = () => {
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
import { PageLoading } from '@ant-design/pro-layout';
|
import { PageLoading } from '@ant-design/pro-layout';
|
||||||
import Ansi from 'ansi-to-react';
|
import Ansi from 'ansi-to-react';
|
||||||
import WebSocketManager from '@/utils/websocket';
|
import WebSocketManager from '@/utils/websocket';
|
||||||
|
import { Status } from './type';
|
||||||
|
|
||||||
const DependenceLogModal = ({
|
const DependenceLogModal = ({
|
||||||
dependence,
|
dependence,
|
||||||
|
@ -96,7 +97,11 @@ const DependenceLogModal = ({
|
||||||
|
|
||||||
const handleMessage = (payload: any) => {
|
const handleMessage = (payload: any) => {
|
||||||
const { message, references } = payload;
|
const { message, references } = payload;
|
||||||
if (references.length > 0 && references.includes(dependence.id)) {
|
if (
|
||||||
|
references.length > 0 &&
|
||||||
|
references.includes(dependence.id) &&
|
||||||
|
[Status.删除中, Status.安装中].includes(dependence.status)
|
||||||
|
) {
|
||||||
if (message.includes('结束时间')) {
|
if (message.includes('结束时间')) {
|
||||||
setExecuting(false);
|
setExecuting(false);
|
||||||
setIsRemoveFailed(message.includes('删除失败'));
|
setIsRemoveFailed(message.includes('删除失败'));
|
||||||
|
@ -108,11 +113,13 @@ const DependenceLogModal = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ws = WebSocketManager.getInstance();
|
const ws = WebSocketManager.getInstance();
|
||||||
ws.subscribe('installDependence', handleMessage);
|
ws.subscribe('installDependence', handleMessage);
|
||||||
|
ws.subscribe('uninstallDependence', handleMessage);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
ws.unsubscribe('installDependence', handleMessage);
|
ws.unsubscribe('installDependence', handleMessage);
|
||||||
|
ws.unsubscribe('uninstallDependence', handleMessage);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [dependence]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsPhone(document.body.clientWidth < 768);
|
setIsPhone(document.body.clientWidth < 768);
|
||||||
|
|
|
@ -7,3 +7,13 @@ export enum DependenceStatus {
|
||||||
'removeFailed',
|
'removeFailed',
|
||||||
'queued',
|
'queued',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Status {
|
||||||
|
'安装中',
|
||||||
|
'已安装',
|
||||||
|
'安装失败',
|
||||||
|
'删除中',
|
||||||
|
'已删除',
|
||||||
|
'删除失败',
|
||||||
|
'队列中',
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user