Spaces:
Running
Running
File size: 5,933 Bytes
15b59ae 160f979 15b59ae 160f979 15b59ae 160f979 5274beb 15b59ae 5274beb 15b59ae 5274beb 15b59ae 5274beb 15b59ae a0dd381 15b59ae 5274beb 15b59ae 5274beb 15b59ae 5274beb 15b59ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reports | TaskMaster Pro</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
<custom-navbar></custom-navbar>
<main class="flex-1 container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<h1 class="text-3xl font-bold text-gray-800 mb-8">Task Reports</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<h2 class="text-xl font-semibold mb-4">Task Completion Rate</h2>
<canvas id="completionChart"></canvas>
</div>
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
<h2 class="text-xl font-semibold mb-4">Priority Distribution</h2>
<canvas id="priorityChart"></canvas>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h2 class="text-xl font-semibold mb-4">Task Comments</h2>
<div id="commentsContainer" class="space-y-4">
<!-- Comments will be loaded here -->
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
// Completion chart
const completed = tasks.filter(t => t.status === 'completed').length;
const inProgress = tasks.filter(t => t.status === 'in-progress').length;
const pending = tasks.filter(t => t.status === 'pending').length;
new Chart(document.getElementById('completionChart'), {
type: 'doughnut',
data: {
labels: ['Completed', 'In Progress', 'Pending'],
datasets: [{
data: [completed, inProgress, pending],
backgroundColor: ['#10b981', '#3b82f6', '#f59e0b'],
}]
}
});
// Priority chart
const high = tasks.filter(t => t.priority === 'high').length;
const medium = tasks.filter(t => t.priority === 'medium').length;
const low = tasks.filter(t => t.priority === 'low').length;
new Chart(document.getElementById('priorityChart'), {
type: 'bar',
data: {
labels: ['High', 'Medium', 'Low'],
datasets: [{
label: 'Tasks by Priority',
data: [high, medium, low],
backgroundColor: ['#ef4444', '#f59e0b', '#10b981'],
}]
}
});
// Load comments with add form
const commentsContainer = document.getElementById('commentsContainer');
commentsContainer.innerHTML = tasks.map(task => `
<div class="border-b border-gray-100 pb-4 last:border-0">
<div class="flex justify-between items-start">
<div>
<h3 class="font-medium">${task.title}</h3>
<p class="text-sm text-gray-500">${new Date(task.createdAt).toLocaleString()}</p>
</div>
<span class="status-badge ${'status-' + task.status.replace(' ', '-')}">
${task.status.replace('-', ' ')}
</span>
</div>
<div class="mt-2 space-y-2">
${(task.comments || []).map((c, i) => `
<div class="bg-gray-50 p-3 rounded-lg">
<p class="text-sm">${i+1}. ${c}</p>
</div>
`).join('')}
</div>
<form class="mt-3 flex gap-2 add-comment" data-taskid="${task.id}">
<input type="text" class="flex-1 px-3 py-2 border border-gray-300 rounded-md"
placeholder="Add comment..." required>
<button type="submit" class="px-3 py-2 bg-primary text-white rounded-md">
<i data-feather="plus" class="w-4 h-4"></i>
</button>
</form>
</div>
`).join('');
// Add comment handlers
document.querySelectorAll('.add-comment').forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
const input = this.querySelector('input');
const taskId = this.getAttribute('data-taskid');
const comment = input.value.trim();
if (comment) {
const task = tasks.find(t => t.id === taskId);
if (task) {
if (!task.comments) task.comments = [];
task.comments.push(comment);
localStorage.setItem('tasks', JSON.stringify(tasks));
input.value = '';
location.reload();
}
}
});
});
feather.replace();
});
</script>
</body>
</html> |