diff --git a/spug_web/src/pages/deploy/do/index.js b/spug_web/src/pages/deploy/do/index.js new file mode 100644 index 0000000..e3b679a --- /dev/null +++ b/spug_web/src/pages/deploy/do/index.js @@ -0,0 +1,73 @@ +import React from 'react'; +import { Steps, Collapse, Icon } from 'antd'; +import http from 'libs/http'; +import styles from './index.module.css'; +import store from './store'; + + +class Index extends React.Component { + componentDidMount() { + const {id} = this.props.match.params; + http.post(`/api/deploy/request/${id}/`) + .then(token => { + this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`); + this.socket.onopen = () => { + this.socket.send('ok'); + }; + this.socket.onmessage = e => { + if (e.data === 'pong') { + this.socket.send('ping') + } else { + console.log(JSON.parse(e.data)); + // const {key, data, type, status} = JSON.parse(e.data); + // 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'}) + // } + // } + } + } + }) + } + + componentWillUnmount() { + if (this.socket) this.socket.close() + } + + render() { + return ( +
+
服务端执行 :
+ + + + + }/> + + }>web -01 + +
目标主机执行 :
+ + +
web-01
+ + + + }/> + +
+ }>web -01 + web -02 + + + ) + } +} + +export default Index \ No newline at end of file diff --git a/spug_web/src/pages/deploy/do/index.module.css b/spug_web/src/pages/deploy/do/index.module.css new file mode 100644 index 0000000..87a3abd --- /dev/null +++ b/spug_web/src/pages/deploy/do/index.module.css @@ -0,0 +1,3 @@ +.header { + display: flex; +} \ No newline at end of file diff --git a/spug_web/src/pages/deploy/do/store.js b/spug_web/src/pages/deploy/do/store.js new file mode 100644 index 0000000..a2df1e8 --- /dev/null +++ b/spug_web/src/pages/deploy/do/store.js @@ -0,0 +1,7 @@ +import { observable } from "mobx"; + +class Store { + @observable outputs = []; +} + +export default new Store() \ No newline at end of file diff --git a/spug_web/src/pages/deploy/request/Table.js b/spug_web/src/pages/deploy/request/Table.js index fc13938..f810aac 100644 --- a/spug_web/src/pages/deploy/request/Table.js +++ b/spug_web/src/pages/deploy/request/Table.js @@ -1,4 +1,5 @@ import React from 'react'; +import { Link } from 'react-router-dom'; import { observer } from 'mobx-react'; import { Table, Divider, Modal, Icon, message } from 'antd'; import http from 'libs/http'; @@ -53,6 +54,8 @@ class ComTable extends React.Component { title: '操作', render: info => ( + 发布 + store.showForm(info)}>编辑 this.handleDelete(info)}>删除 diff --git a/spug_web/src/pages/deploy/routes.js b/spug_web/src/pages/deploy/routes.js index 64b9951..170b799 100644 --- a/spug_web/src/pages/deploy/routes.js +++ b/spug_web/src/pages/deploy/routes.js @@ -1,9 +1,11 @@ import { makeRoute } from "../../libs/router"; import app from './app'; import request from './request'; +import doIndex from './do'; export default [ makeRoute('/app', app), makeRoute('/request', request), + makeRoute('/do/:id', doIndex), ] \ No newline at end of file