wlan_config.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE html>
  2. <html lang="en" xml:lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>WLAN Configuration</title>
  6. <link href="firework.css?v=$COMMIT_HASH" rel="stylesheet">
  7. <script type="text/javascript" src="jquery-3.6.0.min.js?v=$COMMIT_HASH"></script>
  8. <script type="text/javascript" src="firework.js?v=$COMMIT_HASH"></script>
  9. <script type="text/javascript" src="/common.js?v=$COMMIT_HASH"></script>
  10. </head>
  11. <body>
  12. <table>
  13. <tr><td>WLAN-SSID</td><td><input type="text" name="ssid" id="ssid"></td><td>SSID of the WLAN</td></tr>
  14. <tr><td>WLAN-Password</td><td><input type="text" name="password" id="password"></td><td>ATTENTION: the password will not be encrypted during the sending.</td>
  15. </tr><tr><td> Hostname</td><td><input type="text" name="hostname" id="hostname"></td><td></td>
  16. </tr><tr><td>Fixed IP</td><td><input type="text" name="ip" id="ip"></td><td>Leave emtpy if set by router</td></tr>
  17. <tr><td>gateway</td><td><input type="text" name="gateway" id="gateway"></td><td>Leave emtpy if set by router</td></tr>
  18. <tr><td>netmask</td><td><input type="text" name="netmask" id="netmask"></td><td>Leave emtpy if set by router</td>
  19. </tr><tr><td>DNS</td><td><input type="text" name="dns" id="dns"></td><td>Leave emtpy if set by router</td></tr>
  20. <tr><td>RSSI Threshold</td><td><input type="number" name="name" id="threshold" min="-100" max="0" step="1" value = "0"></td><td>WLAN Mesh Parameter: Threshold for RSSI value to check for start switching access point in a mesh system.Possible values: -100 to 0, 0 = disabled - Value will be transfered to wlan.ini at next startup)</td></tr>
  21. </table>
  22. <button class="button" type="button" onclick="wr();">Write wlan.ini</button>
  23. <input id="newfile" type="file">
  24. <button class="button" style="width:300px" id="doUpdate" type="button" onclick="upload()">Upload Files</button>
  25. <p id="status"></p>
  26. <p id="progress"></p>
  27. <script type="text/javascript">
  28. function wr(){
  29. api = "/config?"+"ssid"+document.getElementById("ssid").value+"&pwd="+document.getElementById("password").value;+"&hn="+document.getElementById("hostname").value;+"&ip="+document.getElementById("ip").value;+"&gw="+document.getElementById("gateway").value;+"&nm="+document.getElementById("netmask").value;+"&dns="+document.getElementById("dns").value;+"&rssi="+document.getElementById("threshold").value;
  30. fetch(api);}
  31. // var xhttp = new XMLHttpRequest();
  32. // xhttp.onreadystatechange = function() {if (xhttp.readyState == 4) {if (xhttp.status == 200) {document.reload();}}};
  33. function upload() {
  34. var xhttp = new XMLHttpRequest();
  35. xhttp.onreadystatechange = function() {
  36. if (xhttp.readyState == 4) {stopProgressTimer();if (xhttp.status == 200) {extract();} }};
  37. var filePath = document.getElementById("newfile").value.split(/[\\\/]/).pop();
  38. var file = document.getElementById("newfile").files[0];
  39. if (!file) {
  40. firework.launch("Please select a remote-setup ZIP file first.", "warning", 5000);
  41. return;
  42. }
  43. if (!file.name.includes("remote-setup"))
  44. {
  45. if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure you have downloaded the correct file?"))
  46. return;
  47. }
  48. var upload_path = "/upload/firmware/" + filePath; xhttp.open("POST", upload_path, true); xhttp.send(file);}
  49. function extract() {
  50. document.getElementById("status").innerText = "Status: Processing on device (takes up to 3 minutes)...";
  51. var xhttp = new XMLHttpRequest();
  52. /* first delete the old firmware */
  53. xhttp.onreadystatechange = function() {
  54. if (xhttp.readyState == 4) {
  55. stopProgressTimer();
  56. if (xhttp.status == 200) {
  57. document.getElementById("status").innerText = "Status: Update completed!";
  58. document.getElementById("doUpdate").disabled = true;
  59. document.getElementById("newfile").disabled = false;
  60. document.cookie = "page=overview.html?v=$COMMIT_HASH" + "; path=/"; // Make sure after the reboot we go to the overview page
  61. if (xhttp.responseText.startsWith("reboot"))
  62. {
  63. doRebootAfterUpdate();
  64. }
  65. else
  66. {
  67. firework.launch('Processing done! (' + xhttp.responseText + ')', 'success', 5000);
  68. }
  69. } else if (xhttp.status == 0) {
  70. firework.launch('Server closed the connection abruptly!', 'danger', 30000);
  71. UpdatePage();
  72. } else {
  73. firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000);
  74. UpdatePage();
  75. }
  76. }
  77. };
  78. startProgressTimer("Extraction");
  79. var nameneu = document.getElementById("newfile").value;
  80. filePath = nameneu.split(/[\\\/]/).pop();
  81. var _toDo = getDomainname() + "/ota?task=update&file=" + encodeURIComponent(filePath);
  82. xhttp.open("GET", _toDo, true);
  83. xhttp.send();
  84. }
  85. function startProgressTimer(step) {
  86. console.log(step + "...");
  87. document.getElementById('progress').innerHTML = "(0s)";
  88. action_runtime = 0;
  89. progressTimerHandle = setInterval(function() {
  90. action_runtime += 1;
  91. console.log("Progress: " + action_runtime + "s");
  92. document.getElementById('progress').innerHTML = "(" + action_runtime + "s)";
  93. }, 1000);
  94. }
  95. function stopProgressTimer() {
  96. clearInterval(progressTimerHandle);
  97. document.getElementById('progress').innerHTML = "";
  98. }
  99. </script>
  100. </body>
  101. </html>