添加日志弹窗日志状态显示

This commit is contained in:
whyour 2021-05-14 14:57:30 +08:00
parent 2ba99d9c47
commit e32a56df93
3 changed files with 21 additions and 5 deletions

View File

@ -9,8 +9,8 @@ const initData = [
name: '更新面板',
command: `ql update`,
schedule: `${randomSchedule(60, 1)} ${randomSchedule(
24,
7,
6,
1,
).toString()} * * *`,
status: CrontabStatus.idle,
},

View File

@ -14,7 +14,7 @@ import {
} from 'antd';
import {
ClockCircleOutlined,
SyncOutlined,
Loading3QuartersOutlined,
CloseCircleOutlined,
FileTextOutlined,
EllipsisOutlined,
@ -105,7 +105,7 @@ const Crontab = () => {
</Tag>
)}
{record.status === CrontabStatus.running && (
<Tag icon={<SyncOutlined spin />} color="processing">
<Tag icon={<Loading3QuartersOutlined spin />} color="processing">
</Tag>
)}

View File

@ -2,6 +2,10 @@ import React, { useEffect, useState } from 'react';
import { Modal, notification, Input, Form } from 'antd';
import { request } from '@/utils/http';
import config from '@/utils/config';
import {
Loading3QuartersOutlined,
CheckCircleOutlined,
} from '@ant-design/icons';
enum CrontabStatus {
'running',
@ -20,6 +24,7 @@ const CronLogModal = ({
}) => {
const [value, setValue] = useState<string>('启动中...');
const [loading, setLoading] = useState<any>(true);
const [excuting, setExcuting] = useState<any>(true);
const getCronLog = (isFirst?: boolean) => {
if (isFirst) {
@ -31,6 +36,7 @@ const CronLogModal = ({
if (localStorage.getItem('logCron') === cron._id) {
const log = data.data as string;
setValue(log || '暂无日志');
setExcuting(log && !log.includes('执行结束'));
if (log && !log.includes('执行结束')) {
setTimeout(() => {
getCronLog();
@ -50,6 +56,16 @@ const CronLogModal = ({
handleCancel();
};
const titleElement = () => {
return (
<>
<span style={{ marginRight: 5 }}>-{cron && cron.name}</span>{' '}
{excuting && <Loading3QuartersOutlined spin />}
{!excuting && <CheckCircleOutlined />}
</>
);
};
useEffect(() => {
if (cron) {
getCronLog(true);
@ -58,7 +74,7 @@ const CronLogModal = ({
return (
<Modal
title={`日志-${cron && cron.name}`}
title={titleElement()}
visible={visible}
forceRender
onOk={() => cancel()}