Deploy from Lumerel

This commit is contained in:
Lumerel Deploy
2026-02-16 23:36:29 +00:00
commit 315b42ff7a
19 changed files with 971 additions and 0 deletions

142
public/dashboard.html Normal file
View File

@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskIt! - Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background-color: #f4f6f9;
font-family: 'Inter', sans-serif;
}
.dashboard-container {
max-width: 1200px;
margin: 2rem auto;
}
.project-card {
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
transition: transform 0.3s ease;
}
.project-card:hover {
transform: translateY(-10px);
}
.task-status {
font-size: 0.8rem;
padding: 0.2rem 0.5rem;
border-radius: 20px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="#">TaskIt!</a>
<button class="btn btn-outline-danger" id="logoutBtn">Logout</button>
</div>
</nav>
<div class="dashboard-container">
<div class="row">
<div class="col-md-4">
<div class="card project-card mb-4">
<div class="card-body">
<h5 class="card-title">Create New Project</h5>
<form id="newProjectForm">
<div class="mb-3">
<input type="text" class="form-control" placeholder="Project Name" required>
</div>
<div class="mb-3">
<textarea class="form-control" placeholder="Project Description" rows="3" required></textarea>
</div>
<button type="submit" class="btn btn-primary w-100">Create Project</button>
</form>
</div>
</div>
</div>
<div class="col-md-8" id="projectList">
<!-- Projects will be dynamically loaded here -->
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Check Authentication
async function checkAuth() {
const response = await fetch('/api/projects', {
method: 'GET',
credentials: 'include'
});
if (response.status === 401) {
window.location.href = '/index.html';
}
}
// Logout Handler
document.getElementById('logoutBtn').addEventListener('click', async () => {
try {
const response = await fetch('/api/logout', { method: 'POST' });
const result = await response.json();
if (result.success) {
window.location.href = '/index.html';
}
} catch (error) {
console.error('Logout error:', error);
}
});
// Load Projects
async function loadProjects() {
const projectList = document.getElementById('projectList');
try {
const response = await fetch('/api/projects');
const projects = await response.json();
projectList.innerHTML = projects.map(project => `
<div class="card project-card mb-3">
<div class="card-body">
<h5 class="card-title">${project.name}</h5>
<p class="card-text">${project.description}</p>
<a href="/project.html?id=${project.id}" class="btn btn-outline-primary">View Tasks</a>
</div>
</div>
`).join('');
} catch (error) {
console.error('Projects load error:', error);
}
}
// Create New Project
document.getElementById('newProjectForm').addEventListener('submit', async function(e) {
e.preventDefault();
const name = this.querySelector('input[type="text"]').value;
const description = this.querySelector('textarea').value;
try {
const response = await fetch('/api/projects', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description })
});
const result = await response.json();
if (result) {
loadProjects();
this.reset();
}
} catch (error) {
console.error('Project creation error:', error);
}
});
// Initial Load
checkAuth();
loadProjects();
</script>
</body>
</html>

132
public/index.html Normal file
View File

