basic file up and download working

This commit is contained in:
Clemens 2016-06-01 23:12:49 +02:00 committed by Maximilian Hils
parent cf544318ae
commit a219d33430
3 changed files with 14 additions and 4 deletions

View File

@ -178,6 +178,7 @@ class DumpFlows(RequestHandler):
sio.close()
def post(self):
# self.state.clear()
sio = StringIO(self.request.body)
self.state.load_flows(FlowReader(sio).stream())
sio.close()

View File

@ -122,7 +122,7 @@ export var FlowActions = {
upload: (file) => {
var filereader = new FileReader();
filereader.file = file;
filereader.onload = (e) => $.post("/flows/dump", e.target.result);
filereader.onload = (e) => {$.post("/flows/dump", e.target.result); e.preventDefault();};
filereader.readAsBinaryString(file);
}
};

View File

@ -344,11 +344,15 @@ var FileMenu = React.createClass({
}
},
handleOpenClick: function (e) {
$('#uploadFileInput').trigger('click');
e.preventDefault();
},
handleOpenChange: function (e) {
e.preventDefault();
handleOpenFile: function (e) {
if (e.target.files.length > 0) {
FlowActions.upload(e.target.files[0]);
$('#uploadFileInput').val("");
}
e.preventDefault();
},
handleSaveClick: function (e) {
e.preventDefault();
@ -372,7 +376,12 @@ var FileMenu = React.createClass({
</a>
</li>
<li>
<input type="file" onChange={this.handleOpenChange}/>
<a href="#" onClick={this.handleOpenClick}>
<i className="fa fa-fw fa-folder-open"></i>
Open...
</a>
<input id="uploadFileInput" className="hidden" type="file" onChange={this.handleOpenFile}/>
</li>
<li>
<a href="#" onClick={this.handleSaveClick}>