Skip to content

Commit

Permalink
Fix for #8
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Jul 7, 2019
1 parent 55e5eaf commit e8e2a5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
11 changes: 11 additions & 0 deletions js/maintenance-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,14 @@ function programmingFailed(){
$("#program-stderr-header").text("Something went wrong. Please check the log for details.");
}

function fileValidation(){
var fileInput = document.getElementById('file');
var filePath = fileInput.value;
//var allowedExtensions = /(\.jpg|\.jpeg|\.png|\.gif)$/i;
var allowedExtensions = /(\.hex)$/i;
if(!allowedExtensions.exec(filePath)){
alert('Please upload *.hex file only.');
fileInput.value = '';
return false;
}
}
18 changes: 6 additions & 12 deletions maintenance-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,17 @@ function echoRotarySelect($optionName){
</ul>

<div id="reprogram-arduino">
<div class="settings-container">
<div class="setting-container">
<p><span class="setting-name">Disabled</span></p>
<p>This function has been disabled for now. Please use the script updateFirmware.py in the brewpi/utils folder.</p>
</div>
</div>
<!--<p>Here you can upload a <span class="programFileType">firmware</span> file which will be uploaded to the <span class="boardMoniker">controller</span> by the Python script.
<p>Here you can upload a <span class="programFileType">firmware</span> file which will be uploaded to the <span class="boardMoniker">controller</span> by the Python script.
The script will automatically restart itself after programming.</p>
-->

<!-- This form has a hidden iFrame as target, so the full page is not refreshed -->
<!--<form action="program_arduino.php" method="post" enctype="multipart/form-data" target="upload-target">
<form action="" method="post" enctype="multipart/form-data" target="upload-target">
<!-- <form action="program_arduino.php" method="post" enctype="multipart/form-data" target="upload-target"> -->
<div id="program-options">
<div class="program-option">
<label for="file"><span class="programFileType">HEX</span> file:</label>
<input type="file" name="file" id="file" /> --> <!-- add max file size? -->
<!-- </div>
<input type="file" name="file" id="file" accept=".hex" onchange="return fileValidation()" /> <!-- add max file size? -->
</div>
<div class="program-option">
<label for="boardType"> Board type:</label>
<select name="boardType" class="boardType">
Expand All @@ -124,7 +119,6 @@ function echoRotarySelect($optionName){
<h3 id="program-stderr-header">Script output will auto-refresh while programming if you keep this tab open.</h3>
<div class="stderr console-box"></div>
<iframe id="upload-target" name="upload-target" src="about:blank" style="width:0;height:0;border:0px solid #fff;"></iframe>
</div> -->
</div>

<div id="settings">
Expand Down

0 comments on commit e8e2a5e

Please sign in to comment.