375 lines
17 KiB
PHP
375 lines
17 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Project Details</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #2a3f54;
|
|
--secondary-color: #73879C;
|
|
--background-color: #F7F7F7;
|
|
--surface-color: #FFFFFF;
|
|
--accent-color: #1ABB9C;
|
|
}
|
|
body {
|
|
display: flex;
|
|
background-color: var(--background-color);
|
|
font-family: "Helvetica Neue", Roboto, Arial, sans-serif;
|
|
}
|
|
.sidebar {
|
|
width: 250px;
|
|
height: 100vh;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
background-color: var(--primary-color);
|
|
color: #ECF0F1;
|
|
padding-top: 20px;
|
|
}
|
|
.sidebar h3 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
font-weight: bold;
|
|
}
|
|
.sidebar .nav-link {
|
|
color: #ECF0F1;
|
|
padding: 10px 20px;
|
|
transition: background-color 0.3s;
|
|
}
|
|
.sidebar .nav-link:hover, .sidebar .nav-link.active {
|
|
background-color: var(--accent-color);
|
|
color: var(--surface-color);
|
|
}
|
|
.sidebar .nav-link .fa {
|
|
margin-right: 10px;
|
|
}
|
|
.main-content {
|
|
margin-left: 250px;
|
|
padding: 20px;
|
|
width: calc(100% - 250px);
|
|
}
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
.header h1 {
|
|
font-weight: bold;
|
|
color: var(--primary-color);
|
|
}
|
|
.card {
|
|
border: none;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
margin-bottom: 20px;
|
|
}
|
|
.filter-input {
|
|
margin-bottom: 5px;
|
|
font-size: 0.85rem;
|
|
}
|
|
.sort-indicator {
|
|
cursor: pointer;
|
|
user-select: none;
|
|
font-weight: bold;
|
|
color: var(--primary-color);
|
|
display: inline-block;
|
|
margin-left: 5px;
|
|
}
|
|
.sort-indicator:hover {
|
|
color: var(--accent-color);
|
|
}
|
|
.sort-asc::after {
|
|
content: " ↑";
|
|
}
|
|
.sort-desc::after {
|
|
content: " ↓";
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="sidebar">
|
|
<h3><i class="fa fa-flask"></i> LWM</h3>
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item">
|
|
<hr>
|
|
<a href="index.php" class="nav-link"><i class="fa fa-tasks"></i> Projects</a>
|
|
<a href="users.php" class="nav-link"><i class="fa fa-users"></i> User Management</a>
|
|
<a href="#" class="nav-link"><i class="fa fa-cogs"></i> Settings</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<?php
|
|
require_once 'db/config.php';
|
|
$project = null;
|
|
if (isset($_GET['id'])) {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM Project WHERE project_id = ?");
|
|
$stmt->execute([$_GET['id']]);
|
|
$project = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
|
|
}
|
|
}
|
|
|
|
if ($project):
|
|
// Fetch all candidates for this project
|
|
$candidates = [];
|
|
try {
|
|
$stmt_candidates = $pdo->prepare("SELECT candidate_id, run_id, smiles_id, estimated_cost, generated_time, synthesis_approved, status FROM Candidate WHERE project_id = ? ORDER BY generated_time DESC");
|
|
$stmt_candidates->execute([$_GET['id']]);
|
|
$candidates = $stmt_candidates->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
// Error will be handled in display
|
|
}
|
|
?>
|
|
<div class="header">
|
|
<h1>Project: <?php echo htmlspecialchars($project['name']); ?></h1>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Project Details</h5>
|
|
<p><strong>ID:</strong> <?php echo htmlspecialchars($project['project_id']); ?></p>
|
|
<p><strong>Description:</strong> <?php echo htmlspecialchars($project['description']); ?></p>
|
|
<p><strong>Start Date:</strong> <?php echo htmlspecialchars($project['Start Date']); ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Candidates</h5>
|
|
<?php if (count($candidates) > 0): ?>
|
|
<div class="table-responsive">
|
|
<table id="candidatesTable" class="table table-hover table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Candidate ID" data-column="0">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Run ID" data-column="1">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter SMILES ID" data-column="2">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Cost" data-column="3">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Generated Time" data-column="4">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Synthesis Approved" data-column="5">
|
|
</th>
|
|
<th>
|
|
<input type="text" class="form-control form-control-sm filter-input" placeholder="Filter Status" data-column="6">
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<th>Candidate ID <span class="sort-indicator" data-column="0">↕</span></th>
|
|
<th>Run ID <span class="sort-indicator" data-column="1">↕</span></th>
|
|
<th>SMILES ID <span class="sort-indicator" data-column="2">↕</span></th>
|
|
<th>Estimated Cost <span class="sort-indicator" data-column="3">↕</span></th>
|
|
<th>Generated Time <span class="sort-indicator" data-column="4">↕</span></th>
|
|
<th>Synthesis Approved <span class="sort-indicator" data-column="5">↕</span></th>
|
|
<th>Status <span class="sort-indicator" data-column="6">↕</span></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($candidates as $candidate): ?>
|
|
<tr>
|
|
<td><a href="candidate.php?id=<?php echo urlencode($candidate['candidate_id']); ?>"><?php echo htmlspecialchars($candidate['candidate_id']); ?></a></td>
|
|
<td><?php echo htmlspecialchars($candidate['run_id']); ?></td>
|
|
<td><?php echo htmlspecialchars($candidate['smiles_id']); ?></td>
|
|
<td><?php echo htmlspecialchars($candidate['estimated_cost']); ?></td>
|
|
<td><?php echo htmlspecialchars($candidate['generated_time']); ?></td>
|
|
<td><?php echo htmlspecialchars($candidate['synthesis_approved']); ?></td>
|
|
<td><?php echo htmlspecialchars($candidate['status']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<p class="text-muted">No candidates found for this project.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Generation Runs</h5>
|
|
<?php
|
|
try {
|
|
$stmt_runs = $pdo->prepare("
|
|
SELECT
|
|
gr.run_id,
|
|
gr.repository,
|
|
gr.rounds,
|
|
gr.status,
|
|
gr.run_start,
|
|
gr.run_end,
|
|
COUNT(c.candidate_id) AS candidate_count
|
|
FROM
|
|
Generation_Run gr
|
|
LEFT JOIN
|
|
Candidate c ON gr.run_id = c.run_id
|
|
WHERE
|
|
gr.project_id = ?
|
|
GROUP BY
|
|
gr.run_id
|
|
ORDER BY
|
|
gr.run_start DESC
|
|
");
|
|
$stmt_runs->execute([$_GET['id']]);
|
|
$runs = $stmt_runs->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (count($runs) > 0) {
|
|
echo '<div class="table-responsive"><table class="table table-hover"><thead><tr><th>Run ID</th><th>Repository</th><th>Rounds</th><th>Status</th><th>Start Time</th><th>End Time</th><th>Candidates</th><th></th></tr></thead><tbody>';
|
|
foreach ($runs as $run) {
|
|
echo "<tr>";
|
|
echo "<td>" . htmlspecialchars($run['run_id']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['repository']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['rounds']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['status']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['run_start']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['run_end']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($run['candidate_count']) . "</td>";
|
|
echo "<td><button class='btn btn-sm btn-info' data-bs-toggle='collapse' data-bs-target='#candidates-" . $run['run_id'] . "'>View Candidates</button></td>";
|
|
echo "</tr>";
|
|
echo "<tr class='collapse' id='candidates-" . $run['run_id'] . "'><td colspan='8'>";
|
|
// Candidate table will go here
|
|
try {
|
|
$stmt_candidates = $pdo->prepare("SELECT candidate_id, smiles_id, estimated_cost, status FROM Candidate WHERE run_id = ?");
|
|
$stmt_candidates->execute([$run['run_id']]);
|
|
$candidates = $stmt_candidates->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (count($candidates) > 0) {
|
|
echo '<table class="table table-sm table-bordered"><thead><tr><th>Candidate ID</th><th>SMILES ID</th><th>Est. Cost</th><th>Status</th></tr></thead><tbody>';
|
|
foreach ($candidates as $candidate) {
|
|
echo "<tr>";
|
|
echo "<td><a href='candidate.php?id=" . urlencode($candidate['candidate_id']) . "'>" . htmlspecialchars($candidate['candidate_id']) . "</a></td>";
|
|
echo "<td>" . htmlspecialchars($candidate['smiles_id']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($candidate['estimated_cost']) . "</td>";
|
|
echo "<td>" . htmlspecialchars($candidate['status']) . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo '</tbody></table>';
|
|
} else {
|
|
echo '<p class="text-muted">No candidates found for this run.</p>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger">Database error fetching candidates: ' . $e->getMessage() . '</div>';
|
|
}
|
|
echo "</td></tr>";
|
|
}
|
|
echo '</tbody></table></div>';
|
|
} else {
|
|
echo '<p>No generation runs found for this project.</p>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger">Database error fetching generation runs: ' . $e->getMessage() . '</div>';
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="alert alert-warning">Project not found or ID not provided.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
(function() {
|
|
const table = document.getElementById('candidatesTable');
|
|
if (!table) return;
|
|
|
|
const tbody = table.querySelector('tbody');
|
|
const filterInputs = table.querySelectorAll('.filter-input');
|
|
const sortIndicators = table.querySelectorAll('.sort-indicator');
|
|
let currentSort = { column: null, direction: 'asc' };
|
|
let rows = Array.from(tbody.querySelectorAll('tr'));
|
|
|
|
// Filter function
|
|
function filterTable() {
|
|
const filters = Array.from(filterInputs).map(input => input.value.toLowerCase());
|
|
|
|
rows.forEach(row => {
|
|
const cells = row.querySelectorAll('td');
|
|
let show = true;
|
|
|
|
filters.forEach((filter, index) => {
|
|
if (filter && cells[index]) {
|
|
const cellText = cells[index].textContent.toLowerCase();
|
|
if (!cellText.includes(filter)) {
|
|
show = false;
|
|
}
|
|
}
|
|
});
|
|
|
|
row.style.display = show ? '' : 'none';
|
|
});
|
|
}
|
|
|
|
// Sort function
|
|
function sortTable(columnIndex, direction) {
|
|
const visibleRows = rows.filter(row => row.style.display !== 'none');
|
|
|
|
visibleRows.sort((a, b) => {
|
|
const aText = a.querySelectorAll('td')[columnIndex]?.textContent.trim() || '';
|
|
const bText = b.querySelectorAll('td')[columnIndex]?.textContent.trim() || '';
|
|
|
|
// Try to parse as number
|
|
const aNum = parseFloat(aText);
|
|
const bNum = parseFloat(bText);
|
|
|
|
let comparison = 0;
|
|
if (!isNaN(aNum) && !isNaN(bNum)) {
|
|
comparison = aNum - bNum;
|
|
} else {
|
|
comparison = aText.localeCompare(bText);
|
|
}
|
|
|
|
return direction === 'asc' ? comparison : -comparison;
|
|
});
|
|
|
|
// Clear tbody and re-append sorted rows
|
|
tbody.innerHTML = '';
|
|
visibleRows.forEach(row => tbody.appendChild(row));
|
|
|
|
// Update sort indicators
|
|
sortIndicators.forEach((indicator, index) => {
|
|
indicator.textContent = '↕';
|
|
indicator.classList.remove('sort-asc', 'sort-desc');
|
|
if (index === columnIndex) {
|
|
indicator.classList.add(direction === 'asc' ? 'sort-asc' : 'sort-desc');
|
|
}
|
|
});
|
|
|
|
currentSort = { column: columnIndex, direction: direction };
|
|
}
|
|
|
|
// Add filter event listeners
|
|
filterInputs.forEach(input => {
|
|
input.addEventListener('input', filterTable);
|
|
});
|
|
|
|
// Add sort event listeners
|
|
sortIndicators.forEach((indicator, index) => {
|
|
indicator.addEventListener('click', () => {
|
|
const direction = currentSort.column === index && currentSort.direction === 'asc' ? 'desc' : 'asc';
|
|
sortTable(index, direction);
|
|
});
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|