mirror of https://github.com/openspug/spug
F fix issue
parent
01c8fcd28a
commit
34616970ca
|
@ -11,7 +11,6 @@ export default observer(function () {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [showTmp, setShowTmp] = useState(false);
|
const [showTmp, setShowTmp] = useState(false);
|
||||||
const [command, setCommand] = useState(store.record.command || '');
|
const [command, setCommand] = useState(store.record.command || '');
|
||||||
const [interpreter, setInterpreter] = useState(store.record.interpreter || 'sh');
|
|
||||||
|
|
||||||
function handleAddZone() {
|
function handleAddZone() {
|
||||||
let type;
|
let type;
|
||||||
|
@ -44,6 +43,12 @@ export default observer(function () {
|
||||||
Object.assign(store.record, form.getFieldsValue(), {command: cleanCommand(command)})
|
Object.assign(store.record, form.getFieldsValue(), {command: cleanCommand(command)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSelect(tpl) {
|
||||||
|
const {interpreter, body} = tpl;
|
||||||
|
setCommand(body)
|
||||||
|
form.setFieldsValue({interpreter})
|
||||||
|
}
|
||||||
|
|
||||||
let modePlaceholder;
|
let modePlaceholder;
|
||||||
switch (store.record.rst_notify.mode) {
|
switch (store.record.rst_notify.mode) {
|
||||||
case '0':
|
case '0':
|
||||||
|
@ -80,13 +85,18 @@ export default observer(function () {
|
||||||
<Input placeholder="请输入任务名称"/>
|
<Input placeholder="请输入任务名称"/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item required label="任务内容" extra={<LinkButton onClick={() => setShowTmp(true)}>从模板添加</LinkButton>}>
|
<Form.Item required label="任务内容" extra={<LinkButton onClick={() => setShowTmp(true)}>从模板添加</LinkButton>}>
|
||||||
<Form.Item noStyle name="interpreter" initialValue="sh">
|
<Form.Item noStyle name="interpreter">
|
||||||
<Radio.Group buttonStyle="solid" style={{marginBottom: 12}} onChange={e => setInterpreter(e.target.value)}>
|
<Radio.Group buttonStyle="solid" style={{marginBottom: 12}}>
|
||||||
<Radio.Button value="sh" style={{width: 80, textAlign: 'center'}}>Shell</Radio.Button>
|
<Radio.Button value="sh" style={{width: 80, textAlign: 'center'}}>Shell</Radio.Button>
|
||||||
<Radio.Button value="python" style={{width: 80, textAlign: 'center'}}>Python</Radio.Button>
|
<Radio.Button value="python" style={{width: 80, textAlign: 'center'}}>Python</Radio.Button>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<ACEditor mode={interpreter} value={command} width="100%" height="150px" onChange={setCommand}/>
|
<Form.Item noStyle shouldUpdate>
|
||||||
|
{({getFieldValue}) => (
|
||||||
|
<ACEditor mode={getFieldValue('interpreter')} value={command} width="100%" height="150px"
|
||||||
|
onChange={setCommand}/>
|
||||||
|
)}
|
||||||
|
</Form.Item>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="失败通知" extra={(
|
<Form.Item label="失败通知" extra={(
|
||||||
<span>
|
<span>
|
||||||
|
@ -116,7 +126,7 @@ export default observer(function () {
|
||||||
<Form.Item shouldUpdate wrapperCol={{span: 14, offset: 6}}>
|
<Form.Item shouldUpdate wrapperCol={{span: 14, offset: 6}}>
|
||||||
{() => <Button disabled={canNext()} type="primary" onClick={handleNext}>下一步</Button>}
|
{() => <Button disabled={canNext()} type="primary" onClick={handleNext}>下一步</Button>}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{showTmp && <TemplateSelector onOk={({body}) => setCommand(body)} onCancel={() => setShowTmp(false)}/>}
|
{showTmp && <TemplateSelector onOk={handleSelect} onCancel={() => setShowTmp(false)}/>}
|
||||||
</Form>
|
</Form>
|
||||||
)
|
)
|
||||||
})
|
})
|
|
@ -56,7 +56,7 @@ class Store {
|
||||||
|
|
||||||
showForm = (info) => {
|
showForm = (info) => {
|
||||||
this.page = 0;
|
this.page = 0;
|
||||||
this.record = info || {rst_notify: {mode: '0'}, trigger: 'interval'};
|
this.record = info || {interpreter: 'sh', rst_notify: {mode: '0'}, trigger: 'interval'};
|
||||||
this.formVisible = true
|
this.formVisible = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue