Răsfoiți Sursa

Apply custom information page layout

SybexXx 1 zi în urmă
părinte
comite
cef79e8d70
1 a modificat fișierele cu 127 adăugiri și 227 ștergeri
  1. 127 227
      sd-card/html/info.html

+ 127 - 227
sd-card/html/info.html

@@ -5,244 +5,103 @@
 <meta charset="UTF-8" />
 
 <style>
-h1 {font-size: 2em;}
-h2 {font-size: 1.5em;}
-h3 {font-size: 1.2em;}
-p {font-size: 1em;}
-
-th, td {
-  padding: 5px 5px 5px 5px;
-  border-width: 1px;
-  border-style: solid;
-  border-color: rgb(240, 240, 240);
-}
-
-output {
-	padding-left:5px;
-}
-
-table {
-    width: 660px;
-    padding: 5px;
+  body {
+    font-family: Arial, sans-serif;
+    margin: 20px;
+  }
+
+  h2 {
+    background-color: #ccc;
+    max-width: 100%;
+    min-width: 600px;
+    border-bottom: 1px solid #ccc;
+    padding-bottom: 5px;
+  }
+
+  table {
+    max-width: 100%;
+    min-width: 600px;
     border-collapse: collapse;
-}
+    margin-bottom: 20px;
+  }
 
-caption {
+  th {
     text-align: left;
-}
-
-caption h3 {
-    margin: 0;
-}
+    width: 40%;
+    padding: 6px 10px;
+    vertical-align: top;
+  }
+
+  td {
+    background-color: #eee;
+    width: 60%;
+    padding: 6px 10px;
+    vertical-align: top;
+  }
 </style>
 
 <script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script> 
 </head>
 
-<body style="font-family: arial; padding: 0px 10px;">
-	<table>
-		<caption><h3>Runtime Information</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>Start time:</td>
-			<td><output id="starttime"></output></td>
-		</tr>
-		<tr>
-			<td>Uptime:</td>
-			<td><output id="uptime"></output></td>
-		</tr>
-	</table>
-
-	<table>
-		<caption><h3>Build Info</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>Firmware version:</td>
-			<td>
-				<output id="firmware"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Firmware build time:</td>
-			<td>
-				<output id="build-time"></output>
-			</td>
-		</tr>
-
-		<tr>
-			<td>Web interface version:</td>
-			<td>
-				<output id="web-ui"></output>
-			</td>
-		</tr>
-	</table>
-
-	<table>
-		<caption><h3>Device Info</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>Chip Cores:</td>
-			<td>
-				<output id="chip-cores"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Chip Revision:</td>
-			<td>
-				<output id="chip-revision"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Chip Features:</td>
-			<td>
-				<output id="chip-features"></output>
-			</td>
-		</tr>
-	</table>
-
-
-	<table>
-		<caption><h3>Host Info</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>Hostname:</td>
-			<td>
-				<output id="hostname"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>IP Address:</td>	
-			<td>
-				<output id="IP-address"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>WLAN SSID:</td>	
-			<td>
-				<output id="wlan-ssid"></output>
-			</td>
-		</tr>
-	</table>
-
-	<table>
-		<caption><h3>SD Card Info</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>SD card manufacturer:</td>
-			<td>
-				<output id="SDCardManufacturer"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>SD card name:</td>
-			<td>
-				<output id="SDCardName"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>SD card size:</td>
-			<td>
-				<output id="SDCardCapacity"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>SD card sector size:</td>
-			<td>
-				<output id="SDCardSectorSize"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Partition size:</td>
-			<td>
-				<output id="SDCardPartitionSize"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Partition free space:</td>	
-			<td>
-				<output id="SDCardFreePartitionSpace"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Partition allocation size:</td>	
-			<td>
-				<output id="SDCardPartitionAllocationSize"></output>
-			</td>
-		</tr>
-	</table>
-
-	<table>
-		<caption><h3>Memory Info</h3></caption>
-        <colgroup>
-			<col span="1" style="width: 35%;">
-			<col span="1" style="width: 65%;">
-		</colgroup>
-		<tr>
-			<td>Total Free (Int + Ext):</td>	
-			<td>
-				<output id="RAMTotalFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Ext. RAM - Free:</td>	
-			<td>
-				<output id="ExtRAMFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Ext. RAM - Largest Free Block:</td>	
-			<td>
-				<output id="ExtRAMLargestFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Ext. RAM - Min Free:</td>	
-			<td>
-				<output id="ExtRAMMinFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Int. RAM - Free:</td>	
-			<td>
-				<output id="IntRAMFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Int. RAM - Largest Free Block:</td>	
-			<td>
-				<output id="IntRAMLargestFree"></output>
-			</td>
-		</tr>
-		<tr>
-			<td>Int. RAM - Min Free:</td>	
-			<td>
-				<output id="IntRAMMinFree"></output>
-			</td>
-		</tr>
-	</table>
-
+<body>
+<h2>Runtime Information</h2>
+<table>
+    <tr><th>Start Time</th><td><output id="starttime"></output></td></tr>
+    <tr><th>Uptime</th><td><output id="uptime"></output></td></tr>
+</table>
+
+<h2>Build Info</h2>
+<table>
+    <tr><th>Firmware Version</th><td><output id="firmware"></output></td></tr>
+    <tr><th>Firmware Build Time</th><td><output id="build-time"></output></td></tr>
+    <tr><th>Web Interface Version</th><td><output id="web-ui"></output></td></tr>
+</table>
+
+<h2>Device Info</h2>
+<table>
+    <tr><th>Chip Cores</th><td><output id="chip-cores"></output></td></tr>
+    <tr><th>Chip Revision</th><td><output id="chip-revision"></output></td></tr>
+    <tr><th>Chip Features</th><td><output id="chip-features"></output></td></tr>
+</table>
+
+<h2>Network Info</h2>
+<table>
+    <tr><th>Hostname</th><td><output id="hostname"></output></td></tr>
+    <tr><th>IP Address</th><td><output id="IP-address"></output></td></tr>
+    <tr><th>WiFi SSID</th><td><output id="wlan-ssid"></output></td></tr>
+</table>
+
+<h2>SD Card Info</h2>
+<table>
+    <tr><th>Manufacturer</th><td><output id="SDCardManufacturer"></output></td></tr>
+    <tr><th>Name</th><td><output id="SDCardName"></output></td></tr>
+    <tr><th>Capacity</th><td><output id="SDCardCapacity"></output></td></tr>
+    <tr><th>Sector Size</th><td><output id="SDCardSectorSize"></output></td></tr>
+    <tr><th>Partition Size</th><td><output id="SDCardPartitionSize"></output></td></tr>
+    <tr><th>Free Partition Space</th><td><output id="SDCardFreePartitionSpace"></output></td></tr>
+    <tr><th>Allocation Size</th><td><output id="SDCardPartitionAllocationSize"></output></td></tr>
+</table>
+
+<h2>Heap Info</h2>
+<table>
+    <tr><th>Total RAM Free</th><td><output id="RAMTotalFree"></output></td></tr>
+
+    <tr><th>External RAM Free</th><td><output id="ExtRAMFree"></output></td></tr>
+    <tr><th>External RAM Largest Free</th><td><output id="ExtRAMLargestFree"></output></td></tr>
+    <tr><th>External RAM Min Free</th><td><output id="ExtRAMMinFree"></output></td></tr>
+    <tr><th>External RAM Fragmentation</th><td><output id="ExtRAMFragmentation"></output></td></tr>
+
+    <tr><th>Internal RAM Free</th><td><output id="IntRAMFree"></output></td></tr>
+    <tr><th>Internal RAM Largest Free</th><td><output id="IntRAMLargestFree"></output></td></tr>
+    <tr><th>Internal RAM Min Free</th><td><output id="IntRAMMinFree"></output></td></tr>
+    <tr><th>Internal RAM Fragmentation</th><td><output id="IntRAMFragmentation"></output></td></tr>
+</table>
 
 <h3>Copyright</h3>
-Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edge-device" target=_blank>Jomjol</a> and others.
-
+Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edge-device" target="_blank" rel="noopener">Jomjol</a> and others.
 
-
-    <script type="text/javascript">
+<script type="text/javascript">
+<script type="text/javascript">
         function setOutput(id, value, suffix)
         {
             var field = document.getElementById(id);
@@ -286,6 +145,45 @@ Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edg
                    value.substr(14, 2);
         }
     
+
+        function colorFragmentation(value)
+        {
+            if (value < 15) return "lightgreen";
+            if (value < 25) return "yellow";
+            if (value < 40) return "orange";
+            return "red";
+        }
+
+        function calculateFragmentation(total, largest)
+        {
+            const totalFree = Number(total);
+            const largestFree = Number(largest);
+            if (!Number.isFinite(totalFree) || totalFree <= 0 || !Number.isFinite(largestFree)) {
+                return null;
+            }
+            return 100 - (largestFree / totalFree * 100);
+        }
+
+        function setFragmentation(id, total, largest)
+        {
+            const field = document.getElementById(id);
+            if (!field) {
+                return;
+            }
+
+            const fragmentation = calculateFragmentation(total, largest);
+            if (fragmentation === null) {
+                setOutput(id, null);
+                return;
+            }
+
+            setOutput(id, fragmentation.toFixed(2), " %");
+            const cell = field.closest("td");
+            if (cell) {
+                cell.style.backgroundColor = colorFragmentation(fragmentation);
+            }
+        }
+
         function loadSystemInfo()
         {
             var request = new XMLHttpRequest();
@@ -332,9 +230,11 @@ Copyright &copy; 2020 - 2024 by <a href="https://github.com/jomjol/AI-on-the-edg
                     setOutput("ExtRAMFree", info.ExtRAMFree, " byte");
                     setOutput("ExtRAMLargestFree", info.ExtRAMLargestFree, " byte");
                     setOutput("ExtRAMMinFree", info.ExtRAMMinFree, " byte");
+                    setFragmentation("ExtRAMFragmentation", info.ExtRAMFree, info.ExtRAMLargestFree);
                     setOutput("IntRAMFree", info.IntRAMFree, " byte");
                     setOutput("IntRAMLargestFree", info.IntRAMLargestFree, " byte");
                     setOutput("IntRAMMinFree", info.IntRAMMinFree, " byte");
+                    setFragmentation("IntRAMFragmentation", info.IntRAMFree, info.IntRAMLargestFree);
                 } catch (error) {
                     console.error("Could not parse system information:", error);
                 }