batteryfix commited on
Commit
5274beb
·
verified ·
1 Parent(s): 15b59ae

in report on with the graphs add "in progress" as well and the comment section needs to be linked to task and date so i can type the issues on them as well on the graph numbering . task comment should be linked to task to type on the task matter . setting page. on email section when selected allow to type email so email can send notification. activate data management . as well performance line graph in report page

Browse files
Files changed (4) hide show
  1. reports.html +90 -32
  2. script.js +57 -1
  3. settings.html +10 -8
  4. style.css +10 -0
reports.html CHANGED
@@ -14,9 +14,12 @@
14
  <main class="flex-1 container mx-auto px-4 py-8">
15
  <div class="max-w-6xl mx-auto">
16
  <h1 class="text-3xl font-bold text-gray-800 mb-8">Task Reports</h1>
17
-
18
  <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
19
  <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
 
 
 
 
20
  <h2 class="text-xl font-semibold mb-4">Task Completion Rate</h2>
21
  <canvas id="completionChart"></canvas>
22
  </div>
@@ -42,21 +45,21 @@
42
  <script>
43
  document.addEventListener('DOMContentLoaded', () => {
44
  const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
45
-
46
  // Completion chart
47
  const completed = tasks.filter(t => t.status === 'completed').length;
48
- const pending = tasks.filter(t => t.status !== 'completed').length;
 
49
 
50
  new Chart(document.getElementById('completionChart'), {
51
  type: 'doughnut',
52
  data: {
53
- labels: ['Completed', 'Pending'],
54
  datasets: [{
55
- data: [completed, pending],
56
- backgroundColor: ['#10b981', '#f59e0b'],
57
  }]
58
  }
59
- });
60
 
61
  // Priority chart
62
  const high = tasks.filter(t => t.priority === 'high').length;
@@ -74,34 +77,89 @@
74
  }]
75
  }
76
  });
77
-
78
- // Load comments
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  const commentsContainer = document.getElementById('commentsContainer');
80
- const tasksWithComments = tasks.filter(t => t.comments && t.comments.length > 0);
81
-
82
- if (tasksWithComments.length === 0) {
83
- commentsContainer.innerHTML = `
84
- <div class="text-center text-gray-500 py-8">
85
- <i data-feather="message-square" class="w-12 h-12 mx-auto mb-2"></i>
86
- <p>No comments found on any tasks.</p>
87
- </div>
88
- `;
89
- } else {
90
- commentsContainer.innerHTML = tasksWithComments.map(task => `
91
- <div class="border-b border-gray-100 pb-4 last:border-0">
92
- <h3 class="font-medium">${task.title}</h3>
93
- <div class="mt-2 space-y-2">
94
- ${task.comments.map(c => `
95
- <div class="bg-gray-50 p-3 rounded-lg">
96
- <p class="text-sm">${c}</p>
97
- </div>
98
- `).join('')}
99
  </div>
 
 
 
100
  </div>
101
- `).join('');
102
- }
103
-
104
- feather.replace();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  });
106
  </script>
107
  </body>
 
14
  <main class="flex-1 container mx-auto px-4 py-8">
15
  <div class="max-w-6xl mx-auto">
16
  <h1 class="text-3xl font-bold text-gray-800 mb-8">Task Reports</h1>
 
17
  <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
18
  <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
19
+ <h2 class="text-xl font-semibold mb-4">Performance Trend</h2>
20
+ <canvas id="performanceChart"></canvas>
21
+ </div>
22
+ <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
23
  <h2 class="text-xl font-semibold mb-4">Task Completion Rate</h2>
24
  <canvas id="completionChart"></canvas>
25
  </div>
 
45
  <script>
46
  document.addEventListener('DOMContentLoaded', () => {
47
  const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
 
48
  // Completion chart
49
  const completed = tasks.filter(t => t.status === 'completed').length;
50
+ const inProgress = tasks.filter(t => t.status === 'in-progress').length;
51
+ const pending = tasks.filter(t => t.status === 'pending').length;
52
 
53
  new Chart(document.getElementById('completionChart'), {
54
  type: 'doughnut',
55
  data: {
56
+ labels: ['Completed', 'In Progress', 'Pending'],
57
  datasets: [{
58
+ data: [completed, inProgress, pending],
59
+ backgroundColor: ['#10b981', '#3b82f6', '#f59e0b'],
60
  }]
61
  }
62
+ });
63
 
64
  // Priority chart
65
  const high = tasks.filter(t => t.priority === 'high').length;
 
77
  }]
78
  }
79
  });
80
+ // Performance line chart
81
+ const dates = [...new Set(tasks.map(t => new Date(t.createdAt).toLocaleDateString()))].sort();
82
+ const performanceData = dates.map(date => {
83
+ const dayTasks = tasks.filter(t => new Date(t.createdAt).toLocaleDateString() === date);
84
+ return dayTasks.filter(t => t.status === 'completed').length;
85
+ });
86
+
87
+ new Chart(document.getElementById('performanceChart'), {
88
+ type: 'line',
89
+ data: {
90
+ labels: dates,
91
+ datasets: [{
92
+ label: 'Completed Tasks',
93
+ data: performanceData,
94
+ borderColor: '#10b981',
95
+ backgroundColor: 'rgba(16, 185, 129, 0.1)',
96
+ fill: true,
97
+ tension: 0.3
98
+ }]
99
+ },
100
+ options: {
101
+ scales: {
102
+ y: {
103
+ beginAtZero: true,
104
+ ticks: {
105
+ stepSize: 1
106
+ }
107
+ }
108
+ }
109
+ }
110
+ });
111
+
112
+ // Load comments with add form
113
  const commentsContainer = document.getElementById('commentsContainer');
114
+ commentsContainer.innerHTML = tasks.map(task => `
115
+ <div class="border-b border-gray-100 pb-4 last:border-0">
116
+ <div class="flex justify-between items-start">
117
+ <div>
118
+ <h3 class="font-medium">${task.title}</h3>
119
+ <p class="text-sm text-gray-500">${new Date(task.createdAt).toLocaleString()}</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  </div>
121
+ <span class="status-badge ${'status-' + task.status.replace(' ', '-')}">
122
+ ${task.status.replace('-', ' ')}
123
+ </span>
124
  </div>
125
+ <div class="mt-2 space-y-2">
126
+ ${(task.comments || []).map((c, i) => `
127
+ <div class="bg-gray-50 p-3 rounded-lg">
128
+ <p class="text-sm">${i+1}. ${c}</p>
129
+ </div>
130
+ `).join('')}
131
+ </div>
132
+ <form class="mt-3 flex gap-2 add-comment" data-taskid="${task.id}">
133
+ <input type="text" class="flex-1 px-3 py-2 border border-gray-300 rounded-md"
134
+ placeholder="Add comment..." required>
135
+ <button type="submit" class="px-3 py-2 bg-primary text-white rounded-md">
136
+ <i data-feather="plus" class="w-4 h-4"></i>
137
+ </button>
138
+ </form>
139
+ </div>
140
+ `).join('');
141
+
142
+ // Add comment handlers
143
+ document.querySelectorAll('.add-comment').forEach(form => {
144
+ form.addEventListener('submit', function(e) {
145
+ e.preventDefault();
146
+ const input = this.querySelector('input');
147
+ const taskId = this.getAttribute('data-taskid');
148
+ const comment = input.value.trim();
149
+
150
+ if (comment) {
151
+ const task = tasks.find(t => t.id === taskId);
152
+ if (task) {
153
+ if (!task.comments) task.comments = [];
154
+ task.comments.push(comment);
155
+ localStorage.setItem('tasks', JSON.stringify(tasks));
156
+ input.value = '';
157
+ location.reload();
158
+ }
159
+ }
160
+ });
161
+ });
162
+ feather.replace();
163
  });
164
  </script>
165
  </body>
