mirror of https://github.com/openspug/spug
优化任务计划表单提交提示信息
parent
8f9a1d56fc
commit
033174b5a5
|
@ -17,15 +17,21 @@ import S from './store';
|
|||
import styles from './index.module.less';
|
||||
|
||||
export default observer(function (props) {
|
||||
const [visible, setVisible] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
function handleSubmit() {
|
||||
setLoading(true)
|
||||
const formData = lds.pick(S.record, ['id', 'name', 'type', 'interpreter', 'command', 'desc', 'rst_notify']);
|
||||
formData['targets'] = S.targets.filter(x => x);
|
||||
formData['trigger'] = S.trigger;
|
||||
formData['trigger_args'] = _parse_args();
|
||||
if (S.trigger === 'monitor') {
|
||||
if (formData.targets.length > 1) {
|
||||
return message.error('监控告警类触发器,只能选择一个执行对象')
|
||||
}
|
||||
} else if (formData.targets.includes('monitor')) {
|
||||
return message.error('执行对象选择有误,请重新选择')
|
||||
}
|
||||
setLoading(true)
|
||||
http.post('/api/schedule/', formData)
|
||||
.then(res => {
|
||||
message.success('操作成功');
|
||||
|
@ -52,6 +58,13 @@ export default observer(function (props) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleChange(_, ids) {
|
||||
if (S.targets.includes('local')) {
|
||||
ids.unshift('local')
|
||||
}
|
||||
S.targets = ids
|
||||
}
|
||||
|
||||
return (
|
||||
<Container visible={props.visible} style={{width: 420, margin: '0 auto'}}>
|
||||
<Form layout="vertical" style={{minHeight: 200}}>
|
||||
|
@ -82,10 +95,11 @@ export default observer(function (props) {
|
|||
))}
|
||||
</Form.Item>
|
||||
<Form.Item extra="本机即Spug服务运行所在的容器或主机。">
|
||||
<Button type="dashed" style={{width: '80%'}} disabled={S.trigger === 'monitor'}
|
||||
onClick={() => setVisible(true)}>
|
||||
<PlusOutlined/>添加执行对象
|
||||
</Button>
|
||||
<HostSelector value={S.targets.filter(x => x !== 'local')} onChange={handleChange}>
|
||||
<Button type="dashed" style={{width: 'calc(100% - 40px)'}} disabled={S.trigger === 'monitor'}>
|
||||
<PlusOutlined/>添加执行对象
|
||||
</Button>
|
||||
</HostSelector>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button loading={loading} disabled={S.targets.filter(x => x).length === 0} type="primary"
|
||||
|
@ -93,11 +107,6 @@ export default observer(function (props) {
|
|||
<Button style={{marginLeft: 20}} onClick={() => S.page -= 1}>上一步</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<HostSelector
|
||||
visible={visible}
|
||||
selectedRowKeys={[...S.targets]}
|
||||
onCancel={() => setVisible(false)}
|
||||
onOk={(_, ids) => S.targets = ids}/>
|
||||
</Container>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (c) <spug.dev@gmail.com>
|
||||
* Released under the AGPL-3.0 License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import { Input } from 'antd';
|
||||
import { SearchForm, AuthDiv, Breadcrumb } from 'components';
|
||||
|
|
Loading…
Reference in New Issue