podmanager 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +105 -2
- package/bin/podmanager.js +105 -0
- package/package.json +43 -4
- package/public/css/style.css +2042 -0
- package/public/index.html +1028 -0
- package/public/js/api.js +162 -0
- package/public/js/app.js +1912 -0
- package/public/podmanager.webp +0 -0
- package/src/app.js +23 -0
- package/src/index.js +46 -0
- package/src/middlewares/async-handler.middleware.js +8 -0
- package/src/middlewares/error.middleware.js +13 -0
- package/src/routes/containers.route.js +125 -0
- package/src/routes/events.route.js +48 -0
- package/src/routes/images.route.js +61 -0
- package/src/routes/index.js +20 -0
- package/src/routes/networks.route.js +31 -0
- package/src/routes/pods.route.js +50 -0
- package/src/routes/system.route.js +26 -0
- package/src/routes/volumes.route.js +33 -0
- package/src/services/podman.service.js +404 -0
package/public/js/app.js
ADDED
|
@@ -0,0 +1,1912 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Podman Web UI Application Controller
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Application State
|
|
6
|
+
const state = {
|
|
7
|
+
activeView: 'dashboard',
|
|
8
|
+
systemInfo: null,
|
|
9
|
+
dfInfo: [],
|
|
10
|
+
containers: [],
|
|
11
|
+
pods: [],
|
|
12
|
+
images: [],
|
|
13
|
+
volumes: [],
|
|
14
|
+
networks: [],
|
|
15
|
+
events: [],
|
|
16
|
+
loading: {
|
|
17
|
+
containers: true,
|
|
18
|
+
pods: true,
|
|
19
|
+
images: true,
|
|
20
|
+
volumes: true,
|
|
21
|
+
networks: true
|
|
22
|
+
},
|
|
23
|
+
expandedRows: new Set(),
|
|
24
|
+
refreshTimer: null,
|
|
25
|
+
refreshInterval: 5000,
|
|
26
|
+
activeLogStream: null,
|
|
27
|
+
activePullStream: null,
|
|
28
|
+
containerFilter: { search: '', status: 'all' },
|
|
29
|
+
podFilter: { search: '' },
|
|
30
|
+
imageFilter: { search: '' },
|
|
31
|
+
volumeFilter: { search: '' },
|
|
32
|
+
networkFilter: { search: '' },
|
|
33
|
+
eventFilter: { search: '' },
|
|
34
|
+
logsConfig: {
|
|
35
|
+
containerId: null,
|
|
36
|
+
containerName: '',
|
|
37
|
+
autoscroll: true,
|
|
38
|
+
timestamps: false
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Row details expansion for mobile & tablet (persists across auto-refresh)
|
|
43
|
+
function toggleRowDetails(rowId, btnElement) {
|
|
44
|
+
const row = document.getElementById(rowId);
|
|
45
|
+
if (!row) return;
|
|
46
|
+
const willOpen = !row.classList.contains('open');
|
|
47
|
+
if (willOpen) {
|
|
48
|
+
state.expandedRows.add(rowId);
|
|
49
|
+
row.classList.add('open');
|
|
50
|
+
} else {
|
|
51
|
+
state.expandedRows.delete(rowId);
|
|
52
|
+
row.classList.remove('open');
|
|
53
|
+
}
|
|
54
|
+
const btn = btnElement || document.querySelector(`button[data-target-row="${rowId}"]`);
|
|
55
|
+
if (btn) {
|
|
56
|
+
btn.classList.toggle('expanded', willOpen);
|
|
57
|
+
btn.setAttribute('aria-expanded', String(willOpen));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Click anywhere on a table row item to toggle drawer expansion (except on action buttons, links, copy badges)
|
|
62
|
+
document.addEventListener('click', (e) => {
|
|
63
|
+
// Only activate row-click expansion on tablet & mobile viewports (where drawer info exists)
|
|
64
|
+
if (window.innerWidth > 1024) return;
|
|
65
|
+
|
|
66
|
+
if (e.target.closest('.action-trigger-btn') ||
|
|
67
|
+
e.target.closest('.floating-action-menu') ||
|
|
68
|
+
e.target.closest('a') ||
|
|
69
|
+
e.target.closest('.item-id') ||
|
|
70
|
+
e.target.closest('input') ||
|
|
71
|
+
e.target.closest('select')) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const rowItem = e.target.closest('tr.table-row-item');
|
|
75
|
+
if (!rowItem) return;
|
|
76
|
+
|
|
77
|
+
const expandBtn = rowItem.querySelector('.btn-expand-row');
|
|
78
|
+
if (expandBtn) {
|
|
79
|
+
const rowId = expandBtn.getAttribute('data-target-row');
|
|
80
|
+
if (rowId) {
|
|
81
|
+
toggleRowDetails(rowId, expandBtn);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Floating Action Dropdown Menu (Portal on document.body to prevent clipping & auto-refresh destruction)
|
|
87
|
+
let activeDropdownContext = null;
|
|
88
|
+
|
|
89
|
+
function openFloatingDropdown(type, id, triggerBtn, event) {
|
|
90
|
+
if (event) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
}
|
|
94
|
+
const menu = document.getElementById('floating-action-dropdown');
|
|
95
|
+
if (!menu) return;
|
|
96
|
+
|
|
97
|
+
const rawId = decodeURIComponent(id);
|
|
98
|
+
|
|
99
|
+
// Toggle close if clicking on the same button while already open
|
|
100
|
+
if (activeDropdownContext &&
|
|
101
|
+
(activeDropdownContext.id === id || activeDropdownContext.id === rawId) &&
|
|
102
|
+
activeDropdownContext.type === type &&
|
|
103
|
+
menu.style.display !== 'none') {
|
|
104
|
+
closeFloatingDropdown();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const items = getActionMenuItems(type, id);
|
|
109
|
+
if (!items) {
|
|
110
|
+
console.warn('No action menu items found for:', type, id);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
menu.innerHTML = items;
|
|
115
|
+
menu.style.display = 'flex';
|
|
116
|
+
menu.style.visibility = 'hidden';
|
|
117
|
+
menu._openedAt = Date.now();
|
|
118
|
+
|
|
119
|
+
const rect = triggerBtn.getBoundingClientRect();
|
|
120
|
+
const menuWidth = menu.offsetWidth || 180;
|
|
121
|
+
const menuHeight = menu.offsetHeight || 190;
|
|
122
|
+
|
|
123
|
+
// Calculate vertical position (prefer below, flip above if overflowing bottom)
|
|
124
|
+
let top = rect.bottom + 4;
|
|
125
|
+
if (top + menuHeight > window.innerHeight - 8) {
|
|
126
|
+
top = Math.max(8, rect.top - menuHeight - 4);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Calculate horizontal position (align right edge to button right edge)
|
|
130
|
+
let left = rect.right - menuWidth;
|
|
131
|
+
if (left < 8) left = 8;
|
|
132
|
+
if (left + menuWidth > window.innerWidth - 8) {
|
|
133
|
+
left = window.innerWidth - menuWidth - 8;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
menu.style.top = `${top}px`;
|
|
137
|
+
menu.style.left = `${left}px`;
|
|
138
|
+
menu.style.visibility = 'visible';
|
|
139
|
+
|
|
140
|
+
if (activeDropdownContext && activeDropdownContext.triggerBtn) {
|
|
141
|
+
activeDropdownContext.triggerBtn.setAttribute('aria-expanded', 'false');
|
|
142
|
+
}
|
|
143
|
+
activeDropdownContext = { type, id, triggerBtn };
|
|
144
|
+
triggerBtn.setAttribute('aria-expanded', 'true');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function closeFloatingDropdown() {
|
|
148
|
+
const menu = document.getElementById('floating-action-dropdown');
|
|
149
|
+
if (menu) {
|
|
150
|
+
menu.style.display = 'none';
|
|
151
|
+
}
|
|
152
|
+
if (activeDropdownContext && activeDropdownContext.triggerBtn) {
|
|
153
|
+
activeDropdownContext.triggerBtn.setAttribute('aria-expanded', 'false');
|
|
154
|
+
}
|
|
155
|
+
activeDropdownContext = null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function getActionMenuItems(type, id) {
|
|
159
|
+
const rawId = decodeURIComponent(id);
|
|
160
|
+
|
|
161
|
+
if (type === 'container') {
|
|
162
|
+
const c = state.containers.find(item => item.Id === id || item.Id === rawId || item.id === id || item.id === rawId || (item.Names && item.Names.includes(id)));
|
|
163
|
+
if (!c) return '';
|
|
164
|
+
const cId = c.Id || c.id;
|
|
165
|
+
const name = c.Names?.[0] || shortId(cId);
|
|
166
|
+
const isRunning = (c.State || '').toLowerCase() === 'running';
|
|
167
|
+
const isPaused = (c.State || '').toLowerCase() === 'paused';
|
|
168
|
+
const safeName = escapeHtml(name);
|
|
169
|
+
|
|
170
|
+
return `
|
|
171
|
+
${isRunning ? `
|
|
172
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionContainer('${cId}', 'stop');">
|
|
173
|
+
<svg viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12"></rect></svg>
|
|
174
|
+
<span>Stop Container</span>
|
|
175
|
+
</button>
|
|
176
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionContainer('${cId}', 'restart');">
|
|
177
|
+
<svg viewBox="0 0 24 24"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg>
|
|
178
|
+
<span>Restart Container</span>
|
|
179
|
+
</button>
|
|
180
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); openExecModal('${cId}', '${safeName}');">
|
|
181
|
+
<svg viewBox="0 0 24 24"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>
|
|
182
|
+
<span>Exec Shell</span>
|
|
183
|
+
</button>
|
|
184
|
+
` : isPaused ? `
|
|
185
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionContainer('${cId}', 'unpause');">
|
|
186
|
+
<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
|
|
187
|
+
<span>Resume Container</span>
|
|
188
|
+
</button>
|
|
189
|
+
` : `
|
|
190
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionContainer('${cId}', 'start');">
|
|
191
|
+
<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
|
|
192
|
+
<span>Start Container</span>
|
|
193
|
+
</button>
|
|
194
|
+
`}
|
|
195
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); viewContainerLogs('${cId}', '${safeName}');">
|
|
196
|
+
<svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line></svg>
|
|
197
|
+
<span>View Logs</span>
|
|
198
|
+
</button>
|
|
199
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); inspectItem('container', '${cId}');">
|
|
200
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
|
|
201
|
+
<span>Inspect JSON</span>
|
|
202
|
+
</button>
|
|
203
|
+
<div class="dropdown-divider"></div>
|
|
204
|
+
<button type="button" class="dropdown-item danger" onclick="closeFloatingDropdown(); confirmDeleteContainer('${cId}', '${safeName}');">
|
|
205
|
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
206
|
+
<span>Delete Container</span>
|
|
207
|
+
</button>
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (type === 'pod') {
|
|
212
|
+
const p = state.pods.find(item => item.Id === id || item.Id === rawId || item.id === id || item.Name === id || item.Name === rawId);
|
|
213
|
+
if (!p) return '';
|
|
214
|
+
const pId = p.Id || p.id;
|
|
215
|
+
const isRunning = (p.Status || '').toLowerCase() === 'running';
|
|
216
|
+
const safeName = escapeHtml(p.Name || shortId(pId));
|
|
217
|
+
|
|
218
|
+
return `
|
|
219
|
+
${isRunning ? `
|
|
220
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionPod('${pId}', 'stop');">
|
|
221
|
+
<svg viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12"></rect></svg>
|
|
222
|
+
<span>Stop Pod</span>
|
|
223
|
+
</button>
|
|
224
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionPod('${pId}', 'restart');">
|
|
225
|
+
<svg viewBox="0 0 24 24"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg>
|
|
226
|
+
<span>Restart Pod</span>
|
|
227
|
+
</button>
|
|
228
|
+
` : `
|
|
229
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); actionPod('${pId}', 'start');">
|
|
230
|
+
<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
|
|
231
|
+
<span>Start Pod</span>
|
|
232
|
+
</button>
|
|
233
|
+
`}
|
|
234
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); inspectItem('pod', '${pId}');">
|
|
235
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
|
|
236
|
+
<span>Inspect JSON</span>
|
|
237
|
+
</button>
|
|
238
|
+
<div class="dropdown-divider"></div>
|
|
239
|
+
<button type="button" class="dropdown-item danger" onclick="closeFloatingDropdown(); confirmDeletePod('${pId}', '${safeName}');">
|
|
240
|
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
241
|
+
<span>Delete Pod</span>
|
|
242
|
+
</button>
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (type === 'image') {
|
|
247
|
+
const img = state.images.find(item => item.Id === id || item.Id === rawId || item.id === id || item.id === rawId);
|
|
248
|
+
if (!img) return '';
|
|
249
|
+
const imgId = img.Id || img.id;
|
|
250
|
+
const repo = img.Repositories?.[0] || img.Repository || (img.Names?.[0]?.split(':')[0]) || '<none>';
|
|
251
|
+
const tag = img.Tag || (img.Names?.[0]?.split(':')[1]) || 'latest';
|
|
252
|
+
const imageRef = `${repo}:${tag}`;
|
|
253
|
+
|
|
254
|
+
return `
|
|
255
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); openCreateContainerModal('${escapeHtml(imageRef)}');">
|
|
256
|
+
<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
|
|
257
|
+
<span>Run Container</span>
|
|
258
|
+
</button>
|
|
259
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); inspectItem('image', '${imgId}');">
|
|
260
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
|
|
261
|
+
<span>Inspect JSON</span>
|
|
262
|
+
</button>
|
|
263
|
+
<div class="dropdown-divider"></div>
|
|
264
|
+
<button type="button" class="dropdown-item danger" onclick="closeFloatingDropdown(); confirmDeleteImage('${imgId}', '${escapeHtml(repo)}');">
|
|
265
|
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
266
|
+
<span>Delete Image</span>
|
|
267
|
+
</button>
|
|
268
|
+
`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (type === 'volume') {
|
|
272
|
+
const v = state.volumes.find(item => item.Name === id || item.Name === rawId || item.name === id || item.name === rawId);
|
|
273
|
+
if (!v) return '';
|
|
274
|
+
const volName = v.Name || v.name;
|
|
275
|
+
return `
|
|
276
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); inspectItem('volume', '${encodeURIComponent(volName)}');">
|
|
277
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
|
|
278
|
+
<span>Inspect JSON</span>
|
|
279
|
+
</button>
|
|
280
|
+
<div class="dropdown-divider"></div>
|
|
281
|
+
<button type="button" class="dropdown-item danger" onclick="closeFloatingDropdown(); deleteVolume('${encodeURIComponent(volName)}');">
|
|
282
|
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
283
|
+
<span>Delete Volume</span>
|
|
284
|
+
</button>
|
|
285
|
+
`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (type === 'network') {
|
|
289
|
+
const n = state.networks.find(item => item.name === id || item.id === id || item.name === rawId || item.id === rawId || item.Name === id || item.Name === rawId);
|
|
290
|
+
if (!n) return '';
|
|
291
|
+
const netName = n.name || n.Name;
|
|
292
|
+
return `
|
|
293
|
+
<button type="button" class="dropdown-item" onclick="closeFloatingDropdown(); inspectItem('network', '${encodeURIComponent(netName)}');">
|
|
294
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
|
|
295
|
+
<span>Inspect JSON</span>
|
|
296
|
+
</button>
|
|
297
|
+
${netName !== 'podman' ? `
|
|
298
|
+
<div class="dropdown-divider"></div>
|
|
299
|
+
<button type="button" class="dropdown-item danger" onclick="closeFloatingDropdown(); deleteNetwork('${encodeURIComponent(netName)}');">
|
|
300
|
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
301
|
+
<span>Delete Network</span>
|
|
302
|
+
</button>
|
|
303
|
+
` : ''}
|
|
304
|
+
`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return '';
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Global listeners to close floating dropdown
|
|
311
|
+
document.addEventListener('click', (e) => {
|
|
312
|
+
const menu = document.getElementById('floating-action-dropdown');
|
|
313
|
+
if (!menu || menu.style.display === 'none') return;
|
|
314
|
+
// If clicked inside dropdown menu or on any action trigger button, do not close here
|
|
315
|
+
if (e.target.closest && (e.target.closest('#floating-action-dropdown') || e.target.closest('.action-trigger-btn'))) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
closeFloatingDropdown();
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
document.addEventListener('keydown', (e) => {
|
|
322
|
+
if (e.key === 'Escape') closeFloatingDropdown();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
window.addEventListener('resize', closeFloatingDropdown);
|
|
326
|
+
|
|
327
|
+
// Format utilities
|
|
328
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
329
|
+
if (!+bytes) return '0 B';
|
|
330
|
+
const k = 1024;
|
|
331
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
332
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
333
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
334
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const formatTime = (timestamp) => {
|
|
338
|
+
if (!timestamp) return '-';
|
|
339
|
+
const date = typeof timestamp === 'number' ? new Date(timestamp * 1000) : new Date(timestamp);
|
|
340
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const shortId = (id) => (id ? id.substring(0, 12) : '-');
|
|
344
|
+
|
|
345
|
+
// Toast Notification
|
|
346
|
+
function showToast(title, message = '', type = 'info') {
|
|
347
|
+
const container = document.getElementById('toast-container');
|
|
348
|
+
if (!container) return;
|
|
349
|
+
|
|
350
|
+
const toast = document.createElement('div');
|
|
351
|
+
toast.className = `toast toast-${type}`;
|
|
352
|
+
toast.innerHTML = `
|
|
353
|
+
<div class="toast-content">
|
|
354
|
+
<div class="toast-title">${escapeHtml(title)}</div>
|
|
355
|
+
${message ? `<div class="toast-msg">${escapeHtml(message)}</div>` : ''}
|
|
356
|
+
</div>
|
|
357
|
+
<button class="modal-close" style="padding:2px;" onclick="this.parentElement.remove()">
|
|
358
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
|
|
359
|
+
</button>
|
|
360
|
+
`;
|
|
361
|
+
container.appendChild(toast);
|
|
362
|
+
|
|
363
|
+
setTimeout(() => {
|
|
364
|
+
toast.style.opacity = '0';
|
|
365
|
+
toast.style.transition = 'opacity 0.3s ease';
|
|
366
|
+
setTimeout(() => toast.remove(), 300);
|
|
367
|
+
}, 4500);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function escapeHtml(str) {
|
|
371
|
+
if (!str) return '';
|
|
372
|
+
return String(str)
|
|
373
|
+
.replace(/&/g, '&')
|
|
374
|
+
.replace(/</g, '<')
|
|
375
|
+
.replace(/>/g, '>')
|
|
376
|
+
.replace(/"/g, '"')
|
|
377
|
+
.replace(/'/g, ''');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Modal Handlers
|
|
381
|
+
function openModal(modalId) {
|
|
382
|
+
const modal = document.getElementById(modalId);
|
|
383
|
+
if (modal) {
|
|
384
|
+
modal.classList.add('open');
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function closeModal(modalId) {
|
|
389
|
+
const modal = document.getElementById(modalId);
|
|
390
|
+
if (modal) {
|
|
391
|
+
modal.classList.remove('open');
|
|
392
|
+
if (modalId === 'logs-modal' && state.activeLogStream) {
|
|
393
|
+
state.activeLogStream.close();
|
|
394
|
+
state.activeLogStream = null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Main View Navigation
|
|
400
|
+
function switchView(viewName, updateUrl = true) {
|
|
401
|
+
const validViews = ['dashboard', 'containers', 'pods', 'images', 'volumes', 'networks', 'events'];
|
|
402
|
+
if (!validViews.includes(viewName)) {
|
|
403
|
+
viewName = 'dashboard';
|
|
404
|
+
}
|
|
405
|
+
state.activeView = viewName;
|
|
406
|
+
document.querySelectorAll('.view-section').forEach(el => el.classList.remove('active'));
|
|
407
|
+
document.querySelectorAll('.nav-link').forEach(el => el.classList.remove('active'));
|
|
408
|
+
|
|
409
|
+
const targetView = document.getElementById(`view-${viewName}`);
|
|
410
|
+
if (targetView) targetView.classList.add('active');
|
|
411
|
+
|
|
412
|
+
const navItem = document.querySelector(`.nav-link[data-view="${viewName}"]`);
|
|
413
|
+
if (navItem) navItem.classList.add('active');
|
|
414
|
+
|
|
415
|
+
const pageTitle = document.getElementById('page-title');
|
|
416
|
+
if (pageTitle) {
|
|
417
|
+
const titles = {
|
|
418
|
+
dashboard: 'Dashboard Overview',
|
|
419
|
+
containers: 'Containers Management',
|
|
420
|
+
pods: 'Pods Management',
|
|
421
|
+
images: 'Images Management',
|
|
422
|
+
volumes: 'Volumes Management',
|
|
423
|
+
networks: 'Networks Management',
|
|
424
|
+
events: 'Live System Events'
|
|
425
|
+
};
|
|
426
|
+
pageTitle.textContent = titles[viewName] || 'Podmanager';
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Synchronize state with browser URL
|
|
430
|
+
if (updateUrl && window.history && window.history.pushState) {
|
|
431
|
+
const url = new URL(window.location);
|
|
432
|
+
if (viewName === 'dashboard') {
|
|
433
|
+
url.searchParams.delete('view');
|
|
434
|
+
} else {
|
|
435
|
+
url.searchParams.set('view', viewName);
|
|
436
|
+
}
|
|
437
|
+
window.history.pushState({ view: viewName }, '', url.pathname + url.search + url.hash);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// If navigating to events view, render immediately from cached state
|
|
441
|
+
if (viewName === 'events') {
|
|
442
|
+
renderEvents();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Refresh active view data immediately
|
|
446
|
+
refreshData();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Data Fetching & Sync
|
|
450
|
+
async function refreshData() {
|
|
451
|
+
const refreshIcon = document.getElementById('refresh-icon');
|
|
452
|
+
if (refreshIcon) refreshIcon.classList.add('spin');
|
|
453
|
+
|
|
454
|
+
try {
|
|
455
|
+
// Parallel fetch core lists and all sections for sidebar badges
|
|
456
|
+
const [infoRes, dfRes, containersRes, podsRes, imagesRes, volumesRes, networksRes] = await Promise.all([
|
|
457
|
+
API.getSystemInfo().catch(e => null),
|
|
458
|
+
API.getSystemDf().catch(e => null),
|
|
459
|
+
API.getContainers().catch(e => null),
|
|
460
|
+
API.getPods().catch(e => null),
|
|
461
|
+
API.getImages().catch(e => null),
|
|
462
|
+
API.getVolumes().catch(e => null),
|
|
463
|
+
API.getNetworks().catch(e => null)
|
|
464
|
+
]);
|
|
465
|
+
|
|
466
|
+
if (infoRes?.data) state.systemInfo = infoRes.data;
|
|
467
|
+
if (dfRes?.data) state.dfInfo = dfRes.data;
|
|
468
|
+
if (containersRes?.data) {
|
|
469
|
+
state.containers = containersRes.data;
|
|
470
|
+
state.loading.containers = false;
|
|
471
|
+
}
|
|
472
|
+
if (podsRes?.data) {
|
|
473
|
+
state.pods = podsRes.data;
|
|
474
|
+
state.loading.pods = false;
|
|
475
|
+
}
|
|
476
|
+
if (imagesRes?.data) {
|
|
477
|
+
state.images = imagesRes.data;
|
|
478
|
+
state.loading.images = false;
|
|
479
|
+
}
|
|
480
|
+
if (volumesRes?.data) {
|
|
481
|
+
state.volumes = volumesRes.data;
|
|
482
|
+
state.loading.volumes = false;
|
|
483
|
+
}
|
|
484
|
+
if (networksRes?.data) {
|
|
485
|
+
state.networks = networksRes.data;
|
|
486
|
+
state.loading.networks = false;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Update navigation counter badges for all sections
|
|
490
|
+
updateBadges();
|
|
491
|
+
|
|
492
|
+
// Render current active view
|
|
493
|
+
if (state.activeView === 'dashboard') {
|
|
494
|
+
renderDashboard();
|
|
495
|
+
} else if (state.activeView === 'containers') {
|
|
496
|
+
renderContainers();
|
|
497
|
+
} else if (state.activeView === 'pods') {
|
|
498
|
+
renderPods();
|
|
499
|
+
} else if (state.activeView === 'images') {
|
|
500
|
+
renderImages();
|
|
501
|
+
} else if (state.activeView === 'volumes') {
|
|
502
|
+
renderVolumes();
|
|
503
|
+
} else if (state.activeView === 'networks') {
|
|
504
|
+
renderNetworks();
|
|
505
|
+
} else if (state.activeView === 'events') {
|
|
506
|
+
renderEvents();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
updateSystemStatus(true);
|
|
510
|
+
} catch (err) {
|
|
511
|
+
console.error('Failed to refresh data:', err);
|
|
512
|
+
updateSystemStatus(false);
|
|
513
|
+
} finally {
|
|
514
|
+
if (refreshIcon) refreshIcon.classList.remove('spin');
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function updateBadges() {
|
|
519
|
+
const dBadge = document.getElementById('badge-dashboard');
|
|
520
|
+
const cBadge = document.getElementById('badge-containers');
|
|
521
|
+
const pBadge = document.getElementById('badge-pods');
|
|
522
|
+
const iBadge = document.getElementById('badge-images');
|
|
523
|
+
const vBadge = document.getElementById('badge-volumes');
|
|
524
|
+
const nBadge = document.getElementById('badge-networks');
|
|
525
|
+
const eBadge = document.getElementById('badge-events');
|
|
526
|
+
|
|
527
|
+
const runningCount = state.containers.filter(c => c.State === 'running').length;
|
|
528
|
+
|
|
529
|
+
if (dBadge) {
|
|
530
|
+
dBadge.textContent = 'Live';
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (cBadge) {
|
|
534
|
+
cBadge.textContent = `${runningCount}/${state.containers.length}`;
|
|
535
|
+
cBadge.className = runningCount > 0 ? 'nav-badge active-count' : 'nav-badge';
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (pBadge) {
|
|
539
|
+
pBadge.textContent = state.pods.length;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (iBadge) {
|
|
543
|
+
iBadge.textContent = state.images.length;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (vBadge) {
|
|
547
|
+
vBadge.textContent = state.volumes.length;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (nBadge) {
|
|
551
|
+
nBadge.textContent = state.networks.length;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (eBadge) {
|
|
555
|
+
eBadge.textContent = state.events.length;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function updateSystemStatus(isOnline) {
|
|
560
|
+
const dot = document.getElementById('status-dot');
|
|
561
|
+
const text = document.getElementById('status-text');
|
|
562
|
+
if (dot && text) {
|
|
563
|
+
if (isOnline) {
|
|
564
|
+
dot.className = 'status-dot';
|
|
565
|
+
const version = state.systemInfo?.version?.Version || '';
|
|
566
|
+
text.textContent = version ? `Podman v${version} Connected` : 'Podman Connected';
|
|
567
|
+
} else {
|
|
568
|
+
dot.className = 'status-dot offline';
|
|
569
|
+
text.textContent = 'Connection Error';
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// ----------------- RENDER VIEWS -----------------
|
|
575
|
+
|
|
576
|
+
// 1. Dashboard View
|
|
577
|
+
function renderDashboard() {
|
|
578
|
+
const runningContainers = state.containers.filter(c => c.State === 'running').length;
|
|
579
|
+
|
|
580
|
+
document.getElementById('dash-stat-running').textContent = runningContainers;
|
|
581
|
+
document.getElementById('dash-stat-containers').textContent = state.containers.length;
|
|
582
|
+
document.getElementById('dash-stat-pods').textContent = state.pods.length;
|
|
583
|
+
document.getElementById('dash-stat-images').textContent = state.images.length;
|
|
584
|
+
|
|
585
|
+
// Host specs
|
|
586
|
+
const host = state.systemInfo?.host || {};
|
|
587
|
+
const ver = state.systemInfo?.version || {};
|
|
588
|
+
const store = state.systemInfo?.store || {};
|
|
589
|
+
|
|
590
|
+
document.getElementById('spec-podman-version').textContent = ver.Version || '-';
|
|
591
|
+
document.getElementById('spec-os-arch').textContent = `${host.os || ''} (${host.arch || ''})`;
|
|
592
|
+
document.getElementById('spec-distro').textContent = host.distribution ? `${host.distribution.distribution} ${host.distribution.version}` : '-';
|
|
593
|
+
document.getElementById('spec-kernel').textContent = host.kernel || '-';
|
|
594
|
+
document.getElementById('spec-cpus').textContent = host.cpus ? `${host.cpus} Cores` : '-';
|
|
595
|
+
document.getElementById('spec-mem').textContent = host.memTotal ? formatBytes(host.memTotal) : '-';
|
|
596
|
+
document.getElementById('spec-driver').textContent = store.graphDriverName || '-';
|
|
597
|
+
|
|
598
|
+
const rootlessBadge = document.getElementById('spec-rootless');
|
|
599
|
+
if (rootlessBadge) {
|
|
600
|
+
rootlessBadge.textContent = host.rootless ? 'Rootless Mode' : 'Root Mode';
|
|
601
|
+
rootlessBadge.className = host.rootless ? 'tag-badge rootless' : 'tag-badge';
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Disk usage list
|
|
605
|
+
const diskContainer = document.getElementById('dash-disk-list');
|
|
606
|
+
if (diskContainer && state.dfInfo.length > 0) {
|
|
607
|
+
diskContainer.innerHTML = state.dfInfo.map(item => `
|
|
608
|
+
<div class="disk-item">
|
|
609
|
+
<div class="disk-header">
|
|
610
|
+
<strong>${escapeHtml(item.Type)} (${item.TotalCount ?? item.Total ?? 0})</strong>
|
|
611
|
+
<span>${escapeHtml(item.Size || '0B')}</span>
|
|
612
|
+
</div>
|
|
613
|
+
<div class="disk-bar-bg">
|
|
614
|
+
<div class="disk-bar-fill" style="width: ${item.Active > 0 ? Math.min(100, Math.round((item.Active / (item.Total || 1)) * 100)) : 10}%;"></div>
|
|
615
|
+
</div>
|
|
616
|
+
<div class="disk-reclaimable">Reclaimable: ${escapeHtml(item.Reclaimable || '0B')}</div>
|
|
617
|
+
</div>
|
|
618
|
+
`).join('');
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Skeleton Generator for Tables
|
|
623
|
+
function renderTableSkeletons(type, count = 5) {
|
|
624
|
+
const rows = [];
|
|
625
|
+
for (let i = 0; i < count; i++) {
|
|
626
|
+
const varW = (base, mod) => base + ((i % 3) * mod);
|
|
627
|
+
|
|
628
|
+
if (type === 'containers') {
|
|
629
|
+
rows.push(`
|
|
630
|
+
<tr class="table-row-item skeleton-row">
|
|
631
|
+
<td><div class="skeleton skeleton-badge" style="width:65px;"></div></td>
|
|
632
|
+
<td>
|
|
633
|
+
<div class="skeleton-group">
|
|
634
|
+
<div class="skeleton skeleton-text" style="width:${varW(120, 15)}px;"></div>
|
|
635
|
+
<div class="skeleton skeleton-text skeleton-sub" style="width:${varW(75, 10)}px;"></div>
|
|
636
|
+
</div>
|
|
637
|
+
</td>
|
|
638
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:${varW(100, 20)}px;"></div></td>
|
|
639
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:${varW(80, 15)}px;"></div></td>
|
|
640
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:75px;"></div></td>
|
|
641
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:85px;"></div></td>
|
|
642
|
+
<td class="col-actions-header" style="text-align:right;">
|
|
643
|
+
<div class="skeleton skeleton-btn" style="margin-left:auto;"></div>
|
|
644
|
+
</td>
|
|
645
|
+
<td class="mobile-toggle-cell">
|
|
646
|
+
<div class="skeleton skeleton-icon" style="margin:0 auto;"></div>
|
|
647
|
+
</td>
|
|
648
|
+
</tr>
|
|
649
|
+
`);
|
|
650
|
+
} else if (type === 'pods') {
|
|
651
|
+
rows.push(`
|
|
652
|
+
<tr class="table-row-item skeleton-row">
|
|
653
|
+
<td><div class="skeleton skeleton-badge" style="width:65px;"></div></td>
|
|
654
|
+
<td>
|
|
655
|
+
<div class="skeleton-group">
|
|
656
|
+
<div class="skeleton skeleton-text" style="width:${varW(130, 20)}px;"></div>
|
|
657
|
+
<div class="skeleton skeleton-text skeleton-sub" style="width:${varW(70, 10)}px;"></div>
|
|
658
|
+
</div>
|
|
659
|
+
</td>
|
|
660
|
+
<td class="col-hide-tablet">
|
|
661
|
+
<div class="skeleton-group">
|
|
662
|
+
<div class="skeleton skeleton-badge" style="width:70px;"></div>
|
|
663
|
+
<div class="skeleton skeleton-text skeleton-sub" style="width:110px;"></div>
|
|
664
|
+
</div>
|
|
665
|
+
</td>
|
|
666
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:85px;"></div></td>
|
|
667
|
+
<td class="col-actions-header" style="text-align:right;">
|
|
668
|
+
<div class="skeleton skeleton-btn" style="margin-left:auto;"></div>
|
|
669
|
+
</td>
|
|
670
|
+
<td class="mobile-toggle-cell">
|
|
671
|
+
<div class="skeleton skeleton-icon" style="margin:0 auto;"></div>
|
|
672
|
+
</td>
|
|
673
|
+
</tr>
|
|
674
|
+
`);
|
|
675
|
+
} else if (type === 'images') {
|
|
676
|
+
rows.push(`
|
|
677
|
+
<tr class="table-row-item skeleton-row">
|
|
678
|
+
<td>
|
|
679
|
+
<div class="skeleton-group">
|
|
680
|
+
<div class="skeleton skeleton-text" style="width:${varW(140, 25)}px;"></div>
|
|
681
|
+
<div class="skeleton skeleton-text skeleton-sub" style="width:${varW(85, 10)}px;"></div>
|
|
682
|
+
</div>
|
|
683
|
+
</td>
|
|
684
|
+
<td><div class="skeleton skeleton-badge" style="width:45px;"></div></td>
|
|
685
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:55px;"></div></td>
|
|
686
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-badge" style="width:50px;"></div></td>
|
|
687
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:85px;"></div></td>
|
|
688
|
+
<td class="col-actions-header" style="text-align:right;">
|
|
689
|
+
<div class="skeleton skeleton-btn" style="margin-left:auto;"></div>
|
|
690
|
+
</td>
|
|
691
|
+
<td class="mobile-toggle-cell">
|
|
692
|
+
<div class="skeleton skeleton-icon" style="margin:0 auto;"></div>
|
|
693
|
+
</td>
|
|
694
|
+
</tr>
|
|
695
|
+
`);
|
|
696
|
+
} else if (type === 'volumes') {
|
|
697
|
+
rows.push(`
|
|
698
|
+
<tr class="table-row-item skeleton-row">
|
|
699
|
+
<td><div class="skeleton skeleton-text" style="width:${varW(130, 20)}px;"></div></td>
|
|
700
|
+
<td><div class="skeleton skeleton-badge" style="width:50px;"></div></td>
|
|
701
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:${varW(150, 30)}px;"></div></td>
|
|
702
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:85px;"></div></td>
|
|
703
|
+
<td class="col-actions-header" style="text-align:right;">
|
|
704
|
+
<div class="skeleton skeleton-btn" style="margin-left:auto;"></div>
|
|
705
|
+
</td>
|
|
706
|
+
<td class="mobile-toggle-cell">
|
|
707
|
+
<div class="skeleton skeleton-icon" style="margin:0 auto;"></div>
|
|
708
|
+
</td>
|
|
709
|
+
</tr>
|
|
710
|
+
`);
|
|
711
|
+
} else if (type === 'networks') {
|
|
712
|
+
rows.push(`
|
|
713
|
+
<tr class="table-row-item skeleton-row">
|
|
714
|
+
<td><div class="skeleton skeleton-text" style="width:${varW(110, 20)}px;"></div></td>
|
|
715
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:80px;"></div></td>
|
|
716
|
+
<td><div class="skeleton skeleton-badge" style="width:55px;"></div></td>
|
|
717
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:110px;"></div></td>
|
|
718
|
+
<td class="col-hide-tablet"><div class="skeleton skeleton-text" style="width:95px;"></div></td>
|
|
719
|
+
<td class="col-actions-header" style="text-align:right;">
|
|
720
|
+
<div class="skeleton skeleton-btn" style="margin-left:auto;"></div>
|
|
721
|
+
</td>
|
|
722
|
+
<td class="mobile-toggle-cell">
|
|
723
|
+
<div class="skeleton skeleton-icon" style="margin:0 auto;"></div>
|
|
724
|
+
</td>
|
|
725
|
+
</tr>
|
|
726
|
+
`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return rows.join('');
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// 2. Containers View
|
|
733
|
+
function renderContainers() {
|
|
734
|
+
const tbody = document.getElementById('containers-tbody');
|
|
735
|
+
if (!tbody) return;
|
|
736
|
+
|
|
737
|
+
if (state.loading.containers) {
|
|
738
|
+
tbody.innerHTML = renderTableSkeletons('containers');
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const search = state.containerFilter.search.toLowerCase();
|
|
743
|
+
const status = state.containerFilter.status;
|
|
744
|
+
|
|
745
|
+
const filtered = state.containers.filter(c => {
|
|
746
|
+
const nameMatch = (c.Names?.[0] || '').toLowerCase().includes(search) ||
|
|
747
|
+
(c.Image || '').toLowerCase().includes(search) ||
|
|
748
|
+
(c.Id || '').toLowerCase().includes(search);
|
|
749
|
+
const statusMatch = status === 'all' || c.State === status;
|
|
750
|
+
return nameMatch && statusMatch;
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
if (filtered.length === 0) {
|
|
754
|
+
tbody.innerHTML = `
|
|
755
|
+
<tr>
|
|
756
|
+
<td colspan="8">
|
|
757
|
+
<div class="empty-state">
|
|
758
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect><line x1="8" y1="21" x2="16" y2="21"></line><line x1="12" y1="17" x2="12" y2="21"></line></svg>
|
|
759
|
+
<div class="empty-state-title">No containers found</div>
|
|
760
|
+
<div class="empty-state-desc">No containers match your search or filter. Launch a container to get started.</div>
|
|
761
|
+
<button class="btn btn-primary" onclick="openCreateContainerModal()">
|
|
762
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
|
763
|
+
<span>Run Container</span>
|
|
764
|
+
</button>
|
|
765
|
+
</div>
|
|
766
|
+
</td>
|
|
767
|
+
</tr>
|
|
768
|
+
`;
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
tbody.innerHTML = filtered.map(c => {
|
|
773
|
+
const name = c.Names?.[0] || shortId(c.Id);
|
|
774
|
+
const cShort = shortId(c.Id);
|
|
775
|
+
const rowId = `expand-c-${cShort}`;
|
|
776
|
+
const isExpanded = state.expandedRows.has(rowId);
|
|
777
|
+
|
|
778
|
+
return `
|
|
779
|
+
<tr class="table-row-item">
|
|
780
|
+
<td>
|
|
781
|
+
<span class="status-pill status-${c.State}">${c.State}</span>
|
|
782
|
+
</td>
|
|
783
|
+
<td>
|
|
784
|
+
<div class="item-name">${escapeHtml(name)}</div>
|
|
785
|
+
<span class="item-id" title="Click to copy ID" onclick="navigator.clipboard.writeText('${c.Id}'); showToast('Copied ID', '${cShort}', 'info');">${cShort}</span>
|
|
786
|
+
</td>
|
|
787
|
+
<td class="col-hide-tablet">
|
|
788
|
+
<span title="${escapeHtml(c.Image)}">${escapeHtml(c.Image)}</span>
|
|
789
|
+
</td>
|
|
790
|
+
<td class="col-hide-tablet">${formatPorts(c.Ports)}</td>
|
|
791
|
+
<td class="col-hide-tablet">${c.PodName ? `<span class="tag-badge rootless">${escapeHtml(c.PodName)}</span>` : '-'}</td>
|
|
792
|
+
<td class="col-hide-tablet" style="color:var(--text-secondary); font-size:12px;">${escapeHtml(c.Status)}</td>
|
|
793
|
+
<td class="col-actions-cell" style="text-align:right;">
|
|
794
|
+
<button type="button" class="btn btn-secondary btn-icon-only btn-sm action-trigger-btn" title="Actions" aria-label="Actions" aria-haspopup="true" aria-expanded="false" onclick="openFloatingDropdown('container', '${c.Id}', this, event)">
|
|
795
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg>
|
|
796
|
+
</button>
|
|
797
|
+
</td>
|
|
798
|
+
<td class="mobile-toggle-cell" style="text-align:center;">
|
|
799
|
+
<button type="button" class="btn-expand-row ${isExpanded ? 'expanded' : ''}" data-target-row="${rowId}" aria-label="Toggle details for ${escapeHtml(name)}" aria-expanded="${isExpanded}">
|
|
800
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
801
|
+
</button>
|
|
802
|
+
</td>
|
|
803
|
+
</tr>
|
|
804
|
+
<tr class="expandable-details-row ${isExpanded ? 'open' : ''}" id="${rowId}">
|
|
805
|
+
<td colspan="8">
|
|
806
|
+
<div class="details-drawer-content">
|
|
807
|
+
<div class="drawer-grid">
|
|
808
|
+
<div class="drawer-field">
|
|
809
|
+
<span class="drawer-label">Image</span>
|
|
810
|
+
<span class="drawer-value">${escapeHtml(c.Image)}</span>
|
|
811
|
+
</div>
|
|
812
|
+
<div class="drawer-field">
|
|
813
|
+
<span class="drawer-label">Ports</span>
|
|
814
|
+
<span class="drawer-value">${formatPorts(c.Ports)}</span>
|
|
815
|
+
</div>
|
|
816
|
+
<div class="drawer-field">
|
|
817
|
+
<span class="drawer-label">Pod</span>
|
|
818
|
+
<span class="drawer-value">${c.PodName ? escapeHtml(c.PodName) : 'Standalone'}</span>
|
|
819
|
+
</div>
|
|
820
|
+
<div class="drawer-field">
|
|
821
|
+
<span class="drawer-label">Status / Uptime</span>
|
|
822
|
+
<span class="drawer-value">${escapeHtml(c.Status)}</span>
|
|
823
|
+
</div>
|
|
824
|
+
</div>
|
|
825
|
+
</div>
|
|
826
|
+
</td>
|
|
827
|
+
</tr>
|
|
828
|
+
`;
|
|
829
|
+
}).join('');
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function formatPorts(ports) {
|
|
833
|
+
if (!ports || ports.length === 0) return '<span style="color:var(--text-tertiary);">-</span>';
|
|
834
|
+
return ports.map(p => {
|
|
835
|
+
const hostPort = p.host_port || p.HostPort;
|
|
836
|
+
const containerPort = p.container_port || p.ContainerPort;
|
|
837
|
+
const protocol = p.protocol || 'tcp';
|
|
838
|
+
if (hostPort) {
|
|
839
|
+
return `<a class="ports-badge" href="http://localhost:${hostPort}" target="_blank" title="Open port in browser">${hostPort}:${containerPort}/${protocol}</a>`;
|
|
840
|
+
}
|
|
841
|
+
return `<span class="ports-badge">${containerPort}/${protocol}</span>`;
|
|
842
|
+
}).join(' ');
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// 3. Pods View
|
|
846
|
+
function renderPods() {
|
|
847
|
+
const tbody = document.getElementById('pods-tbody');
|
|
848
|
+
if (!tbody) return;
|
|
849
|
+
|
|
850
|
+
if (state.loading.pods) {
|
|
851
|
+
tbody.innerHTML = renderTableSkeletons('pods');
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const search = state.podFilter.search.toLowerCase();
|
|
856
|
+
const filtered = state.pods.filter(p => {
|
|
857
|
+
return (p.Name || '').toLowerCase().includes(search) || (p.Id || '').toLowerCase().includes(search);
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
if (filtered.length === 0) {
|
|
861
|
+
tbody.innerHTML = `
|
|
862
|
+
<tr>
|
|
863
|
+
<td colspan="6">
|
|
864
|
+
<div class="empty-state">
|
|
865
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"></path><path d="M2 12h20"></path></svg>
|
|
866
|
+
<div class="empty-state-title">No pods found</div>
|
|
867
|
+
<div class="empty-state-desc">No pods match your search. Create a pod to group multiple containers together.</div>
|
|
868
|
+
<button class="btn btn-primary" onclick="openModal('create-pod-modal')">
|
|
869
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
|
870
|
+
<span>Create Pod</span>
|
|
871
|
+
</button>
|
|
872
|
+
</div>
|
|
873
|
+
</td>
|
|
874
|
+
</tr>
|
|
875
|
+
`;
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
tbody.innerHTML = filtered.map(p => {
|
|
880
|
+
const isRunning = p.Status?.toLowerCase() === 'running';
|
|
881
|
+
const containerCount = p.Containers ? p.Containers.length : 0;
|
|
882
|
+
const pShort = shortId(p.Id);
|
|
883
|
+
const rowId = `expand-p-${pShort}`;
|
|
884
|
+
const isExpanded = state.expandedRows.has(rowId);
|
|
885
|
+
const containersSummary = p.Containers ? p.Containers.map(c => escapeHtml(c.Names || c.Name || '')).join(', ') : '';
|
|
886
|
+
|
|
887
|
+
return `
|
|
888
|
+
<tr class="table-row-item">
|
|
889
|
+
<td>
|
|
890
|
+
<span class="status-pill status-${isRunning ? 'running' : 'exited'}">${p.Status}</span>
|
|
891
|
+
</td>
|
|
892
|
+
<td>
|
|
893
|
+
<div class="item-name">${escapeHtml(p.Name)}</div>
|
|
894
|
+
<span class="item-id" title="Copy ID" onclick="navigator.clipboard.writeText('${p.Id}'); showToast('Copied Pod ID', '${pShort}', 'info');">${pShort}</span>
|
|
895
|
+
</td>
|
|
896
|
+
<td class="col-hide-tablet">
|
|
897
|
+
<span class="tag-badge rootless">${containerCount} Container${containerCount === 1 ? '' : 's'}</span>
|
|
898
|
+
<div style="font-size:11px; color:var(--text-tertiary); margin-top:4px;">
|
|
899
|
+
${containersSummary}
|
|
900
|
+
</div>
|
|
901
|
+
</td>
|
|
902
|
+
<td class="col-hide-tablet" style="color:var(--text-secondary); font-size:12px;">${escapeHtml(p.Created || '-')}</td>
|
|
903
|
+
<td class="col-actions-cell" style="text-align:right;">
|
|
904
|
+
<button type="button" class="btn btn-secondary btn-icon-only btn-sm action-trigger-btn" title="Actions" aria-label="Actions" aria-haspopup="true" aria-expanded="false" onclick="openFloatingDropdown('pod', '${p.Id}', this, event)">
|
|
905
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg>
|
|
906
|
+
</button>
|
|
907
|
+
</td>
|
|
908
|
+
<td class="mobile-toggle-cell" style="text-align:center;">
|
|
909
|
+
<button type="button" class="btn-expand-row ${isExpanded ? 'expanded' : ''}" data-target-row="${rowId}" aria-label="Toggle details for ${escapeHtml(p.Name)}" aria-expanded="${isExpanded}">
|
|
910
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
911
|
+
</button>
|
|
912
|
+
</td>
|
|
913
|
+
</tr>
|
|
914
|
+
<tr class="expandable-details-row ${isExpanded ? 'open' : ''}" id="${rowId}">
|
|
915
|
+
<td colspan="6">
|
|
916
|
+
<div class="details-drawer-content">
|
|
917
|
+
<div class="drawer-grid">
|
|
918
|
+
<div class="drawer-field">
|
|
919
|
+
<span class="drawer-label">Containers (${containerCount})</span>
|
|
920
|
+
<span class="drawer-value">${containersSummary || 'None'}</span>
|
|
921
|
+
</div>
|
|
922
|
+
<div class="drawer-field">
|
|
923
|
+
<span class="drawer-label">Created</span>
|
|
924
|
+
<span class="drawer-value">${escapeHtml(p.Created || '-')}</span>
|
|
925
|
+
</div>
|
|
926
|
+
</div>
|
|
927
|
+
</div>
|
|
928
|
+
</td>
|
|
929
|
+
</tr>
|
|
930
|
+
`;
|
|
931
|
+
}).join('');
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// 4. Images View
|
|
935
|
+
function renderImages() {
|
|
936
|
+
const tbody = document.getElementById('images-tbody');
|
|
937
|
+
if (!tbody) return;
|
|
938
|
+
|
|
939
|
+
if (state.loading.images) {
|
|
940
|
+
tbody.innerHTML = renderTableSkeletons('images');
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
const search = state.imageFilter.search.toLowerCase();
|
|
945
|
+
const filtered = state.images.filter(img => {
|
|
946
|
+
const repo = (img.Repositories?.[0] || img.Repository || '').toLowerCase();
|
|
947
|
+
const id = (img.Id || '').toLowerCase();
|
|
948
|
+
return repo.includes(search) || id.includes(search);
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
if (filtered.length === 0) {
|
|
952
|
+
tbody.innerHTML = `
|
|
953
|
+
<tr>
|
|
954
|
+
<td colspan="7">
|
|
955
|
+
<div class="empty-state">
|
|
956
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="16.5" y1="9.4" x2="7.5" y2="4.21"></line><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>
|
|
957
|
+
<div class="empty-state-title">No images found</div>
|
|
958
|
+
<div class="empty-state-desc">No container images match your search. Pull an image from a registry to get started.</div>
|
|
959
|
+
<button class="btn btn-primary" onclick="openModal('pull-image-modal')">
|
|
960
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
|
|
961
|
+
<span>Pull Image</span>
|
|
962
|
+
</button>
|
|
963
|
+
</div>
|
|
964
|
+
</td>
|
|
965
|
+
</tr>
|
|
966
|
+
`;
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
tbody.innerHTML = filtered.map(img => {
|
|
971
|
+
const repo = img.Repositories?.[0] || img.Repository || '<none>';
|
|
972
|
+
const tag = img.Tag || (img.Names?.[0]?.split(':')[1]) || 'latest';
|
|
973
|
+
const size = img.Size ? (typeof img.Size === 'number' ? formatBytes(img.Size) : img.Size) : '-';
|
|
974
|
+
const containersInUse = img.Containers || 0;
|
|
975
|
+
const imgShort = shortId(img.Id);
|
|
976
|
+
const rowId = `expand-img-${imgShort}`;
|
|
977
|
+
const isExpanded = state.expandedRows.has(rowId);
|
|
978
|
+
const createdStr = img.Created ? (typeof img.Created === 'number' ? new Date(img.Created * 1000).toLocaleDateString() : img.Created) : '-';
|
|
979
|
+
|
|
980
|
+
return `
|
|
981
|
+
<tr class="table-row-item">
|
|
982
|
+
<td>
|
|
983
|
+
<div class="item-name">${escapeHtml(repo)}</div>
|
|
984
|
+
<span class="item-id" title="Copy ID" onclick="navigator.clipboard.writeText('${img.Id}'); showToast('Copied Image ID', '${imgShort}', 'info');">${imgShort}</span>
|
|
985
|
+
</td>
|
|
986
|
+
<td><span class="tag-badge rootless">${escapeHtml(tag)}</span></td>
|
|
987
|
+
<td class="col-hide-tablet">${escapeHtml(size)}</td>
|
|
988
|
+
<td class="col-hide-tablet">
|
|
989
|
+
${containersInUse > 0
|
|
990
|
+
? `<span class="tag-badge" style="background-color:var(--apple-green-soft); color:var(--apple-green);">${containersInUse} In Use</span>`
|
|
991
|
+
: `<span style="color:var(--text-tertiary); font-size:12px;">Unused</span>`}
|
|
992
|
+
</td>
|
|
993
|
+
<td class="col-hide-tablet" style="color:var(--text-secondary); font-size:12px;">${escapeHtml(createdStr)}</td>
|
|
994
|
+
<td class="col-actions-cell" style="text-align:right;">
|
|
995
|
+
<button type="button" class="btn btn-secondary btn-icon-only btn-sm action-trigger-btn" title="Actions" aria-label="Actions" aria-haspopup="true" aria-expanded="false" onclick="openFloatingDropdown('image', '${img.Id}', this, event)">
|
|
996
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg>
|
|
997
|
+
</button>
|
|
998
|
+
</td>
|
|
999
|
+
<td class="mobile-toggle-cell" style="text-align:center;">
|
|
1000
|
+
<button type="button" class="btn-expand-row ${isExpanded ? 'expanded' : ''}" data-target-row="${rowId}" aria-label="Toggle details for ${escapeHtml(repo)}" aria-expanded="${isExpanded}">
|
|
1001
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
1002
|
+
</button>
|
|
1003
|
+
</td>
|
|
1004
|
+
</tr>
|
|
1005
|
+
<tr class="expandable-details-row ${isExpanded ? 'open' : ''}" id="${rowId}">
|
|
1006
|
+
<td colspan="7">
|
|
1007
|
+
<div class="details-drawer-content">
|
|
1008
|
+
<div class="drawer-grid">
|
|
1009
|
+
<div class="drawer-field">
|
|
1010
|
+
<span class="drawer-label">Size</span>
|
|
1011
|
+
<span class="drawer-value">${escapeHtml(size)}</span>
|
|
1012
|
+
</div>
|
|
1013
|
+
<div class="drawer-field">
|
|
1014
|
+
<span class="drawer-label">In Use</span>
|
|
1015
|
+
<span class="drawer-value">${containersInUse > 0 ? `${containersInUse} container(s)` : 'Unused'}</span>
|
|
1016
|
+
</div>
|
|
1017
|
+
<div class="drawer-field">
|
|
1018
|
+
<span class="drawer-label">Created</span>
|
|
1019
|
+
<span class="drawer-value">${escapeHtml(createdStr)}</span>
|
|
1020
|
+
</div>
|
|
1021
|
+
</div>
|
|
1022
|
+
</div>
|
|
1023
|
+
</td>
|
|
1024
|
+
</tr>
|
|
1025
|
+
`;
|
|
1026
|
+
}).join('');
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// 5. Volumes View
|
|
1030
|
+
function renderVolumes() {
|
|
1031
|
+
const tbody = document.getElementById('volumes-tbody');
|
|
1032
|
+
if (!tbody) return;
|
|
1033
|
+
|
|
1034
|
+
if (state.loading.volumes) {
|
|
1035
|
+
tbody.innerHTML = renderTableSkeletons('volumes');
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
const search = state.volumeFilter.search.toLowerCase();
|
|
1040
|
+
const filtered = state.volumes.filter(v => {
|
|
1041
|
+
return (v.Name || '').toLowerCase().includes(search) || (v.Driver || '').toLowerCase().includes(search);
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
if (filtered.length === 0) {
|
|
1045
|
+
tbody.innerHTML = `
|
|
1046
|
+
<tr>
|
|
1047
|
+
<td colspan="6">
|
|
1048
|
+
<div class="empty-state">
|
|
1049
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>
|
|
1050
|
+
<div class="empty-state-title">No volumes found</div>
|
|
1051
|
+
<div class="empty-state-desc">No storage volumes match your search. Create a persistent volume for your application data.</div>
|
|
1052
|
+
<button class="btn btn-primary" onclick="openModal('create-volume-modal')">
|
|
1053
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
|
1054
|
+
<span>Create Volume</span>
|
|
1055
|
+
</button>
|
|
1056
|
+
</div>
|
|
1057
|
+
</td>
|
|
1058
|
+
</tr>
|
|
1059
|
+
`;
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
tbody.innerHTML = filtered.map(v => {
|
|
1064
|
+
const volIdSafe = encodeURIComponent(v.Name).replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
1065
|
+
const rowId = `expand-vol-${volIdSafe}`;
|
|
1066
|
+
const isExpanded = state.expandedRows.has(rowId);
|
|
1067
|
+
|
|
1068
|
+
return `
|
|
1069
|
+
<tr class="table-row-item">
|
|
1070
|
+
<td><strong>${escapeHtml(v.Name)}</strong></td>
|
|
1071
|
+
<td><span class="tag-badge rootless">${escapeHtml(v.Driver || 'local')}</span></td>
|
|
1072
|
+
<td class="col-hide-tablet" style="font-family:monospace; font-size:11px; color:var(--text-secondary);">${escapeHtml(v.MountPoint || '-')}</td>
|
|
1073
|
+
<td class="col-hide-tablet" style="color:var(--text-secondary); font-size:12px;">${escapeHtml(v.CreatedAt || '-')}</td>
|
|
1074
|
+
<td class="col-actions-cell" style="text-align:right;">
|
|
1075
|
+
<button type="button" class="btn btn-secondary btn-icon-only btn-sm action-trigger-btn" title="Actions" aria-label="Actions" aria-haspopup="true" aria-expanded="false" onclick="openFloatingDropdown('volume', '${encodeURIComponent(v.Name)}', this, event)">
|
|
1076
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg>
|
|
1077
|
+
</button>
|
|
1078
|
+
</td>
|
|
1079
|
+
<td class="mobile-toggle-cell" style="text-align:center;">
|
|
1080
|
+
<button type="button" class="btn-expand-row ${isExpanded ? 'expanded' : ''}" data-target-row="${rowId}" aria-label="Toggle details for ${escapeHtml(v.Name)}" aria-expanded="${isExpanded}">
|
|
1081
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
1082
|
+
</button>
|
|
1083
|
+
</td>
|
|
1084
|
+
</tr>
|
|
1085
|
+
<tr class="expandable-details-row ${isExpanded ? 'open' : ''}" id="${rowId}">
|
|
1086
|
+
<td colspan="6">
|
|
1087
|
+
<div class="details-drawer-content">
|
|
1088
|
+
<div class="drawer-grid">
|
|
1089
|
+
<div class="drawer-field">
|
|
1090
|
+
<span class="drawer-label">Mountpoint</span>
|
|
1091
|
+
<span class="drawer-value" style="font-family:monospace; font-size:11px;">${escapeHtml(v.MountPoint || '-')}</span>
|
|
1092
|
+
</div>
|
|
1093
|
+
<div class="drawer-field">
|
|
1094
|
+
<span class="drawer-label">Created</span>
|
|
1095
|
+
<span class="drawer-value">${escapeHtml(v.CreatedAt || '-')}</span>
|
|
1096
|
+
</div>
|
|
1097
|
+
</div>
|
|
1098
|
+
</div>
|
|
1099
|
+
</td>
|
|
1100
|
+
</tr>
|
|
1101
|
+
`;
|
|
1102
|
+
}).join('');
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// 6. Networks View
|
|
1106
|
+
function renderNetworks() {
|
|
1107
|
+
const tbody = document.getElementById('networks-tbody');
|
|
1108
|
+
if (!tbody) return;
|
|
1109
|
+
|
|
1110
|
+
if (state.loading.networks) {
|
|
1111
|
+
tbody.innerHTML = renderTableSkeletons('networks');
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
const search = state.networkFilter.search.toLowerCase();
|
|
1116
|
+
const filtered = state.networks.filter(n => {
|
|
1117
|
+
return (n.name || '').toLowerCase().includes(search) ||
|
|
1118
|
+
(n.driver || '').toLowerCase().includes(search) ||
|
|
1119
|
+
(n.id || '').toLowerCase().includes(search);
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
if (filtered.length === 0) {
|
|
1123
|
+
tbody.innerHTML = `
|
|
1124
|
+
<tr>
|
|
1125
|
+
<td colspan="7">
|
|
1126
|
+
<div class="empty-state">
|
|
1127
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="16" y="16" width="6" height="6" rx="1"></rect><rect x="2" y="16" width="6" height="6" rx="1"></rect><rect x="9" y="2" width="6" height="6" rx="1"></rect><path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"></path><path d="M12 12V8"></path></svg>
|
|
1128
|
+
<div class="empty-state-title">No networks found</div>
|
|
1129
|
+
<div class="empty-state-desc">No networks match your search. Create a custom network to isolate or connect containers.</div>
|
|
1130
|
+
<button class="btn btn-primary" onclick="openModal('create-network-modal')">
|
|
1131
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
|
1132
|
+
<span>Create Network</span>
|
|
1133
|
+
</button>
|
|
1134
|
+
</div>
|
|
1135
|
+
</td>
|
|
1136
|
+
</tr>
|
|
1137
|
+
`;
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
tbody.innerHTML = filtered.map(n => {
|
|
1142
|
+
const subnets = n.subnets ? n.subnets.map(s => s.subnet).join(', ') : '-';
|
|
1143
|
+
const gateways = n.subnets ? n.subnets.map(s => s.gateway).filter(Boolean).join(', ') : '-';
|
|
1144
|
+
const nShort = shortId(n.id);
|
|
1145
|
+
const netIdSafe = encodeURIComponent(n.name).replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
1146
|
+
const rowId = `expand-net-${netIdSafe}`;
|
|
1147
|
+
const isExpanded = state.expandedRows.has(rowId);
|
|
1148
|
+
|
|
1149
|
+
return `
|
|
1150
|
+
<tr class="table-row-item">
|
|
1151
|
+
<td><strong>${escapeHtml(n.name)}</strong></td>
|
|
1152
|
+
<td class="col-hide-tablet"><span class="item-id">${nShort}</span></td>
|
|
1153
|
+
<td><span class="tag-badge rootless">${escapeHtml(n.driver || 'bridge')}</span></td>
|
|
1154
|
+
<td class="col-hide-tablet" style="font-family:monospace; font-size:12px;">${escapeHtml(subnets)}</td>
|
|
1155
|
+
<td class="col-hide-tablet" style="font-family:monospace; font-size:12px;">${escapeHtml(gateways)}</td>
|
|
1156
|
+
<td class="col-actions-cell" style="text-align:right;">
|
|
1157
|
+
<button type="button" class="btn btn-secondary btn-icon-only btn-sm action-trigger-btn" title="Actions" aria-label="Actions" aria-haspopup="true" aria-expanded="false" onclick="openFloatingDropdown('network', '${encodeURIComponent(n.name)}', this, event)">
|
|
1158
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg>
|
|
1159
|
+
</button>
|
|
1160
|
+
</td>
|
|
1161
|
+
<td class="mobile-toggle-cell" style="text-align:center;">
|
|
1162
|
+
<button type="button" class="btn-expand-row ${isExpanded ? 'expanded' : ''}" data-target-row="${rowId}" aria-label="Toggle details for ${escapeHtml(n.name)}" aria-expanded="${isExpanded}">
|
|
1163
|
+
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
1164
|
+
</button>
|
|
1165
|
+
</td>
|
|
1166
|
+
</tr>
|
|
1167
|
+
<tr class="expandable-details-row ${isExpanded ? 'open' : ''}" id="${rowId}">
|
|
1168
|
+
<td colspan="7">
|
|
1169
|
+
<div class="details-drawer-content">
|
|
1170
|
+
<div class="drawer-grid">
|
|
1171
|
+
<div class="drawer-field">
|
|
1172
|
+
<span class="drawer-label">Network ID</span>
|
|
1173
|
+
<span class="drawer-value" style="font-family:monospace; font-size:11px;">${nShort}</span>
|
|
1174
|
+
</div>
|
|
1175
|
+
<div class="drawer-field">
|
|
1176
|
+
<span class="drawer-label">Subnets</span>
|
|
1177
|
+
<span class="drawer-value" style="font-family:monospace; font-size:11px;">${escapeHtml(subnets)}</span>
|
|
1178
|
+
</div>
|
|
1179
|
+
<div class="drawer-field">
|
|
1180
|
+
<span class="drawer-label">Gateways</span>
|
|
1181
|
+
<span class="drawer-value" style="font-family:monospace; font-size:11px;">${escapeHtml(gateways)}</span>
|
|
1182
|
+
</div>
|
|
1183
|
+
</div>
|
|
1184
|
+
</div>
|
|
1185
|
+
</td>
|
|
1186
|
+
</tr>
|
|
1187
|
+
`;
|
|
1188
|
+
}).join('');
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// 7. Events Log
|
|
1192
|
+
async function loadEvents(force = false) {
|
|
1193
|
+
try {
|
|
1194
|
+
const res = await API.getEvents('24h');
|
|
1195
|
+
if (res?.data && Array.isArray(res.data)) {
|
|
1196
|
+
if (force || state.events.length === 0) {
|
|
1197
|
+
state.events = res.data;
|
|
1198
|
+
} else {
|
|
1199
|
+
// Merge without duplicating
|
|
1200
|
+
const existingKeys = new Set(state.events.map(e => `${e.time || e.Time}_${e.timeNano || ''}_${e.ID || e.Name}_${e.Status || e.Action}`));
|
|
1201
|
+
for (const item of res.data) {
|
|
1202
|
+
const key = `${item.time || item.Time}_${item.timeNano || ''}_${item.ID || item.Name}_${item.Status || item.Action}`;
|
|
1203
|
+
if (!existingKeys.has(key)) {
|
|
1204
|
+
state.events.push(item);
|
|
1205
|
+
existingKeys.add(key);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
state.events.sort((a, b) => ((b.time || b.Time || 0) - (a.time || a.Time || 0)));
|
|
1209
|
+
}
|
|
1210
|
+
updateBadges();
|
|
1211
|
+
if (state.activeView === 'events') {
|
|
1212
|
+
renderEvents();
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
} catch (err) {
|
|
1216
|
+
console.warn('Failed to load past events:', err);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
function initEventStream() {
|
|
1221
|
+
try {
|
|
1222
|
+
const eventSource = new EventSource('/api/events/stream');
|
|
1223
|
+
eventSource.onmessage = (e) => {
|
|
1224
|
+
try {
|
|
1225
|
+
const item = JSON.parse(e.data);
|
|
1226
|
+
if (item && (item.Type || item.Action || item.Status)) {
|
|
1227
|
+
state.events.unshift(item);
|
|
1228
|
+
if (state.events.length > 250) state.events.pop();
|
|
1229
|
+
updateBadges();
|
|
1230
|
+
if (state.activeView === 'events') {
|
|
1231
|
+
renderEvents();
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
} catch {}
|
|
1235
|
+
};
|
|
1236
|
+
eventSource.onerror = () => {
|
|
1237
|
+
// Reconnect handled automatically by EventSource
|
|
1238
|
+
};
|
|
1239
|
+
} catch (err) {
|
|
1240
|
+
console.warn('Events SSE not supported or blocked:', err);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
function renderEvents() {
|
|
1245
|
+
const container = document.getElementById('events-container');
|
|
1246
|
+
if (!container) return;
|
|
1247
|
+
|
|
1248
|
+
const search = (state.eventFilter?.search || '').toLowerCase();
|
|
1249
|
+
const filtered = state.events.filter(ev => {
|
|
1250
|
+
if (!search) return true;
|
|
1251
|
+
const type = (ev.Type || '').toLowerCase();
|
|
1252
|
+
const action = (ev.Action || ev.Status || '').toLowerCase();
|
|
1253
|
+
const name = (ev.Name || ev.ID || '').toLowerCase();
|
|
1254
|
+
return type.includes(search) || action.includes(search) || name.includes(search);
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
if (filtered.length === 0) {
|
|
1258
|
+
container.innerHTML = `
|
|
1259
|
+
<div class="empty-state">
|
|
1260
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline></svg>
|
|
1261
|
+
<div class="empty-state-title">No events found</div>
|
|
1262
|
+
<div class="empty-state-desc">Listening for Podman daemon activity (containers created, started, stopped, images pulled, etc.).</div>
|
|
1263
|
+
</div>
|
|
1264
|
+
`;
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
container.innerHTML = filtered.map(ev => {
|
|
1269
|
+
const type = ev.Type || 'system';
|
|
1270
|
+
const action = ev.Action || ev.Status || 'event';
|
|
1271
|
+
const name = ev.Name || (ev.Image ? ev.Image.split('/').pop() : '') || (ev.ID ? shortId(ev.ID) : '-');
|
|
1272
|
+
const timestamp = ev.time || ev.Time;
|
|
1273
|
+
const timeStr = timestamp ? new Date(timestamp * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' }) : '-';
|
|
1274
|
+
const dateStr = timestamp ? new Date(timestamp * 1000).toLocaleDateString([], { month: 'short', day: 'numeric' }) : '';
|
|
1275
|
+
|
|
1276
|
+
let actionStyle = 'background-color:rgba(255,255,255,0.06); color:var(--text-secondary);';
|
|
1277
|
+
if (['start', 'create', 'pull'].includes(action)) {
|
|
1278
|
+
actionStyle = 'background-color:var(--apple-green-soft); color:var(--apple-green);';
|
|
1279
|
+
} else if (['died', 'die', 'kill', 'remove', 'rm'].includes(action)) {
|
|
1280
|
+
actionStyle = 'background-color:var(--apple-red-soft); color:var(--apple-red);';
|
|
1281
|
+
} else if (['stop', 'pause'].includes(action)) {
|
|
1282
|
+
actionStyle = 'background-color:var(--apple-yellow-soft); color:var(--apple-yellow);';
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
return `
|
|
1286
|
+
<div style="padding:12px 18px; border-bottom:1px solid var(--border-subtle); display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:13px;">
|
|
1287
|
+
<div style="display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0;">
|
|
1288
|
+
<span class="tag-badge rootless" style="text-transform:uppercase; font-size:10px; letter-spacing:0.5px;">${escapeHtml(type)}</span>
|
|
1289
|
+
<span class="tag-badge" style="${actionStyle}; font-weight:600;">${escapeHtml(action)}</span>
|
|
1290
|
+
<strong style="color:var(--text-primary); word-break:break-all;">${escapeHtml(name)}</strong>
|
|
1291
|
+
${ev.ID ? `<span class="item-id" title="${escapeHtml(ev.ID)}">${shortId(ev.ID)}</span>` : ''}
|
|
1292
|
+
${ev.ExitCode !== undefined || ev.ContainerExitCode !== undefined ? `<span style="font-size:11px; color:var(--text-tertiary);">(exit ${ev.ExitCode ?? ev.ContainerExitCode})</span>` : ''}
|
|
1293
|
+
</div>
|
|
1294
|
+
<div style="text-align:right; white-space:nowrap; flex-shrink:0;">
|
|
1295
|
+
<div style="font-size:12px; font-weight:500; color:var(--text-primary); font-family:ui-monospace, SFMono-Regular, monospace;">${timeStr}</div>
|
|
1296
|
+
<div style="font-size:10px; color:var(--text-tertiary);">${dateStr}</div>
|
|
1297
|
+
</div>
|
|
1298
|
+
</div>
|
|
1299
|
+
`;
|
|
1300
|
+
}).join('');
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// ----------------- ACTIONS -----------------
|
|
1304
|
+
|
|
1305
|
+
// Container Actions
|
|
1306
|
+
async function actionContainer(id, action) {
|
|
1307
|
+
try {
|
|
1308
|
+
showToast('Executing...', `${action.toUpperCase()} container ${shortId(id)}`, 'info');
|
|
1309
|
+
if (action === 'start') await API.startContainer(id);
|
|
1310
|
+
else if (action === 'stop') await API.stopContainer(id);
|
|
1311
|
+
else if (action === 'restart') await API.restartContainer(id);
|
|
1312
|
+
else if (action === 'pause') await API.pauseContainer(id);
|
|
1313
|
+
else if (action === 'unpause') await API.unpauseContainer(id);
|
|
1314
|
+
|
|
1315
|
+
showToast('Success', `Container ${action} completed`, 'success');
|
|
1316
|
+
await refreshData();
|
|
1317
|
+
} catch (err) {
|
|
1318
|
+
showToast(`Failed to ${action} container`, err.message, 'error');
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function confirmDeleteContainer(id, name) {
|
|
1323
|
+
if (confirm(`Are you sure you want to remove container "${name}" (${shortId(id)})?`)) {
|
|
1324
|
+
API.removeContainer(id, true)
|
|
1325
|
+
.then(() => {
|
|
1326
|
+
showToast('Container Removed', `Removed ${name}`, 'success');
|
|
1327
|
+
refreshData();
|
|
1328
|
+
})
|
|
1329
|
+
.catch(err => {
|
|
1330
|
+
showToast('Failed to Remove Container', err.message, 'error');
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// Pod Actions
|
|
1336
|
+
async function actionPod(id, action) {
|
|
1337
|
+
try {
|
|
1338
|
+
showToast('Executing...', `${action.toUpperCase()} pod ${shortId(id)}`, 'info');
|
|
1339
|
+
if (action === 'start') await API.startPod(id);
|
|
1340
|
+
else if (action === 'stop') await API.stopPod(id);
|
|
1341
|
+
else if (action === 'restart') await API.restartPod(id);
|
|
1342
|
+
|
|
1343
|
+
showToast('Success', `Pod ${action} completed`, 'success');
|
|
1344
|
+
await refreshData();
|
|
1345
|
+
} catch (err) {
|
|
1346
|
+
showToast(`Failed to ${action} pod`, err.message, 'error');
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function confirmDeletePod(id, name) {
|
|
1351
|
+
if (confirm(`Are you sure you want to delete pod "${name}"? Containers inside will also be removed.`)) {
|
|
1352
|
+
API.removePod(id, true)
|
|
1353
|
+
.then(() => {
|
|
1354
|
+
showToast('Pod Removed', `Removed ${name}`, 'success');
|
|
1355
|
+
refreshData();
|
|
1356
|
+
})
|
|
1357
|
+
.catch(err => {
|
|
1358
|
+
showToast('Failed to Remove Pod', err.message, 'error');
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// Image Actions
|
|
1364
|
+
function confirmDeleteImage(id, name) {
|
|
1365
|
+
if (confirm(`Are you sure you want to remove image "${name}"?`)) {
|
|
1366
|
+
API.removeImage(id, true)
|
|
1367
|
+
.then(() => {
|
|
1368
|
+
showToast('Image Removed', `Removed ${name}`, 'success');
|
|
1369
|
+
refreshData();
|
|
1370
|
+
})
|
|
1371
|
+
.catch(err => {
|
|
1372
|
+
showToast('Failed to Remove Image', err.message, 'error');
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// Volume Actions
|
|
1378
|
+
function deleteVolume(name) {
|
|
1379
|
+
if (confirm(`Are you sure you want to delete volume "${decodeURIComponent(name)}"?`)) {
|
|
1380
|
+
API.removeVolume(name, true)
|
|
1381
|
+
.then(() => {
|
|
1382
|
+
showToast('Volume Removed', decodeURIComponent(name), 'success');
|
|
1383
|
+
refreshData();
|
|
1384
|
+
})
|
|
1385
|
+
.catch(err => {
|
|
1386
|
+
showToast('Failed to Remove Volume', err.message, 'error');
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// Network Actions
|
|
1392
|
+
function deleteNetwork(name) {
|
|
1393
|
+
if (confirm(`Are you sure you want to delete network "${decodeURIComponent(name)}"?`)) {
|
|
1394
|
+
API.removeNetwork(name)
|
|
1395
|
+
.then(() => {
|
|
1396
|
+
showToast('Network Removed', decodeURIComponent(name), 'success');
|
|
1397
|
+
refreshData();
|
|
1398
|
+
})
|
|
1399
|
+
.catch(err => {
|
|
1400
|
+
showToast('Failed to Remove Network', err.message, 'error');
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// System Prune
|
|
1406
|
+
async function executePrune(type) {
|
|
1407
|
+
if (!confirm(`Are you sure you want to prune ${type}? This will delete unused data irreversibly.`)) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
try {
|
|
1411
|
+
showToast('Pruning...', `Pruning ${type}...`, 'info');
|
|
1412
|
+
const res = await API.pruneSystem(type);
|
|
1413
|
+
showToast('Prune Completed', res.stdout || 'Cleaned unused resources', 'success');
|
|
1414
|
+
closeModal('prune-modal');
|
|
1415
|
+
await refreshData();
|
|
1416
|
+
} catch (err) {
|
|
1417
|
+
showToast('Prune Failed', err.message, 'error');
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// Inspect Modal
|
|
1422
|
+
async function inspectItem(type, id) {
|
|
1423
|
+
openModal('inspect-modal');
|
|
1424
|
+
const inspectTitle = document.getElementById('inspect-modal-title');
|
|
1425
|
+
const inspectViewer = document.getElementById('inspect-content');
|
|
1426
|
+
|
|
1427
|
+
inspectTitle.textContent = `Inspect ${type.toUpperCase()}: ${decodeURIComponent(id)}`;
|
|
1428
|
+
inspectViewer.textContent = 'Loading details...';
|
|
1429
|
+
|
|
1430
|
+
try {
|
|
1431
|
+
let data;
|
|
1432
|
+
if (type === 'container') data = (await API.inspectContainer(id)).data;
|
|
1433
|
+
else if (type === 'pod') data = (await API.inspectPod(id)).data;
|
|
1434
|
+
else if (type === 'image') data = (await API.inspectImage(id)).data;
|
|
1435
|
+
else if (type === 'volume') data = (await API.inspectVolume(id)).data;
|
|
1436
|
+
else if (type === 'network') data = (await API.inspectNetwork(id)).data;
|
|
1437
|
+
|
|
1438
|
+
inspectViewer.textContent = JSON.stringify(data, null, 2);
|
|
1439
|
+
} catch (err) {
|
|
1440
|
+
inspectViewer.textContent = `Error loading inspection data:\n${err.message}`;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// Container Logs Viewer
|
|
1445
|
+
function viewContainerLogs(id, name) {
|
|
1446
|
+
state.logsConfig.containerId = id;
|
|
1447
|
+
state.logsConfig.containerName = name;
|
|
1448
|
+
openModal('logs-modal');
|
|
1449
|
+
document.getElementById('logs-modal-title').textContent = `Logs: ${name}`;
|
|
1450
|
+
|
|
1451
|
+
// Sync button active states
|
|
1452
|
+
const autoBtn = document.getElementById('btn-logs-autoscroll');
|
|
1453
|
+
if (autoBtn) autoBtn.classList.toggle('active', state.logsConfig.autoscroll);
|
|
1454
|
+
const timeBtn = document.getElementById('btn-logs-timestamps');
|
|
1455
|
+
if (timeBtn) timeBtn.classList.toggle('active', state.logsConfig.timestamps);
|
|
1456
|
+
|
|
1457
|
+
restartLogsStream();
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
function restartLogsStream() {
|
|
1461
|
+
const viewer = document.getElementById('logs-viewer');
|
|
1462
|
+
if (!viewer) return;
|
|
1463
|
+
const id = state.logsConfig.containerId;
|
|
1464
|
+
if (!id) return;
|
|
1465
|
+
|
|
1466
|
+
viewer.textContent = 'Streaming logs...\n';
|
|
1467
|
+
|
|
1468
|
+
if (state.activeLogStream) {
|
|
1469
|
+
state.activeLogStream.close();
|
|
1470
|
+
state.activeLogStream = null;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
const tail = document.getElementById('logs-tail-select')?.value || 100;
|
|
1474
|
+
const timestamps = state.logsConfig.timestamps;
|
|
1475
|
+
|
|
1476
|
+
try {
|
|
1477
|
+
const sse = new EventSource(`/api/containers/${id}/logs/stream?tail=${tail}×tamps=${timestamps}`);
|
|
1478
|
+
state.activeLogStream = sse;
|
|
1479
|
+
|
|
1480
|
+
sse.onmessage = (e) => {
|
|
1481
|
+
try {
|
|
1482
|
+
const item = JSON.parse(e.data);
|
|
1483
|
+
if (item.log) {
|
|
1484
|
+
viewer.textContent += item.log + '\n';
|
|
1485
|
+
if (state.logsConfig.autoscroll) {
|
|
1486
|
+
viewer.scrollTop = viewer.scrollHeight;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
} catch {}
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
sse.addEventListener('end', () => {
|
|
1493
|
+
viewer.textContent += '\n[Log stream closed]\n';
|
|
1494
|
+
sse.close();
|
|
1495
|
+
state.activeLogStream = null;
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
sse.onerror = () => {
|
|
1499
|
+
// fallback to static log fetch if streaming encounters error
|
|
1500
|
+
API.getContainerLogs(id, tail, timestamps).then(res => {
|
|
1501
|
+
viewer.textContent = res.logs || 'No logs available.';
|
|
1502
|
+
if (state.logsConfig.autoscroll) {
|
|
1503
|
+
viewer.scrollTop = viewer.scrollHeight;
|
|
1504
|
+
}
|
|
1505
|
+
}).catch(err => {
|
|
1506
|
+
viewer.textContent = `Error fetching logs: ${err.message}`;
|
|
1507
|
+
});
|
|
1508
|
+
sse.close();
|
|
1509
|
+
state.activeLogStream = null;
|
|
1510
|
+
};
|
|
1511
|
+
} catch (err) {
|
|
1512
|
+
viewer.textContent = `Log viewer error: ${err.message}`;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
function toggleLogsAutoscroll() {
|
|
1517
|
+
state.logsConfig.autoscroll = !state.logsConfig.autoscroll;
|
|
1518
|
+
const btn = document.getElementById('btn-logs-autoscroll');
|
|
1519
|
+
if (btn) {
|
|
1520
|
+
btn.classList.toggle('active', state.logsConfig.autoscroll);
|
|
1521
|
+
}
|
|
1522
|
+
if (state.logsConfig.autoscroll) {
|
|
1523
|
+
const viewer = document.getElementById('logs-viewer');
|
|
1524
|
+
if (viewer) viewer.scrollTop = viewer.scrollHeight;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
function toggleLogsTimestamps() {
|
|
1529
|
+
state.logsConfig.timestamps = !state.logsConfig.timestamps;
|
|
1530
|
+
const btn = document.getElementById('btn-logs-timestamps');
|
|
1531
|
+
if (btn) {
|
|
1532
|
+
btn.classList.toggle('active', state.logsConfig.timestamps);
|
|
1533
|
+
}
|
|
1534
|
+
restartLogsStream();
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
function copyLogsToClipboard() {
|
|
1538
|
+
const viewer = document.getElementById('logs-viewer');
|
|
1539
|
+
if (!viewer) return;
|
|
1540
|
+
navigator.clipboard.writeText(viewer.textContent).then(() => {
|
|
1541
|
+
showToast('Copied to Clipboard', 'Container logs copied', 'info');
|
|
1542
|
+
}).catch(() => {
|
|
1543
|
+
showToast('Copy Failed', 'Unable to copy logs', 'error');
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function clearLogsViewer() {
|
|
1548
|
+
const viewer = document.getElementById('logs-viewer');
|
|
1549
|
+
if (viewer) viewer.textContent = '';
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// Container Exec Terminal
|
|
1553
|
+
let activeExecContainerId = null;
|
|
1554
|
+
function openExecModal(id, name) {
|
|
1555
|
+
activeExecContainerId = id;
|
|
1556
|
+
openModal('exec-modal');
|
|
1557
|
+
document.getElementById('exec-modal-title').textContent = `Execute Command: ${name}`;
|
|
1558
|
+
document.getElementById('exec-cmd-input').value = '';
|
|
1559
|
+
document.getElementById('exec-output').textContent = 'Enter a command above and press Run (e.g. uname -a, ps aux, ls -la, env)...';
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
async function runContainerExec() {
|
|
1563
|
+
if (!activeExecContainerId) return;
|
|
1564
|
+
const cmd = document.getElementById('exec-cmd-input').value.trim();
|
|
1565
|
+
if (!cmd) return;
|
|
1566
|
+
|
|
1567
|
+
const outputBox = document.getElementById('exec-output');
|
|
1568
|
+
outputBox.textContent = `Running: ${cmd}...\n`;
|
|
1569
|
+
|
|
1570
|
+
try {
|
|
1571
|
+
const res = await API.execContainer(activeExecContainerId, cmd);
|
|
1572
|
+
outputBox.textContent = (res.stdout || '') + (res.stderr ? '\n[STDERR]:\n' + res.stderr : '');
|
|
1573
|
+
if (!res.stdout && !res.stderr) {
|
|
1574
|
+
outputBox.textContent = '[Command completed with empty output]';
|
|
1575
|
+
}
|
|
1576
|
+
} catch (err) {
|
|
1577
|
+
outputBox.textContent = `Execution failed:\n${err.message}`;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
// Create Container Modal
|
|
1582
|
+
function openCreateContainerModal(prefillImage = '') {
|
|
1583
|
+
openModal('create-container-modal');
|
|
1584
|
+
if (prefillImage) {
|
|
1585
|
+
document.getElementById('create-image-input').value = prefillImage;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
async function handleCreateContainer(e) {
|
|
1590
|
+
e.preventDefault();
|
|
1591
|
+
const btn = document.getElementById('btn-submit-create-container');
|
|
1592
|
+
btn.disabled = true;
|
|
1593
|
+
btn.textContent = 'Launching Container...';
|
|
1594
|
+
|
|
1595
|
+
const payload = {
|
|
1596
|
+
image: document.getElementById('create-image-input').value.trim(),
|
|
1597
|
+
name: document.getElementById('create-name-input').value.trim(),
|
|
1598
|
+
ports: document.getElementById('create-ports-input').value.trim(),
|
|
1599
|
+
envs: document.getElementById('create-envs-input').value.trim(),
|
|
1600
|
+
volumes: document.getElementById('create-volumes-input').value.trim(),
|
|
1601
|
+
cmd: document.getElementById('create-cmd-input').value.trim(),
|
|
1602
|
+
restart: document.getElementById('create-restart-select').value,
|
|
1603
|
+
autoRemove: document.getElementById('create-autoremove-check').checked
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
try {
|
|
1607
|
+
const result = await API.createContainer(payload);
|
|
1608
|
+
showToast('Container Launched', `ID: ${shortId(result.containerId)}`, 'success');
|
|
1609
|
+
closeModal('create-container-modal');
|
|
1610
|
+
e.target.reset();
|
|
1611
|
+
await refreshData();
|
|
1612
|
+
} catch (err) {
|
|
1613
|
+
showToast('Launch Failed', err.message, 'error');
|
|
1614
|
+
} finally {
|
|
1615
|
+
btn.disabled = false;
|
|
1616
|
+
btn.textContent = 'Run Container';
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// Create Pod Modal
|
|
1621
|
+
async function handleCreatePod(e) {
|
|
1622
|
+
e.preventDefault();
|
|
1623
|
+
const name = document.getElementById('create-pod-name').value.trim();
|
|
1624
|
+
const ports = document.getElementById('create-pod-ports').value.trim();
|
|
1625
|
+
|
|
1626
|
+
try {
|
|
1627
|
+
await API.createPod({ name, ports });
|
|
1628
|
+
showToast('Pod Created', name || 'New Pod', 'success');
|
|
1629
|
+
closeModal('create-pod-modal');
|
|
1630
|
+
e.target.reset();
|
|
1631
|
+
await refreshData();
|
|
1632
|
+
} catch (err) {
|
|
1633
|
+
showToast('Failed to Create Pod', err.message, 'error');
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
// Pull Image Modal
|
|
1638
|
+
function handlePullImage(e) {
|
|
1639
|
+
e.preventDefault();
|
|
1640
|
+
const image = document.getElementById('pull-image-input').value.trim();
|
|
1641
|
+
if (!image) return;
|
|
1642
|
+
|
|
1643
|
+
const outputBox = document.getElementById('pull-output');
|
|
1644
|
+
outputBox.style.display = 'block';
|
|
1645
|
+
outputBox.textContent = `Starting pull for ${image}...\n`;
|
|
1646
|
+
|
|
1647
|
+
const btn = document.getElementById('btn-submit-pull');
|
|
1648
|
+
btn.disabled = true;
|
|
1649
|
+
btn.textContent = 'Pulling...';
|
|
1650
|
+
|
|
1651
|
+
try {
|
|
1652
|
+
const sse = new EventSource(`/api/images/pull-stream?image=${encodeURIComponent(image)}`);
|
|
1653
|
+
sse.onmessage = (event) => {
|
|
1654
|
+
try {
|
|
1655
|
+
const data = JSON.parse(event.data);
|
|
1656
|
+
if (data.text) {
|
|
1657
|
+
outputBox.textContent += data.text;
|
|
1658
|
+
outputBox.scrollTop = outputBox.scrollHeight;
|
|
1659
|
+
}
|
|
1660
|
+
} catch {}
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
sse.addEventListener('complete', () => {
|
|
1664
|
+
outputBox.textContent += '\nImage pull completed successfully!\n';
|
|
1665
|
+
showToast('Image Pulled', image, 'success');
|
|
1666
|
+
btn.disabled = false;
|
|
1667
|
+
btn.textContent = 'Pull Image';
|
|
1668
|
+
sse.close();
|
|
1669
|
+
refreshData();
|
|
1670
|
+
});
|
|
1671
|
+
|
|
1672
|
+
sse.addEventListener('error', (event) => {
|
|
1673
|
+
try {
|
|
1674
|
+
const data = JSON.parse(event.data);
|
|
1675
|
+
outputBox.textContent += `\nError pulling image: ${data.error}\n`;
|
|
1676
|
+
showToast('Pull Failed', data.error, 'error');
|
|
1677
|
+
} catch {
|
|
1678
|
+
outputBox.textContent += '\nConnection to pull stream closed or failed.\n';
|
|
1679
|
+
}
|
|
1680
|
+
btn.disabled = false;
|
|
1681
|
+
btn.textContent = 'Pull Image';
|
|
1682
|
+
sse.close();
|
|
1683
|
+
});
|
|
1684
|
+
} catch (err) {
|
|
1685
|
+
outputBox.textContent += `\nError: ${err.message}\n`;
|
|
1686
|
+
btn.disabled = false;
|
|
1687
|
+
btn.textContent = 'Pull Image';
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
// Create Volume Modal
|
|
1692
|
+
async function handleCreateVolume(e) {
|
|
1693
|
+
e.preventDefault();
|
|
1694
|
+
const name = document.getElementById('create-vol-name').value.trim();
|
|
1695
|
+
const driver = document.getElementById('create-vol-driver').value.trim();
|
|
1696
|
+
|
|
1697
|
+
try {
|
|
1698
|
+
await API.createVolume(name, driver);
|
|
1699
|
+
showToast('Volume Created', name, 'success');
|
|
1700
|
+
closeModal('create-volume-modal');
|
|
1701
|
+
e.target.reset();
|
|
1702
|
+
await refreshData();
|
|
1703
|
+
} catch (err) {
|
|
1704
|
+
showToast('Failed to Create Volume', err.message, 'error');
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// Create Network Modal
|
|
1709
|
+
async function handleCreateNetwork(e) {
|
|
1710
|
+
e.preventDefault();
|
|
1711
|
+
const name = document.getElementById('create-net-name').value.trim();
|
|
1712
|
+
const driver = document.getElementById('create-net-driver').value.trim() || 'bridge';
|
|
1713
|
+
const subnet = document.getElementById('create-net-subnet').value.trim() || undefined;
|
|
1714
|
+
const gateway = document.getElementById('create-net-gateway').value.trim() || undefined;
|
|
1715
|
+
|
|
1716
|
+
try {
|
|
1717
|
+
await API.createNetwork({ name, driver, subnet, gateway });
|
|
1718
|
+
showToast('Network Created', name, 'success');
|
|
1719
|
+
closeModal('create-network-modal');
|
|
1720
|
+
e.target.reset();
|
|
1721
|
+
await refreshData();
|
|
1722
|
+
} catch (err) {
|
|
1723
|
+
showToast('Failed to Create Network', err.message, 'error');
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// Setup Auto Refresh
|
|
1728
|
+
function setupAutoRefresh() {
|
|
1729
|
+
const select = document.getElementById('refresh-interval-select');
|
|
1730
|
+
if (!select) return;
|
|
1731
|
+
|
|
1732
|
+
const updateInterval = () => {
|
|
1733
|
+
if (state.refreshTimer) clearInterval(state.refreshTimer);
|
|
1734
|
+
const val = parseInt(select.value, 10);
|
|
1735
|
+
state.refreshInterval = val;
|
|
1736
|
+
if (val > 0) {
|
|
1737
|
+
state.refreshTimer = setInterval(() => {
|
|
1738
|
+
refreshData();
|
|
1739
|
+
}, val);
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
select.addEventListener('change', updateInterval);
|
|
1744
|
+
updateInterval();
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
// Mobile Navigation Toggle
|
|
1748
|
+
function toggleMobileSidebar(open) {
|
|
1749
|
+
const sidebar = document.getElementById('sidebar');
|
|
1750
|
+
const backdrop = document.getElementById('sidebar-backdrop');
|
|
1751
|
+
const toggleBtn = document.getElementById('btn-menu-toggle');
|
|
1752
|
+
|
|
1753
|
+
const shouldOpen = typeof open === 'boolean' ? open : !sidebar?.classList.contains('mobile-open');
|
|
1754
|
+
if (sidebar) {
|
|
1755
|
+
sidebar.classList.toggle('mobile-open', shouldOpen);
|
|
1756
|
+
}
|
|
1757
|
+
if (backdrop) {
|
|
1758
|
+
backdrop.classList.toggle('active', shouldOpen);
|
|
1759
|
+
}
|
|
1760
|
+
if (toggleBtn) {
|
|
1761
|
+
toggleBtn.setAttribute('aria-expanded', String(shouldOpen));
|
|
1762
|
+
}
|
|
1763
|
+
if (shouldOpen) {
|
|
1764
|
+
document.body.style.overflow = 'hidden';
|
|
1765
|
+
} else {
|
|
1766
|
+
document.body.style.overflow = '';
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// Event Listeners Initialization
|
|
1771
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
1772
|
+
// Mobile drawer controls
|
|
1773
|
+
document.getElementById('btn-menu-toggle')?.addEventListener('click', () => toggleMobileSidebar());
|
|
1774
|
+
document.getElementById('btn-sidebar-close')?.addEventListener('click', () => toggleMobileSidebar(false));
|
|
1775
|
+
document.getElementById('sidebar-backdrop')?.addEventListener('click', () => toggleMobileSidebar(false));
|
|
1776
|
+
|
|
1777
|
+
// Navigation tabs with mobile auto-collapse and keyboard support
|
|
1778
|
+
document.querySelectorAll('.nav-link[data-view]').forEach(link => {
|
|
1779
|
+
const handleNav = (e) => {
|
|
1780
|
+
e.preventDefault();
|
|
1781
|
+
switchView(link.getAttribute('data-view'));
|
|
1782
|
+
toggleMobileSidebar(false);
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
link.addEventListener('click', handleNav);
|
|
1786
|
+
link.addEventListener('keydown', (e) => {
|
|
1787
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1788
|
+
handleNav(e);
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
});
|
|
1792
|
+
|
|
1793
|
+
// Global Keyboard Navigation (Escape closes modals or mobile drawer)
|
|
1794
|
+
document.addEventListener('keydown', (e) => {
|
|
1795
|
+
if (e.key === 'Escape') {
|
|
1796
|
+
closeFloatingDropdown();
|
|
1797
|
+
const openModalEl = document.querySelector('.modal-overlay.open');
|
|
1798
|
+
if (openModalEl) {
|
|
1799
|
+
closeModal(openModalEl.id);
|
|
1800
|
+
} else {
|
|
1801
|
+
toggleMobileSidebar(false);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
|
|
1806
|
+
// Manual refresh button
|
|
1807
|
+
document.getElementById('btn-refresh-manual')?.addEventListener('click', () => {
|
|
1808
|
+
refreshData();
|
|
1809
|
+
});
|
|
1810
|
+
|
|
1811
|
+
// Auto-refresh config
|
|
1812
|
+
setupAutoRefresh();
|
|
1813
|
+
|
|
1814
|
+
// Filter & Search inputs
|
|
1815
|
+
document.getElementById('container-search')?.addEventListener('input', (e) => {
|
|
1816
|
+
state.containerFilter.search = e.target.value;
|
|
1817
|
+
renderContainers();
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1820
|
+
// Container status segmented control
|
|
1821
|
+
document.querySelectorAll('#container-status-segmented .segment-btn').forEach(btn => {
|
|
1822
|
+
btn.addEventListener('click', () => {
|
|
1823
|
+
document.querySelectorAll('#container-status-segmented .segment-btn').forEach(b => {
|
|
1824
|
+
b.classList.remove('active');
|
|
1825
|
+
b.setAttribute('aria-selected', 'false');
|
|
1826
|
+
});
|
|
1827
|
+
btn.classList.add('active');
|
|
1828
|
+
btn.setAttribute('aria-selected', 'true');
|
|
1829
|
+
state.containerFilter.status = btn.dataset.status || 'all';
|
|
1830
|
+
renderContainers();
|
|
1831
|
+
});
|
|
1832
|
+
});
|
|
1833
|
+
|
|
1834
|
+
// Fallback native select if present
|
|
1835
|
+
document.getElementById('container-status-filter')?.addEventListener('change', (e) => {
|
|
1836
|
+
state.containerFilter.status = e.target.value;
|
|
1837
|
+
renderContainers();
|
|
1838
|
+
});
|
|
1839
|
+
|
|
1840
|
+
document.getElementById('pod-search')?.addEventListener('input', (e) => {
|
|
1841
|
+
state.podFilter.search = e.target.value;
|
|
1842
|
+
renderPods();
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
document.getElementById('image-search')?.addEventListener('input', (e) => {
|
|
1846
|
+
state.imageFilter.search = e.target.value;
|
|
1847
|
+
renderImages();
|
|
1848
|
+
});
|
|
1849
|
+
|
|
1850
|
+
document.getElementById('volume-search')?.addEventListener('input', (e) => {
|
|
1851
|
+
state.volumeFilter.search = e.target.value;
|
|
1852
|
+
renderVolumes();
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1855
|
+
document.getElementById('network-search')?.addEventListener('input', (e) => {
|
|
1856
|
+
state.networkFilter.search = e.target.value;
|
|
1857
|
+
renderNetworks();
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
document.getElementById('event-search')?.addEventListener('input', (e) => {
|
|
1861
|
+
state.eventFilter.search = e.target.value;
|
|
1862
|
+
renderEvents();
|
|
1863
|
+
});
|
|
1864
|
+
|
|
1865
|
+
// Forms submission
|
|
1866
|
+
document.getElementById('form-create-container')?.addEventListener('submit', handleCreateContainer);
|
|
1867
|
+
document.getElementById('form-create-pod')?.addEventListener('submit', handleCreatePod);
|
|
1868
|
+
document.getElementById('form-pull-image')?.addEventListener('submit', handlePullImage);
|
|
1869
|
+
document.getElementById('form-create-volume')?.addEventListener('submit', handleCreateVolume);
|
|
1870
|
+
document.getElementById('form-create-network')?.addEventListener('submit', handleCreateNetwork);
|
|
1871
|
+
|
|
1872
|
+
// Exec run button & Enter key
|
|
1873
|
+
document.getElementById('btn-run-exec')?.addEventListener('click', runContainerExec);
|
|
1874
|
+
document.getElementById('exec-cmd-input')?.addEventListener('keydown', (e) => {
|
|
1875
|
+
if (e.key === 'Enter') runContainerExec();
|
|
1876
|
+
});
|
|
1877
|
+
|
|
1878
|
+
// Copy inspect JSON
|
|
1879
|
+
document.getElementById('btn-copy-inspect')?.addEventListener('click', () => {
|
|
1880
|
+
const text = document.getElementById('inspect-content').textContent;
|
|
1881
|
+
navigator.clipboard.writeText(text);
|
|
1882
|
+
showToast('Copied to Clipboard', 'Inspection JSON copied', 'info');
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1885
|
+
// Modal overlay click outside to close
|
|
1886
|
+
document.querySelectorAll('.modal-overlay').forEach(overlay => {
|
|
1887
|
+
overlay.addEventListener('click', (e) => {
|
|
1888
|
+
if (e.target === overlay) {
|
|
1889
|
+
closeModal(overlay.id);
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1894
|
+
// Popstate listener for browser back/forward navigation
|
|
1895
|
+
window.addEventListener('popstate', () => {
|
|
1896
|
+
const params = new URLSearchParams(window.location.search);
|
|
1897
|
+
const viewFromQuery = params.get('view');
|
|
1898
|
+
const viewFromHash = window.location.hash ? window.location.hash.replace(/^#\/?/, '') : null;
|
|
1899
|
+
const target = viewFromQuery || viewFromHash || 'dashboard';
|
|
1900
|
+
switchView(target, false);
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
// Initial load from URL state
|
|
1904
|
+
const initialParams = new URLSearchParams(window.location.search);
|
|
1905
|
+
const initialViewQuery = initialParams.get('view');
|
|
1906
|
+
const initialViewHash = window.location.hash ? window.location.hash.replace(/^#\/?/, '') : null;
|
|
1907
|
+
const initialView = initialViewQuery || initialViewHash || 'dashboard';
|
|
1908
|
+
|
|
1909
|
+
switchView(initialView, false);
|
|
1910
|
+
loadEvents();
|
|
1911
|
+
initEventStream();
|
|
1912
|
+
});
|