mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 00:16:06 +08:00
自动刷新cron列表状态
This commit is contained in:
parent
da74481ec4
commit
364a582389
|
@ -42,6 +42,8 @@ enum CrontabStatus {
|
||||||
'queued',
|
'queued',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CrontabSort = [0, 3, 1];
|
||||||
|
|
||||||
enum OperationName {
|
enum OperationName {
|
||||||
'启用',
|
'启用',
|
||||||
'禁用',
|
'禁用',
|
||||||
|
@ -186,14 +188,30 @@ const Crontab = () => {
|
||||||
const [logCron, setLogCron] = useState<any>();
|
const [logCron, setLogCron] = useState<any>();
|
||||||
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
|
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
|
||||||
|
|
||||||
const getCrons = () => {
|
const getCrons = (needLoading: boolean = true) => {
|
||||||
setLoading(true);
|
needLoading && setLoading(true);
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}crons?searchValue=${searchText}`)
|
.get(`${config.apiPrefix}crons?searchValue=${searchText}`)
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
setValue(data.data.sort((a: any, b: any) => a.status - b.status));
|
setValue(
|
||||||
|
data.data.sort(
|
||||||
|
(a: any, b: any) => CrontabSort[a.status] - CrontabSort[b.status],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const runningTasks = data.data.filter(
|
||||||
|
(x: any) => x.status !== CrontabStatus.idle,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
runningTasks.length > 0 &&
|
||||||
|
!logCron &&
|
||||||
|
location.pathname === '/crontab'
|
||||||
|
) {
|
||||||
|
setTimeout(() => {
|
||||||
|
getCrons(false);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => setLoading(false));
|
.finally(() => needLoading && setLoading(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
const addCron = () => {
|
const addCron = () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user