podmanager 1.0.0 → 1.0.1
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/bin/podmanager.js +78 -58
- package/package.json +1 -1
- package/public/css/style.css +4 -97
- package/public/index.html +6 -34
- package/public/js/api.js +0 -10
- package/public/js/app.js +0 -74
- package/src/app.js +0 -4
- package/src/index.js +10 -3
- package/src/middlewares/async-handler.middleware.js +0 -3
- package/src/middlewares/error.middleware.js +0 -3
- package/src/routes/containers.route.js +0 -13
- package/src/routes/events.route.js +1 -3
- package/src/routes/images.route.js +0 -5
- package/src/routes/networks.route.js +0 -4
- package/src/routes/pods.route.js +0 -7
- package/src/routes/system.route.js +0 -3
- package/src/routes/volumes.route.js +0 -4
- package/src/services/podman.service.js +4 -19
package/public/js/app.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Podman Web UI Application Controller
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Application State
|
|
6
1
|
const state = {
|
|
7
2
|
activeView: 'dashboard',
|
|
8
3
|
systemInfo: null,
|
|
@@ -39,7 +34,6 @@ const state = {
|
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
36
|
|
|
42
|
-
// Row details expansion for mobile & tablet (persists across auto-refresh)
|
|
43
37
|
function toggleRowDetails(rowId, btnElement) {
|
|
44
38
|
const row = document.getElementById(rowId);
|
|
45
39
|
if (!row) return;
|
|
@@ -58,9 +52,7 @@ function toggleRowDetails(rowId, btnElement) {
|
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
|
|
61
|
-
// Click anywhere on a table row item to toggle drawer expansion (except on action buttons, links, copy badges)
|
|
62
55
|
document.addEventListener('click', (e) => {
|
|
63
|
-
// Only activate row-click expansion on tablet & mobile viewports (where drawer info exists)
|
|
64
56
|
if (window.innerWidth > 1024) return;
|
|
65
57
|
|
|
66
58
|
if (e.target.closest('.action-trigger-btn') ||
|
|
@@ -83,7 +75,6 @@ document.addEventListener('click', (e) => {
|
|
|
83
75
|
}
|
|
84
76
|
});
|
|
85
77
|
|
|
86
|
-
// Floating Action Dropdown Menu (Portal on document.body to prevent clipping & auto-refresh destruction)
|
|
87
78
|
let activeDropdownContext = null;
|
|
88
79
|
|
|
89
80
|
function openFloatingDropdown(type, id, triggerBtn, event) {
|
|
@@ -96,7 +87,6 @@ function openFloatingDropdown(type, id, triggerBtn, event) {
|
|
|
96
87
|
|
|
97
88
|
const rawId = decodeURIComponent(id);
|
|
98
89
|
|
|
99
|
-
// Toggle close if clicking on the same button while already open
|
|
100
90
|
if (activeDropdownContext &&
|
|
101
91
|
(activeDropdownContext.id === id || activeDropdownContext.id === rawId) &&
|
|
102
92
|
activeDropdownContext.type === type &&
|
|
@@ -120,13 +110,11 @@ function openFloatingDropdown(type, id, triggerBtn, event) {
|
|
|
120
110
|
const menuWidth = menu.offsetWidth || 180;
|
|
121
111
|
const menuHeight = menu.offsetHeight || 190;
|
|
122
112
|
|
|
123
|
-
// Calculate vertical position (prefer below, flip above if overflowing bottom)
|
|
124
113
|
let top = rect.bottom + 4;
|
|
125
114
|
if (top + menuHeight > window.innerHeight - 8) {
|
|
126
115
|
top = Math.max(8, rect.top - menuHeight - 4);
|
|
127
116
|
}
|
|
128
117
|
|
|
129
|
-
// Calculate horizontal position (align right edge to button right edge)
|
|
130
118
|
let left = rect.right - menuWidth;
|
|
131
119
|
if (left < 8) left = 8;
|
|
132
120
|
if (left + menuWidth > window.innerWidth - 8) {
|
|
@@ -307,11 +295,9 @@ function getActionMenuItems(type, id) {
|
|
|
307
295
|
return '';
|
|
308
296
|
}
|
|
309
297
|
|
|
310
|
-
// Global listeners to close floating dropdown
|
|
311
298
|
document.addEventListener('click', (e) => {
|
|
312
299
|
const menu = document.getElementById('floating-action-dropdown');
|
|
313
300
|
if (!menu || menu.style.display === 'none') return;
|
|
314
|
-
// If clicked inside dropdown menu or on any action trigger button, do not close here
|
|
315
301
|
if (e.target.closest && (e.target.closest('#floating-action-dropdown') || e.target.closest('.action-trigger-btn'))) {
|
|
316
302
|
return;
|
|
317
303
|
}
|
|
@@ -324,7 +310,6 @@ document.addEventListener('keydown', (e) => {
|
|
|
324
310
|
|
|
325
311
|
window.addEventListener('resize', closeFloatingDropdown);
|
|
326
312
|
|
|
327
|
-
// Format utilities
|
|
328
313
|
const formatBytes = (bytes, decimals = 2) => {
|
|
329
314
|
if (!+bytes) return '0 B';
|
|
330
315
|
const k = 1024;
|
|
@@ -342,7 +327,6 @@ const formatTime = (timestamp) => {
|
|
|
342
327
|
|
|
343
328
|
const shortId = (id) => (id ? id.substring(0, 12) : '-');
|
|
344
329
|
|
|
345
|
-
// Toast Notification
|
|
346
330
|
function showToast(title, message = '', type = 'info') {
|
|
347
331
|
const container = document.getElementById('toast-container');
|
|
348
332
|
if (!container) return;
|
|
@@ -377,7 +361,6 @@ function escapeHtml(str) {
|
|
|
377
361
|
.replace(/'/g, ''');
|
|
378
362
|
}
|
|
379
363
|
|
|
380
|
-
// Modal Handlers
|
|
381
364
|
function openModal(modalId) {
|
|
382
365
|
const modal = document.getElementById(modalId);
|
|
383
366
|
if (modal) {
|
|
@@ -396,7 +379,6 @@ function closeModal(modalId) {
|
|
|
396
379
|
}
|
|
397
380
|
}
|
|
398
381
|
|
|
399
|
-
// Main View Navigation
|
|
400
382
|
function switchView(viewName, updateUrl = true) {
|
|
401
383
|
const validViews = ['dashboard', 'containers', 'pods', 'images', 'volumes', 'networks', 'events'];
|
|
402
384
|
if (!validViews.includes(viewName)) {
|
|
@@ -426,7 +408,6 @@ function switchView(viewName, updateUrl = true) {
|
|
|
426
408
|
pageTitle.textContent = titles[viewName] || 'Podmanager';
|
|
427
409
|
}
|
|
428
410
|
|
|
429
|
-
// Synchronize state with browser URL
|
|
430
411
|
if (updateUrl && window.history && window.history.pushState) {
|
|
431
412
|
const url = new URL(window.location);
|
|
432
413
|
if (viewName === 'dashboard') {
|
|
@@ -437,22 +418,18 @@ function switchView(viewName, updateUrl = true) {
|
|
|
437
418
|
window.history.pushState({ view: viewName }, '', url.pathname + url.search + url.hash);
|
|
438
419
|
}
|
|
439
420
|
|
|
440
|
-
// If navigating to events view, render immediately from cached state
|
|
441
421
|
if (viewName === 'events') {
|
|
442
422
|
renderEvents();
|
|
443
423
|
}
|
|
444
424
|
|
|
445
|
-
// Refresh active view data immediately
|
|
446
425
|
refreshData();
|
|
447
426
|
}
|
|
448
427
|
|
|
449
|
-
// Data Fetching & Sync
|
|
450
428
|
async function refreshData() {
|
|
451
429
|
const refreshIcon = document.getElementById('refresh-icon');
|
|
452
430
|
if (refreshIcon) refreshIcon.classList.add('spin');
|
|
453
431
|
|
|
454
432
|
try {
|
|
455
|
-
// Parallel fetch core lists and all sections for sidebar badges
|
|
456
433
|
const [infoRes, dfRes, containersRes, podsRes, imagesRes, volumesRes, networksRes] = await Promise.all([
|
|
457
434
|
API.getSystemInfo().catch(e => null),
|
|
458
435
|
API.getSystemDf().catch(e => null),
|
|
@@ -486,10 +463,8 @@ async function refreshData() {
|
|
|
486
463
|
state.loading.networks = false;
|
|
487
464
|
}
|
|
488
465
|
|
|
489
|
-
// Update navigation counter badges for all sections
|
|
490
466
|
updateBadges();
|
|
491
467
|
|
|
492
|
-
// Render current active view
|
|
493
468
|
if (state.activeView === 'dashboard') {
|
|
494
469
|
renderDashboard();
|
|
495
470
|
} else if (state.activeView === 'containers') {
|
|
@@ -571,9 +546,6 @@ function updateSystemStatus(isOnline) {
|
|
|
571
546
|
}
|
|
572
547
|
}
|
|
573
548
|
|
|
574
|
-
// ----------------- RENDER VIEWS -----------------
|
|
575
|
-
|
|
576
|
-
// 1. Dashboard View
|
|
577
549
|
function renderDashboard() {
|
|
578
550
|
const runningContainers = state.containers.filter(c => c.State === 'running').length;
|
|
579
551
|
|
|
@@ -582,7 +554,6 @@ function renderDashboard() {
|
|
|
582
554
|
document.getElementById('dash-stat-pods').textContent = state.pods.length;
|
|
583
555
|
document.getElementById('dash-stat-images').textContent = state.images.length;
|
|
584
556
|
|
|
585
|
-
// Host specs
|
|
586
557
|
const host = state.systemInfo?.host || {};
|
|
587
558
|
const ver = state.systemInfo?.version || {};
|
|
588
559
|
const store = state.systemInfo?.store || {};
|
|
@@ -601,7 +572,6 @@ function renderDashboard() {
|
|
|
601
572
|
rootlessBadge.className = host.rootless ? 'tag-badge rootless' : 'tag-badge';
|
|
602
573
|
}
|
|
603
574
|
|
|
604
|
-
// Disk usage list
|
|
605
575
|
const diskContainer = document.getElementById('dash-disk-list');
|
|
606
576
|
if (diskContainer && state.dfInfo.length > 0) {
|
|
607
577
|
diskContainer.innerHTML = state.dfInfo.map(item => `
|
|
@@ -619,7 +589,6 @@ function renderDashboard() {
|
|
|
619
589
|
}
|
|
620
590
|
}
|
|
621
591
|
|
|
622
|
-
// Skeleton Generator for Tables
|
|
623
592
|
function renderTableSkeletons(type, count = 5) {
|
|
624
593
|
const rows = [];
|
|
625
594
|
for (let i = 0; i < count; i++) {
|
|
@@ -729,7 +698,6 @@ function renderTableSkeletons(type, count = 5) {
|
|
|
729
698
|
return rows.join('');
|
|
730
699
|
}
|
|
731
700
|
|
|
732
|
-
// 2. Containers View
|
|
733
701
|
function renderContainers() {
|
|
734
702
|
const tbody = document.getElementById('containers-tbody');
|
|
735
703
|
if (!tbody) return;
|
|
@@ -842,7 +810,6 @@ function formatPorts(ports) {
|
|
|
842
810
|
}).join(' ');
|
|
843
811
|
}
|
|
844
812
|
|
|
845
|
-
// 3. Pods View
|
|
846
813
|
function renderPods() {
|
|
847
814
|
const tbody = document.getElementById('pods-tbody');
|
|
848
815
|
if (!tbody) return;
|
|
@@ -931,7 +898,6 @@ function renderPods() {
|
|
|
931
898
|
}).join('');
|
|
932
899
|
}
|
|
933
900
|
|
|
934
|
-
// 4. Images View
|
|
935
901
|
function renderImages() {
|
|
936
902
|
const tbody = document.getElementById('images-tbody');
|
|
937
903
|
if (!tbody) return;
|
|
@@ -1026,7 +992,6 @@ function renderImages() {
|
|
|
1026
992
|
}).join('');
|
|
1027
993
|
}
|
|
1028
994
|
|
|
1029
|
-
// 5. Volumes View
|
|
1030
995
|
function renderVolumes() {
|
|
1031
996
|
const tbody = document.getElementById('volumes-tbody');
|
|
1032
997
|
if (!tbody) return;
|
|
@@ -1102,7 +1067,6 @@ function renderVolumes() {
|
|
|
1102
1067
|
}).join('');
|
|
1103
1068
|
}
|
|
1104
1069
|
|
|
1105
|
-
// 6. Networks View
|
|
1106
1070
|
function renderNetworks() {
|
|
1107
1071
|
const tbody = document.getElementById('networks-tbody');
|
|
1108
1072
|
if (!tbody) return;
|
|
@@ -1188,7 +1152,6 @@ function renderNetworks() {
|
|
|
1188
1152
|
}).join('');
|
|
1189
1153
|
}
|
|
1190
1154
|
|
|
1191
|
-
// 7. Events Log
|
|
1192
1155
|
async function loadEvents(force = false) {
|
|
1193
1156
|
try {
|
|
1194
1157
|
const res = await API.getEvents('24h');
|
|
@@ -1196,7 +1159,6 @@ async function loadEvents(force = false) {
|
|
|
1196
1159
|
if (force || state.events.length === 0) {
|
|
1197
1160
|
state.events = res.data;
|
|
1198
1161
|
} else {
|
|
1199
|
-
// Merge without duplicating
|
|
1200
1162
|
const existingKeys = new Set(state.events.map(e => `${e.time || e.Time}_${e.timeNano || ''}_${e.ID || e.Name}_${e.Status || e.Action}`));
|
|
1201
1163
|
for (const item of res.data) {
|
|
1202
1164
|
const key = `${item.time || item.Time}_${item.timeNano || ''}_${item.ID || item.Name}_${item.Status || item.Action}`;
|
|
@@ -1234,7 +1196,6 @@ function initEventStream() {
|
|
|
1234
1196
|
} catch {}
|
|
1235
1197
|
};
|
|
1236
1198
|
eventSource.onerror = () => {
|
|
1237
|
-
// Reconnect handled automatically by EventSource
|
|
1238
1199
|
};
|
|
1239
1200
|
} catch (err) {
|
|
1240
1201
|
console.warn('Events SSE not supported or blocked:', err);
|
|
@@ -1300,9 +1261,6 @@ function renderEvents() {
|
|
|
1300
1261
|
}).join('');
|
|
1301
1262
|
}
|
|
1302
1263
|
|
|
1303
|
-
// ----------------- ACTIONS -----------------
|
|
1304
|
-
|
|
1305
|
-
// Container Actions
|
|
1306
1264
|
async function actionContainer(id, action) {
|
|
1307
1265
|
try {
|
|
1308
1266
|
showToast('Executing...', `${action.toUpperCase()} container ${shortId(id)}`, 'info');
|
|
@@ -1332,7 +1290,6 @@ function confirmDeleteContainer(id, name) {
|
|
|
1332
1290
|
}
|
|
1333
1291
|
}
|
|
1334
1292
|
|
|
1335
|
-
// Pod Actions
|
|
1336
1293
|
async function actionPod(id, action) {
|
|
1337
1294
|
try {
|
|
1338
1295
|
showToast('Executing...', `${action.toUpperCase()} pod ${shortId(id)}`, 'info');
|
|
@@ -1360,7 +1317,6 @@ function confirmDeletePod(id, name) {
|
|
|
1360
1317
|
}
|
|
1361
1318
|
}
|
|
1362
1319
|
|
|
1363
|
-
// Image Actions
|
|
1364
1320
|
function confirmDeleteImage(id, name) {
|
|
1365
1321
|
if (confirm(`Are you sure you want to remove image "${name}"?`)) {
|
|
1366
1322
|
API.removeImage(id, true)
|
|
@@ -1374,7 +1330,6 @@ function confirmDeleteImage(id, name) {
|
|
|
1374
1330
|
}
|
|
1375
1331
|
}
|
|
1376
1332
|
|
|
1377
|
-
// Volume Actions
|
|
1378
1333
|
function deleteVolume(name) {
|
|
1379
1334
|
if (confirm(`Are you sure you want to delete volume "${decodeURIComponent(name)}"?`)) {
|
|
1380
1335
|
API.removeVolume(name, true)
|
|
@@ -1388,7 +1343,6 @@ function deleteVolume(name) {
|
|
|
1388
1343
|
}
|
|
1389
1344
|
}
|
|
1390
1345
|
|
|
1391
|
-
// Network Actions
|
|
1392
1346
|
function deleteNetwork(name) {
|
|
1393
1347
|
if (confirm(`Are you sure you want to delete network "${decodeURIComponent(name)}"?`)) {
|
|
1394
1348
|
API.removeNetwork(name)
|
|
@@ -1402,7 +1356,6 @@ function deleteNetwork(name) {
|
|
|
1402
1356
|
}
|
|
1403
1357
|
}
|
|
1404
1358
|
|
|
1405
|
-
// System Prune
|
|
1406
1359
|
async function executePrune(type) {
|
|
1407
1360
|
if (!confirm(`Are you sure you want to prune ${type}? This will delete unused data irreversibly.`)) {
|
|
1408
1361
|
return;
|
|
@@ -1418,7 +1371,6 @@ async function executePrune(type) {
|
|
|
1418
1371
|
}
|
|
1419
1372
|
}
|
|
1420
1373
|
|
|
1421
|
-
// Inspect Modal
|
|
1422
1374
|
async function inspectItem(type, id) {
|
|
1423
1375
|
openModal('inspect-modal');
|
|
1424
1376
|
const inspectTitle = document.getElementById('inspect-modal-title');
|
|
@@ -1441,14 +1393,12 @@ async function inspectItem(type, id) {
|
|
|
1441
1393
|
}
|
|
1442
1394
|
}
|
|
1443
1395
|
|
|
1444
|
-
// Container Logs Viewer
|
|
1445
1396
|
function viewContainerLogs(id, name) {
|
|
1446
1397
|
state.logsConfig.containerId = id;
|
|
1447
1398
|
state.logsConfig.containerName = name;
|
|
1448
1399
|
openModal('logs-modal');
|
|
1449
1400
|
document.getElementById('logs-modal-title').textContent = `Logs: ${name}`;
|
|
1450
1401
|
|
|
1451
|
-
// Sync button active states
|
|
1452
1402
|
const autoBtn = document.getElementById('btn-logs-autoscroll');
|
|
1453
1403
|
if (autoBtn) autoBtn.classList.toggle('active', state.logsConfig.autoscroll);
|
|
1454
1404
|
const timeBtn = document.getElementById('btn-logs-timestamps');
|
|
@@ -1496,7 +1446,6 @@ function restartLogsStream() {
|
|
|
1496
1446
|
});
|
|
1497
1447
|
|
|
1498
1448
|
sse.onerror = () => {
|
|
1499
|
-
// fallback to static log fetch if streaming encounters error
|
|
1500
1449
|
API.getContainerLogs(id, tail, timestamps).then(res => {
|
|
1501
1450
|
viewer.textContent = res.logs || 'No logs available.';
|
|
1502
1451
|
if (state.logsConfig.autoscroll) {
|
|
@@ -1549,7 +1498,6 @@ function clearLogsViewer() {
|
|
|
1549
1498
|
if (viewer) viewer.textContent = '';
|
|
1550
1499
|
}
|
|
1551
1500
|
|
|
1552
|
-
// Container Exec Terminal
|
|
1553
1501
|
let activeExecContainerId = null;
|
|
1554
1502
|
function openExecModal(id, name) {
|
|
1555
1503
|
activeExecContainerId = id;
|
|
@@ -1578,7 +1526,6 @@ async function runContainerExec() {
|
|
|
1578
1526
|
}
|
|
1579
1527
|
}
|
|
1580
1528
|
|
|
1581
|
-
// Create Container Modal
|
|
1582
1529
|
function openCreateContainerModal(prefillImage = '') {
|
|
1583
1530
|
openModal('create-container-modal');
|
|
1584
1531
|
if (prefillImage) {
|
|
@@ -1617,7 +1564,6 @@ async function handleCreateContainer(e) {
|
|
|
1617
1564
|
}
|
|
1618
1565
|
}
|
|
1619
1566
|
|
|
1620
|
-
// Create Pod Modal
|
|
1621
1567
|
async function handleCreatePod(e) {
|
|
1622
1568
|
e.preventDefault();
|
|
1623
1569
|
const name = document.getElementById('create-pod-name').value.trim();
|
|
@@ -1634,7 +1580,6 @@ async function handleCreatePod(e) {
|
|
|
1634
1580
|
}
|
|
1635
1581
|
}
|
|
1636
1582
|
|
|
1637
|
-
// Pull Image Modal
|
|
1638
1583
|
function handlePullImage(e) {
|
|
1639
1584
|
e.preventDefault();
|
|
1640
1585
|
const image = document.getElementById('pull-image-input').value.trim();
|
|
@@ -1688,7 +1633,6 @@ function handlePullImage(e) {
|
|
|
1688
1633
|
}
|
|
1689
1634
|
}
|
|
1690
1635
|
|
|
1691
|
-
// Create Volume Modal
|
|
1692
1636
|
async function handleCreateVolume(e) {
|
|
1693
1637
|
e.preventDefault();
|
|
1694
1638
|
const name = document.getElementById('create-vol-name').value.trim();
|
|
@@ -1705,7 +1649,6 @@ async function handleCreateVolume(e) {
|
|
|
1705
1649
|
}
|
|
1706
1650
|
}
|
|
1707
1651
|
|
|
1708
|
-
// Create Network Modal
|
|
1709
1652
|
async function handleCreateNetwork(e) {
|
|
1710
1653
|
e.preventDefault();
|
|
1711
1654
|
const name = document.getElementById('create-net-name').value.trim();
|
|
@@ -1724,7 +1667,6 @@ async function handleCreateNetwork(e) {
|
|
|
1724
1667
|
}
|
|
1725
1668
|
}
|
|
1726
1669
|
|
|
1727
|
-
// Setup Auto Refresh
|
|
1728
1670
|
function setupAutoRefresh() {
|
|
1729
1671
|
const select = document.getElementById('refresh-interval-select');
|
|
1730
1672
|
if (!select) return;
|
|
@@ -1744,7 +1686,6 @@ function setupAutoRefresh() {
|
|
|
1744
1686
|
updateInterval();
|
|
1745
1687
|
}
|
|
1746
1688
|
|
|
1747
|
-
// Mobile Navigation Toggle
|
|
1748
1689
|
function toggleMobileSidebar(open) {
|
|
1749
1690
|
const sidebar = document.getElementById('sidebar');
|
|
1750
1691
|
const backdrop = document.getElementById('sidebar-backdrop');
|
|
@@ -1767,14 +1708,11 @@ function toggleMobileSidebar(open) {
|
|
|
1767
1708
|
}
|
|
1768
1709
|
}
|
|
1769
1710
|
|
|
1770
|
-
// Event Listeners Initialization
|
|
1771
1711
|
document.addEventListener('DOMContentLoaded', () => {
|
|
1772
|
-
// Mobile drawer controls
|
|
1773
1712
|
document.getElementById('btn-menu-toggle')?.addEventListener('click', () => toggleMobileSidebar());
|
|
1774
1713
|
document.getElementById('btn-sidebar-close')?.addEventListener('click', () => toggleMobileSidebar(false));
|
|
1775
1714
|
document.getElementById('sidebar-backdrop')?.addEventListener('click', () => toggleMobileSidebar(false));
|
|
1776
1715
|
|
|
1777
|
-
// Navigation tabs with mobile auto-collapse and keyboard support
|
|
1778
1716
|
document.querySelectorAll('.nav-link[data-view]').forEach(link => {
|
|
1779
1717
|
const handleNav = (e) => {
|
|
1780
1718
|
e.preventDefault();
|
|
@@ -1790,7 +1728,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1790
1728
|
});
|
|
1791
1729
|
});
|
|
1792
1730
|
|
|
1793
|
-
// Global Keyboard Navigation (Escape closes modals or mobile drawer)
|
|
1794
1731
|
document.addEventListener('keydown', (e) => {
|
|
1795
1732
|
if (e.key === 'Escape') {
|
|
1796
1733
|
closeFloatingDropdown();
|
|
@@ -1803,21 +1740,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1803
1740
|
}
|
|
1804
1741
|
});
|
|
1805
1742
|
|
|
1806
|
-
// Manual refresh button
|
|
1807
1743
|
document.getElementById('btn-refresh-manual')?.addEventListener('click', () => {
|
|
1808
1744
|
refreshData();
|
|
1809
1745
|
});
|
|
1810
1746
|
|
|
1811
|
-
// Auto-refresh config
|
|
1812
1747
|
setupAutoRefresh();
|
|
1813
1748
|
|
|
1814
|
-
// Filter & Search inputs
|
|
1815
1749
|
document.getElementById('container-search')?.addEventListener('input', (e) => {
|
|
1816
1750
|
state.containerFilter.search = e.target.value;
|
|
1817
1751
|
renderContainers();
|
|
1818
1752
|
});
|
|
1819
1753
|
|
|
1820
|
-
// Container status segmented control
|
|
1821
1754
|
document.querySelectorAll('#container-status-segmented .segment-btn').forEach(btn => {
|
|
1822
1755
|
btn.addEventListener('click', () => {
|
|
1823
1756
|
document.querySelectorAll('#container-status-segmented .segment-btn').forEach(b => {
|
|
@@ -1831,7 +1764,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1831
1764
|
});
|
|
1832
1765
|
});
|
|
1833
1766
|
|
|
1834
|
-
// Fallback native select if present
|
|
1835
1767
|
document.getElementById('container-status-filter')?.addEventListener('change', (e) => {
|
|
1836
1768
|
state.containerFilter.status = e.target.value;
|
|
1837
1769
|
renderContainers();
|
|
@@ -1862,27 +1794,23 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1862
1794
|
renderEvents();
|
|
1863
1795
|
});
|
|
1864
1796
|
|
|
1865
|
-
// Forms submission
|
|
1866
1797
|
document.getElementById('form-create-container')?.addEventListener('submit', handleCreateContainer);
|
|
1867
1798
|
document.getElementById('form-create-pod')?.addEventListener('submit', handleCreatePod);
|
|
1868
1799
|
document.getElementById('form-pull-image')?.addEventListener('submit', handlePullImage);
|
|
1869
1800
|
document.getElementById('form-create-volume')?.addEventListener('submit', handleCreateVolume);
|
|
1870
1801
|
document.getElementById('form-create-network')?.addEventListener('submit', handleCreateNetwork);
|
|
1871
1802
|
|
|
1872
|
-
// Exec run button & Enter key
|
|
1873
1803
|
document.getElementById('btn-run-exec')?.addEventListener('click', runContainerExec);
|
|
1874
1804
|
document.getElementById('exec-cmd-input')?.addEventListener('keydown', (e) => {
|
|
1875
1805
|
if (e.key === 'Enter') runContainerExec();
|
|
1876
1806
|
});
|
|
1877
1807
|
|
|
1878
|
-
// Copy inspect JSON
|
|
1879
1808
|
document.getElementById('btn-copy-inspect')?.addEventListener('click', () => {
|
|
1880
1809
|
const text = document.getElementById('inspect-content').textContent;
|
|
1881
1810
|
navigator.clipboard.writeText(text);
|
|
1882
1811
|
showToast('Copied to Clipboard', 'Inspection JSON copied', 'info');
|
|
1883
1812
|
});
|
|
1884
1813
|
|
|
1885
|
-
// Modal overlay click outside to close
|
|
1886
1814
|
document.querySelectorAll('.modal-overlay').forEach(overlay => {
|
|
1887
1815
|
overlay.addEventListener('click', (e) => {
|
|
1888
1816
|
if (e.target === overlay) {
|
|
@@ -1891,7 +1819,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1891
1819
|
});
|
|
1892
1820
|
});
|
|
1893
1821
|
|
|
1894
|
-
// Popstate listener for browser back/forward navigation
|
|
1895
1822
|
window.addEventListener('popstate', () => {
|
|
1896
1823
|
const params = new URLSearchParams(window.location.search);
|
|
1897
1824
|
const viewFromQuery = params.get('view');
|
|
@@ -1900,7 +1827,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1900
1827
|
switchView(target, false);
|
|
1901
1828
|
});
|
|
1902
1829
|
|
|
1903
|
-
// Initial load from URL state
|
|
1904
1830
|
const initialParams = new URLSearchParams(window.location.search);
|
|
1905
1831
|
const initialViewQuery = initialParams.get('view');
|
|
1906
1832
|
const initialViewHash = window.location.hash ? window.location.hash.replace(/^#\/?/, '') : null;
|
package/src/app.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
const { createApp } = require('./app');
|
|
2
2
|
|
|
3
|
+
function forceCloseActiveConnections(server) {
|
|
4
|
+
if (typeof server.closeAllConnections === 'function') {
|
|
5
|
+
server.closeAllConnections();
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
function startServer({ port, host, app: customApp, onReady } = {}) {
|
|
4
10
|
const resolvedPort = port !== undefined ? port : (parseInt(process.env.PORT, 10) || 3030);
|
|
5
11
|
const resolvedHost = host || process.env.HOST || '0.0.0.0';
|
|
@@ -25,16 +31,17 @@ function startServer({ port, host, app: customApp, onReady } = {}) {
|
|
|
25
31
|
}
|
|
26
32
|
});
|
|
27
33
|
|
|
28
|
-
const
|
|
34
|
+
const shutdownGracefully = (signal) => {
|
|
29
35
|
console.log(`\nReceived ${signal}. Gracefully shutting down...`);
|
|
30
36
|
server.close(() => {
|
|
31
37
|
console.log('Server stopped.');
|
|
32
38
|
process.exit(0);
|
|
33
39
|
});
|
|
40
|
+
forceCloseActiveConnections(server);
|
|
34
41
|
};
|
|
35
42
|
|
|
36
|
-
process.on('SIGINT', () =>
|
|
37
|
-
process.on('SIGTERM', () =>
|
|
43
|
+
process.on('SIGINT', () => shutdownGracefully('SIGINT'));
|
|
44
|
+
process.on('SIGTERM', () => shutdownGracefully('SIGTERM'));
|
|
38
45
|
|
|
39
46
|
return server;
|
|
40
47
|
}
|
|
@@ -4,65 +4,55 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/containers
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const all = req.query.all !== 'false';
|
|
10
9
|
const containers = await Podman.listContainers(all);
|
|
11
10
|
res.json({ success: true, data: containers });
|
|
12
11
|
}));
|
|
13
12
|
|
|
14
|
-
// GET /api/containers/:id
|
|
15
13
|
router.get('/:id', asyncHandler(async (req, res) => {
|
|
16
14
|
const data = await Podman.inspectContainer(req.params.id);
|
|
17
15
|
res.json({ success: true, data });
|
|
18
16
|
}));
|
|
19
17
|
|
|
20
|
-
// POST /api/containers
|
|
21
18
|
router.post('/', asyncHandler(async (req, res) => {
|
|
22
19
|
const result = await Podman.createRunContainer(req.body);
|
|
23
20
|
res.json({ success: true, message: 'Container created successfully', ...result });
|
|
24
21
|
}));
|
|
25
22
|
|
|
26
|
-
// POST /api/containers/:id/start
|
|
27
23
|
router.post('/:id/start', asyncHandler(async (req, res) => {
|
|
28
24
|
const result = await Podman.startContainer(req.params.id);
|
|
29
25
|
res.json({ success: true, message: 'Container started', ...result });
|
|
30
26
|
}));
|
|
31
27
|
|
|
32
|
-
// POST /api/containers/:id/stop
|
|
33
28
|
router.post('/:id/stop', asyncHandler(async (req, res) => {
|
|
34
29
|
const timeout = req.body.timeout ? parseInt(req.body.timeout, 10) : 10;
|
|
35
30
|
const result = await Podman.stopContainer(req.params.id, timeout);
|
|
36
31
|
res.json({ success: true, message: 'Container stopped', ...result });
|
|
37
32
|
}));
|
|
38
33
|
|
|
39
|
-
// POST /api/containers/:id/restart
|
|
40
34
|
router.post('/:id/restart', asyncHandler(async (req, res) => {
|
|
41
35
|
const timeout = req.body.timeout ? parseInt(req.body.timeout, 10) : 10;
|
|
42
36
|
const result = await Podman.restartContainer(req.params.id, timeout);
|
|
43
37
|
res.json({ success: true, message: 'Container restarted', ...result });
|
|
44
38
|
}));
|
|
45
39
|
|
|
46
|
-
// POST /api/containers/:id/kill
|
|
47
40
|
router.post('/:id/kill', asyncHandler(async (req, res) => {
|
|
48
41
|
const signal = req.body.signal || 'SIGKILL';
|
|
49
42
|
const result = await Podman.killContainer(req.params.id, signal);
|
|
50
43
|
res.json({ success: true, message: `Sent ${signal} to container`, ...result });
|
|
51
44
|
}));
|
|
52
45
|
|
|
53
|
-
// POST /api/containers/:id/pause
|
|
54
46
|
router.post('/:id/pause', asyncHandler(async (req, res) => {
|
|
55
47
|
const result = await Podman.pauseContainer(req.params.id);
|
|
56
48
|
res.json({ success: true, message: 'Container paused', ...result });
|
|
57
49
|
}));
|
|
58
50
|
|
|
59
|
-
// POST /api/containers/:id/unpause
|
|
60
51
|
router.post('/:id/unpause', asyncHandler(async (req, res) => {
|
|
61
52
|
const result = await Podman.unpauseContainer(req.params.id);
|
|
62
53
|
res.json({ success: true, message: 'Container unpaused', ...result });
|
|
63
54
|
}));
|
|
64
55
|
|
|
65
|
-
// DELETE /api/containers/:id
|
|
66
56
|
router.delete('/:id', asyncHandler(async (req, res) => {
|
|
67
57
|
const force = req.query.force === 'true';
|
|
68
58
|
const volumes = req.query.volumes === 'true';
|
|
@@ -70,7 +60,6 @@ router.delete('/:id', asyncHandler(async (req, res) => {
|
|
|
70
60
|
res.json({ success: true, message: 'Container removed', ...result });
|
|
71
61
|
}));
|
|
72
62
|
|
|
73
|
-
// GET /api/containers/:id/logs
|
|
74
63
|
router.get('/:id/logs', asyncHandler(async (req, res) => {
|
|
75
64
|
const tail = req.query.tail || 100;
|
|
76
65
|
const timestamps = req.query.timestamps === 'true';
|
|
@@ -78,7 +67,6 @@ router.get('/:id/logs', asyncHandler(async (req, res) => {
|
|
|
78
67
|
res.json({ success: true, logs });
|
|
79
68
|
}));
|
|
80
69
|
|
|
81
|
-
// GET /api/containers/:id/logs/stream - SSE streaming
|
|
82
70
|
router.get('/:id/logs/stream', (req, res) => {
|
|
83
71
|
const tail = req.query.tail || 50;
|
|
84
72
|
const timestamps = req.query.timestamps === 'true';
|
|
@@ -112,7 +100,6 @@ router.get('/:id/logs/stream', (req, res) => {
|
|
|
112
100
|
});
|
|
113
101
|
});
|
|
114
102
|
|
|
115
|
-
// POST /api/containers/:id/exec
|
|
116
103
|
router.post('/:id/exec', asyncHandler(async (req, res) => {
|
|
117
104
|
const { command, workdir } = req.body;
|
|
118
105
|
if (!command) {
|
|
@@ -4,14 +4,12 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/events
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const since = req.query.since || '24h';
|
|
10
9
|
const events = await Podman.getEvents(since);
|
|
11
10
|
res.json({ success: true, data: events });
|
|
12
11
|
}));
|
|
13
12
|
|
|
14
|
-
// GET /api/events/stream - Real-time events SSE stream
|
|
15
13
|
router.get('/stream', (req, res) => {
|
|
16
14
|
res.setHeader('Content-Type', 'text/event-stream');
|
|
17
15
|
res.setHeader('Cache-Control', 'no-cache');
|
|
@@ -32,7 +30,7 @@ router.get('/stream', (req, res) => {
|
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
proc.stderr.on('data', () => {
|
|
35
|
-
|
|
33
|
+
|
|
36
34
|
});
|
|
37
35
|
|
|
38
36
|
const heartbeat = setInterval(() => {
|
|
@@ -4,19 +4,16 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/images
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const images = await Podman.listImages();
|
|
10
9
|
res.json({ success: true, data: images });
|
|
11
10
|
}));
|
|
12
11
|
|
|
13
|
-
// GET /api/images/:id
|
|
14
12
|
router.get('/:id', asyncHandler(async (req, res) => {
|
|
15
13
|
const data = await Podman.inspectImage(req.params.id);
|
|
16
14
|
res.json({ success: true, data });
|
|
17
15
|
}));
|
|
18
16
|
|
|
19
|
-
// GET /api/images/pull-stream - Pull image with streaming updates
|
|
20
17
|
router.get('/pull-stream', (req, res) => {
|
|
21
18
|
const image = req.query.image;
|
|
22
19
|
if (!image) {
|
|
@@ -41,7 +38,6 @@ router.get('/pull-stream', (req, res) => {
|
|
|
41
38
|
});
|
|
42
39
|
});
|
|
43
40
|
|
|
44
|
-
// POST /api/images/pull
|
|
45
41
|
router.post('/pull', asyncHandler(async (req, res) => {
|
|
46
42
|
const { image } = req.body;
|
|
47
43
|
if (!image) {
|
|
@@ -51,7 +47,6 @@ router.post('/pull', asyncHandler(async (req, res) => {
|
|
|
51
47
|
res.json({ success: true, message: `Pulled ${image}`, ...result });
|
|
52
48
|
}));
|
|
53
49
|
|
|
54
|
-
// DELETE /api/images/:id
|
|
55
50
|
router.delete('/:id', asyncHandler(async (req, res) => {
|
|
56
51
|
const force = req.query.force === 'true';
|
|
57
52
|
const result = await Podman.removeImage(req.params.id, force);
|