Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vapao committed Sep 19, 2021
1 parent c67f7c2 commit c5838f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
25 changes: 19 additions & 6 deletions spug_web/src/pages/exec/task/ExecConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import store from './store';
class ExecConsole extends React.Component {
constructor(props) {
super(props);
this.lastOutputs = {};
this.socket = null;
this.terms = {};
this.outputs = {};
Expand All @@ -49,6 +50,7 @@ class ExecConsole extends React.Component {
const {key, data, status} = JSON.parse(e.data);
if (status !== undefined) store.outputs[key].status = status;
if (data) {
if (data.replace(/\r\n/g, '')) this.lastOutputs[key] = data.trim()
this.handleWrite(key, data)
}
}
Expand Down Expand Up @@ -80,16 +82,24 @@ class ExecConsole extends React.Component {
}
}

genExtra = (status) => {
genExtra = (status, key) => {
if (status === -2) {
return <LoadingOutlined style={{fontSize: 20, color: '#108ee9'}}/>;
} else if (status === 0) {
return <CheckCircleTwoTone style={{fontSize: 20}} twoToneColor="#52c41a"/>
return (
<div style={{display: 'flex', alignItems: 'center'}}>
<pre className={styles.header2}>{this.lastOutputs[key]}</pre>
<CheckCircleTwoTone style={{fontSize: 20}} twoToneColor="#52c41a"/>
</div>
)
} else {
return (
<Tooltip title={`退出状态码:${status}`}>
<WarningTwoTone style={{fontSize: 20}} twoToneColor="red"/>
</Tooltip>
<div style={{display: 'flex', alignItems: 'center'}}>
<pre className={styles.header2}>{this.lastOutputs[key]}</pre>
<Tooltip title={`退出状态码:${status}`}>
<WarningTwoTone style={{fontSize: 20}} twoToneColor="red"/>
</Tooltip>
</div>
)
}
};
Expand Down Expand Up @@ -124,7 +134,10 @@ class ExecConsole extends React.Component {
onChange={key => this.handleUpdate({activeKey: key})}
expandIcon={({isActive}) => <CaretRightOutlined style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}>
{Object.entries(store.outputs).map(([key, item], index) => (
<Collapse.Panel key={key} header={<b>{item['title']}</b>} extra={this.genExtra(item.status)}>
<Collapse.Panel
key={key}
header={<div className={styles.header1}>{item['title']}</div>}
extra={this.genExtra(item.status, key)}>
<OutView
isFullscreen={isFullscreen}
getOutput={() => this.outputs[key]}
Expand Down
15 changes: 13 additions & 2 deletions spug_web/src/pages/exec/task/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@
color: #000;
}

.header {
.header1 {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 400px;
font-weight: bold;
margin: 0;
}

.header2 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 450px;
padding-right: 20px;
margin: 0
margin: 0;
}

pre {
Expand Down

0 comments on commit c5838f1

Please sign in to comment.