Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 034bb3eb63 | |||
| 06a50880b7 | |||
| c66b57f9cb | |||
| ba30f84f49 |
22
HISTORY.md
22
HISTORY.md
@@ -5,10 +5,32 @@ Changelog
|
|||||||
(unreleased)
|
(unreleased)
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
Fix
|
||||||
|
~~~
|
||||||
|
- Some cleanup, refs NOISSUE. [Simon Diesenreiter]
|
||||||
|
|
||||||
|
|
||||||
|
0.3.4 (2026-04-04)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Fix
|
||||||
|
~~~
|
||||||
|
- Fix database init, refs NOISSUE. [Simon Diesenreiter]
|
||||||
|
|
||||||
|
Other
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
0.3.3 (2026-04-04)
|
||||||
|
------------------
|
||||||
|
|
||||||
Fix
|
Fix
|
||||||
~~~
|
~~~
|
||||||
- Fix runtime errors, refs NOISSUE. [Simon Diesenreiter]
|
- Fix runtime errors, refs NOISSUE. [Simon Diesenreiter]
|
||||||
|
|
||||||
|
Other
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
|
||||||
0.3.2 (2026-04-04)
|
0.3.2 (2026-04-04)
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"dark_mode":false}
|
||||||
@@ -1 +1 @@
|
|||||||
0.3.3
|
0.3.5
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def create_dashboard():
|
|||||||
subtitle = ui.label('Real-time Dashboard & Audit Trail Display').style('font-size: 14px; opacity: 0.9; margin-top: 5px;')
|
subtitle = ui.label('Real-time Dashboard & Audit Trail Display').style('font-size: 14px; opacity: 0.9; margin-top: 5px;')
|
||||||
|
|
||||||
# Stats grid
|
# Stats grid
|
||||||
with ui.grid(columns=4, cols=4).props('gutter=1').style('margin-top: 15px;') as stats_grid:
|
with ui.grid(columns=4).props('gutter=1').style('margin-top: 15px;') as stats_grid:
|
||||||
# Current Project
|
# Current Project
|
||||||
with ui.column().classes('text-center').style('background: rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 8px;') as card1:
|
with ui.column().classes('text-center').style('background: rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 8px;') as card1:
|
||||||
ui.label('Current Project').style('font-size: 12px; text-transform: uppercase; opacity: 0.8;')
|
ui.label('Current Project').style('font-size: 12px; text-transform: uppercase; opacity: 0.8;')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Database connection and session management."""
|
"""Database connection and session management."""
|
||||||
|
|
||||||
from sqlalchemy import create_engine, event
|
from sqlalchemy import create_engine, text
|
||||||
from sqlalchemy.orm import sessionmaker, Session
|
from sqlalchemy.orm import sessionmaker, Session
|
||||||
from config import settings
|
from config import settings
|
||||||
from models import Base
|
from models import Base
|
||||||
@@ -92,18 +92,86 @@ def get_db_session() -> Session:
|
|||||||
return session
|
return session
|
||||||
|
|
||||||
|
|
||||||
def init_db() -> None:
|
def init_db() -> dict:
|
||||||
"""Initialize database tables."""
|
"""Initialize database tables and database if needed."""
|
||||||
|
if settings.USE_SQLITE:
|
||||||
|
# SQLite - auto-creates file and tables
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
|
try:
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
print("Database tables created successfully.")
|
print("SQLite database tables created successfully.")
|
||||||
|
return {'status': 'success', 'message': 'SQLite database initialized.'}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error initializing SQLite database: {str(e)}")
|
||||||
|
return {'status': 'error', 'message': f'Error: {str(e)}'}
|
||||||
|
else:
|
||||||
|
# PostgreSQL
|
||||||
|
db_url = settings.POSTGRES_URL or settings.database_url
|
||||||
|
db_name = db_url.split('/')[-1] if '/' in db_url else 'ai_software_factory'
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Create engine to check/create database
|
||||||
|
engine = create_engine(db_url)
|
||||||
|
|
||||||
|
# Try to create database if it doesn't exist
|
||||||
|
try:
|
||||||
|
with engine.connect() as conn:
|
||||||
|
# Check if database exists
|
||||||
|
result = conn.execute(text(f"SELECT 1 FROM {db_name} WHERE 1=0"))
|
||||||
|
# If no error, database exists
|
||||||
|
conn.commit()
|
||||||
|
print(f"PostgreSQL database '{db_name}' already exists.")
|
||||||
|
except Exception as e:
|
||||||
|
# Database doesn't exist or has different error - try to create it
|
||||||
|
error_msg = str(e).lower()
|
||||||
|
# Only create if it's a relation does not exist error or similar
|
||||||
|
if "does not exist" in error_msg or "database" in error_msg:
|
||||||
|
try:
|
||||||
|
conn = engine.connect()
|
||||||
|
conn.execute(text(f"CREATE DATABASE {db_name}"))
|
||||||
|
conn.commit()
|
||||||
|
print(f"PostgreSQL database '{db_name}' created.")
|
||||||
|
except Exception as db_error:
|
||||||
|
print(f"Could not create database: {str(db_error)}")
|
||||||
|
# Try to connect anyway - maybe using existing db name
|
||||||
|
engine = create_engine(db_url.replace(f'/{db_name}', '/postgres'))
|
||||||
|
with engine.connect() as conn:
|
||||||
|
# Just create tables in postgres database for now
|
||||||
|
print(f"Using existing 'postgres' database.")
|
||||||
|
|
||||||
|
# Create tables
|
||||||
|
Base.metadata.create_all(bind=engine)
|
||||||
|
print(f"PostgreSQL database '{db_name}' tables created successfully.")
|
||||||
|
return {'status': 'success', 'message': f'PostgreSQL database "{db_name}" initialized.'}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error initializing PostgreSQL database: {str(e)}")
|
||||||
|
return {'status': 'error', 'message': f'Error: {str(e)}'}
|
||||||
|
|
||||||
|
|
||||||
def drop_db() -> None:
|
def drop_db() -> dict:
|
||||||
"""Drop all database tables (use with caution!)."""
|
"""Drop all database tables (use with caution!)."""
|
||||||
|
if settings.USE_SQLITE:
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
|
try:
|
||||||
Base.metadata.drop_all(bind=engine)
|
Base.metadata.drop_all(bind=engine)
|
||||||
print("Database tables dropped successfully.")
|
print("SQLite database tables dropped successfully.")
|
||||||
|
return {'status': 'success', 'message': 'SQLite tables dropped.'}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error dropping SQLite tables: {str(e)}")
|
||||||
|
return {'status': 'error', 'message': str(e)}
|
||||||
|
else:
|
||||||
|
db_url = settings.POSTGRES_URL or settings.database_url
|
||||||
|
db_name = db_url.split('/')[-1] if '/' in db_url else 'ai_software_factory'
|
||||||
|
|
||||||
|
try:
|
||||||
|
engine = create_engine(db_url)
|
||||||
|
Base.metadata.drop_all(bind=engine)
|
||||||
|
print(f"PostgreSQL database '{db_name}' tables dropped successfully.")
|
||||||
|
return {'status': 'success', 'message': f'PostgreSQL "{db_name}" tables dropped.'}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error dropping PostgreSQL tables: {str(e)}")
|
||||||
|
return {'status': 'error', 'message': str(e)}
|
||||||
|
|
||||||
|
|
||||||
def create_migration_script() -> str:
|
def create_migration_script() -> str:
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ def read_root():
|
|||||||
@app.post('/init-db')
|
@app.post('/init-db')
|
||||||
def initialize_database():
|
def initialize_database():
|
||||||
"""Initialize database tables (POST endpoint for NiceGUI to call before dashboard)."""
|
"""Initialize database tables (POST endpoint for NiceGUI to call before dashboard)."""
|
||||||
|
try:
|
||||||
init_db()
|
init_db()
|
||||||
return {'message': 'Database initialized successfully'}
|
return {'message': 'Database tables created successfully', 'status': 'success'}
|
||||||
|
except Exception as e:
|
||||||
|
return {'message': f'Error initializing database: {str(e)}', 'status': 'error'}
|
||||||
|
|
||||||
|
|
||||||
frontend.init(app)
|
frontend.init(app)
|
||||||
|
|||||||
@@ -1,385 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>AI Software Factory Dashboard</title>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
||||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
||||||
min-height: 100vh;
|
|
||||||
color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dashboard {
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
text-align: center;
|
|
||||||
padding: 30px;
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.header h1 {
|
|
||||||
font-size: 2.5em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
background-clip: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header p {
|
|
||||||
color: #888;
|
|
||||||
font-size: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
||||||
gap: 20px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 25px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card h3 {
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: #888;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card .value {
|
|
||||||
font-size: 2.5em;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #00d4ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card.project .value { color: #00ff88; }
|
|
||||||
.stat-card.active .value { color: #ff6b6b; }
|
|
||||||
.stat-card.code .value { color: #ffd93d; }
|
|
||||||
|
|
||||||
.status-panel {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 25px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-panel h2 {
|
|
||||||
font-size: 1.3em;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #00d4ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-bar {
|
|
||||||
height: 20px;
|
|
||||||
background: #2a2a4a;
|
|
||||||
border-radius: 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-fill {
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(90deg, #00d4ff, #00ff88);
|
|
||||||
border-radius: 10px;
|
|
||||||
transition: width 0.5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message {
|
|
||||||
padding: 10px;
|
|
||||||
background: rgba(0, 212, 255, 0.1);
|
|
||||||
border-radius: 8px;
|
|
||||||
border-left: 4px solid #00d4ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.projects-section {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 25px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.projects-section h2 {
|
|
||||||
font-size: 1.3em;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #00ff88;
|
|
||||||
}
|
|
||||||
|
|
||||||
.projects-list {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-item {
|
|
||||||
background: rgba(0, 255, 136, 0.1);
|
|
||||||
padding: 15px 20px;
|
|
||||||
border-radius: 10px;
|
|
||||||
border: 1px solid rgba(0, 255, 136, 0.3);
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-item.active {
|
|
||||||
background: rgba(255, 107, 107, 0.1);
|
|
||||||
border-color: rgba(255, 107, 107, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-section {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 25px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-section h2 {
|
|
||||||
font-size: 1.3em;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #ffd93d;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-table th, .audit-table td {
|
|
||||||
padding: 12px;
|
|
||||||
text-align: left;
|
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-table th {
|
|
||||||
color: #888;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 0.85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-table td {
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audit-table .timestamp {
|
|
||||||
color: #666;
|
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions-panel {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 25px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions-panel h2 {
|
|
||||||
font-size: 1.3em;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #ff6b6b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions-panel p {
|
|
||||||
color: #888;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading {
|
|
||||||
text-align: center;
|
|
||||||
padding: 50px;
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.stats-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.projects-list {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="dashboard">
|
|
||||||
<div class="header">
|
|
||||||
<h1>🚀 AI Software Factory</h1>
|
|
||||||
<p>Real-time Dashboard & Audit Trail Display</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="stats-grid">
|
|
||||||
<div class="stat-card project">
|
|
||||||
<h3>Current Project</h3>
|
|
||||||
<div class="value" id="project-name">Loading...</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card active">
|
|
||||||
<h3>Active Projects</h3>
|
|
||||||
<div class="value" id="active-projects">0</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card code">
|
|
||||||
<h3>Total Projects</h3>
|
|
||||||
<div class="value" id="total-projects">0</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card">
|
|
||||||
<h3>Status</h3>
|
|
||||||
<div class="value" id="status-value">Loading...</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="status-panel">
|
|
||||||
<h2>📊 Current Status</h2>
|
|
||||||
<div class="status-bar">
|
|
||||||
<div class="status-fill" id="status-fill" style="width: 0%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="message" id="status-message">Loading...</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="projects-section">
|
|
||||||
<h2>📁 Active Projects</h2>
|
|
||||||
<div class="projects-list" id="projects-list">
|
|
||||||
<div class="loading">Loading projects...</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="audit-section">
|
|
||||||
<h2>📜 Audit Trail</h2>
|
|
||||||
<table class="audit-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Timestamp</th>
|
|
||||||
<th>Agent</th>
|
|
||||||
<th>Action</th>
|
|
||||||
<th>Status</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="audit-trail-body">
|
|
||||||
<tr>
|
|
||||||
<td class="timestamp">Loading...</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>-</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="actions-panel">
|
|
||||||
<h2>⚙️ System Actions</h2>
|
|
||||||
<p id="actions-message">Dashboard is rendering successfully.</p>
|
|
||||||
<p style="color: #888; font-size: 0.9em;">This dashboard is powered by the AI Software Factory and displays real-time status updates, audit trails, and project information.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Fetch data from API
|
|
||||||
async function loadDashboardData() {
|
|
||||||
try {
|
|
||||||
// Load projects
|
|
||||||
const projectsResponse = await fetch('/projects');
|
|
||||||
const projectsData = await projectsResponse.json();
|
|
||||||
updateProjects(projectsData.projects);
|
|
||||||
|
|
||||||
// Get latest active project
|
|
||||||
const activeProject = projectsData.projects.find(p => p.status === 'RUNNING' || p.status === 'IN_PROGRESS');
|
|
||||||
|
|
||||||
if (activeProject) {
|
|
||||||
document.getElementById('project-name').textContent = activeProject.project_name || activeProject.project_id;
|
|
||||||
updateStatusPanel(activeProject);
|
|
||||||
|
|
||||||
// Load audit trail for this project
|
|
||||||
const auditResponse = await fetch(`/audit/trail?limit=10`);
|
|
||||||
const auditData = await auditResponse.json();
|
|
||||||
updateAuditTrail(auditData.audit_trail);
|
|
||||||
} else {
|
|
||||||
// No active project, show all projects
|
|
||||||
document.getElementById('projects-list').innerHTML = projectsData.projects.map(p =>
|
|
||||||
`<div class="project-item ${p.status === 'RUNNING' || p.status === 'IN_PROGRESS' ? 'active' : ''}">
|
|
||||||
<strong>${p.project_name || p.project_id}</strong> • ${p.status} • ${p.progress || 0}%
|
|
||||||
</div>`
|
|
||||||
).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error loading dashboard data:', error);
|
|
||||||
document.getElementById('status-message').innerHTML =
|
|
||||||
`<strong>Error:</strong> Failed to load dashboard data. Please check the console for details.`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateProjects(projects) {
|
|
||||||
const activeProjects = projects.filter(p => p.status === 'RUNNING' || p.status === 'IN_PROGRESS' || p.status === 'COMPLETED').length;
|
|
||||||
document.getElementById('active-projects').textContent = activeProjects;
|
|
||||||
document.getElementById('total-projects').textContent = projects.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateStatusPanel(project) {
|
|
||||||
const progress = project.progress || 0;
|
|
||||||
document.getElementById('status-fill').style.width = progress + '%';
|
|
||||||
document.getElementById('status-message').innerHTML =
|
|
||||||
`<strong>${project.message || 'Project running...'}</strong><br>` +
|
|
||||||
`<span style="color: #888;">Progress: ${progress}%</span>`;
|
|
||||||
document.getElementById('status-value').textContent = project.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateAuditTrail(auditEntries) {
|
|
||||||
if (auditEntries.length === 0) {
|
|
||||||
document.getElementById('audit-trail-body').innerHTML =
|
|
||||||
`<tr><td colspan="4" style="text-align: center; color: #888;">No audit entries yet</td></tr>`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedEntries = auditEntries.map(entry => ({
|
|
||||||
...entry,
|
|
||||||
timestamp: entry.timestamp ? new Date(entry.timestamp).toLocaleString() : '-'
|
|
||||||
}));
|
|
||||||
|
|
||||||
document.getElementById('audit-trail-body').innerHTML = formattedEntries.map(entry => `
|
|
||||||
<tr>
|
|
||||||
<td class="timestamp">${entry.timestamp}</td>
|
|
||||||
<td>${entry.actor || '-'}</td>
|
|
||||||
<td>${entry.action || entry.details || '-'}</td>
|
|
||||||
<td style="color: ${getStatusColor(entry.action_type || entry.status)};">${entry.action_type || entry.status || '-'}</td>
|
|
||||||
</tr>
|
|
||||||
`).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStatusColor(status) {
|
|
||||||
if (!status) return '#888';
|
|
||||||
const upper = status.toUpperCase();
|
|
||||||
if (['SUCCESS', 'COMPLETED', 'FINISHED'].includes(upper)) return '#00ff88';
|
|
||||||
if (['IN_PROGRESS', 'RUNNING', 'PENDING'].includes(upper)) return '#00d4ff';
|
|
||||||
if (['ERROR', 'FAILED', 'FAILED'].includes(upper)) return '#ff6b6b';
|
|
||||||
return '#888';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load data when dashboard is ready
|
|
||||||
loadDashboardData();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user