feat: 删除任务
This commit is contained in:
parent
b2af30448d
commit
fcb84098a4
|
|
@ -386,7 +386,7 @@ def create_app():
|
||||||
|
|
||||||
return StreamingResponse(_event(), media_type="text/event-stream")
|
return StreamingResponse(_event(), media_type="text/event-stream")
|
||||||
|
|
||||||
@app.delete("/api/flows/status", tags=["Flow"], description="任务删除", response_model=BaseResponse)
|
@app.delete("/api/flows", tags=["Flow"], description="任务删除", response_model=BaseResponse)
|
||||||
async def del_client(work_uuid: str, user: DB.User = Depends(get_current_user)):
|
async def del_client(work_uuid: str, user: DB.User = Depends(get_current_user)):
|
||||||
work = await DB.Work.filter(uuid=work_uuid).first()
|
work = await DB.Work.filter(uuid=work_uuid).first()
|
||||||
if not work:
|
if not work:
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ export const flowCreate = async (data = {}) => {
|
||||||
return request("/api/flows", "POST", data)
|
return request("/api/flows", "POST", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const flowDel = async (id) => {
|
||||||
|
return request("/api/flows?work_uuid=" + id, "DELETE")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
import { ProTable } from "@ant-design/pro-components"
|
import { ProTable } from "@ant-design/pro-components"
|
||||||
import { Button, Card, Popconfirm, Space, Typography } from "antd"
|
import { App, Button, Card, message, Popconfirm, Space, Typography } from "antd"
|
||||||
import { useAuth } from "../../context/AuthContext";
|
import { useAuth } from "../../context/AuthContext";
|
||||||
import { LoadingOutlined, PlusOutlined } from "@ant-design/icons";
|
import { LoadingOutlined, PlusOutlined } from "@ant-design/icons";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { tableList, flowRun, flowStop } from "../../api/flow";
|
import { tableList, flowRun, flowStop, flowDel } from "../../api/flow";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import './Detail.css';
|
import './Detail.css';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const { user, logout } = useAuth();
|
const { user, logout } = useAuth();
|
||||||
const [status, setStatus] = useState({});
|
const [status, setStatus] = useState({});
|
||||||
|
const { message } = App.useApp();
|
||||||
const eventSourceRef = useRef(null);
|
const eventSourceRef = useRef(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const needReload = useRef(false);
|
const needReload = useRef(false);
|
||||||
|
|
@ -43,6 +44,11 @@ export default () => {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
const onDelete = async (record) => {
|
||||||
|
const res = await flowDel(record.uuid);
|
||||||
|
message.success("删除成功");
|
||||||
|
actionRef?.current?.reload();
|
||||||
|
}
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
|
|
@ -112,7 +118,11 @@ export default () => {
|
||||||
user?.level === 0 && <Button key='2' type="link" style={{ padding: '0 0', border: 'none' }} onClick={() => {
|
user?.level === 0 && <Button key='2' type="link" style={{ padding: '0 0', border: 'none' }} onClick={() => {
|
||||||
navigate("/flow/detail/" + record.uuid);
|
navigate("/flow/detail/" + record.uuid);
|
||||||
}}>编辑</Button>,
|
}}>编辑</Button>,
|
||||||
user?.level === 0 && <Button key='3' type="link" danger style={{ padding: '0 0', border: 'none' }}>删除</Button>,
|
user?.level === 0 &&
|
||||||
|
<Popconfirm key='3' title="是否删除工作?" okText="删除" cancelText="取消" onConfirm={async () => await onDelete(record)}>
|
||||||
|
<Button key='3' type="link" danger style={{ padding: '0 0', border: 'none' }}>删除</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue