Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>My Projects - AI Builder Platform</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| </head> | |
| <body class="min-h-screen bg-gray-50"> | |
| <!-- Navigation --> | |
| <nav class="bg-white shadow-sm"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="flex justify-between h-16"> | |
| <div class="flex items-center"> | |
| <a href="/index.html" class="text-2xl font-bold text-purple-600">AI Builder</a> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <a href="/index.html" class="text-gray-600 hover:text-purple-600">Build</a> | |
| <a href="/projects.html" class="text-purple-600 font-semibold">Projects</a> | |
| <a href="/profile.html" class="text-gray-600 hover:text-purple-600">Profile</a> | |
| <button onclick="logout()" class="bg-gray-600 text-white px-4 py-2 rounded-lg hover:bg-gray-700"> | |
| Logout | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </nav> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <h1 class="text-3xl font-bold text-gray-900">My Projects</h1> | |
| <a href="/index.html" class="bg-purple-600 text-white px-4 py-2 rounded-lg hover:bg-purple-700"> | |
| + New Project | |
| </a> | |
| </div> | |
| <div id="projectsGrid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> | |
| <div class="text-center py-12"> | |
| <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-purple-600 mx-auto"></div> | |
| <p class="mt-4 text-gray-600">Loading projects...</p> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const userToken = localStorage.getItem('userToken'); | |
| if (!userToken) { | |
| window.location.href = '/login.html'; | |
| } | |
| async function loadProjects() { | |
| try { | |
| const response = await fetch('https://api.aibuilder.com/projects', { | |
| headers: { 'Authorization': `Bearer ${userToken}` } | |
| }); | |
| if (response.ok) { | |
| const projects = await response.json(); | |
| displayProjects(projects); | |
| } else { | |
| window.location.href = '/login.html'; | |
| } | |
| } catch (error) { | |
| console.error('Failed to load projects:', error); | |
| } | |
| } | |
| function displayProjects(projects) { | |
| const grid = document.getElementById('projectsGrid'); | |
| if (projects.length === 0) { | |
| grid.innerHTML = ` | |
| <div class="col-span-full text-center py-12"> | |
| <i data-feather="folder" class="w-16 h-16 text-gray-400 mx-auto"></i> | |
| <p class="mt-4 text-gray-600">No projects yet</p> | |
| <a href="/index.html" class="text-purple-600 hover:text-purple-700">Create your first project</a> | |
| </div> | |
| `; | |
| return; | |
| } | |
| grid.innerHTML = projects.map(project => ` | |
| <div class="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow"> | |
| <h3 class="text-lg font-semibold text-gray-900 mb-2">${project.name}</h3> | |
| <p class="text-sm text-gray-600 mb-4">${project.type} • ${new Date(project.createdAt).toLocaleDateString()}</p> | |
| <p class="text-sm text-gray-700 mb-4 line-clamp-2">${project.description || 'No description'}</p> | |
| <div class="flex space-x-2"> | |
| <button onclick="viewProject('${project.id}')" class="flex-1 bg-purple-600 text-white py-2 px-3 rounded text-sm hover:bg-purple-700"> | |
| View | |
| </button> | |
| <button onclick="downloadProject('${project.id}')" class="bg-gray-200 text-gray-700 py-2 px-3 rounded text-sm hover:bg-gray-300"> | |
| <i data-feather="download" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `).join(''); | |
| feather.replace(); | |
| } | |
| function viewProject(projectId) { | |
| window.location.href = `/project.html?id=${projectId}`; | |
| } | |
| async function downloadProject(projectId) { | |
| try { | |
| const response = await fetch(`https://api.aibuilder.com/projects/${projectId}/download`, { | |
| headers: { 'Authorization': `Bearer ${userToken}` } | |
| }); | |
| if (response.ok) { | |
| const blob = await response.blob(); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `project-${projectId}.zip`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| } catch (error) { | |
| alert('Download failed: ' + error.message); | |
| } | |
| } | |
| function logout() { | |
| localStorage.removeItem('userToken'); | |
| window.location.href = '/login.html'; | |
| } | |
| document.addEventListener('DOMContentLoaded', loadProjects); | |
| feather.replace(); | |
| </script> | |
| </body> | |
| </html> |