-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathindex.html
313 lines (286 loc) · 15.4 KB
/
index.html
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!DOCTYPE html>
<html lang="en" class="h-full bg-gray-100">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ProductPlan Pro</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'primary': '#3b82f6',
'secondary': '#64748b',
}
}
}
}
</script>
</head>
<body class="h-full">
<div class="min-h-full">
<nav class="bg-primary">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 items-center justify-between">
<div class="flex items-center">
<div class="flex-shrink-0">
<h1 class="text-white text-2xl font-bold">ProductPlan Pro</h1>
</div>
<div class="hidden md:block">
<div class="ml-10 flex items-baseline space-x-4">
<a href="#projects" class="text-white hover:bg-blue-600 px-3 py-2 rounded-md text-sm font-medium">Projects</a>
<a href="#deadlines" class="text-white hover:bg-blue-600 px-3 py-2 rounded-md text-sm font-medium">Deadlines</a>
<a href="#settings" class="text-white hover:bg-blue-600 px-3 py-2 rounded-md text-sm font-medium">Settings</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<main>
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
<div class="px-4 py-6 sm:px-0">
<div class="overflow-hidden bg-white shadow sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<h2 class="text-lg font-medium leading-6 text-gray-900">Projects</h2>
<p class="mt-1 max-w-2xl text-sm text-gray-500">A list of all the projects in your account.</p>
</div>
<div class="border-t border-gray-200">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Description</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Start Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">End Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Progress</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200" id="projectTableBody">
<!-- Project rows will be dynamically added here -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<aside class="fixed top-16 right-0 w-64 h-full bg-white shadow-lg overflow-y-auto">
<div class="p-4">
<button id="addNewBtn" class="w-full bg-primary text-white py-2 px-4 rounded hover:bg-blue-600 transition duration-200">
Add New Project
</button>
<div class="mt-8">
<h3 class="text-lg font-medium text-gray-900">Upcoming Deadlines</h3>
<ul id="upcomingDeadlines" class="mt-2 space-y-2">
<!-- Upcoming deadlines will be dynamically added here -->
</ul>
</div>
</div>
</aside>
</div>
<footer class="bg-secondary">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="py-4 text-center text-sm text-white">
<p>© 2023 ProductPlan Pro. All rights reserved.</p>
<div class="mt-2">
<a href="#help" class="text-white hover:text-gray-300">Help</a> |
<a href="#docs" class="text-white hover:text-gray-300">Documentation</a>
</div>
</div>
</div>
</footer>
<!-- Modal -->
<div id="projectModal" class="fixed z-10 inset-0 overflow-y-auto hidden" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span>
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title">Add/Edit Project</h3>
<div class="mt-2">
<form id="projectForm" class="space-y-4">
<input type="hidden" id="projectId">
<div>
<label for="projectName" class="block text-sm font-medium text-gray-700">Name</label>
<input type="text" id="projectName" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm">
</div>
<div>
<label for="projectDescription" class="block text-sm font-medium text-gray-700">Description</label>
<textarea id="projectDescription" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm"></textarea>
</div>
<div>
<label for="projectStartDate" class="block text-sm font-medium text-gray-700">Start Date</label>
<input type="date" id="projectStartDate" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm">
</div>
<div>
<label for="projectEndDate" class="block text-sm font-medium text-gray-700">End Date</label>
<input type="date" id="projectEndDate" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm">
</div>
</form>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<button type="submit" form="projectForm" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-primary text-base font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary sm:ml-3 sm:w-auto sm:text-sm">Save</button>
<button type="button" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm" onclick="hideModal('projectModal')">Cancel</button>
</div>
</div>
</div>
</div>
<script src="https://d3js.org/d3.v7.min.js"></script>
<script>
// Global variables
const API_URL = 'http://localhost:5120';
let currentProject = null;
// Helper functions
function formatDate(dateString) {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
}
function showModal(modalId) {
document.getElementById(modalId).classList.remove('hidden');
}
function hideModal(modalId) {
document.getElementById(modalId).classList.add('hidden');
}
// API functions
async function fetchProjects() {
const response = await fetch(`${API_URL}/projects`, {
headers: {
'Authorization': 'Basic ' + btoa('admin:password')
}
});
return await response.json();
}
async function createProject(projectData) {
const response = await fetch(`${API_URL}/projects`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('admin:password')
},
body: JSON.stringify(projectData)
});
return await response.json();
}
async function updateProject(projectId, projectData) {
const response = await fetch(`${API_URL}/projects/${projectId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('admin:password')
},
body: JSON.stringify(projectData)
});
return await response.json();
}
async function deleteProject(projectId) {
await fetch(`${API_URL}/projects/${projectId}`, {
method: 'DELETE',
headers: {
'Authorization': 'Basic ' + btoa('admin:password')
}
});
}
async function fetchUpcomingDeadlines() {
const response = await fetch(`${API_URL}/upcoming-deadlines`, {
headers: {
'Authorization': 'Basic ' + btoa('admin:password')
}
});
return await response.json();
}
// UI update functions
function updateProjectList(projects) {
const tbody = document.getElementById('projectTableBody');
tbody.innerHTML = '';
projects.forEach(project => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${project.name}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${project.description}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${formatDate(project.start_date)}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${formatDate(project.end_date)}</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="w-full bg-gray-200 rounded-full h-2.5">
<div class="bg-primary h-2.5 rounded-full" style="width: ${project.progress}%"></div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<button onclick="editProject(${project.id})" class="text-primary hover:text-blue-600 mr-2">
<i class="fas fa-edit"></i>
</button>
<button onclick="deleteProjectConfirm(${project.id})" class="text-red-600 hover:text-red-800">
<i class="fas fa-trash"></i>
</button>
</td>
`;
tbody.appendChild(row);
});
}
function updateUpcomingDeadlines(deadlines) {
const ul = document.getElementById('upcomingDeadlines');
ul.innerHTML = '';
deadlines.forEach(task => {
const li = document.createElement('li');
li.className = 'text-sm text-gray-600';
li.innerHTML = `
<i class="fas fa-calendar-alt text-primary mr-2"></i>
${task.name} <span class="text-gray-400">(${formatDate(task.deadline)})</span>
`;
ul.appendChild(li);
});
}
// Event handlers
document.getElementById('addNewBtn').addEventListener('click', () => {
document.getElementById('projectForm').reset();
document.getElementById('projectId').value = '';
showModal('projectModal');
});
document.getElementById('projectForm').addEventListener('submit', async (e) => {
e.preventDefault();
const projectData = {
name: document.getElementById('projectName').value,
description: document.getElementById('projectDescription').value,
start_date: document.getElementById('projectStartDate').value,
end_date: document.getElementById('projectEndDate').value
};
const projectId = document.getElementById('projectId').value;
if (projectId) {
await updateProject(projectId, projectData);
} else {
await createProject(projectData);
}
hideModal('projectModal');
refreshProjectList();
});
async function refreshProjectList() {
const projects = await fetchProjects();
updateProjectList(projects);
}
async function refreshUpcomingDeadlines() {
const deadlines = await fetchUpcomingDeadlines();
updateUpcomingDeadlines(deadlines);
}
function editProject(projectId) {
// Implement edit project functionality
console.log('Edit project:', projectId);
// For now, just show the modal
showModal('projectModal');
}
function deleteProjectConfirm(projectId) {
if (confirm('Are you sure you want to delete this project?')) {
deleteProject(projectId).then(refreshProjectList);
}
}
// Initial load
document.addEventListener('DOMContentLoaded', () => {
refreshProjectList();
refreshUpcomingDeadlines();
});
</script>
</body>
</html>