@@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskIt! - Project Management</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background-color: #f4f6f9;
font-family: 'Inter', sans-serif;
}
.auth-container {
max-width: 400px;
margin: 5rem auto;
background-color: white;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
padding: 2rem;
}
.dashboard-card {
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
transition: transform 0.3s ease;
}
.dashboard-card:hover {
transform: translateY(-10px);
}
</style>
</head>
<body>
<div id="app" class="container-fluid">
<!-- Login Screen -->
<div id="loginScreen" class="auth-container text-center">
<h2 class="mb-4">TaskIt!</h2>
<form id="loginForm">
<div class="mb-3">
<input type="email" class="form-control" placeholder="Email" required>
</div>
<div class="mb-3">
<input type="password" class="form-control" placeholder="Password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
<p class="mt-3">Don't have an account? <a href="#" id="showRegister">Register</a></p>
</form>
</div>
<!-- Registration Screen -->
<div id="registerScreen" class="auth-container text-center" style="display:none;">
<h2 class="mb-4">Create Account</h2>
<form id="registerForm">
<div class="mb-3">
<input type="text" class="form-control" placeholder="Full Name" required>
</div>
<div class="mb-3">
<input type="email" class="form-control" placeholder="Email" required>
</div>
<div class="mb-3">
<input type="password" class="form-control" placeholder="Password" required>
</div>
<button type="submit" class="btn btn-success w-100">Register</button>
<p class="mt-3">Already have an account? <a href="#" id="showLogin">Login</a></p>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Simple Auth UI Toggle
document.getElementById('showRegister').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('loginScreen').style.display = 'none';
document.getElementById('registerScreen').style.display = 'block';
});
document.getElementById('showLogin').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('registerScreen').style.display = 'none';
document.getElementById('loginScreen').style.display = 'block';
});
// Authentication Handlers
document.getElementById('loginForm').addEventListener('submit', async function(e) {
e.preventDefault();
const email = this.querySelector('input[type="email"]').value;
const password = this.querySelector('input[type="password"]').value;
try {
const response = await fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
const result = await response.json();
if (result.success) {
window.location.href = '/dashboard.html';
} else {
alert(result.error);
}
} catch (error) {
console.error('Login error:', error);
}
});
document.getElementById('registerForm').addEventListener('submit', async function(e) {
e.preventDefault();
const name = this.querySelector('input[type="text"]').value;
const email = this.querySelector('input[type="email"]').value;
const password = this.querySelector('input[type="password"]').value;
try {
const response = await fetch('/api/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, email, password })
});
const result = await response.json();
if (result.success) {
window.location.href = '/dashboard.html';
} else {
alert(result.error);
}
} catch (error) {
console.error('Registration error:', error);
}
});
</script>
</body>
</html>

151
public/index.php Normal file
View File

@@ -0,0 +1,151 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../db.php';
use App\Controllers\AuthController;
use App\Controllers\ProjectController;
use App\Controllers\TaskController;
// Simple routing
$requestUri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$method = $_SERVER['REQUEST_METHOD'];
// Serve HTML files for non-API routes
if (!str_starts_with($requestUri, '/api/')) {
switch ($requestUri) {
case '/':
case '/index.html':
readfile(__DIR__ . '/index.html');
exit;
case '/dashboard.html':
readfile(__DIR__ . '/dashboard.html');
exit;
case '/project.html':
readfile(__DIR__ . '/project.html');
exit;
default:
// Try to serve static file if it exists
$filePath = __DIR__ . $requestUri;
if (file_exists($filePath) && is_file($filePath)) {
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
$mimeTypes = [
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'svg' => 'image/svg+xml',
];
if (isset($mimeTypes[$extension])) {
header('Content-Type: ' . $mimeTypes[$extension]);
}
readfile($filePath);
exit;
}
}
}
// Headers for JSON responses
header('Content-Type: application/json');
try {
switch (true) {
case $requestUri === '/api/register' && $method === 'POST':
$data = json_decode(file_get_contents('php://input'), true);
$authController = new AuthController();
echo json_encode($authController->register(
$data['name'],
$data['email'],
$data['password']
));
break;
case $requestUri === '/api/login' && $method === 'POST':
$data = json_decode(file_get_contents('php://input'), true);
$authController = new AuthController();
echo json_encode($authController->login(
$data['email'],
$data['password']
));
break;
case $requestUri === '/api/logout' && $method === 'POST':
$authController = new AuthController();
echo json_encode($authController->logout());
break;
case $requestUri === '/api/projects' && $method === 'GET':
if (!AuthController::isAuthenticated()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
break;
}
$projectController = new ProjectController();
echo json_encode($projectController->getUserProjects());
break;
case $requestUri === '/api/projects' && $method === 'POST':
if (!AuthController::isAuthenticated()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
break;
}
$data = json_decode(file_get_contents('php://input'), true);
$projectController = new ProjectController();
echo json_encode($projectController->createProject(
$data['name'],
$data['description']
));
break;
case preg_match('/^\/api\/projects\/(\d+)$/', $requestUri, $matches) && $method === 'GET':
if (!AuthController::isAuthenticated()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
break;
}
$projectController = new ProjectController();
echo json_encode($projectController->getProjectDetails($matches[1]));
break;
case $requestUri === '/api/tasks' && $method === 'POST':
if (!AuthController::isAuthenticated()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
break;
}
$data = json_decode(file_get_contents('php://input'), true);
$taskController = new TaskController();
echo json_encode($taskController->createTask(
$data['name'],
$data['description'],
$data['project_id'],
$data['status'] ?? 'created'
));
break;
case preg_match('/^\/api\/tasks\/(\d+)\/status$/', $requestUri, $matches) && $method === 'PUT':
if (!AuthController::isAuthenticated()) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
break;
}
$data = json_decode(file_get_contents('php://input'), true);
$taskController = new TaskController();
echo json_encode($taskController->updateTaskStatus(
$matches[1],
$data['status']
));
break;
default:
http_response_code(404);
echo json_encode(['error' => 'Not Found']);
break;
}
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}

