info.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <!DOCTYPE html>
  2. <html lang="en" xml:lang="en">
  3. <head>
  4. <title>Info</title>
  5. <meta charset="UTF-8" />
  6. <style>
  7. body {
  8. font-family: Arial, sans-serif;
  9. margin: 20px;
  10. }
  11. h2 {
  12. background-color: #ccc;
  13. max-width: 100%;
  14. min-width: 600px;
  15. border-bottom: 1px solid #ccc;
  16. padding-bottom: 5px;
  17. }
  18. table {
  19. max-width: 100%;
  20. min-width: 600px;
  21. border-collapse: collapse;
  22. margin-bottom: 20px;
  23. }
  24. th {
  25. text-align: left;
  26. width: 40%;
  27. padding: 6px 10px;
  28. vertical-align: top;
  29. }
  30. td {
  31. background-color: #eee;
  32. width: 60%;
  33. padding: 6px 10px;
  34. vertical-align: top;
  35. }
  36. </style>
  37. <script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
  38. </head>
  39. <body>
  40. <h2>Runtime Information</h2>
  41. <table>
  42. <tr><th>Start Time</th><td><output id="starttime"></output></td></tr>
  43. <tr><th>Uptime</th><td><output id="uptime"></output></td></tr>
  44. </table>
  45. <h2>Build Info</h2>
  46. <table>
  47. <tr><th>Firmware Version</th><td><output id="firmware"></output></td></tr>
  48. <tr><th>Firmware Build Time</th><td><output id="build-time"></output></td></tr>
  49. <tr><th>Web Interface Version</th><td><output id="web-ui"></output></td></tr>
  50. </table>
  51. <h2>Device Info</h2>
  52. <table>
  53. <tr><th>Chip Cores</th><td><output id="chip-cores"></output></td></tr>
  54. <tr><th>Chip Revision</th><td><output id="chip-revision"></output></td></tr>
  55. <tr><th>Chip Features</th><td><output id="chip-features"></output></td></tr>
  56. </table>
  57. <h2>Network Info</h2>
  58. <table>
  59. <tr><th>Hostname</th><td><output id="hostname"></output></td></tr>
  60. <tr><th>IP Address</th><td><output id="IP-address"></output></td></tr>
  61. <tr><th>WiFi SSID</th><td><output id="wlan-ssid"></output></td></tr>
  62. </table>
  63. <h2>SD Card Info</h2>
  64. <table>
  65. <tr><th>Manufacturer</th><td><output id="SDCardManufacturer"></output></td></tr>
  66. <tr><th>Name</th><td><output id="SDCardName"></output></td></tr>
  67. <tr><th>Capacity</th><td><output id="SDCardCapacity"></output></td></tr>
  68. <tr><th>Sector Size</th><td><output id="SDCardSectorSize"></output></td></tr>
  69. <tr><th>Partition Size</th><td><output id="SDCardPartitionSize"></output></td></tr>
  70. <tr><th>Free Partition Space</th><td><output id="SDCardFreePartitionSpace"></output></td></tr>
  71. <tr><th>Allocation Size</th><td><output id="SDCardPartitionAllocationSize"></output></td></tr>
  72. </table>
  73. <h2>Heap Info</h2>
  74. <table>
  75. <tr><th>Total RAM Free</th><td><output id="RAMTotalFree"></output></td></tr>
  76. <tr><th>External RAM Free</th><td><output id="ExtRAMFree"></output></td></tr>
  77. <tr><th>External RAM Largest Free</th><td><output id="ExtRAMLargestFree"></output></td></tr>
  78. <tr><th>External RAM Min Free</th><td><output id="ExtRAMMinFree"></output></td></tr>
  79. <tr><th>External RAM Fragmentation</th><td><output id="ExtRAMFragmentation"></output></td></tr>
  80. <tr><th>Internal RAM Free</th><td><output id="IntRAMFree"></output></td></tr>
  81. <tr><th>Internal RAM Largest Free</th><td><output id="IntRAMLargestFree"></output></td></tr>
  82. <tr><th>Internal RAM Min Free</th><td><output id="IntRAMMinFree"></output></td></tr>
  83. <tr><th>Internal RAM Fragmentation</th><td><output id="IntRAMFragmentation"></output></td></tr>
  84. </table>
  85. <h3>Copyright</h3>
  86. Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edge-device" target="_blank" rel="noopener">Jomjol</a> and others.
  87. <script type="text/javascript">
  88. <script type="text/javascript">
  89. function setOutput(id, value, suffix)
  90. {
  91. var field = document.getElementById(id);
  92. if (!field) {
  93. return;
  94. }
  95. if (value === undefined || value === null || value === "") {
  96. field.value = "N/A";
  97. } else {
  98. field.value = String(value) + (suffix || "");
  99. }
  100. }
  101. function formatStartTime(value)
  102. {
  103. if (!value || value.length < 15) {
  104. return value || "";
  105. }
  106. // Input format: YYYYMMDD-HHMMSS
  107. return value.substr(6, 2) + "." +
  108. value.substr(4, 2) + "." +
  109. value.substr(0, 4) + " " +
  110. value.substr(9, 2) + ":" +
  111. value.substr(11, 2) + ":" +
  112. value.substr(13, 2);
  113. }
  114. function formatBuildTime(value)
  115. {
  116. if (!value || value.length < 16) {
  117. return value || "";
  118. }
  119. // Input format: YYYY-MM-DD HH:MM
  120. return value.substr(8, 2) + "." +
  121. value.substr(5, 2) + "." +
  122. value.substr(0, 4) + " " +
  123. value.substr(11, 2) + ":" +
  124. value.substr(14, 2);
  125. }
  126. function colorFragmentation(value)
  127. {
  128. if (value < 15) return "lightgreen";
  129. if (value < 25) return "yellow";
  130. if (value < 40) return "orange";
  131. return "red";
  132. }
  133. function calculateFragmentation(total, largest)
  134. {
  135. const totalFree = Number(total);
  136. const largestFree = Number(largest);
  137. if (!Number.isFinite(totalFree) || totalFree <= 0 || !Number.isFinite(largestFree)) {
  138. return null;
  139. }
  140. return 100 - (largestFree / totalFree * 100);
  141. }
  142. function setFragmentation(id, total, largest)
  143. {
  144. const field = document.getElementById(id);
  145. if (!field) {
  146. return;
  147. }
  148. const fragmentation = calculateFragmentation(total, largest);
  149. if (fragmentation === null) {
  150. setOutput(id, null);
  151. return;
  152. }
  153. setOutput(id, fragmentation.toFixed(2), " %");
  154. const cell = field.closest("td");
  155. if (cell) {
  156. cell.style.backgroundColor = colorFragmentation(fragmentation);
  157. }
  158. }
  159. function loadSystemInfo()
  160. {
  161. var request = new XMLHttpRequest();
  162. request.onreadystatechange = function() {
  163. if (this.readyState !== 4) {
  164. return;
  165. }
  166. if (this.status !== 200) {
  167. console.error("Could not load system information:", this.status);
  168. return;
  169. }
  170. try {
  171. var response = JSON.parse(this.responseText);
  172. var info = Array.isArray(response) ? response[0] : response;
  173. if (!info || typeof info !== "object") {
  174. throw new Error("Invalid system information response");
  175. }
  176. setOutput("starttime", formatStartTime(info.starttime));
  177. setOutput("uptime", info.uptime);
  178. setOutput("firmware", info.firmware);
  179. setOutput("build-time", formatBuildTime(info.buildtime));
  180. setOutput("web-ui", info.html);
  181. setOutput("chip-cores", info.chipCores);
  182. setOutput("chip-revision", info.chipRevision);
  183. setOutput("chip-features", info.chipFeatures);
  184. setOutput("hostname", info.hostname);
  185. setOutput("IP-address", info.IPv4);
  186. setOutput("wlan-ssid", info.SSID);
  187. setOutput("SDCardManufacturer", info.sdCardManufacturer);
  188. setOutput("SDCardName", info.sdCardName);
  189. setOutput("SDCardCapacity", info.sdCardCapacity, " MB");
  190. setOutput("SDCardSectorSize", info.sdCardSectorSize, " byte");
  191. setOutput("SDCardPartitionSize", info.sdCardPartitionSize, " MB");
  192. setOutput("SDCardFreePartitionSpace", info.sdCardFreePartitionSpace, " MB");
  193. setOutput("SDCardPartitionAllocationSize", info.sdCardPartitionAllocationSize, " byte");
  194. setOutput("RAMTotalFree", info.RAMTotalFree, " byte");
  195. setOutput("ExtRAMFree", info.ExtRAMFree, " byte");
  196. setOutput("ExtRAMLargestFree", info.ExtRAMLargestFree, " byte");
  197. setOutput("ExtRAMMinFree", info.ExtRAMMinFree, " byte");
  198. setFragmentation("ExtRAMFragmentation", info.ExtRAMFree, info.ExtRAMLargestFree);
  199. setOutput("IntRAMFree", info.IntRAMFree, " byte");
  200. setOutput("IntRAMLargestFree", info.IntRAMLargestFree, " byte");
  201. setOutput("IntRAMMinFree", info.IntRAMMinFree, " byte");
  202. setFragmentation("IntRAMFragmentation", info.IntRAMFree, info.IntRAMLargestFree);
  203. } catch (error) {
  204. console.error("Could not parse system information:", error);
  205. }
  206. };
  207. request.open("GET", getDomainname() + "/sysinfo", true);
  208. request.send();
  209. }
  210. loadSystemInfo();
  211. </script>
  212. </body>
  213. </html>