-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_modal.html
More file actions
138 lines (126 loc) · 5.55 KB
/
Copy pathdebug_modal.html
File metadata and controls
138 lines (126 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Debug Modal</title>
<link rel="stylesheet" href="public/static/css/style.css">
</head>
<body>
<div class="container">
<h1>Debug Modal</h1>
<button class="log-link"
data-domain-id="annas.gl"
data-log-path="logs/annas/annas.gl.log"
data-domain-url="annas.gl"
data-archive-links="[]">
logs
</button>
<!-- Log Preview Modal -->
<div id="logModal" class="log-modal">
<div class="log-modal-content">
<div class="log-modal-header">
<h3 id="logModalTitle">Recent Log Entries</h3>
<button class="log-modal-close" onclick="closeLogModal()">×</button>
</div>
<div class="log-modal-body">
<div id="logModalLoading" class="log-modal-loading">Loading...</div>
<div id="logModalError" class="log-modal-error" style="display: none;"></div>
<table id="logModalTable" class="log-modal-table" style="display: none;">
<thead>
<tr>
<th>Time</th>
<th>Status</th>
<th>HTTP</th>
<th>Latency</th>
<th>Reason</th>
</tr>
</thead>
<tbody id="logModalTableBody">
</tbody>
</table>
</div>
<div class="log-modal-footer">
<a id="logModalFullLog" href="#" target="_blank" rel="noopener noreferrer" class="log-modal-btn">View full log</a>
<div id="logModalArchives" class="log-modal-archives" style="display: none;">
<span class="log-modal-archives-label">Archives:</span>
<div id="logModalArchivesList" class="log-modal-archives-list"></div>
</div>
</div>
</div>
</div>
</div>
<script>
let currentArchiveLinks = [];
// Add event listener for log link buttons
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM loaded - adding event listeners');
document.querySelectorAll('.log-link').forEach(button => {
console.log('Found log link button:', button);
button.addEventListener('click', function() {
console.log('Button clicked!');
const domainId = this.dataset.domainId;
const logPath = this.dataset.logPath;
const domainUrl = this.dataset.domainUrl;
const archiveLinks = JSON.parse(this.dataset.archiveLinks || '[]');
console.log('Calling openLogModal with:', { domainId, logPath, domainUrl, archiveLinks });
openLogModal(domainId, logPath, domainUrl, archiveLinks);
});
});
});
function openLogModal(domainId, logPath, domainUrl, archiveLinks) {
console.log('openLogModal called');
const modal = document.getElementById('logModal');
const title = document.getElementById('logModalTitle');
const loading = document.getElementById('logModalLoading');
const error = document.getElementById('logModalError');
const table = document.getElementById('logModalTable');
const tbody = document.getElementById('logModalTableBody');
const fullLogLink = document.getElementById('logModalFullLog');
const archivesSection = document.getElementById('logModalArchives');
const archivesList = document.getElementById('logModalArchivesList');
// Store archive links for potential retry
currentArchiveLinks = archiveLinks || [];
title.textContent = 'Recent Log Entries - ' + domainUrl;
loading.style.display = 'block';
error.style.display = 'none';
table.style.display = 'none';
fullLogLink.href = logPath;
// Populate archive links
if (currentArchiveLinks.length > 0) {
archivesList.innerHTML = currentArchiveLinks.map(archive =>
`<a href="${archive.url}" target="_blank" rel="noopener noreferrer" class="log-modal-archive-link">${archive.date}</a>`
).join('');
archivesSection.style.display = 'block';
} else {
archivesSection.style.display = 'none';
}
modal.style.display = 'flex';
console.log('Modal display set to flex, current display:', modal.style.display);
// Simulate loading some data
setTimeout(() => {
loading.style.display = 'none';
table.style.display = 'table';
tbody.innerHTML = '<tr><td>Test Time</td><td>UP</td><td>200</td><td>100ms</td><td></td></tr>';
}, 1000);
}
function closeLogModal() {
const modal = document.getElementById('logModal');
modal.style.display = 'none';
}
// Close modal on ESC key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeLogModal();
}
});
// Close modal when clicking outside
window.onclick = function(event) {
const modal = document.getElementById('logModal');
if (event.target === modal) {
closeLogModal();
}
}
</script>
</body>
</html>