diff --git a/spug_web/src/pages/deploy/do/index.js b/spug_web/src/pages/deploy/do/index.js
index 129a5b0..49cc89b 100644
--- a/spug_web/src/pages/deploy/do/index.js
+++ b/spug_web/src/pages/deploy/do/index.js
@@ -1,17 +1,42 @@
import React from 'react';
import { observer } from 'mobx-react';
-import { Steps, Collapse, Icon } from 'antd';
+import { Steps, Collapse, PageHeader, Spin, Tag, Button, Icon } from 'antd';
import http from 'libs/http';
+import history from 'libs/history';
import styles from './index.module.css';
import store from './store';
import lds from 'lodash';
@observer
class Index extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ fetching: true,
+ loading: false,
+ request: {},
+ }
+ }
+
componentDidMount() {
- const {id} = this.props.match.params;
- http.post(`/api/deploy/request/${id}/`)
+ this.id = this.props.match.params.id;
+ http.get(`/api/deploy/request/${this.id}/`)
+ .then(res => store.request = res)
+ .finally(() => this.setState({fetching: false}))
+ }
+
+ componentWillUnmount() {
+ if (this.socket) this.socket.close();
+ store.request = {};
+ store.outputs = {};
+ store.targets = []
+ }
+
+ handleDeploy = () => {
+ this.setState({loading: true});
+ http.post(`/api/deploy/request/${this.id}/`)
.then(({token, outputs, targets}) => {
+ store.request.status = '3';
store.outputs = outputs;
store.targets = targets;
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`);
@@ -26,20 +51,14 @@ class Index extends React.Component {
if (data !== undefined) store.outputs[key]['data'] += data;
if (step !== undefined) store.outputs[key]['step'] = step;
if (status !== undefined) store.outputs[key]['status'] = status;
- // if (this.elements[key]) {
- // this.elements[key].scrollIntoView({behavior: 'smooth'})
- // }
}
}
})
- }
-
- componentWillUnmount() {
- if (this.socket) this.socket.close()
- }
+ .finally(() => this.setState({loading: false}))
+ };
getStatus = (key, n) => {
- const step = lds.get(store.outputs, `${key}.step`, 0);
+ const step = lds.get(store.outputs, `${key}.step`, -1);
const isError = lds.get(store.outputs, `${key}.status`) === 'error';
const icon =
{lds.get(store.outputs, 'local.data')}