-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.js
86 lines (77 loc) · 2.78 KB
/
project.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const React = require('react')
const $ = require('jquery')
const fixtures = {
'persistence.py': require('raw!./fixtures/persistence.py'),
'persistence-test.py': require('raw!./fixtures/persistence-test.py')
}
function commandFor(fixtures, name) {
return `if [ ! - f /home/${name} ]; then echo '${fixtures[name].replace(/'/g, "'\\''")}' > /home/${name}`
}
module.exports = function ({ bootstrap, PanelManager, Terminal, Editor, Files, Layout }) {
class Project extends React.Component {
componentWillMount() {
bootstrap(this.props.serverUrl)
console.log('full project')
this.terminalManager = new PanelManager()
this.editorManager = new PanelManager()
this.filesManager = new PanelManager()
}
componentDidMount() {
$.ajax({
type: 'POST',
url: this.props.serverUrl + '/exec',
data: JSON.stringify({ cmd: fixtureCommand }),
success: () => { this.addWorkFile(); this.run('persistence.py') }
})
}
run(file) {
this.editorManager.saveAllFiles().then(() => {
this.terminalManager.destroyTerm(this.terminalManager.getCurrentTermId())
this.terminalManager.newTerm('test code', '/usr/bin/python', ['-i', '/home/' + file])
})
}
addWorkFile() {
this.editorManager.openFile('/home/persistence.py')
}
render() {
const layoutBoxStyle = {
position: 'absolute',
height: '100%',
width: '100%'
}
return <div className='theme_light' style={layoutBoxStyle}>
<div style={{ display: 'none' }}>
<Files manager={this.filesManager} editorManager={this.editorManager} serverUrl={this.props.serverUrl}/>
</div>
<Layout layout={{
override: true,
is_hidden: {},
maximized: '',
layout: {
type: 'vertical',
parts: [
{
component: <Editor manager={this.editorManager}
filesManager={this.filesManager}
serverUrl={this.props.serverUrl}/>,
key: 'editor',
weight: 6
},
{
component: <Terminal manager={this.terminalManager} serverUrl={this.props.serverUrl}/>,
key: 'terminal',
weight: 6
},
{
component: <div><div id="runcode_container" className="panel"><button className="btn btn-primary" onClick={() => this.run('persistence.py')}>Run Code!</button><button className="btn btn-primary test" onClick={() => this.run('persistence-test.py')}>Test Code</button></div></div>,
key: 'run-button',
weight: 1
}
]
}
}}/>
</div>
}
}
return Project;
}