-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.full.js
135 lines (123 loc) · 5.03 KB
/
project.full.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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}`
}
const fixtureCommand = Object.keys(fixtures).map(name => commandFor(fixtures, name)).join('\n')
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()
this.terminal2Manager = new PanelManager()
}
componentDidMount() {
$.ajax({
type: 'POST',
url: this.props.serverUrl + '/exec',
data: JSON.stringify({ cmd: fixtureCommand}),
success: () => { this.addWorkFile(); this.run('persistence.py') }
})
this.terminal2Manager.destroyTerm('repl')
this.terminal2Manager.newTerm('repl', '/usr/bin/python', [], () => this.terminal2Manager.SelectTab('repl'))
}
run(file) {
this.editorManager.saveAllFiles().then(() => {
this.terminalManager.destroyTerm('test code')
this.terminalManager.newTerm('test code', '/usr/bin/python', ['-i', '/home/' + file], () => this.terminalManager.SelectTab('test code'))
})
}
addWorkFile() {
this.editorManager.openFile('/home/persistence.py')
}
render() {
const layoutBoxStyle = {
position: 'absolute',
height: '100%',
width: '100%'
}
return (
<div className="multiple-components">
<div className='full-project theme_dark' style={layoutBoxStyle}>
<Layout layout={{
override: true,
is_hidden: {},
maximized: '',
layout: {
type: 'vertical',
parts: [
{
type: 'horizontal',
parts: [
{
component: <Files manager={this.filesManager}
editorManager={this.editorManager}
serverUrl={this.props.serverUrl}/>,
key: 'files',
weight: 2
},
{
component: <Editor manager={this.editorManager}
filesManager={this.filesManager}
serverUrl={this.props.serverUrl}/>,
key: 'editor',
weight: 6
},
],
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-default test" onClick={() => this.run('persistence-test.py')}>Test Code</button></div></div>,
key: 'run-button',
weight: 1
}
]
}
}}/>
</div>
<article className="demo-text" style={{ position: 'relative', top: 680 }}>
<p>
Let's focus on how python math actually works. When you're working in Python you can use
the "math" library to access many functions to speed your everyday computations along. For
instance, you can use ceil(), floor(), and round() to convert fractional numbers to nice round
integers in a predictable way.
</p>
<p>
To show this off, let's play with a few of these in the python interpreter below. Enter math.ceil(4.5) into
the interpreter and see what it says. Then try math.floor(4.5). Did this do what you'd expect?
</p>
</article>
<div className="terminal-only" style={{ top: 700, position: 'relative', height: 300, marginBottom: 200 }}>
<Layout layout={{
is_hidden: {},
maximized: '',
layout: {
type: 'horizontal',
parts: [
{
component: <Terminal manager={this.terminal2Manager} serverUrl={this.props.serverUrl}/>,
key: 'terminal',
weight: 1
}
]
}
}}/>
</div>
</div>
)
}
}
return Project;
}