-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexecute.js
51 lines (48 loc) · 1.3 KB
/
execute.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, {Component} from 'react';
export default class Execute extends Component {
execute = data => {
const {session, messages} = this.state;
const {socket} = this.props;
let {waitingList, pendingBlocks} = this.props.kernelStatus;
const {code, msg_id, blockID} = data;
waitingList = waitingList.filter(w => w.msg_id !== msg_id);
messages[msg_id] = blockID;
pendingBlocks.push(blockID);
this.changeKernelStatus({waitingList, pendingBlocks});
this.setWaitingList(waitingList);
const msg = {
header: {
username: '',
version: '5.2',
session,
msg_id,
msg_type: 'execute_request'
},
parent_header: {},
channel: 'shell',
content: {
silent: false,
store_history: true,
user_expressions: {},
allow_stdin: true,
stop_on_error: true,
code
},
metadata: {},
buffers: []
};
this.currentEditor.change(c => {
const {document} = c.value;
const currentNode = document.getNode(blockID);
if (!currentNode) return;
const data = currentNode.data.toJS();
data.result = {};
c.setNodeByKey(blockID, {data})
});
console.log('execute', data);
socket.send(JSON.stringify(msg))
};
render() {
return <div />
}
}