Spaces:
Running
Running
File size: 42,160 Bytes
ab3ac32 |
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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project Manager - Card View</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.card-hover {
transition: all 0.3s ease;
}
.card-hover:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}
.status-badge {
position: absolute;
top: -10px;
right: -10px;
border-radius: 9999px;
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-weight: 600;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.tag-pill {
transition: all 0.2s ease;
}
.tag-pill:hover {
transform: scale(1.05);
}
.fade-in {
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.modal-overlay {
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(4px);
}
.form-input:focus {
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-center mb-8">
<div>
<h1 class="text-3xl font-bold text-gray-800">Project Manager</h1>
<p class="text-gray-600">Track and manage your projects</p>
</div>
<button id="addProjectBtn" class="mt-4 md:mt-0 bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center transition-colors">
<i class="fas fa-plus mr-2"></i> Add Project
</button>
</header>
<!-- Filter Controls -->
<div class="mb-8 bg-white p-4 rounded-lg shadow-sm">
<div class="flex flex-wrap items-center gap-4">
<div class="flex-1 min-w-[200px]">
<label for="statusFilter" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
<select id="statusFilter" class="w-full border border-gray-300 rounded-md py-2 px-3 focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="all">All Statuses</option>
<option value="Not Started">Not Started</option>
<option value="In Progress">In Progress</option>
<option value="Completed">Completed</option>
<option value="On Hold">On Hold</option>
</select>
</div>
<div class="flex-1 min-w-[200px]">
<label for="tagFilter" class="block text-sm font-medium text-gray-700 mb-1">Tags</label>
<select id="tagFilter" class="w-full border border-gray-300 rounded-md py-2 px-3 focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="all">All Tags</option>
<!-- Tags will be populated dynamically -->
</select>
</div>
<div class="flex items-end">
<button id="resetFilters" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md transition-colors">
Reset Filters
</button>
</div>
</div>
</div>
<!-- Projects Grid -->
<div id="projectsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Project cards will be inserted here dynamically -->
</div>
<!-- Empty State -->
<div id="emptyState" class="hidden text-center py-12">
<div class="mx-auto max-w-md">
<i class="fas fa-folder-open text-5xl text-gray-300 mb-4"></i>
<h3 class="text-xl font-medium text-gray-700 mb-2">No projects found</h3>
<p class="text-gray-500 mb-4">Add a new project or adjust your filters</p>
<button id="addProjectBtnEmpty" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg inline-flex items-center transition-colors">
<i class="fas fa-plus mr-2"></i> Add Project
</button>
</div>
</div>
</div>
<!-- Add/Edit Project Modal -->
<div id="projectModal" class="fixed inset-0 z-50 hidden">
<div class="modal-overlay absolute inset-0"></div>
<div class="flex items-center justify-center min-h-screen">
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 id="modalTitle" class="text-xl font-bold text-gray-800">Add New Project</h3>
<button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<form id="projectForm" class="space-y-4">
<input type="hidden" id="projectId">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="projectName" class="block text-sm font-medium text-gray-700 mb-1">Project Name *</label>
<input type="text" id="projectName" required class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div>
<label for="projectStatus" class="block text-sm font-medium text-gray-700 mb-1">Status *</label>
<select id="projectStatus" required class="w-full border border-gray-300 rounded-md py-2 px-3 focus:outline-none focus:border-blue-500">
<option value="Not Started">Not Started</option>
<option value="In Progress">In Progress</option>
<option value="Completed">Completed</option>
<option value="On Hold">On Hold</option>
</select>
</div>
</div>
<div>
<label for="projectImage" class="block text-sm font-medium text-gray-700 mb-1">Image URL</label>
<input type="url" id="projectImage" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="projectDateRange" class="block text-sm font-medium text-gray-700 mb-1">Date Range</label>
<input type="text" id="projectDateRange" placeholder="e.g. Jan 2023 - Mar 2023" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div>
<label for="projectTechnologies" class="block text-sm font-medium text-gray-700 mb-1">Technologies (comma separated)</label>
<input type="text" id="projectTechnologies" placeholder="e.g. React, Node.js, MongoDB" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
</div>
<div>
<label for="projectDescription" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="projectDescription" rows="3" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500"></textarea>
</div>
<div>
<label for="projectTags" class="block text-sm font-medium text-gray-700 mb-1">Tags (comma separated)</label>
<input type="text" id="projectTags" placeholder="e.g. web, mobile, api" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label for="projectGithub" class="block text-sm font-medium text-gray-700 mb-1">GitHub Link</label>
<input type="url" id="projectGithub" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div>
<label for="projectDemo" class="block text-sm font-medium text-gray-700 mb-1">Demo Link</label>
<input type="url" id="projectDemo" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
<div>
<label for="projectReadme" class="block text-sm font-medium text-gray-700 mb-1">README Link</label>
<input type="url" id="projectReadme" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500">
</div>
</div>
<div>
<label for="projectNotes" class="block text-sm font-medium text-gray-700 mb-1">Notes</label>
<textarea id="projectNotes" rows="3" class="w-full border border-gray-300 rounded-md py-2 px-3 form-input focus:outline-none focus:border-blue-500"></textarea>
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" id="cancelModalBtn" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors">
Cancel
</button>
<button type="submit" id="saveProjectBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors">
Save Project
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Project Details Modal -->
<div id="detailsModal" class="fixed inset-0 z-50 hidden">
<div class="modal-overlay absolute inset-0"></div>
<div class="flex items-center justify-center min-h-screen">
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 id="detailsTitle" class="text-xl font-bold text-gray-800">Project Details</h3>
<button id="closeDetailsBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div id="detailsContent" class="space-y-4">
<!-- Details will be populated here -->
</div>
<div class="flex justify-end space-x-3 pt-6">
<button id="editDetailsBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors">
Edit Project
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div id="deleteModal" class="fixed inset-0 z-50 hidden">
<div class="modal-overlay absolute inset-0"></div>
<div class="flex items-center justify-center min-h-screen">
<div class="bg-white rounded-lg shadow-xl w-full max-w-md m-4">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Confirm Deletion</h3>
<button id="closeDeleteBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<p id="deleteMessage" class="text-gray-700 mb-6">Are you sure you want to delete this project?</p>
<div class="flex justify-end space-x-3">
<button id="cancelDeleteBtn" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors">
Cancel
</button>
<button id="confirmDeleteBtn" class="px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors">
Delete
</button>
</div>
</div>
</div>
</div>
</div>
<script>
// Sample initial data
let projects = [
{
id: "1",
name: "E-commerce Website",
image_link: "https://images.unsplash.com/photo-1555529669-e69e7aa0ba9a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80",
date_range: "Mar 2023 - Jun 2023",
description: "A full-featured e-commerce platform with product listings, cart functionality, and payment processing.",
tags: ["web", "ecommerce", "react"],
github_link: "https://github.com/example/ecommerce",
demo_link: "https://ecommerce.example.com",
readme_link: "https://github.com/example/ecommerce/blob/main/README.md",
status: "Completed",
technologies: ["React", "Node.js", "MongoDB", "Stripe"],
notes: "The project was completed on time and under budget. Customer satisfaction was high.",
created_at: "2023-03-15T10:00:00Z",
updated_at: "2023-06-20T14:30:00Z"
},
{
id: "2",
name: "Mobile Task Manager",
image_link: "https://images.unsplash.com/photo-1512941937669-90a1b58e7e9c?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80",
date_range: "Jul 2023 - Present",
description: "A cross-platform mobile application for task management with sync across devices.",
tags: ["mobile", "productivity", "react-native"],
github_link: "https://github.com/example/task-manager",
demo_link: "",
readme_link: "https://github.com/example/task-manager/blob/main/README.md",
status: "In Progress",
technologies: ["React Native", "Firebase", "Redux"],
notes: "Currently working on the offline sync functionality. Expected completion in Q4 2023.",
created_at: "2023-07-01T09:15:00Z",
updated_at: "2023-08-10T16:45:00Z"
},
{
id: "3",
name: "API Service",
image_link: "https://images.unsplash.com/photo-1558494949-ef010cbdcc31?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=500&q=80",
date_range: "",
description: "Backend API service for data processing and integration with third-party services.",
tags: ["api", "backend", "node"],
github_link: "https://github.com/example/api-service",
demo_link: "",
readme_link: "",
status: "On Hold",
technologies: ["Node.js", "Express", "PostgreSQL"],
notes: "Project put on hold due to shifting priorities. Will revisit in Q1 2024.",
created_at: "2023-05-10T14:20:00Z",
updated_at: "2023-08-01T11:10:00Z"
}
];
// DOM Elements
const projectsContainer = document.getElementById('projectsContainer');
const emptyState = document.getElementById('emptyState');
const addProjectBtn = document.getElementById('addProjectBtn');
const addProjectBtnEmpty = document.getElementById('addProjectBtnEmpty');
const statusFilter = document.getElementById('statusFilter');
const tagFilter = document.getElementById('tagFilter');
const resetFilters = document.getElementById('resetFilters');
// Modal Elements
const projectModal = document.getElementById('projectModal');
const modalTitle = document.getElementById('modalTitle');
const projectForm = document.getElementById('projectForm');
const projectId = document.getElementById('projectId');
const projectName = document.getElementById('projectName');
const projectImage = document.getElementById('projectImage');
const projectDateRange = document.getElementById('projectDateRange');
const projectDescription = document.getElementById('projectDescription');
const projectTags = document.getElementById('projectTags');
const projectGithub = document.getElementById('projectGithub');
const projectDemo = document.getElementById('projectDemo');
const projectReadme = document.getElementById('projectReadme');
const projectStatus = document.getElementById('projectStatus');
const projectTechnologies = document.getElementById('projectTechnologies');
const projectNotes = document.getElementById('projectNotes');
const closeModalBtn = document.getElementById('closeModalBtn');
const cancelModalBtn = document.getElementById('cancelModalBtn');
const saveProjectBtn = document.getElementById('saveProjectBtn');
// Details Modal Elements
const detailsModal = document.getElementById('detailsModal');
const detailsTitle = document.getElementById('detailsTitle');
const detailsContent = document.getElementById('detailsContent');
const closeDetailsBtn = document.getElementById('closeDetailsBtn');
const editDetailsBtn = document.getElementById('editDetailsBtn');
// Delete Modal Elements
const deleteModal = document.getElementById('deleteModal');
const deleteMessage = document.getElementById('deleteMessage');
const closeDeleteBtn = document.getElementById('closeDeleteBtn');
const cancelDeleteBtn = document.getElementById('cancelDeleteBtn');
const confirmDeleteBtn = document.getElementById('confirmDeleteBtn');
// State
let currentProjectId = null;
let allTags = [];
// Initialize the app
function init() {
renderProjects();
setupEventListeners();
updateTagFilterOptions();
}
// Render all projects
function renderProjects() {
projectsContainer.innerHTML = '';
const statusFilterValue = statusFilter.value;
const tagFilterValue = tagFilter.value;
let filteredProjects = projects;
// Apply status filter
if (statusFilterValue !== 'all') {
filteredProjects = filteredProjects.filter(project => project.status === statusFilterValue);
}
// Apply tag filter
if (tagFilterValue !== 'all') {
filteredProjects = filteredProjects.filter(project =>
project.tags && project.tags.includes(tagFilterValue)
);
}
if (filteredProjects.length === 0) {
emptyState.classList.remove('hidden');
projectsContainer.classList.add('hidden');
} else {
emptyState.classList.add('hidden');
projectsContainer.classList.remove('hidden');
filteredProjects.forEach(project => {
const projectCard = createProjectCard(project);
projectsContainer.appendChild(projectCard);
});
}
}
// Create a project card element
function createProjectCard(project) {
const card = document.createElement('div');
card.className = 'bg-white rounded-lg shadow-md overflow-hidden card-hover fade-in relative';
card.dataset.id = project.id;
// Status badge with color coding
let statusColor = 'bg-gray-500'; // Default for unknown status
if (project.status === 'Not Started') statusColor = 'bg-gray-500';
else if (project.status === 'In Progress') statusColor = 'bg-yellow-500';
else if (project.status === 'Completed') statusColor = 'bg-green-500';
else if (project.status === 'On Hold') statusColor = 'bg-red-500';
// Card content
card.innerHTML = `
<div class="relative">
${project.image_link ?
`<img src="${project.image_link}" alt="${project.name}" class="w-full h-48 object-cover">` :
`<div class="w-full h-48 bg-gray-200 flex items-center justify-center">
<i class="fas fa-image text-4xl text-gray-400"></i>
</div>`
}
<span class="status-badge ${statusColor} text-white">${project.status}</span>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold text-gray-800 mb-1 truncate">${project.name}</h3>
${project.date_range ?
`<p class="text-sm text-gray-500 mb-2 flex items-center">
<i class="fas fa-calendar-alt mr-2"></i>${project.date_range}
</p>` : ''
}
<p class="text-gray-600 text-sm mb-3 line-clamp-2">${project.description || 'No description available'}</p>
${project.tags && project.tags.length > 0 ?
`<div class="flex flex-wrap gap-2 mb-4">
${project.tags.map(tag => `
<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full tag-pill">${tag}</span>
`).join('')}
</div>` : ''
}
<div class="flex justify-between items-center border-t pt-3">
<div class="flex space-x-2">
${project.github_link ? `
<a href="${project.github_link}" target="_blank" class="text-gray-500 hover:text-gray-700 transition-colors" title="GitHub">
<i class="fab fa-github"></i>
</a>
` : ''}
${project.demo_link ? `
<a href="${project.demo_link}" target="_blank" class="text-gray-500 hover:text-gray-700 transition-colors" title="Live Demo">
<i class="fas fa-external-link-alt"></i>
</a>
` : ''}
${project.readme_link ? `
<a href="${project.readme_link}" target="_blank" class="text-gray-500 hover:text-gray-700 transition-colors" title="README">
<i class="fas fa-book"></i>
</a>
` : ''}
</div>
<div class="flex space-x-2">
<button class="text-gray-500 hover:text-blue-500 transition-colors edit-btn" title="Edit">
<i class="fas fa-edit"></i>
</button>
<button class="text-gray-500 hover:text-red-500 transition-colors delete-btn" title="Delete">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
</div>
`;
// Add click event for viewing details
card.addEventListener('click', (e) => {
// Don't open details if clicking on edit/delete buttons or links
if (e.target.closest('.edit-btn, .delete-btn, a')) {
return;
}
openDetailsModal(project.id);
});
// Add edit and delete button events
const editBtn = card.querySelector('.edit-btn');
const deleteBtn = card.querySelector('.delete-btn');
editBtn.addEventListener('click', (e) => {
e.stopPropagation();
openEditModal(project.id);
});
deleteBtn.addEventListener('click', (e) => {
e.stopPropagation();
openDeleteModal(project.id);
});
return card;
}
// Open the add project modal
function openAddModal() {
projectForm.reset();
projectId.value = '';
modalTitle.textContent = 'Add New Project';
projectModal.classList.remove('hidden');
}
// Open the edit project modal
function openEditModal(id) {
const project = projects.find(p => p.id === id);
if (!project) return;
currentProjectId = id;
// Populate form fields
projectId.value = project.id;
projectName.value = project.name || '';
projectImage.value = project.image_link || '';
projectDateRange.value = project.date_range || '';
projectDescription.value = project.description || '';
projectTags.value = project.tags ? project.tags.join(', ') : '';
projectGithub.value = project.github_link || '';
projectDemo.value = project.demo_link || '';
projectReadme.value = project.readme_link || '';
projectStatus.value = project.status || 'Not Started';
projectTechnologies.value = project.technologies ? project.technologies.join(', ') : '';
projectNotes.value = project.notes || '';
modalTitle.textContent = 'Edit Project';
projectModal.classList.remove('hidden');
}
// Open the project details modal
function openDetailsModal(id) {
const project = projects.find(p => p.id === id);
if (!project) return;
currentProjectId = id;
detailsTitle.textContent = project.name;
// Format dates
const createdDate = project.created_at ? new Date(project.created_at).toLocaleDateString() : 'Unknown';
const updatedDate = project.updated_at ? new Date(project.updated_at).toLocaleDateString() : 'Unknown';
// Create details content
detailsContent.innerHTML = `
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-4">
${project.image_link ? `
<div class="rounded-lg overflow-hidden">
<img src="${project.image_link}" alt="${project.name}" class="w-full h-auto max-h-48 object-cover">
</div>
` : ''}
<div class="bg-gray-50 p-4 rounded-lg">
<h4 class="font-medium text-gray-800 mb-2">Quick Info</h4>
<div class="space-y-2">
${project.status ? `
<div class="flex items-center">
<span class="inline-block w-3 h-3 rounded-full mr-2 ${getStatusColorClass(project.status)}"></span>
<span class="text-sm text-gray-700">Status: ${project.status}</span>
</div>
` : ''}
${project.date_range ? `
<div class="flex items-center text-sm text-gray-700">
<i class="fas fa-calendar-alt mr-2 text-gray-500"></i>
<span>${project.date_range}</span>
</div>
` : ''}
<div class="flex items-center text-sm text-gray-700">
<i class="fas fa-calendar-plus mr-2 text-gray-500"></i>
<span>Created: ${createdDate}</span>
</div>
<div class="flex items-center text-sm text-gray-700">
<i class="fas fa-calendar-check mr-2 text-gray-500"></i>
<span>Last Updated: ${updatedDate}</span>
</div>
</div>
</div>
</div>
<div class="space-y-4">
${project.description ? `
<div>
<h4 class="font-medium text-gray-800 mb-1">Description</h4>
<p class="text-gray-700">${project.description}</p>
</div>
` : ''}
${project.technologies && project.technologies.length > 0 ? `
<div>
<h4 class="font-medium text-gray-800 mb-1">Technologies</h4>
<div class="flex flex-wrap gap-2">
${project.technologies.map(tech => `
<span class="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded-full">${tech}</span>
`).join('')}
</div>
</div>
` : ''}
${project.tags && project.tags.length > 0 ? `
<div>
<h4 class="font-medium text-gray-800 mb-1">Tags</h4>
<div class="flex flex-wrap gap-2">
${project.tags.map(tag => `
<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full">${tag}</span>
`).join('')}
</div>
</div>
` : ''}
${project.notes ? `
<div>
<h4 class="font-medium text-gray-800 mb-1">Notes</h4>
<p class="text-gray-700 whitespace-pre-line">${project.notes}</p>
</div>
` : ''}
</div>
</div>
<div class="pt-4 border-t">
<h4 class="font-medium text-gray-800 mb-2">Links</h4>
<div class="flex flex-wrap gap-4">
${project.github_link ? `
<a href="${project.github_link}" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800 transition-colors">
<i class="fab fa-github mr-2"></i> GitHub Repository
</a>
` : ''}
${project.demo_link ? `
<a href="${project.demo_link}" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800 transition-colors">
<i class="fas fa-external-link-alt mr-2"></i> Live Demo
</a>
` : ''}
${project.readme_link ? `
<a href="${project.readme_link}" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800 transition-colors">
<i class="fas fa-book mr-2"></i> README
</a>
` : ''}
${!project.github_link && !project.demo_link && !project.readme_link ? `
<span class="text-gray-500">No links available</span>
` : ''}
</div>
</div>
`;
detailsModal.classList.remove('hidden');
}
// Open the delete confirmation modal
function openDeleteModal(id) {
currentProjectId = id;
const project = projects.find(p => p.id === id);
if (project) {
deleteMessage.textContent = `Are you sure you want to delete "${project.name}"? This action cannot be undone.`;
} else {
deleteMessage.textContent = 'Are you sure you want to delete this project?';
}
deleteModal.classList.remove('hidden');
}
// Close all modals
function closeAllModals() {
projectModal.classList.add('hidden');
detailsModal.classList.add('hidden');
deleteModal.classList.add('hidden');
currentProjectId = null;
}
// Save project (add or edit)
function saveProject(e) {
e.preventDefault();
// Validate required fields
if (!projectName.value.trim()) {
alert('Project name is required');
return;
}
// Get form values
const id = projectId.value || generateId();
const now = new Date().toISOString();
const projectData = {
id,
name: projectName.value.trim(),
image_link: projectImage.value.trim(),
date_range: projectDateRange.value.trim(),
description: projectDescription.value.trim(),
tags: projectTags.value ? projectTags.value.split(',').map(tag => tag.trim()).filter(tag => tag) : [],
github_link: projectGithub.value.trim(),
demo_link: projectDemo.value.trim(),
readme_link: projectReadme.value.trim(),
status: projectStatus.value,
technologies: projectTechnologies.value ? projectTechnologies.value.split(',').map(tech => tech.trim()).filter(tech => tech) : [],
notes: projectNotes.value.trim(),
updated_at: now
};
// If new project, set created_at
if (!projectId.value) {
projectData.created_at = now;
} else {
// For existing projects, preserve created_at
const existingProject = projects.find(p => p.id === projectId.value);
if (existingProject) {
projectData.created_at = existingProject.created_at;
} else {
projectData.created_at = now;
}
}
// Update or add the project
if (projectId.value) {
// Edit existing project
const index = projects.findIndex(p => p.id === projectId.value);
if (index !== -1) {
projects[index] = projectData;
}
} else {
// Add new project
projects.push(projectData);
}
// Update UI
renderProjects();
updateTagFilterOptions();
closeAllModals();
}
// Delete project
function deleteProject() {
projects = projects.filter(p => p.id !== currentProjectId);
renderProjects();
updateTagFilterOptions();
closeAllModals();
}
// Generate a unique ID
function generateId() {
return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
// Get status color class
function getStatusColorClass(status) {
switch (status) {
case 'Not Started': return 'bg-gray-500';
case 'In Progress': return 'bg-yellow-500';
case 'Completed': return 'bg-green-500';
case 'On Hold': return 'bg-red-500';
default: return 'bg-gray-500';
}
}
// Update tag filter options
function updateTagFilterOptions() {
// Collect all unique tags from projects
const tagsSet = new Set();
projects.forEach(project => {
if (project.tags) {
project.tags.forEach(tag => tagsSet.add(tag));
}
});
allTags = Array.from(tagsSet).sort();
// Update tag filter dropdown
tagFilter.innerHTML = `
<option value="all">All Tags</option>
${allTags.map(tag => `<option value="${tag}">${tag}</option>`).join('')}
`;
}
// Set up event listeners
function setupEventListeners() {
// Add project buttons
addProjectBtn.addEventListener('click', openAddModal);
addProjectBtnEmpty.addEventListener('click', openAddModal);
// Filter controls
statusFilter.addEventListener('change', renderProjects);
tagFilter.addEventListener('change', renderProjects);
resetFilters.addEventListener('click', () => {
statusFilter.value = 'all';
tagFilter.value = 'all';
renderProjects();
});
// Modal buttons
closeModalBtn.addEventListener('click', closeAllModals);
cancelModalBtn.addEventListener('click', closeAllModals);
projectForm.addEventListener('submit', saveProject);
// Details modal buttons
closeDetailsBtn.addEventListener('click', closeAllModals);
editDetailsBtn.addEventListener('click', () => {
closeAllModals();
openEditModal(currentProjectId);
});
// Delete modal buttons
closeDeleteBtn.addEventListener('click', closeAllModals);
cancelDeleteBtn.addEventListener('click', closeAllModals);
confirmDeleteBtn.addEventListener('click', deleteProject);
}
// Initialize the app when DOM is loaded
document.addEventListener('DOMContentLoaded', init);
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MoiMoi-01/project-manager" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |