test
This commit is contained in:
parent
6a1cddbb47
commit
0fa627ca6d
18 changed files with 6192 additions and 0 deletions
149
frontend/src/main.js
Normal file
149
frontend/src/main.js
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
const API_URL = 'http://localhost:3000';
|
||||
|
||||
const state = {
|
||||
tasks: [],
|
||||
selectedTaskId: null,
|
||||
};
|
||||
|
||||
// DOM elements
|
||||
const taskListEl = document.getElementById('task-list');
|
||||
const newTaskBtn = document.getElementById('new-task-btn');
|
||||
const modalContainer = document.getElementById('modal-container');
|
||||
const newTaskForm = document.getElementById('new-task-form');
|
||||
const cancelTaskBtn = document.getElementById('cancel-task');
|
||||
const emptyStateEl = document.getElementById('empty-state');
|
||||
const taskViewEl = document.getElementById('task-view');
|
||||
const logsOutputEl = document.getElementById('logs-output');
|
||||
const viewGoalEl = document.getElementById('view-goal');
|
||||
const viewStatusEl = document.getElementById('view-status');
|
||||
const viewDateEl = document.getElementById('view-date');
|
||||
const answerContainerEl = document.getElementById('answer-container');
|
||||
const answerOutputEl = document.getElementById('answer-output');
|
||||
|
||||
async function fetchTasks() {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/tasks`);
|
||||
state.tasks = await response.json();
|
||||
renderTaskList();
|
||||
|
||||
// Update current view if a task is selected
|
||||
if (state.selectedTaskId) {
|
||||
const task = state.tasks.find(t => t.id === state.selectedTaskId);
|
||||
if (task) {
|
||||
showTaskView(task);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching tasks:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function renderTaskList() {
|
||||
taskListEl.innerHTML = state.tasks
|
||||
.map(
|
||||
(task) => `
|
||||
<li class="task-item ${state.selectedTaskId === task.id ? 'active' : ''}" data-id="${task.id}">
|
||||
<div class="task-item-title">${task.goal}</div>
|
||||
<div class="task-item-meta">
|
||||
<span class="status-dot ${task.status}"></span>
|
||||
<span>${new Date(task.created_at).toLocaleDateString()}</span>
|
||||
</div>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
.join('');
|
||||
|
||||
// Add event listeners
|
||||
document.querySelectorAll('.task-item').forEach((item) => {
|
||||
item.addEventListener('click', () => {
|
||||
selectTask(item.dataset.id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function selectTask(id) {
|
||||
state.selectedTaskId = id;
|
||||
const task = state.tasks.find((t) => t.id === id);
|
||||
if (!task) return;
|
||||
|
||||
renderTaskList();
|
||||
showTaskView(task);
|
||||
}
|
||||
|
||||
function showTaskView(task) {
|
||||
emptyStateEl.classList.add('hidden');
|
||||
taskViewEl.classList.remove('hidden');
|
||||
|
||||
viewGoalEl.textContent = task.goal;
|
||||
viewStatusEl.textContent = task.status;
|
||||
viewStatusEl.className = `status-badge ${task.status}`;
|
||||
viewDateEl.textContent = new Date(task.created_at).toLocaleDateString(undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
});
|
||||
|
||||
if (task.answer) {
|
||||
answerContainerEl.classList.remove('hidden');
|
||||
answerOutputEl.textContent = task.answer;
|
||||
} else {
|
||||
answerContainerEl.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Check if we should auto-scroll
|
||||
const isAtBottom = logsOutputEl.scrollHeight - logsOutputEl.scrollTop <= logsOutputEl.clientHeight + 10;
|
||||
const isFirstLoad = logsOutputEl.innerHTML === '';
|
||||
|
||||
// Simple log format
|
||||
logsOutputEl.innerHTML = task.logs
|
||||
.split('\n')
|
||||
.map((line) => `<div class="log-entry">${escapeHtml(line)}</div>`)
|
||||
.join('');
|
||||
|
||||
if (isAtBottom || isFirstLoad) {
|
||||
logsOutputEl.scrollTop = logsOutputEl.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// Event Listeners
|
||||
newTaskBtn.addEventListener('click', () => {
|
||||
modalContainer.classList.remove('hidden');
|
||||
});
|
||||
|
||||
cancelTaskBtn.addEventListener('click', () => {
|
||||
modalContainer.classList.add('hidden');
|
||||
});
|
||||
|
||||
newTaskForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(newTaskForm);
|
||||
const goal = formData.get('goal');
|
||||
|
||||
modalContainer.classList.add('hidden');
|
||||
newTaskForm.reset();
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/tasks`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ goal }),
|
||||
});
|
||||
const newTask = await response.json();
|
||||
state.tasks.unshift(newTask);
|
||||
selectTask(newTask.id);
|
||||
} catch (error) {
|
||||
console.error('Error creating task:', error);
|
||||
alert('Failed to execute task. Check console.');
|
||||
}
|
||||
});
|
||||
|
||||
// Initial load
|
||||
fetchTasks();
|
||||
// Poll for updates every 5 seconds (simplistic for now)
|
||||
setInterval(fetchTasks, 5000);
|
||||
373
frontend/src/style.css
Normal file
373
frontend/src/style.css
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
:root {
|
||||
--bg-dark: #0a0a0c;
|
||||
--bg-sidebar: #121216;
|
||||
--primary: #5d5dff;
|
||||
--primary-glow: rgba(93, 93, 255, 0.4);
|
||||
--text-main: #e0e0e6;
|
||||
--text-dim: #9494a5;
|
||||
--glass-bg: rgba(255, 255, 255, 0.03);
|
||||
--glass-border: rgba(255, 255, 255, 0.08);
|
||||
--status-running: #4dabf7;
|
||||
--status-completed: #51cf66;
|
||||
--status-failed: #ff6b6b;
|
||||
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
background-color: var(--bg-dark);
|
||||
color: var(--text-main);
|
||||
line-height: 1.5;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#app {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--glass-border);
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
width: 320px;
|
||||
background: var(--bg-sidebar);
|
||||
border-right: 1px solid var(--glass-border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 24px;
|
||||
border-bottom: 1px solid var(--glass-border);
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
font-size: 24px;
|
||||
color: var(--primary);
|
||||
text-shadow: 0 0 10px var(--primary-glow);
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.task-nav {
|
||||
flex: 1;
|
||||
padding: 24px 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
color: var(--text-dim);
|
||||
margin-bottom: 12px;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
#task-list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 4px;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.task-item:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.task-item.active {
|
||||
background: rgba(93, 93, 255, 0.1);
|
||||
border-left: 3px solid var(--primary);
|
||||
}
|
||||
|
||||
.task-item-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.task-item-meta {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main-content {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
background: radial-gradient(circle at 50% 50%, #1a1a24 0%, #0a0a0c 100%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 64px;
|
||||
color: var(--text-dim);
|
||||
opacity: 0.3;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.task-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 48px;
|
||||
}
|
||||
|
||||
.view-header {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.header-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 4px 12px;
|
||||
border-radius: 100px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-badge.running {
|
||||
background: rgba(77, 171, 247, 0.1);
|
||||
color: var(--status-running);
|
||||
border: 1px solid rgba(77, 171, 247, 0.2);
|
||||
}
|
||||
|
||||
.status-badge.completed {
|
||||
background: rgba(81, 207, 102, 0.1);
|
||||
color: var(--status-completed);
|
||||
border: 1px solid rgba(81, 207, 102, 0.2);
|
||||
}
|
||||
|
||||
.logs-container {
|
||||
flex: 1;
|
||||
min-height: 200px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.logs-header {
|
||||
padding: 16px 24px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
border-bottom: 1px solid var(--glass-border);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logs-header h3 {
|
||||
font-size: 14px;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.logs-output {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
overflow-y: auto;
|
||||
color: #c9c9d1;
|
||||
}
|
||||
|
||||
.log-entry {
|
||||
margin-bottom: 4px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* Answer Section */
|
||||
.answer-container {
|
||||
margin-bottom: 32px;
|
||||
border-radius: 12px;
|
||||
border-left: 4px solid var(--primary);
|
||||
background: linear-gradient(to right, rgba(93, 93, 255, 0.05), transparent);
|
||||
max-height: 40vh;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.answer-header {
|
||||
padding: 16px 24px;
|
||||
border-bottom: 1px solid var(--glass-border);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: var(--bg-dark);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.answer-header h3 {
|
||||
font-size: 14px;
|
||||
color: var(--primary);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.answer-output {
|
||||
padding: 24px;
|
||||
font-size: 16px;
|
||||
line-height: 1.7;
|
||||
color: var(--text-main);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
transition: var(--transition);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
box-shadow: 0 4px 14px 0 rgba(93, 93, 255, 0.39);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 6px 20px rgba(93, 93, 255, 0.45);
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.btn-ghost:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.modal {
|
||||
width: 500px;
|
||||
padding: 32px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.modal h2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.modal p {
|
||||
color: var(--text-dim);
|
||||
margin-bottom: 24px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
color: var(--text-main);
|
||||
font-family: inherit;
|
||||
margin-bottom: 24px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--glass-border);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-dim);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue