Implementing an RPC monitoring solution with a web-ui as implementation example. (#244)
* bd sync: 2025-10-30 12:12:27 * Working on frontend * bd sync: 2025-11-06 16:55:55 * feat: finish bd monitor human viewer * Merge conflicts resolved and added tests * bd sync: 2025-11-06 17:23:41 * bd sync: 2025-11-06 17:34:52 * feat: Add reload button and multiselect status filter to monitor - Changed status filter from single select to multiselect with 'Open' selected by default - Added reload button with visual feedback (hover/active states) - Updated filterIssues() to handle multiple selected statuses - Added reloadData() function that reloads both stats and issues - Improved responsive design for mobile devices - Filter controls now use flexbox layout with better spacing * fix: Update monitor statistics to show Total, In Progress, Open, Closed - Replaced 'Ready to Work' stat with 'In Progress' stat - Reordered stats to show logical progression: Total -> In Progress -> Open -> Closed - Updated loadStats() to fetch in-progress count from stats API - Removed unnecessary separate API call for ready count * fix: Correct API field names in monitor stats JavaScript The JavaScript was using incorrect field names (stats.total, stats.by_status) that don't match the actual types.Statistics struct which uses flat fields with underscores (total_issues, in_progress_issues, etc). Fixed by updating loadStats() to use correct field names: - stats.total -> stats.total_issues - stats.by_status?.['in-progress'] -> stats.in_progress_issues - stats.by_status?.open -> stats.open_issues - stats.by_status?.closed -> stats.closed_issues Fixes beads-9 * bd sync: 2025-11-06 17:51:24 * bd sync: 2025-11-06 17:56:09 * fix: Make monitor require daemon to prevent SQLite locking Implemented Option 1 from beads-eel: monitor now requires daemon and never opens direct SQLite connection. Changes: - Added 'monitor' to noDbCommands list in main.go to skip normal DB initialization - Added validateDaemonForMonitor() PreRun function that: - Finds database path using beads.FindDatabasePath() - Validates daemon is running and healthy - Fails gracefully with clear error message if no daemon - Only uses RPC connection, never opens SQLite directly Benefits: - Eliminates SQLite locking conflicts between monitor and daemon - Users can now close/update issues via CLI while monitor runs - Clear error messages guide users to start daemon first Fixes beads-eel * bd sync: 2025-11-06 18:03:50 * docs: Add bd daemons restart subcommand documentation Added documentation for the 'bd daemons restart' subcommand across all documentation files: - commands/daemons.md: Added full restart subcommand section with synopsis, description, arguments, flags, and examples - README.md: Added restart examples to daemon management section - AGENTS.md: Added restart examples with --json flag for agents The restart command gracefully stops and starts a specific daemon by workspace path or PID, useful after upgrading bd or when a daemon needs refreshing. Fixes beads-11 * bd sync: 2025-11-06 18:13:16 * Separated the web ui from the general monitoring functionality --------- Co-authored-by: Steve Yegge <stevey@sourcegraph.com>
This commit is contained in:
108
examples/monitor-webui/web/index.html
Normal file
108
examples/monitor-webui/web/index.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>bd monitor - Issue Tracker</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.min.css">
|
||||
<link rel="stylesheet" href="/static/css/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="loading-overlay" id="loading-overlay">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div>
|
||||
<h1>bd monitor</h1>
|
||||
<p>Real-time issue tracking dashboard</p>
|
||||
</div>
|
||||
<div class="connection-status disconnected" id="connection-status">
|
||||
<span class="connection-dot disconnected" id="connection-dot"></span>
|
||||
<span id="connection-text">Connecting...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="error-message" id="error-message"></div>
|
||||
|
||||
<div class="stats">
|
||||
<h2>Statistics</h2>
|
||||
<div class="stats-grid" id="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" id="stat-total">-</div>
|
||||
<div class="stat-label">Total Issues</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" id="stat-in-progress">-</div>
|
||||
<div class="stat-label">In Progress</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" id="stat-open">-</div>
|
||||
<div class="stat-label">Open</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" id="stat-closed">-</div>
|
||||
<div class="stat-label">Closed</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-controls">
|
||||
<label>
|
||||
Status (multi-select):
|
||||
<select id="filter-status" multiple>
|
||||
<option value="open" selected>Open</option>
|
||||
<option value="in-progress">In Progress</option>
|
||||
<option value="closed">Closed</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Priority:
|
||||
<select id="filter-priority">
|
||||
<option value="">All</option>
|
||||
<option value="1">P1</option>
|
||||
<option value="2">P2</option>
|
||||
<option value="3">P3</option>
|
||||
</select>
|
||||
</label>
|
||||
<button class="reload-button" id="reload-button" title="Reload all data">
|
||||
🔄 Reload
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h2>Issues</h2>
|
||||
<table id="issues-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Title</th>
|
||||
<th>Status</th>
|
||||
<th>Priority</th>
|
||||
<th>Type</th>
|
||||
<th>Assignee</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="issues-tbody">
|
||||
<tr><td colspan="6"><div class="spinner"></div></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Mobile card view -->
|
||||
<div class="issues-card-view" id="issues-card-view">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
|
||||
<!-- Modal for issue details -->
|
||||
<div id="issue-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<span class="close">×</span>
|
||||
<h2 id="modal-title">Issue Details</h2>
|
||||
<div id="modal-body">
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
222
examples/monitor-webui/web/static/css/styles.css
Normal file
222
examples/monitor-webui/web/static/css/styles.css
Normal file
@@ -0,0 +1,222 @@
|
||||
body { padding: 2rem; }
|
||||
.header {
|
||||
margin-bottom: 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.connection-status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 0.4rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.connection-status.connected {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
.connection-status.disconnected {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
.connection-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.connection-dot.connected {
|
||||
background: #28a745;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
.connection-dot.disconnected {
|
||||
background: #dc3545;
|
||||
}
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
.stats { margin-bottom: 2rem; }
|
||||
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
|
||||
.stat-card { padding: 1rem; background: #f4f5f6; border-radius: 0.4rem; }
|
||||
.stat-value { font-size: 2.4rem; font-weight: bold; color: #9b4dca; }
|
||||
.stat-label { font-size: 1.2rem; color: #606c76; }
|
||||
|
||||
/* Loading spinner */
|
||||
.spinner {
|
||||
border: 3px solid #f3f3f3;
|
||||
border-top: 3px solid #9b4dca;
|
||||
border-radius: 50%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 2rem auto;
|
||||
}
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
.loading-overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
z-index: 999;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.loading-overlay.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Error message */
|
||||
.error-message {
|
||||
display: none;
|
||||
padding: 1rem;
|
||||
margin: 1rem 0;
|
||||
background: #f8d7da;
|
||||
border: 1px solid #f5c6cb;
|
||||
border-radius: 0.4rem;
|
||||
color: #721c24;
|
||||
}
|
||||
.error-message.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 4rem 2rem;
|
||||
color: #606c76;
|
||||
}
|
||||
.empty-state-icon {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* Table styles */
|
||||
table { width: 100%; }
|
||||
tbody tr { cursor: pointer; }
|
||||
tbody tr:hover { background: #f4f5f6; }
|
||||
.status-open { color: #0074d9; }
|
||||
.status-closed { color: #2ecc40; }
|
||||
.status-in-progress { color: #ff851b; }
|
||||
.priority-1 { color: #ff4136; font-weight: bold; }
|
||||
.priority-2 { color: #ff851b; }
|
||||
.priority-3 { color: #ffdc00; }
|
||||
|
||||
/* Modal styles */
|
||||
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); }
|
||||
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 2rem; border-radius: 0.4rem; width: 80%; max-width: 800px; }
|
||||
.close { color: #aaa; float: right; font-size: 2.8rem; font-weight: bold; line-height: 2rem; cursor: pointer; }
|
||||
.close:hover, .close:focus { color: #000; }
|
||||
|
||||
.filter-controls {
|
||||
margin-bottom: 2rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
align-items: flex-end;
|
||||
}
|
||||
.filter-controls label {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.filter-controls select { margin-right: 0; }
|
||||
.filter-controls select[multiple] {
|
||||
height: auto;
|
||||
min-height: 100px;
|
||||
}
|
||||
.reload-button {
|
||||
padding: 0.6rem 1.2rem;
|
||||
background: #9b4dca;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 0.4rem;
|
||||
cursor: pointer;
|
||||
font-size: 1.4rem;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.reload-button:hover {
|
||||
background: #8b3dba;
|
||||
}
|
||||
.reload-button:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
/* Responsive design for mobile */
|
||||
@media screen and (max-width: 768px) {
|
||||
body { padding: 1rem; }
|
||||
.header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.connection-status {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.filter-controls {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
.filter-controls label {
|
||||
width: 100%;
|
||||
}
|
||||
.filter-controls select {
|
||||
width: 100%;
|
||||
}
|
||||
.reload-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Hide table, show card view on mobile */
|
||||
table { display: none; }
|
||||
.issues-card-view { display: block; }
|
||||
|
||||
.issue-card {
|
||||
background: #fff;
|
||||
border: 1px solid #d1d1d1;
|
||||
border-radius: 0.4rem;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.2s;
|
||||
}
|
||||
.issue-card:hover {
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
.issue-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: start;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.issue-card-id {
|
||||
font-weight: bold;
|
||||
color: #9b4dca;
|
||||
}
|
||||
.issue-card-title {
|
||||
font-size: 1.6rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
.issue-card-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.modal-content {
|
||||
width: 95%;
|
||||
margin: 10% auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 769px) {
|
||||
.issues-card-view { display: none; }
|
||||
}
|
||||
248
examples/monitor-webui/web/static/js/app.js
Normal file
248
examples/monitor-webui/web/static/js/app.js
Normal file
@@ -0,0 +1,248 @@
|
||||
let allIssues = [];
|
||||
let ws = null;
|
||||
let wsConnected = false;
|
||||
|
||||
// WebSocket connection
|
||||
function connectWebSocket() {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = protocol + '//' + window.location.host + '/ws';
|
||||
|
||||
ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = function() {
|
||||
console.log('WebSocket connected');
|
||||
wsConnected = true;
|
||||
updateConnectionStatus(true);
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
console.log('WebSocket message:', event.data);
|
||||
const mutation = JSON.parse(event.data);
|
||||
handleMutation(mutation);
|
||||
};
|
||||
|
||||
ws.onerror = function(error) {
|
||||
console.error('WebSocket error:', error);
|
||||
wsConnected = false;
|
||||
updateConnectionStatus(false);
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
console.log('WebSocket disconnected');
|
||||
wsConnected = false;
|
||||
updateConnectionStatus(false);
|
||||
// Reconnect after 5 seconds
|
||||
setTimeout(connectWebSocket, 5000);
|
||||
};
|
||||
}
|
||||
|
||||
// Update connection status indicator
|
||||
function updateConnectionStatus(connected) {
|
||||
const statusEl = document.getElementById('connection-status');
|
||||
const dotEl = document.getElementById('connection-dot');
|
||||
const textEl = document.getElementById('connection-text');
|
||||
|
||||
if (connected) {
|
||||
statusEl.className = 'connection-status connected';
|
||||
dotEl.className = 'connection-dot connected';
|
||||
textEl.textContent = 'Connected';
|
||||
} else {
|
||||
statusEl.className = 'connection-status disconnected';
|
||||
dotEl.className = 'connection-dot disconnected';
|
||||
textEl.textContent = 'Disconnected';
|
||||
}
|
||||
}
|
||||
|
||||
// Show/hide loading overlay
|
||||
function setLoading(isLoading) {
|
||||
const overlay = document.getElementById('loading-overlay');
|
||||
if (isLoading) {
|
||||
overlay.classList.add('active');
|
||||
} else {
|
||||
overlay.classList.remove('active');
|
||||
}
|
||||
}
|
||||
|
||||
// Show error message
|
||||
function showError(message) {
|
||||
const errorEl = document.getElementById('error-message');
|
||||
errorEl.textContent = message;
|
||||
errorEl.classList.add('active');
|
||||
setTimeout(() => {
|
||||
errorEl.classList.remove('active');
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Handle mutation event
|
||||
function handleMutation(mutation) {
|
||||
console.log('Mutation:', mutation.type, mutation.issue_id);
|
||||
// Refresh data on mutation
|
||||
loadStats();
|
||||
loadIssues();
|
||||
}
|
||||
|
||||
// Load statistics
|
||||
async function loadStats() {
|
||||
try {
|
||||
const response = await fetch('/api/stats');
|
||||
if (!response.ok) throw new Error('Failed to load statistics');
|
||||
const stats = await response.json();
|
||||
document.getElementById('stat-total').textContent = stats.total_issues || 0;
|
||||
document.getElementById('stat-in-progress').textContent = stats.in_progress_issues || 0;
|
||||
document.getElementById('stat-open').textContent = stats.open_issues || 0;
|
||||
document.getElementById('stat-closed').textContent = stats.closed_issues || 0;
|
||||
} catch (error) {
|
||||
console.error('Error loading statistics:', error);
|
||||
showError('Failed to load statistics: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Load all issues
|
||||
async function loadIssues() {
|
||||
try {
|
||||
const response = await fetch('/api/issues');
|
||||
if (!response.ok) throw new Error('Failed to load issues');
|
||||
allIssues = await response.json();
|
||||
renderIssues(allIssues);
|
||||
} catch (error) {
|
||||
console.error('Error loading issues:', error);
|
||||
showError('Failed to load issues: ' + error.message);
|
||||
document.getElementById('issues-tbody').innerHTML = '<tr><td colspan="6" style="text-align: center; color: #721c24;">Error loading issues</td></tr>';
|
||||
document.getElementById('issues-card-view').innerHTML = '<div class="empty-state"><div class="empty-state-icon">⚠️</div><p>Error loading issues</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Render issues table
|
||||
function renderIssues(issues) {
|
||||
const tbody = document.getElementById('issues-tbody');
|
||||
const cardView = document.getElementById('issues-card-view');
|
||||
|
||||
if (!issues || issues.length === 0) {
|
||||
const emptyState = '<div class="empty-state"><div class="empty-state-icon">📋</div><h3>No issues found</h3><p>Create your first issue to get started!</p></div>';
|
||||
tbody.innerHTML = '<tr><td colspan="6">' + emptyState + '</td></tr>';
|
||||
cardView.innerHTML = emptyState;
|
||||
return;
|
||||
}
|
||||
|
||||
// Render table view
|
||||
tbody.innerHTML = issues.map(issue => {
|
||||
const statusClass = 'status-' + (issue.status || 'open').toLowerCase().replace('_', '-');
|
||||
const priorityClass = 'priority-' + (issue.priority || 2);
|
||||
return '<tr onclick="showIssueDetail(\'' + issue.id + '\')"><td>' + issue.id + '</td><td>' + issue.title + '</td><td class="' + statusClass + '">' + (issue.status || 'open') + '</td><td class="' + priorityClass + '">P' + (issue.priority || 2) + '</td><td>' + (issue.issue_type || 'task') + '</td><td>' + (issue.assignee || '-') + '</td></tr>';
|
||||
}).join('');
|
||||
|
||||
// Render card view for mobile
|
||||
cardView.innerHTML = issues.map(issue => {
|
||||
const statusClass = 'status-' + (issue.status || 'open').toLowerCase().replace('_', '-');
|
||||
const priorityClass = 'priority-' + (issue.priority || 2);
|
||||
let html = '<div class="issue-card" onclick="showIssueDetail(\'' + issue.id + '\')">';
|
||||
html += '<div class="issue-card-header">';
|
||||
html += '<span class="issue-card-id">' + issue.id + '</span>';
|
||||
html += '<span class="' + priorityClass + '">P' + (issue.priority || 2) + '</span>';
|
||||
html += '</div>';
|
||||
html += '<h3 class="issue-card-title">' + issue.title + '</h3>';
|
||||
html += '<div class="issue-card-meta">';
|
||||
html += '<span class="' + statusClass + '">● ' + (issue.status || 'open') + '</span>';
|
||||
html += '<span>Type: ' + (issue.issue_type || 'task') + '</span>';
|
||||
if (issue.assignee) html += '<span>👤 ' + issue.assignee + '</span>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
// Filter issues
|
||||
function filterIssues() {
|
||||
const statusSelect = document.getElementById('filter-status');
|
||||
const selectedStatuses = Array.from(statusSelect.selectedOptions).map(opt => opt.value);
|
||||
const priorityFilter = document.getElementById('filter-priority').value;
|
||||
|
||||
const filtered = allIssues.filter(issue => {
|
||||
// If statuses are selected, check if issue status is in the selected list
|
||||
if (selectedStatuses.length > 0 && !selectedStatuses.includes(issue.status)) return false;
|
||||
if (priorityFilter && issue.priority !== parseInt(priorityFilter)) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
renderIssues(filtered);
|
||||
}
|
||||
|
||||
// Reload all data
|
||||
function reloadData() {
|
||||
setLoading(true);
|
||||
Promise.all([loadStats(), loadIssues()])
|
||||
.then(() => {
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error reloading data:', error);
|
||||
setLoading(false);
|
||||
showError('Failed to reload data: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
// Show issue detail modal
|
||||
async function showIssueDetail(issueId) {
|
||||
const modal = document.getElementById('issue-modal');
|
||||
const modalTitle = document.getElementById('modal-title');
|
||||
const modalBody = document.getElementById('modal-body');
|
||||
|
||||
modal.style.display = 'block';
|
||||
modalTitle.textContent = 'Loading...';
|
||||
modalBody.innerHTML = '<div class="spinner"></div>';
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/issues/' + issueId);
|
||||
if (!response.ok) throw new Error('Issue not found');
|
||||
const issue = await response.json();
|
||||
|
||||
modalTitle.textContent = issue.id + ': ' + issue.title;
|
||||
let html = '<p><strong>Status:</strong> ' + issue.status + '</p>';
|
||||
html += '<p><strong>Priority:</strong> P' + issue.priority + '</p>';
|
||||
html += '<p><strong>Type:</strong> ' + issue.issue_type + '</p>';
|
||||
html += '<p><strong>Assignee:</strong> ' + (issue.assignee || 'Unassigned') + '</p>';
|
||||
html += '<p><strong>Created:</strong> ' + new Date(issue.created_at).toLocaleString() + '</p>';
|
||||
html += '<p><strong>Updated:</strong> ' + new Date(issue.updated_at).toLocaleString() + '</p>';
|
||||
if (issue.description) html += '<h3>Description</h3><pre>' + issue.description + '</pre>';
|
||||
if (issue.design) html += '<h3>Design</h3><pre>' + issue.design + '</pre>';
|
||||
if (issue.notes) html += '<h3>Notes</h3><pre>' + issue.notes + '</pre>';
|
||||
if (issue.labels && issue.labels.length > 0) html += '<p><strong>Labels:</strong> ' + issue.labels.join(', ') + '</p>';
|
||||
modalBody.innerHTML = html;
|
||||
} catch (error) {
|
||||
console.error('Error loading issue details:', error);
|
||||
showError('Failed to load issue details: ' + error.message);
|
||||
modalBody.innerHTML = '<div class="empty-state"><div class="empty-state-icon">⚠️</div><p>Error loading issue details</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Close modal
|
||||
document.querySelector('.close').onclick = function() {
|
||||
document.getElementById('issue-modal').style.display = 'none';
|
||||
};
|
||||
|
||||
window.onclick = function(event) {
|
||||
const modal = document.getElementById('issue-modal');
|
||||
if (event.target == modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
// Filter event listeners
|
||||
document.getElementById('filter-status').addEventListener('change', filterIssues);
|
||||
document.getElementById('filter-priority').addEventListener('change', filterIssues);
|
||||
|
||||
// Reload button listener
|
||||
document.getElementById('reload-button').addEventListener('click', reloadData);
|
||||
|
||||
// Initial load
|
||||
connectWebSocket();
|
||||
loadStats();
|
||||
loadIssues();
|
||||
|
||||
// Fallback: Refresh every 30 seconds (WebSocket should handle real-time updates)
|
||||
setInterval(() => {
|
||||
if (!wsConnected) {
|
||||
loadStats();
|
||||
loadIssues();
|
||||
}
|
||||
}, 30000);
|
||||
Reference in New Issue
Block a user