162
public/project.html Normal file
View File

@@ -0,0 +1,162 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskIt! - Project Details</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background-color: #f4f6f9;
font-family: 'Inter', sans-serif;
}
.project-container {
max-width: 1200px;
margin: 2rem auto;
}
.task-card {
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
transition: transform 0.3s ease;
}
.task-card:hover {
transform: translateY(-5px);
}
.status-created { background-color: #e9ecef; color: #6c757d; }
.status-in_progress { background-color: #ffc107; color: white; }
.status-testing { background-color: #17a2b8; color: white; }
.status-complete { background-color: #28a745; color: white; }
.status-approved { background-color: #007bff; color: white; }
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="/dashboard.html">TaskIt!</a>
<button class="btn btn-outline-danger" id="logoutBtn">Logout</button>
</div>
</nav>
<div class="project-container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Create New Task</h5>
<form id="newTaskForm">
<div class="mb-3">
<input type="text" class="form-control" placeholder="Task Name" required>
</div>
<div class="mb-3">
<textarea class="form-control" placeholder="Task Description" rows="3" required></textarea>
</div>
<div class="mb-3">
<select class="form-control" required>
<option value="created">Created</option>
<option value="in_progress">In Progress</option>
<option value="testing">Testing</option>
<option value="complete">Complete</option>
<option value="approved">Approved</option>
</select>
</div>
<button type="submit" class="btn btn-primary w-100">Create Task</button>
</form>
</div>
</div>
</div>
<div class="col-md-8">
<div id="projectHeader" class="mb-4">
<h2 id="projectName"></h2>
<p id="projectDescription"></p>
</div>
<div id="taskList">
<!-- Tasks will be dynamically loaded here -->
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const urlParams = new URLSearchParams(window.location.search);
const projectId = urlParams.get('id');
// Logout Handler
document.getElementById('logoutBtn').addEventListener('click', async () => {
try {
const response = await fetch('/api/logout', { method: 'POST' });
const result = await response.json();
if (result.success) {
window.location.href = '/index.html';
}
} catch (error) {
console.error('Logout error:', error);
}
});
// Load Project Details
async function loadProjectDetails() {
try {
const response = await fetch(`/api/projects/${projectId}`);
const data = await response.json();
document.getElementById('projectName').textContent = data.project.name;
document.getElementById('projectDescription').textContent = data.project.description;
const taskList = document.getElementById('taskList');
taskList.innerHTML = data.tasks.map(task => `
<div class="card task-card mb-3">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<h5 class="card-title">${task.name}</h5>
<p class="card-text">${task.description}</p>
</div>
<div class="task-status status-${task.status} px-2 py-1 rounded">
${task.status.replace('_', ' ')}
</div>
</div>
</div>
</div>
`).join('');
} catch (error) {
console.error('Project details load error:', error);
}
}
// Create New Task
document.getElementById('newTaskForm').addEventListener('submit', async function(e) {
e.preventDefault();
const name = this.querySelector('input[type="text"]').value;
const description = this.querySelector('textarea').value;
const status = this.querySelector('select').value;
try {
const response = await fetch('/api/tasks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name,
description,
project_id: projectId,
status
})
});
const result = await response.json();
if (result) {
loadProjectDetails();
this.reset();
}
} catch (error) {
console.error('Task creation error:', error);
}
});
// Initial Load
loadProjectDetails();
</script>
</body>
</html>