diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f2e537..afdff93 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ + +## Version 0.7.0 - 2025-12-29 + +The dashboard now formats numbers and times in metrics for improved readability. + +**Changes:** 1 files, 14 lines +**Languages:** C (14 lines) + ## Version 0.6.0 - 2025-12-29 Integrates monitoring metrics into connection handling to provide real-time insights into network performance. Redesigns the dashboard with advanced metrics and charts for enhanced visualization of system data. diff --git a/src/dashboard.c b/src/dashboard.c index ccba962..78af4ba 100755 --- a/src/dashboard.c +++ b/src/dashboard.c @@ -86,6 +86,8 @@ static const char *DASHBOARD_HTML = " const formatDisk = v => v>=1024?(v/1024).toFixed(1)+' GB/s':v.toFixed(1)+' MB/s';\n" " const formatBytes = b => { if(b===0)return'0 B'; const k=1024,s=['B','KB','MB','GB','TB'],i=Math.floor(Math.log(b)/Math.log(k)); return(b/Math.pow(k,i)).toFixed(1)+' '+s[i]; };\n" " const formatUptime = s => { const d=Math.floor(s/86400),h=Math.floor((s%86400)/3600),m=Math.floor((s%3600)/60); return d>0?d+'d '+h+'h':h>0?h+'h '+m+'m':m+'m'; };\n" +" const formatNum = n => { if(n===null||n===undefined)return'0'; n=parseFloat(n); if(isNaN(n))return'0'; if(n>=1e9)return(n/1e9).toFixed(1)+'B'; if(n>=1e6)return(n/1e6).toFixed(1)+'M'; if(n>=1e3)return(n/1e3).toFixed(1)+'K'; return n.toFixed(0); };\n" +" const formatMs = v => { if(v>=1000)return(v/1000).toFixed(1)+'s'; return v.toFixed(0)+'ms'; };\n" " const baseOpts = (sec,yCb) => ({responsive:true,maintainAspectRatio:false,animation:false,layout:{padding:{top:30}},interaction:{mode:'nearest',axis:'x',intersect:false},scales:{x:{type:'linear',display:true,grid:{color:'#2a2e3e'},ticks:{color:'#666',maxTicksLimit:7,callback:formatTime},min:-sec*1000,max:0},y:{display:true,grid:{color:'#2a2e3e'},ticks:{color:'#666',beginAtZero:true,callback:yCb}}},plugins:{legend:{display:false}},elements:{point:{radius:0},line:{borderWidth:2,tension:0.4,fill:true}}});\n" " const cpuChart = new Chart(document.getElementById('cpuChart'),{type:'line',data:{datasets:[{data:[],borderColor:'#f39c12',backgroundColor:'rgba(243,156,18,0.1)'}]},options:{...baseOpts(300,v=>v+'%'),scales:{...baseOpts(300).scales,y:{...baseOpts(300).scales.y,max:100}}}});\n" " const memChart = new Chart(document.getElementById('memChart'),{type:'line',data:{datasets:[{data:[],borderColor:'#e74c3c',backgroundColor:'rgba(231,76,60,0.1)'}]},options:baseOpts(300,v=>v.toFixed(1)+' GB')});\n" @@ -102,13 +104,13 @@ static const char *DASHBOARD_HTML = " const r=await fetch('/rproxy/api/stats'),d=await r.json();\n" " const hs=d.current.health_score||100; document.getElementById('healthScore').textContent=hs.toFixed(0);\n" " const hEl=document.getElementById('healthScore'); hEl.className='metric-value '+(hs>=80?'health':hs>=50?'warning':'danger');\n" -" document.getElementById('rps').textContent=(d.current.requests_per_second||0).toFixed(0);\n" -" document.getElementById('p50').textContent=(d.latency?.p50_ms||0).toFixed(0);\n" -" document.getElementById('p99').textContent=(d.latency?.p99_ms||0).toFixed(0);\n" +" document.getElementById('rps').textContent=formatNum(d.current.requests_per_second||0);\n" +" document.getElementById('p50').textContent=formatMs(d.latency?.p50_ms||0);\n" +" document.getElementById('p99').textContent=formatMs(d.latency?.p99_ms||0);\n" " document.getElementById('errorRate').textContent=((d.current.error_rate_1m||0)*100).toFixed(1)+'%';\n" -" document.getElementById('connections').textContent=d.current.active_connections;\n" +" document.getElementById('connections').textContent=formatNum(d.current.active_connections);\n" " document.getElementById('cpu').textContent=d.current.cpu_percent+'%';\n" -" document.getElementById('memory').textContent=d.current.memory_gb+'G';\n" +" document.getElementById('memory').textContent=d.current.memory_gb+'GB';\n" " document.getElementById('uptime').textContent=formatUptime(d.current.uptime_seconds||0);\n" " cpuChart.data.datasets[0].data=d.cpu_history; memChart.data.datasets[0].data=d.memory_history;\n" " netChart.data.datasets[0].data=d.network_rx_history; netChart.data.datasets[1].data=d.network_tx_history;\n" @@ -124,7 +126,7 @@ static const char *DASHBOARD_HTML = " d.processes.forEach((p,i)=>{\n" " let row=tbody.children[i*2]; if(!row){row=document.createElement('tr'); tbody.appendChild(row);}\n" " const errP=(p.error_rate*100).toFixed(1); const cls=parseFloat(errP)>5?'status-error':parseFloat(errP)>1?'status-warn':'status-ok';\n" -" row.innerHTML=`