mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修复定时任务详情日志查看
This commit is contained in:
parent
54dd90e7c5
commit
d0e46224dc
|
@ -66,6 +66,7 @@ const CronDetailModal = ({
|
||||||
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
||||||
const editorRef = useRef<any>(null);
|
const editorRef = useRef<any>(null);
|
||||||
const [scriptInfo, setScriptInfo] = useState<any>({});
|
const [scriptInfo, setScriptInfo] = useState<any>({});
|
||||||
|
const [logUrl, setLogUrl] = useState('');
|
||||||
|
|
||||||
const contentList: any = {
|
const contentList: any = {
|
||||||
log: (
|
log: (
|
||||||
|
@ -101,6 +102,8 @@ const CronDetailModal = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClickItem = (item: LogItem) => {
|
const onClickItem = (item: LogItem) => {
|
||||||
|
localStorage.setItem('logCron', cron.id);
|
||||||
|
setLogUrl(`${config.apiPrefix}logs/${item.directory}/${item.filename}`);
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}logs/${item.directory}/${item.filename}`)
|
.get(`${config.apiPrefix}logs/${item.directory}/${item.filename}`)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
@ -173,6 +176,7 @@ const CronDetailModal = ({
|
||||||
})
|
})
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
if (_data.code === 200) {
|
if (_data.code === 200) {
|
||||||
|
setValue(content);
|
||||||
message.success(`保存成功`);
|
message.success(`保存成功`);
|
||||||
} else {
|
} else {
|
||||||
message.error(_data);
|
message.error(_data);
|
||||||
|
@ -220,6 +224,12 @@ const CronDetailModal = ({
|
||||||
>
|
>
|
||||||
<div style={{ height: '80vh' }}>
|
<div style={{ height: '80vh' }}>
|
||||||
<Card>
|
<Card>
|
||||||
|
<div className="cron-detail-info-item">
|
||||||
|
<div className="cron-detail-info-title">任务</div>
|
||||||
|
<div className="cron-detail-info-value">{cron.command}</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
<Card style={{ marginTop: 10 }}>
|
||||||
<div className="cron-detail-info-item">
|
<div className="cron-detail-info-item">
|
||||||
<div className="cron-detail-info-title">状态</div>
|
<div className="cron-detail-info-title">状态</div>
|
||||||
<div className="cron-detail-info-value">
|
<div className="cron-detail-info-value">
|
||||||
|
@ -252,10 +262,6 @@ const CronDetailModal = ({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="cron-detail-info-item">
|
|
||||||
<div className="cron-detail-info-title">任务</div>
|
|
||||||
<div className="cron-detail-info-value">{cron.command}</div>
|
|
||||||
</div>
|
|
||||||
<div className="cron-detail-info-item">
|
<div className="cron-detail-info-item">
|
||||||
<div className="cron-detail-info-title">定时</div>
|
<div className="cron-detail-info-title">定时</div>
|
||||||
<div className="cron-detail-info-value">{cron.schedule}</div>
|
<div className="cron-detail-info-value">{cron.schedule}</div>
|
||||||
|
@ -291,7 +297,7 @@ const CronDetailModal = ({
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<Card
|
<Card
|
||||||
style={{ marginTop: 16 }}
|
style={{ marginTop: 10 }}
|
||||||
tabList={tabList}
|
tabList={tabList}
|
||||||
activeTabKey={activeTabKey}
|
activeTabKey={activeTabKey}
|
||||||
onTabChange={(key) => {
|
onTabChange={(key) => {
|
||||||
|
@ -308,7 +314,7 @@ const CronDetailModal = ({
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
bodyStyle={{ height: 'calc(80vh - 188px)', overflowY: 'auto' }}
|
bodyStyle={{ height: 'calc(80vh - 238px)', overflowY: 'auto' }}
|
||||||
>
|
>
|
||||||
{contentList[activeTabKey]}
|
{contentList[activeTabKey]}
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -320,6 +326,7 @@ const CronDetailModal = ({
|
||||||
}}
|
}}
|
||||||
cron={cron}
|
cron={cron}
|
||||||
data={log}
|
data={log}
|
||||||
|
logUrl={logUrl}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,13 +14,42 @@
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-card-body {
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
.ant-card-head {
|
||||||
|
padding: 0 18px;
|
||||||
|
}
|
||||||
|
|
||||||
.ant-card:first-child {
|
.ant-card:first-child {
|
||||||
|
max-height: 66px;
|
||||||
|
overflow: auto;
|
||||||
|
|
||||||
|
.ant-card-body {
|
||||||
|
min-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cron-detail-info-item {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.cron-detail-info-title {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cron-detail-info-value {
|
||||||
|
flex: 1;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-card:nth-child(2) {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
|
||||||
.ant-card-body {
|
.ant-card-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
min-width: 700px;
|
min-width: 600px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +61,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.cron-detail-info-value {
|
.cron-detail-info-value {
|
||||||
margin-top: 18px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import { getTableScroll } from '@/utils/index';
|
||||||
import { history } from 'umi';
|
import { history } from 'umi';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text, Paragraph } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
|
||||||
export enum CrontabStatus {
|
export enum CrontabStatus {
|
||||||
|
@ -130,16 +130,16 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
render: (text: string, record: any) => {
|
render: (text: string, record: any) => {
|
||||||
return (
|
return (
|
||||||
<span
|
<Paragraph
|
||||||
style={{
|
style={{
|
||||||
textAlign: 'left',
|
|
||||||
width: '100%',
|
|
||||||
display: 'inline-block',
|
|
||||||
wordBreak: 'break-all',
|
wordBreak: 'break-all',
|
||||||
|
marginBottom: 0,
|
||||||
|
textAlign: 'left',
|
||||||
}}
|
}}
|
||||||
|
ellipsis={{ tooltip: text, rows: 2 }}
|
||||||
>
|
>
|
||||||
{text}
|
{text}
|
||||||
</span>
|
</Paragraph>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sorter: {
|
sorter: {
|
||||||
|
@ -628,7 +628,8 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
index: number;
|
index: number;
|
||||||
}> = ({ record, index }) => (
|
}> = ({ record, index }) => (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
arrow
|
arrow={{ pointAtCenter: true }}
|
||||||
|
placement="bottomRight"
|
||||||
trigger={['click']}
|
trigger={['click']}
|
||||||
overlay={
|
overlay={
|
||||||
<Menu
|
<Menu
|
||||||
|
|
|
@ -21,11 +21,13 @@ const CronLogModal = ({
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
visible,
|
||||||
data,
|
data,
|
||||||
|
logUrl,
|
||||||
}: {
|
}: {
|
||||||
cron?: any;
|
cron?: any;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
data?: string;
|
data?: string;
|
||||||
|
logUrl?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState<string>('启动中...');
|
const [value, setValue] = useState<string>('启动中...');
|
||||||
const [loading, setLoading] = useState<any>(true);
|
const [loading, setLoading] = useState<any>(true);
|
||||||
|
@ -38,7 +40,7 @@ const CronLogModal = ({
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
}
|
}
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}crons/${cron.id}/log`)
|
.get(logUrl ? logUrl : `${config.apiPrefix}crons/${cron.id}/log`)
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
if (localStorage.getItem('logCron') === String(cron.id)) {
|
if (localStorage.getItem('logCron') === String(cron.id)) {
|
||||||
const log = data.data as string;
|
const log = data.data as string;
|
||||||
|
@ -99,10 +101,10 @@ const CronLogModal = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (cron && cron.id) {
|
if (cron && cron.id && visible) {
|
||||||
getCronLog(true);
|
getCronLog(true);
|
||||||
}
|
}
|
||||||
}, [cron]);
|
}, [cron, visible]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
20
src/pages/env/index.tsx
vendored
20
src/pages/env/index.tsx
vendored
|
@ -27,7 +27,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
import { getTableScroll } from '@/utils/index';
|
import { getTableScroll } from '@/utils/index';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text, Paragraph } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
|
@ -119,18 +119,18 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
key: 'value',
|
key: 'value',
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
width: '35%',
|
width: '35%',
|
||||||
ellipsis: {
|
|
||||||
showTitle: false,
|
|
||||||
},
|
|
||||||
render: (text: string, record: any) => {
|
render: (text: string, record: any) => {
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Paragraph
|
||||||
placement="topLeft"
|
style={{
|
||||||
title={text}
|
wordBreak: 'break-all',
|
||||||
trigger={['hover', 'click']}
|
marginBottom: 0,
|
||||||
|
textAlign: 'left',
|
||||||
|
}}
|
||||||
|
ellipsis={{ tooltip: text, rows: 2 }}
|
||||||
>
|
>
|
||||||
<span>{text}</span>
|
{text}
|
||||||
</Tooltip>
|
</Paragraph>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user