diff --git a/spug_web/src/pages/exec/task/ExecConsole.js b/spug_web/src/pages/exec/task/ExecConsole.js
index cdacde5d..b6a8faa5 100644
--- a/spug_web/src/pages/exec/task/ExecConsole.js
+++ b/spug_web/src/pages/exec/task/ExecConsole.js
@@ -6,6 +6,7 @@
import React from 'react';
import { observer } from 'mobx-react';
import { Modal, Collapse, Icon } from 'antd';
+import OutView from './OutView';
import styles from './index.module.css';
import store from './store';
@@ -27,7 +28,7 @@ class ExecConsole extends React.Component {
this.socket.onopen = () => {
this.socket.send('ok');
for (let item of Object.values(store.outputs)) {
- item['system'] += '### Waiting for schedule\n'
+ item['system'].push('### Waiting for schedule\n')
}
};
this.socket.onmessage = e => {
@@ -38,11 +39,7 @@ class ExecConsole extends React.Component {
if (status !== undefined) {
store.outputs[key]['status'] = status
} else if (data) {
- store.outputs[key][type] += data;
- store.outputs[key]['latest'] = data;
- if (this.elements[key]) {
- this.elements[key].scrollIntoView({behavior: 'smooth'})
- }
+ store.outputs[key][type].push(data);
}
}
}
@@ -52,15 +49,21 @@ class ExecConsole extends React.Component {
this.socket.close()
}
- genExtra = (key) => {
- const item = store.outputs[key];
+ genExtra = (outputs) => {
+ let latest, icon;
+ if (outputs['status'] === -2) {
+ return
+ } else if (outputs['status'] === 0) {
+ latest = outputs['info'][outputs['info'].length - 1];
+ icon =
+ } else {
+ latest = outputs['error'][outputs['error'].length - 1]
+ icon =
+ }
return (
-
{item['latest']}
- {item['status'] === -2 ?
:
- item['status'] === 0 ?
-
:
-
}
+
{latest}
+ {icon}
)
};
@@ -84,12 +87,8 @@ class ExecConsole extends React.Component {
{item['title']}}
- extra={this.genExtra(key)}>
-
- {item['system']}
- {item['info']}
- this.elements[key] = ref} style={{color: '#ffa39e'}}>{item['error']}
-
+ extra={this.genExtra(item)}>
+
))}
diff --git a/spug_web/src/pages/exec/task/OutView.js b/spug_web/src/pages/exec/task/OutView.js
new file mode 100644
index 00000000..ee550202
--- /dev/null
+++ b/spug_web/src/pages/exec/task/OutView.js
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
+ * Copyright (c)
+ * Released under the AGPL-3.0 License.
+ */
+import React from 'react';
+import { toJS } from 'mobx';
+import { observer } from 'mobx-react';
+import styles from './index.module.css';
+
+@observer
+class OutView extends React.Component {
+ constructor(props) {
+ super(props);
+ this.el = null;
+ }
+
+ componentDidUpdate(prevProps, prevState, snapshot) {
+ setTimeout(() => this.el.scrollTop = this.el.scrollHeight, 100)
+ }
+
+ render() {
+ const outputs = toJS(this.props.outputs);
+ return (
+ this.el = ref} className={styles.console}>
+
{outputs['system']}
+
{outputs['info']}
+
{outputs['error']}
+
+ )
+ }
+}
+
+export default OutView
\ No newline at end of file
diff --git a/spug_web/src/pages/exec/task/index.module.css b/spug_web/src/pages/exec/task/index.module.css
index a62f56f5..c128bca4 100644
--- a/spug_web/src/pages/exec/task/index.module.css
+++ b/spug_web/src/pages/exec/task/index.module.css
@@ -5,6 +5,7 @@
.console {
max-height: 300px;
padding: 10px 15px;
+ overflow: scroll;
}
.header {
diff --git a/spug_web/src/pages/exec/task/store.js b/spug_web/src/pages/exec/task/store.js
index 097fdcd5..3a03e6b7 100644
--- a/spug_web/src/pages/exec/task/store.js
+++ b/spug_web/src/pages/exec/task/store.js
@@ -30,10 +30,9 @@ class Store {
const key = `${item.hostname}:${item.port}`;
this.outputs[key] = {
title: `${item.name}(${key})`,
- system: '### Establishing communication\n',
- info: '',
- error: '',
- latest: '',
+ system: ['### Establishing communication\n'],
+ info: [],
+ error: [],
status: -2
}
}