Initial commit: Claude Code Project Tracker
Add comprehensive development intelligence system that tracks: - Development sessions with automatic start/stop - Full conversation history with semantic search - Tool usage and file operation analytics - Think time and engagement analysis - Git activity correlation - Learning pattern recognition - Productivity insights and metrics Features: - FastAPI backend with SQLite database - Modern web dashboard with interactive charts - Claude Code hook integration for automatic tracking - Comprehensive test suite with 100+ tests - Complete API documentation (OpenAPI/Swagger) - Privacy-first design with local data storage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
44ed9936b7
48 changed files with 9707 additions and 0 deletions
327
app/dashboard/static/js/dashboard.js
Normal file
327
app/dashboard/static/js/dashboard.js
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
/**
|
||||
* Dashboard JavaScript functionality
|
||||
*/
|
||||
|
||||
let productivityChart = null;
|
||||
let toolsChart = null;
|
||||
|
||||
async function loadDashboardData() {
|
||||
try {
|
||||
// Show loading state
|
||||
showLoadingState();
|
||||
|
||||
// Load data in parallel
|
||||
const [
|
||||
analyticsSummary,
|
||||
productivityMetrics,
|
||||
toolUsageStats,
|
||||
recentProjects
|
||||
] = await Promise.all([
|
||||
apiClient.getAnalyticsSummary(),
|
||||
apiClient.getProductivityMetrics(null, 30),
|
||||
apiClient.getToolUsageStats(null, null, 30),
|
||||
apiClient.getProjects(5, 0)
|
||||
]);
|
||||
|
||||
// Update summary cards
|
||||
updateSummaryCards(analyticsSummary);
|
||||
|
||||
// Update engagement metrics
|
||||
updateEngagementMetrics(productivityMetrics);
|
||||
|
||||
// Update charts
|
||||
updateProductivityChart(productivityMetrics.productivity_trends);
|
||||
updateToolsChart(toolUsageStats);
|
||||
|
||||
// Update recent projects
|
||||
updateRecentProjects(recentProjects);
|
||||
|
||||
// Update quick stats
|
||||
updateQuickStats(analyticsSummary);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to load dashboard data:', error);
|
||||
showErrorState('Failed to load dashboard data. Please try refreshing the page.');
|
||||
}
|
||||
}
|
||||
|
||||
function showLoadingState() {
|
||||
// Update cards with loading state
|
||||
document.getElementById('total-sessions').textContent = '-';
|
||||
document.getElementById('total-time').textContent = '-';
|
||||
document.getElementById('active-projects').textContent = '-';
|
||||
document.getElementById('productivity-score').textContent = '-';
|
||||
}
|
||||
|
||||
function showErrorState(message) {
|
||||
// Show error message
|
||||
const alertHtml = `
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<i class="fas fa-exclamation-triangle me-2"></i>
|
||||
${message}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const container = document.querySelector('.container');
|
||||
container.insertAdjacentHTML('afterbegin', alertHtml);
|
||||
}
|
||||
|
||||
function updateSummaryCards(summary) {
|
||||
const overview = summary.overview || {};
|
||||
|
||||
document.getElementById('total-sessions').textContent =
|
||||
overview.total_sessions?.toLocaleString() || '0';
|
||||
|
||||
document.getElementById('total-time').textContent =
|
||||
overview.total_time_hours?.toFixed(1) || '0';
|
||||
|
||||
document.getElementById('active-projects').textContent =
|
||||
overview.projects_tracked?.toLocaleString() || '0';
|
||||
|
||||
document.getElementById('productivity-score').textContent =
|
||||
overview.productivity_indicators?.productivity_score?.toFixed(0) || '0';
|
||||
}
|
||||
|
||||
function updateEngagementMetrics(metrics) {
|
||||
document.getElementById('engagement-score').textContent =
|
||||
metrics.engagement_score?.toFixed(0) || '-';
|
||||
|
||||
document.getElementById('avg-session-length').textContent =
|
||||
metrics.average_session_length?.toFixed(0) || '-';
|
||||
|
||||
document.getElementById('think-time').textContent =
|
||||
metrics.think_time_average?.toFixed(0) || '-';
|
||||
}
|
||||
|
||||
function updateProductivityChart(trendsData) {
|
||||
const ctx = document.getElementById('productivityChart').getContext('2d');
|
||||
|
||||
// Destroy existing chart
|
||||
if (productivityChart) {
|
||||
productivityChart.destroy();
|
||||
}
|
||||
|
||||
const labels = trendsData.map(item => {
|
||||
const date = new Date(item.date);
|
||||
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
||||
});
|
||||
|
||||
const data = trendsData.map(item => item.score);
|
||||
|
||||
productivityChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Productivity Score',
|
||||
data: data,
|
||||
borderColor: '#007bff',
|
||||
backgroundColor: 'rgba(0, 123, 255, 0.1)',
|
||||
borderWidth: 2,
|
||||
fill: true,
|
||||
tension: 0.4
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
max: 100,
|
||||
ticks: {
|
||||
callback: function(value) {
|
||||
return value + '%';
|
||||
}
|
||||
}
|
||||
},
|
||||
x: {
|
||||
ticks: {
|
||||
maxTicksLimit: 7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateToolsChart(toolsData) {
|
||||
const ctx = document.getElementById('toolsChart').getContext('2d');
|
||||
|
||||
// Destroy existing chart
|
||||
if (toolsChart) {
|
||||
toolsChart.destroy();
|
||||
}
|
||||
|
||||
// Get top 5 tools
|
||||
const topTools = toolsData.slice(0, 5);
|
||||
const labels = topTools.map(item => item.tool_name);
|
||||
const data = topTools.map(item => item.usage_count);
|
||||
|
||||
const colors = [
|
||||
'#007bff', '#28a745', '#17a2b8', '#ffc107', '#dc3545'
|
||||
];
|
||||
|
||||
toolsChart = new Chart(ctx, {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
data: data,
|
||||
backgroundColor: colors,
|
||||
borderWidth: 2,
|
||||
borderColor: '#fff'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
labels: {
|
||||
padding: 20,
|
||||
usePointStyle: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateRecentProjects(projects) {
|
||||
const container = document.getElementById('recent-projects');
|
||||
|
||||
if (!projects.length) {
|
||||
container.innerHTML = `
|
||||
<div class="text-center text-muted py-4">
|
||||
<i class="fas fa-folder-open fa-2x mb-2"></i>
|
||||
<p>No projects found</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
const projectsHtml = projects.map(project => `
|
||||
<div class="project-item fade-in">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<div class="project-title">${project.name}</div>
|
||||
<div class="project-path">${project.path}</div>
|
||||
<div class="project-stats mt-2">
|
||||
<span class="me-3">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
${ApiUtils.formatDuration(project.total_time_minutes)}
|
||||
</span>
|
||||
<span class="me-3">
|
||||
<i class="fas fa-play-circle me-1"></i>
|
||||
${project.total_sessions} sessions
|
||||
</span>
|
||||
${project.languages ? `
|
||||
<span>
|
||||
<i class="fas fa-code me-1"></i>
|
||||
${project.languages.slice(0, 2).join(', ')}
|
||||
</span>
|
||||
` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-muted">
|
||||
${ApiUtils.formatRelativeTime(project.last_activity)}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
container.innerHTML = projectsHtml;
|
||||
}
|
||||
|
||||
function updateQuickStats(summary) {
|
||||
const container = document.getElementById('quick-stats');
|
||||
const recent = summary.recent_activity || {};
|
||||
|
||||
const statsHtml = `
|
||||
<div class="row g-3">
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="fas fa-calendar-week fa-2x text-primary"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<div class="fw-bold">${recent.sessions_last_7_days || 0}</div>
|
||||
<small class="text-muted">Sessions this week</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="fas fa-clock fa-2x text-success"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<div class="fw-bold">${(recent.time_last_7_days_hours || 0).toFixed(1)}h</div>
|
||||
<small class="text-muted">Time this week</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="fas fa-chart-line fa-2x text-info"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<div class="fw-bold">${(recent.daily_average_last_week || 0).toFixed(1)}</div>
|
||||
<small class="text-muted">Daily average</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<i class="fas fa-fire fa-2x text-warning"></i>
|
||||
</div>
|
||||
<div class="flex-grow-1 ms-3">
|
||||
<div class="fw-bold">${summary.overview?.tracking_period_days || 0}</div>
|
||||
<small class="text-muted">Days tracked</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
container.innerHTML = statsHtml;
|
||||
}
|
||||
|
||||
function refreshDashboard() {
|
||||
// Add visual feedback
|
||||
const refreshBtn = document.querySelector('[onclick="refreshDashboard()"]');
|
||||
const icon = refreshBtn.querySelector('i');
|
||||
|
||||
icon.classList.add('fa-spin');
|
||||
refreshBtn.disabled = true;
|
||||
|
||||
loadDashboardData().finally(() => {
|
||||
icon.classList.remove('fa-spin');
|
||||
refreshBtn.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-refresh dashboard every 5 minutes
|
||||
setInterval(() => {
|
||||
loadDashboardData();
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
// Handle window resize for charts
|
||||
window.addEventListener('resize', () => {
|
||||
if (productivityChart) {
|
||||
productivityChart.resize();
|
||||
}
|
||||
if (toolsChart) {
|
||||
toolsChart.resize();
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue