fix issue

pull/330/head
vapao 2021-04-26 18:23:50 +08:00
parent 19f5ba5cfb
commit d428933b8f
2 changed files with 29 additions and 22 deletions

View File

@ -130,6 +130,8 @@ class RequestDetailView(View):
outputs['local'] = {'id': 'local', 'data': [f'{human_time()} 读取数据... ']} outputs['local'] = {'id': 'local', 'data': [f'{human_time()} 读取数据... ']}
response['s_actions'] = json.loads(req.deploy.extend_obj.server_actions) response['s_actions'] = json.loads(req.deploy.extend_obj.server_actions)
response['h_actions'] = json.loads(req.deploy.extend_obj.host_actions) response['h_actions'] = json.loads(req.deploy.extend_obj.host_actions)
if not response['h_actions']:
response['outputs'] = {'local': outputs['local']}
rds, key, counter = get_redis_connection(), f'{settings.REQUEST_KEY}:{r_id}', 0 rds, key, counter = get_redis_connection(), f'{settings.REQUEST_KEY}:{r_id}', 0
data = rds.lrange(key, counter, counter + 9) data = rds.lrange(key, counter, counter + 9)
while data: while data:
@ -169,6 +171,8 @@ class RequestDetailView(View):
outputs['local'] = {'id': 'local', 'step': 0, 'data': [message]} outputs['local'] = {'id': 'local', 'step': 0, 'data': [message]}
s_actions = json.loads(req.deploy.extend_obj.server_actions) s_actions = json.loads(req.deploy.extend_obj.server_actions)
h_actions = json.loads(req.deploy.extend_obj.host_actions) h_actions = json.loads(req.deploy.extend_obj.host_actions)
if not h_actions:
outputs = {'local': outputs['local']}
return json_response({'s_actions': s_actions, 'h_actions': h_actions, 'outputs': outputs}) return json_response({'s_actions': s_actions, 'h_actions': h_actions, 'outputs': outputs})
return json_response({'outputs': outputs}) return json_response({'outputs': outputs})

View File

@ -80,6 +80,7 @@ function Ext2Console(props) {
store.tabModes[props.request.id] = !value store.tabModes[props.request.id] = !value
} }
const hostOutputs = Object.values(outputs).filter(x => x.id !== 'local');
return store.tabModes[props.request.id] ? ( return store.tabModes[props.request.id] ? (
<Card <Card
className={styles.item} className={styles.item}
@ -127,28 +128,30 @@ function Ext2Console(props) {
<OutView records={outputs.local.data}/> <OutView records={outputs.local.data}/>
</Collapse.Panel> </Collapse.Panel>
</Collapse> </Collapse>
<Collapse {hostOutputs.length > 0 && (
defaultActiveKey="0" <Collapse
className={styles.collapse} defaultActiveKey="0"
style={{marginTop: 24}} className={styles.collapse}
expandIcon={({isActive}) => <CaretRightOutlined style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}> style={{marginTop: 24}}
{Object.values(outputs).filter(x => x.id !== 'local').map((item, index) => ( expandIcon={({isActive}) => <CaretRightOutlined style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}>
<Collapse.Panel {hostOutputs.map((item, index) => (
key={index} <Collapse.Panel
header={ key={index}
<div className={styles.header}> header={
<b className={styles.title}>{item.title}</b> <div className={styles.header}>
<Steps size="small" className={styles.step} current={item.step} status={item.status}> <b className={styles.title}>{item.title}</b>
<StepItem title="等待调度" item={item} step={0}/> <Steps size="small" className={styles.step} current={item.step} status={item.status}>
{hActions.map((action, index) => ( <StepItem title="等待调度" item={item} step={0}/>
<StepItem key={index} title={action.title} item={item} step={index + 1}/> {hActions.map((action, index) => (
))} <StepItem key={index} title={action.title} item={item} step={index + 1}/>
</Steps> ))}
</div>}> </Steps>
<OutView records={item.data}/> </div>}>
</Collapse.Panel> <OutView records={item.data}/>
))} </Collapse.Panel>
</Collapse> ))}
</Collapse>
)}
</Modal> </Modal>
) )
} }