diff --git a/spug_web/src/components/Action.js b/spug_web/src/components/Action.js
index 230b337..43c4095 100644
--- a/spug_web/src/components/Action.js
+++ b/spug_web/src/components/Action.js
@@ -21,14 +21,21 @@ class Action extends React.Component {
return
}
+ _handle = (data, el) => {
+ const length = data.length;
+ if (canVisible(el.props.auth)) {
+ if (length !== 0) data.push()
+ data.push(el)
+ }
+ }
+
render() {
const children = [];
- this.props.children.forEach((el, index) => {
- if (canVisible(el.props.auth)) {
- if (children.length !== 0) children.push();
- children.push(el)
- }
- })
+ if (Array.isArray(this.props.children)) {
+ this.props.children.forEach(el => this._handle(children, el))
+ } else {
+ this._handle(children, this.props.children)
+ }
return
{children}
diff --git a/spug_web/src/pages/deploy/do/Ext1Index.js b/spug_web/src/pages/deploy/do/Ext1Index.js
index 33205c7..c213418 100644
--- a/spug_web/src/pages/deploy/do/Ext1Index.js
+++ b/spug_web/src/pages/deploy/do/Ext1Index.js
@@ -18,10 +18,11 @@ import lds from 'lodash';
class Ext1Index extends React.Component {
constructor(props) {
super(props);
+ this.timer = null;
this.id = props.match.params.id;
this.log = props.match.params.log;
this.state = {
- fetching: false,
+ fetching: true,
loading: false,
}
}
@@ -32,14 +33,13 @@ class Ext1Index extends React.Component {
componentWillUnmount() {
if (this.socket) this.socket.close();
- if (this.interval) clearInterval(this.interval);
+ if (this.timer) clearTimeout(this.timer);
store.request = {targets: [], host_actions: [], server_actions: []};
store.outputs = {};
}
fetch = () => {
- if (this.state.fetching) return ;
- this.setState({fetching: true});
+ if (!this.timer) this.setState({fetching: true});
http.get(`/api/deploy/request/${this.id}/`, {params: {log: this.log}})
.then(res => {
store.request = res;
@@ -53,12 +53,10 @@ class Ext1Index extends React.Component {
this._parse_message(msg, outputs)
}
store.outputs = outputs;
- if (this.interval) {
- if (['3', '-3'].includes(store.request.status)) {
- clearInterval(this.interval)
- }
- } else if (store.request.status === '2') {
- this.interval = setInterval(this.fetch, 2000)
+ if (store.request.status === '2') {
+ this.timer = setTimeout(this.fetch, 2000)
+ } else {
+ this.timer = null
}
})
.finally(() => this.setState({fetching: false}))
diff --git a/spug_web/src/pages/deploy/do/Ext2Index.js b/spug_web/src/pages/deploy/do/Ext2Index.js
index 8f256ad..4c4f107 100644
--- a/spug_web/src/pages/deploy/do/Ext2Index.js
+++ b/spug_web/src/pages/deploy/do/Ext2Index.js
@@ -18,10 +18,11 @@ import lds from 'lodash';
class Ext1Index extends React.Component {
constructor(props) {
super(props);
+ this.timer = null;
this.id = props.match.params.id;
this.log = props.match.params.log;
this.state = {
- fetching: false,
+ fetching: true,
loading: false,
}
}
@@ -32,15 +33,14 @@ class Ext1Index extends React.Component {
componentWillUnmount() {
if (this.socket) this.socket.close();
- if (this.interval) clearInterval(this.interval);
+ if (this.timer) clearTimeout(this.timer);
store.request = {targets: [], server_actions: [], host_actions: []};
store.outputs = {};
}
fetch = () => {
- if (this.state.fetching) return;
- this.setState({fetching: true});
+ if (!this.timer) this.setState({fetching: true});
http.get(`/api/deploy/request/${this.id}/`, {params: {log: this.log}})
.then(res => {
store.request = res;
@@ -54,12 +54,10 @@ class Ext1Index extends React.Component {
this._parse_message(msg, outputs)
}
store.outputs = outputs;
- if (this.interval) {
- if (['3', '-3'].includes(store.request.status)) {
- clearInterval(this.interval)
- }
- } else if (store.request.status === '2') {
- this.interval = setInterval(this.fetch, 2000)
+ if (store.request.status === '2') {
+ this.timer = setTimeout(this.fetch, 2000)
+ } else {
+ this.timer = null
}
})
.finally(() => this.setState({fetching: false}))