Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions dashboard_homepage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Developer Analytics Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body { margin: 0; font-family: Arial, sans-serif; background: #f5f5f5; }
.container { display: flex; height: 100vh; }
aside { width: 200px; background: #dcdcdc; padding: 20px; }
aside h2 { font-size: 16px; margin-bottom: 20px; }
nav a { display: block; margin: 10px 0; text-decoration: none; color: black; }
nav a.active { font-weight: bold; color: #007bff; }

main { flex: 1; padding: 20px; overflow-y: auto; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
header select, header button, input { margin-left: 10px; padding: 5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.card { background: white; border-radius: 10px; padding: 15px; box-shadow: 0 0 5px rgba(0,0,0,0.1); }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border-bottom: 1px solid #ddd; text-align: left; padding: 5px; font-size: 14px; }

.progress { background: #eee; border-radius: 10px; height: 8px; margin: 5px 0; }
.bar { background: #007bff; height: 8px; border-radius: 10px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
</style>
</head>
<body>
<div class="container">
<!-- Sidebar -->
<aside>
<h2>Developer Analytics</h2>
<nav>
<a href="#" class="active">🏠 Home</a>
<a href="#">👥 Teams</a>
<a href="#">📊 Metrics</a>
</nav>
</aside>

<!-- Main Content -->
<main>
<header>
<div>
<h1 id="orgTitle">Organization Dashboard</h1>
<input type="text" id="orgInput" placeholder="Enter GitHub Org name (e.g. microsoft)" />
<button onclick="loadData()">Load</button>
</div>
<div>
<select id="sprintSelect">
<option>Last 30 days</option>
<option>Last 60 days</option>
<option>Last Quarter</option>
</select>
<button onclick="exportData()">Export CSV/PNG</button>
</div>
</header>

<div class="grid" id="summaryGrid">
<div class="card"><p>Total Repos</p><h2 id="reposCount">-</h2></div>
<div class="card"><p>Total Commits</p><h2 id="commitsCount">-</h2></div>
<div class="card"><p>Avg Lead Time</p><h2 id="leadTime">-</h2></div>
<div class="card"><p>Avg Cycle Time</p><h2 id="cycleTime">-</h2></div>
<div class="card"><p>Total Contributors</p><h2 id="contributorsCount">-</h2></div>
</div>

<div class="grid" style="margin-top:20px;">
<div class="card">
<h3>Total Repos by Activity</h3>
<div id="repoActivity"></div>
</div>
<div class="card">
<h3>Contributor Details</h3>
<table id="contributorsTable">
<thead>
<tr><th>Contributor</th><th>Commits</th><th>PRs</th><th>Issues</th></tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>

<div class="charts">
<div class="card"><h3>Delivery Velocity over time</h3><canvas id="velocityChart"></canvas></div>
<div class="card"><h3>Lead & Cycle Time over time</h3><canvas id="leadCycleChart"></canvas></div>
</div>
</main>
</div>

<script>
const GITHUB_TOKEN = ""; // Optional: Add your GitHub PAT for higher API rate

async function loadData() {
const org = document.getElementById("orgInput").value.trim();
if (!org) return alert("Please enter an organization name.");
document.getElementById("orgTitle").textContent = `${org} Organization`;

const headers = GITHUB_TOKEN ? { Authorization: `token ${GITHUB_TOKEN}` } : {};
const repoRes = await fetch(`https://api.github.com/orgs/${org}/repos?per_page=100`, { headers });
const repos = await repoRes.json();

document.getElementById("reposCount").textContent = repos.length;

// --- Fetch commits & contributors summary ---
let totalCommits = 0, contributorsSet = new Set();
for (let repo of repos.slice(0, 10)) { // limit to 10 repos to avoid rate limit
const commitsRes = await fetch(repo.commits_url.replace("{/sha}", ""), { headers });
const commits = await commitsRes.json();
totalCommits += commits.length;
commits.forEach(c => { if (c.author) contributorsSet.add(c.author.login); });
}

document.getElementById("commitsCount").textContent = totalCommits;
document.getElementById("contributorsCount").textContent = contributorsSet.size;
document.getElementById("leadTime").textContent = "3.5 days"; // Mock calculation for now
document.getElementById("cycleTime").textContent = "2.1 days";

// --- Repo Activity ---
const repoActivity = document.getElementById("repoActivity");
repoActivity.innerHTML = "";
repos.slice(0, 5).forEach(r => {
const val = Math.min(100, Math.random() * 100);
repoActivity.innerHTML += `
<div style="margin-bottom:8px;">
<div style="display:flex;justify-content:space-between;font-size:14px;">
<span>${r.name}</span><span>${val.toFixed(0)}%</span>
</div>
<div class="progress"><div class="bar" style="width:${val}%;"></div></div>
</div>`;
});

// --- Contributors Table ---
const tbody = document.querySelector("#contributorsTable tbody");
tbody.innerHTML = "";
contributorsSet.forEach(c => {
tbody.innerHTML += `<tr><td>${c}</td><td>${Math.floor(Math.random()*100)}</td><td>${Math.floor(Math.random()*30)}</td><td>${Math.floor(Math.random()*20)}</td></tr>`;
});

// --- Charts ---
renderCharts();
}

function renderCharts() {
const velocityCtx = document.getElementById("velocityChart");
new Chart(velocityCtx, {
type: "line",
data: {
labels: ["Week 1","Week 2","Week 3","Week 4"],
datasets: [{ label: "Completed Items", data: [5,8,6,12], borderColor: "#007bff", fill: false }]
},
});

const leadCycleCtx = document.getElementById("leadCycleChart");
new Chart(leadCycleCtx, {
type: "line",
data: {
labels: ["Week 1","Week 2","Week 3","Week 4"],
datasets: [
{ label: "Lead Time", data: [1.5,2.5,3.1,3.5], borderColor: "#3b82f6", fill: false },
{ label: "Cycle Time", data: [1.0,1.8,2.3,2.1], borderColor: "#22c55e", fill: false },
]
},
});
}

function exportData() {
alert("Export feature can be added with FileSaver.js or html2canvas for PNG.");
}
</script>
</body>
</html>