info.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Disk Info</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" >
  7. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  8. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
  10. <style>
  11. body{
  12. background-color: rgb(243, 243, 243);
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <br>
  18. <div class="ui container">
  19. <div class="ui segment">
  20. <h3 class="ui header">
  21. <img src="img/network.svg">
  22. <div class="content">
  23. Network Storage
  24. <div class="sub header">Total space used on SD card</div>
  25. </div>
  26. </h3>
  27. <div class="ui blue progress" style="margin-bottom: 0.3em;">
  28. <div id="spaceUsedBar" class="bar" style="width: 30%;">
  29. <div class="progress">Loading...</div>
  30. </div>
  31. </div>
  32. <p id="volText"></p>
  33. <button onclick="initSDCardInfo();" style="position: absolute; top: 0.6em; right: 0.6em;" class="ui circular icon right floated basic button"><i class="ui green refresh icon"></i></button>
  34. </div>
  35. <div class="ui segment">
  36. <h3 class="ui header">
  37. <img src="img/wifi.svg">
  38. <div class="content">
  39. Network Details
  40. <div class="sub header">WiFi information for the current connected AP</div>
  41. </div>
  42. </h3>
  43. <div class="ui text container">
  44. <table class="ui very basic celled small table">
  45. <tbody id="wifiInfoTable">
  46. <tr>
  47. <td colspan="2"><i class="ui loading spinner icon"></i> Loading</td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. <div class="ui divider"></div>
  54. <p>WebStick Management Interface designed by <a href="https://imuslab.com" target="_blank">tobychui</a></p>
  55. </div>
  56. <script>
  57. function initWiFiInfo(){
  58. $.get("/api/info/wifi", function(data){
  59. if (data.error == undefined){
  60. $("#wifiInfoTable").empty();
  61. $("#wifiInfoTable").append(`
  62. <tr>
  63. <td>SSID</td>
  64. <td>${data.SSID}</td>
  65. </tr>
  66. <tr>
  67. <td>Wifi Channel</td>
  68. <td>${data.WifiStatus}</td>
  69. </tr>
  70. <tr>
  71. <td>Wifi Strength</td>
  72. <td>${data.WifiStrength}</td>
  73. </tr>
  74. <tr>
  75. <td>MAC Address</td>
  76. <td>${data.MAC}</td>
  77. </tr>
  78. <tr>
  79. <td>IP Address</td>
  80. <td>${data.IP}</td>
  81. </tr>
  82. <tr>
  83. <td>Subnet Mask</td>
  84. <td>${data.Subnet}</td>
  85. </tr>
  86. <tr>
  87. <td>Gateway</td>
  88. <td>${data.Gateway}</td>
  89. </tr>
  90. <tr>
  91. <td>DNS1</td>
  92. <td>${data.DNS1}</td>
  93. </tr>
  94. <tr>
  95. <td>DNS2</td>
  96. <td>${data.DNS2}</td>
  97. </tr>
  98. <tr>
  99. <td>DNS3</td>
  100. <td>${data.DNS3}</td>
  101. </tr>
  102. `);
  103. }
  104. });
  105. }
  106. initWiFiInfo();
  107. function initSDCardInfo(){
  108. $("#spaceUsedBar").find(".progress").text("Loading...");
  109. $.get("/api/fs/disk", function(data){
  110. if (data.error != undefined){
  111. alert(data.error);
  112. return;
  113. }
  114. let usedPercentage = data.usedSpace / data.diskSpace * 100;
  115. $("#spaceUsedBar").css("width", usedPercentage + "%");
  116. $("#spaceUsedBar").find(".progress").text(Math.round(usedPercentage) + "%");
  117. $("#volText").text(`Used: ${humanFileSize(data.usedSpace)} / Total: ${humanFileSize(data.diskSpace)}`);
  118. });
  119. }
  120. initSDCardInfo();
  121. function humanFileSize(bytes, si=false, dp=1) {
  122. const thresh = si ? 1000 : 1024;
  123. if (Math.abs(bytes) < thresh) {
  124. return bytes + ' B';
  125. }
  126. const units = si
  127. ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
  128. : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
  129. let u = -1;
  130. const r = 10**dp;
  131. do {
  132. bytes /= thresh;
  133. ++u;
  134. } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
  135. return bytes.toFixed(dp) + ' ' + units[u];
  136. }
  137. //Check login status
  138. function initLoginCheck(){
  139. $.get("/api/auth/chk", function(data){
  140. if (data == false){
  141. window.location.href = "/login.html"
  142. }
  143. });
  144. }
  145. initLoginCheck();
  146. </script>
  147. </body>
  148. </html>