script.js CHANGED
@@ -253,4 +253,60 @@ updateTaskStatus(taskId, newStatus) {
253
  // Initialize the app when DOM is loaded
254
  document.addEventListener('DOMContentLoaded', () => {
255
  const app = new TaskManager();
256
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  // Initialize the app when DOM is loaded
254
  document.addEventListener('DOMContentLoaded', () => {
255
  const app = new TaskManager();
256
+
257
+ // Email notification toggle
258
+ const emailCheckbox = document.getElementById('emailNotifications');
259
+ const emailInput = document.getElementById('notificationEmail');
260
+ if (emailCheckbox && emailInput) {
261
+ emailCheckbox.addEventListener('change', function() {
262
+ emailInput.classList.toggle('hidden', !this.checked);
263
+ if (this.checked) emailInput.focus();
264
+ });
265
+ }
266
+ });
267
+
268
+ // Data management functions
269
+ function exportTasks() {
270
+ const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
271
+ const dataStr = JSON.stringify(tasks);
272
+ const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
273
+
274
+ const exportName = 'taskmaster-export-' + new Date().toISOString().slice(0,10) + '.json';
275
+
276
+ const linkElement = document.createElement('a');
277
+ linkElement.setAttribute('href', dataUri);
278
+ linkElement.setAttribute('download', exportName);
279
+ linkElement.click();
280
+ }
281
+
282
+ function importTasks() {
283
+ const input = document.createElement('input');
284
+ input.type = 'file';
285
+ input.accept = '.json';
286
+
287
+ input.onchange = e => {
288
+ const file = e.target.files[0];
289
+ const reader = new FileReader();
290
+ reader.onload = event => {
291
+ try {
292
+ const importedTasks = JSON.parse(event.target.result);
293
+ localStorage.setItem('tasks', JSON.stringify(importedTasks));
294
+ alert('Tasks imported successfully!');
295
+ location.reload();
296
+ } catch (error) {
297
+ alert('Error importing tasks: Invalid file format');
298
+ }
299
+ };
300
+ reader.readAsText(file);
301
+ };
302
+
303
+ input.click();
304
+ }
305
+
306
+ function clearAllData() {
307
+ if (confirm('Are you sure you want to delete ALL tasks? This cannot be undone.')) {
308
+ localStorage.removeItem('tasks');
309
+ alert('All tasks have been deleted.');
310
+ location.reload();
311
+ }
312
+ }
settings.html CHANGED
@@ -43,9 +43,13 @@
43
  <label class="block text-sm font-medium text-gray-700 mb-1">Notification Settings</label>
44
  <div class="space-y-2">
45
  <div class="flex items-center">
 
46
  <input type="checkbox" id="emailNotifications" class="mr-2">
47
  <label for="emailNotifications">Email Notifications</label>
 
 
48
  </div>
 
49
  <div class="flex items-center">
50
  <input type="checkbox" id="browserNotifications" class="mr-2" checked>
51
  <label for="browserNotifications">Browser Notifications</label>
@@ -88,18 +92,16 @@
88
  <h2 class="text-xl font-semibold mb-4">Data Management</h2>
89
 
90
  <div class="space-y-3">
91
- <button class="w-full py-2 px-4 bg-gray-100 hover:bg-gray-200 rounded-lg text-left flex items-center gap-2">
92
- <i data-feather="download" class="w-4 h-4"></i>
93
  Export Tasks
94
  </button>
95
-
96
- <button class="w-full py-2 px-4 bg-gray-100 hover:bg-gray-200 rounded-lg text-left flex items-center gap-2">
97
- <i data-feather="upload" class="w-4 h-4"></i>
98
  Import Tasks
99
  </button>
100
-
101
- <button class="w-full py-2 px-4 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg text-left flex items-center gap-2">
102
- <i data-feather="trash-2" class="w-4 h-4"></i>
103
  Clear All Data
104
  </button>
105
  </div>
 
43
  <label class="block text-sm font-medium text-gray-700 mb-1">Notification Settings</label>
44
  <div class="space-y-2">
45
  <div class="flex items-center">
46
+ <div class="flex items-center w-full">
47
  <input type="checkbox" id="emailNotifications" class="mr-2">
48
  <label for="emailNotifications">Email Notifications</label>
49
+ <input type="email" id="notificationEmail" placeholder="Your email"
50
+ class="ml-4 px-2 py-1 border border-gray-300 rounded-md hidden">
51
  </div>
52
+ </div>
53
  <div class="flex items-center">
54
  <input type="checkbox" id="browserNotifications" class="mr-2" checked>
55
  <label for="browserNotifications">Browser Notifications</label>
 
92
  <h2 class="text-xl font-semibold mb-4">Data Management</h2>
93
 
94
  <div class="space-y-3">
95
+ <button onclick="exportTasks()" class="w-full py-2 px-4 bg-gray-100 hover:bg-gray-200 rounded-lg text-left flex items-center gap-2">
96
+ <i data-feather="download" class="w-4 h-4"></i>
97
  Export Tasks
98
  </button>
99
+ <button onclick="importTasks()" class="w-full py-2 px-4 bg-gray-100 hover:bg-gray-200 rounded-lg text-left flex items-center gap-2">
100
+ <i data-feather="upload" class="w-4 h-4"></i>
 
101
  Import Tasks
102
  </button>
103
+ <button onclick="clearAllData()" class="w-full py-2 px-4 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg text-left flex items-center gap-2">
104
+ <i data-feather="trash-2" class="w-4 h-4"></i>
 
105
  Clear All Data
106
  </button>
107
  </div>
style.css CHANGED
@@ -70,6 +70,16 @@ body {
70
  .bg-green-50 {
71
  background-color: rgba(16, 185, 129, 0.1);
72
  }
 
 
 
 
 
 
 
 
 
 
73
 
74
  /* Responsive adjustments */
75
  @media (max-width: 640px) {
 
70
  .bg-green-50 {
71
  background-color: rgba(16, 185, 129, 0.1);
72
  }
73
+ /* Settings page email input transition */
74
+ #notificationEmail {
75
+ transition: all 0.3s ease;
76
+ max-width: 0;
77
+ opacity: 0;
78
+ }
79
+ #notificationEmail:not(.hidden) {
80
+ max-width: 200px;
81
+ opacity: 1;
82
+ }
83
 
84
  /* Responsive adjustments */
85
  @media (max-width: 640px) {