Files
notfiles/crates/notgraph/templates/report.html.template
2026-04-02 02:30:21 -04:00

59 lines
1.9 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>notgraph Report</title>
<script src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
<style>
body {{ font-family: sans-serif; margin: 2rem; max-width: 1200px; }}
#graph {{ height: 400px; border: 1px solid #ccc; margin-bottom: 2rem; }}
table {{ border-collapse: collapse; width: 100%; margin-bottom: 2rem; }}
th, td {{ border: 1px solid #ccc; padding: 0.4rem 0.8rem; text-align: left; }}
th {{ background: #f5f5f5; cursor: pointer; user-select: none; }}
th:hover {{ background: #e8e8e8; }}
h2 {{ border-bottom: 2px solid #333; padding-bottom: 0.3rem; }}
</style>
</head>
<body>
<h1>notgraph Report</h1>
<h2>Crate Dependency Graph</h2>
<div id="graph"></div>
<script>
const nodes = new vis.DataSet([{nodes_js}]);
const edges = new vis.DataSet([]);
new vis.Network(document.getElementById('graph'), {{nodes, edges}}, {{
layout: {{ hierarchical: {{ direction: 'LR', sortMethod: 'directed' }} }},
physics: false,
nodes: {{ shape: 'box', color: {{ background: '#d4e8ff', border: '#336699' }} }}
}});
</script>
<h2>Hotspots</h2>
<table id="hotspots">
<thead><tr>
<th onclick="sortTable('hotspots',0,this)">Name</th>
<th onclick="sortTable('hotspots',1,this)">Kind</th>
<th onclick="sortTable('hotspots',2,this)">Score</th>
</tr></thead>
<tbody>{hotspot_rows}</tbody>
</table>
<h2>Cycle Report</h2>
{cycle_html}
<script>
function sortTable(id, col, th) {{
const t = document.getElementById(id);
const asc = th.dataset.dir !== 'asc';
th.dataset.dir = asc ? 'asc' : 'desc';
const rows = Array.from(t.querySelectorAll('tbody tr'));
rows.sort((a, b) => {{
const av = a.cells[col].textContent.trim();
const bv = b.cells[col].textContent.trim();
const cmp = av.localeCompare(bv, undefined, {{numeric: true}});
return asc ? cmp : -cmp;
}});
const tbody = t.querySelector('tbody');
rows.forEach(r => tbody.appendChild(r));
}}
</script>
</body>
</html>