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 (