Line-by-line web file upload added, but causes troub by blitzing http requests; so commented out. Unused pages for first release removed.
This commit is contained in:
parent
21424714f7
commit
713a9fb6b1
2 changed files with 117 additions and 16 deletions
|
@ -114,6 +114,10 @@ function jogRowHTML(axis)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function heatRowHTML(heater, hNumber)
|
||||
{
|
||||
var result = "";
|
||||
|
@ -139,8 +143,11 @@ function heatRowHTML(heater, hNumber)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<a href="http://reprappro.com" target="_blank"><img src="https://github.com/reprappro/RepRapFirmware/raw/duet/SD-image/www/logo.png" alt="RepRapPro logo" align="right"></a>
|
||||
|
@ -295,7 +302,49 @@ Click a file to <span data-bind="text: fileAction"></span><br>
|
|||
</ol>
|
||||
|
||||
<hr>
|
||||
<!--
|
||||
Upload a G Code file: <br>
|
||||
<input type="file" id="fileinput" />
|
||||
-->
|
||||
<script>
|
||||
function uploadGCode (evt)
|
||||
{
|
||||
//Retrieve the first (and only!) File from the FileList object
|
||||
var f = evt.target.files[0];
|
||||
//alert("Starting.");
|
||||
if (f)
|
||||
{
|
||||
var r = new FileReader();
|
||||
r.onload = function(e)
|
||||
{
|
||||
var contents = e.target.result;
|
||||
window.vm.gcode("M28 " + f.name);
|
||||
window.vm.sendGCode();
|
||||
var nextNL = contents.indexOf("\n");
|
||||
window.vm.gcode(contents.substr(0, nextNL));
|
||||
setTimeout(function() {}, 300);
|
||||
window.vm.sendGCode();
|
||||
window.vm.gcode("M29");
|
||||
setTimeout(function() {}, 300);
|
||||
window.vm.sendGCode();
|
||||
|
||||
// alert( "Got the file.\n"
|
||||
// +"name: " + f.name + "\n"
|
||||
// +"type: " + f.type + "\n"
|
||||
// +"size: " + f.size + " bytes\n"
|
||||
// + "starts with: " + contents.substr(1, contents.indexOf("\n"))
|
||||
// );
|
||||
};
|
||||
r.readAsText(f);
|
||||
//alert("Read file");
|
||||
} else
|
||||
{
|
||||
alert("Failed to load file");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<!--
|
||||
<form action="reprap.htm?upload=myFile"
|
||||
enctype="multipart/form-data" method="post">
|
||||
<p>
|
||||
|
@ -306,6 +355,9 @@ Upload a G Code file: <br>
|
|||
<input type="submit" value="Upload">
|
||||
</div>
|
||||
</form>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<form onSubmit="return checkFileName(this)" action="upload.htm"
|
||||
|
@ -336,18 +388,19 @@ Upload a G Code file :
|
|||
Help
|
||||
</div>
|
||||
|
||||
<!-- SETTINGS PAGE -->
|
||||
<!-- SETTINGS PAGE
|
||||
<div data-bind="if: chosenPageId() == pages[3]">
|
||||
Settings
|
||||
</div>
|
||||
|
||||
<!-- MESSAGES PAGE -->
|
||||
MESSAGES PAGE
|
||||
<div data-bind="if: chosenPageId() == pages[4]">
|
||||
Messages
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- LOGOUT/LOGIN PAGE -->
|
||||
<div data-bind="if: (chosenPageId() == pages[5] && gotPassword().password != 'right')">
|
||||
<div data-bind="if: (chosenPageId() == pages[3] && gotPassword().password != 'right')">
|
||||
<form data-bind="submit: sendPassword">
|
||||
Password: <input type="password" id="pwd" value="" data-bind="value: pwd" />
|
||||
<button type="submit">Submit</button>
|
||||
|
@ -375,7 +428,8 @@ function viewModel()
|
|||
{
|
||||
var self = this;
|
||||
|
||||
self.pages = ['Control', 'Print', 'Help', 'Settings', 'Messages', 'Logout'];
|
||||
//self.pages = ['Control', 'Print', 'Help', 'Settings', 'Messages', 'Logout'];
|
||||
self.pages = ['Control', 'Print', 'Help', 'Logout'];
|
||||
self.chosenPageId = ko.observable('');
|
||||
self.chosenFileId = ko.observable('');
|
||||
self.machineName = ko.observable();
|
||||
|
@ -484,7 +538,7 @@ function viewModel()
|
|||
self.fanButton('Fan off');
|
||||
} else
|
||||
{
|
||||
$.get('/rr_gcode', {gcode: "M107"}, self.dummy);
|
||||
$.get('/rr_gcode', {gcode: "M106 S0"}, self.dummy);
|
||||
self.fanButton('Fan on');
|
||||
}
|
||||
};
|
||||
|
@ -569,6 +623,7 @@ function viewModel()
|
|||
$.get('/rr_gcode', {gcode: self.gcode()}, self.dummy);
|
||||
};
|
||||
|
||||
|
||||
self.setTemperature = function(heater, data, event)
|
||||
{
|
||||
if(dontInterruptFilePrint())
|
||||
|
@ -589,7 +644,7 @@ function viewModel()
|
|||
self.fileAction('print it');
|
||||
self.deleteButton('Delete a file');
|
||||
};
|
||||
|
||||
/*
|
||||
self.goToPage = function(page)
|
||||
{
|
||||
if(page == self.pages[5])
|
||||
|
@ -611,6 +666,44 @@ function viewModel()
|
|||
return;
|
||||
}
|
||||
|
||||
onControlPage = (page == self.pages[0]);
|
||||
self.chosenPageId(page);
|
||||
|
||||
if(page == self.pages[1])
|
||||
{
|
||||
try
|
||||
{
|
||||
//alert("attaching");
|
||||
document.getElementById('fileinput').addEventListener('change', uploadGCode, false);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
alert(e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
self.goToPage = function(page)
|
||||
{
|
||||
if(page == self.pages[3])
|
||||
self.gotPassword(JSON.parse('{"password":"wrong"}'));
|
||||
|
||||
if(page == self.pages[1])
|
||||
self.resetFileAction();
|
||||
|
||||
if(page == self.pages[2])
|
||||
{
|
||||
var win=window.open("http://www.reprappro.com/documentation/RepRapPro_Firmware", '_blank');
|
||||
win.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if(self.gotPassword().password != "right")
|
||||
{
|
||||
self.chosenPageId(self.pages[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
onControlPage = (page == self.pages[0]);
|
||||
self.chosenPageId(page);
|
||||
};
|
||||
|
@ -631,14 +724,18 @@ function viewModel()
|
|||
return true;
|
||||
};
|
||||
|
||||
self.uploadGCode = function(uploadForm, event)
|
||||
|
||||
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob)
|
||||
{
|
||||
if(self.checkFileName(uploadForm))
|
||||
{
|
||||
alert('upload ' + uploadForm.datafile.value);
|
||||
// TODO put post upload here
|
||||
}
|
||||
};
|
||||
setTimeout(function() {
|
||||
onControlPage = false;
|
||||
}, 1000);
|
||||
//AttachEventListener();
|
||||
} else
|
||||
{
|
||||
alert('The File APIs are not fully supported by your browser. GCode upload may not work.');
|
||||
}
|
||||
|
||||
onControlPage = false;
|
||||
self.getName();
|
||||
|
@ -655,7 +752,7 @@ function viewModel()
|
|||
onControlPage = false;
|
||||
}, 300);
|
||||
printingAFile = false;
|
||||
self.goToPage(self.pages[5]);
|
||||
self.goToPage(self.pages[3]);
|
||||
//self.gotPassword(JSON.parse('{"password":"wrong"}'));
|
||||
}
|
||||
|
||||
|
@ -668,6 +765,8 @@ function poll()
|
|||
}, 3000)
|
||||
}
|
||||
|
||||
|
||||
|
||||
printingAFile = false;
|
||||
window.vm = new viewModel();
|
||||
ko.applyBindings(vm);
|
||||
|
@ -675,4 +774,6 @@ poll();
|
|||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
|
|
|
@ -701,7 +701,7 @@ void Webserver::Init()
|
|||
|
||||
// Reinitialise the message file
|
||||
|
||||
platform->GetMassStorage()->Delete(platform->GetWebDir(), MESSAGE_FILE);
|
||||
//platform->GetMassStorage()->Delete(platform->GetWebDir(), MESSAGE_FILE);
|
||||
}
|
||||
|
||||
void Webserver::Exit()
|
||||
|
|
Reference in a new issue