From 20d8686b6135b8a84f868fe7fa98a1c8176bbaf2 Mon Sep 17 00:00:00 2001 From: magges Date: Sun, 12 Jul 2026 23:05:04 +0000 Subject: [PATCH] Show Start/Stop/Restart Podman progress in a log modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same pattern already used for container update checking (P.openLogModal) — these can take a while (storage checks, container stop grace periods, ...) and are exactly the actions someone reaches for when something's actually wrong, so a button that just sits there disabled with no feedback until it's done isn't good enough. "Refresh Status" stays inline (quick, read-only, no modal needed). Co-Authored-By: Claude Sonnet 5 --- webui/plugins/podman/javascript/settings.js | 46 ++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/webui/plugins/podman/javascript/settings.js b/webui/plugins/podman/javascript/settings.js index 35a6838..c9270df 100644 --- a/webui/plugins/podman/javascript/settings.js +++ b/webui/plugins/podman/javascript/settings.js @@ -57,19 +57,12 @@ }); } - // --- Podman service status/start/restart ---------------------------------- + // --- Podman service status/start/stop/restart ------------------------------ - function renderServiceResult(data) { + function renderServiceChip(data) { const chip = P.el('settings-service-chip'); chip.className = 'podman-chip ' + (data.running ? 'podman-chip-good' : 'podman-chip-bad'); chip.innerHTML = '' + (data.running ? 'Running' : 'Not running'); - - const log = P.el('settings-service-log'); - if (data.output) { - log.style.display = ''; - log.textContent = data.output; - log.scrollTop = log.scrollHeight; - } } function serviceButtons() { @@ -77,10 +70,17 @@ .map(function (id) { return P.el(id); }); } + // "Refresh Status" is quick and read-only — shown inline, no modal needed. function refreshServiceStatus() { const buttons = serviceButtons(); buttons.forEach(function (b) { b.disabled = true; }); - return P.get('settings', 'service_status').then(renderServiceResult).catch(function (err) { + return P.get('settings', 'service_status').then(function (data) { + renderServiceChip(data); + const log = P.el('settings-service-log'); + log.style.display = ''; + log.textContent = data.output || ''; + log.scrollTop = log.scrollHeight; + }).catch(function (err) { P.el('settings-service-chip').className = 'podman-chip podman-chip-bad'; P.el('settings-service-chip').innerHTML = 'Unknown'; P.el('settings-service-log').style.display = ''; @@ -90,14 +90,22 @@ }); } - function runServiceAction(action) { + // Start/Stop/Restart can take a while (storage checks, container + // stop grace periods, ...) and are exactly the actions someone reaches + // for when something's actually wrong — a small log modal (same pattern + // as container update checking) shows what's happening instead of + // leaving the button just spinning with no feedback. + function runServiceAction(action, title) { const buttons = serviceButtons(); buttons.forEach(function (b) { b.disabled = true; }); - P.el('settings-service-log').style.display = ''; - P.el('settings-service-log').textContent = 'Working…'; - return P.post('settings', action, {}).then(renderServiceResult).catch(function (err) { - P.el('settings-service-log').style.display = ''; - P.el('settings-service-log').textContent = err.message; + const modal = P.openLogModal(title); + return P.post('settings', action, {}).then(function (data) { + renderServiceChip(data); + (data.output || '').split('\n').forEach(function (line) { modal.log(line); }); + modal.done(); + }).catch(function (err) { + modal.log('Error: ' + err.message); + modal.done('Close'); }).finally(function () { buttons.forEach(function (b) { b.disabled = false; }); }); @@ -209,14 +217,14 @@ }); P.el('settings-service-status-btn').addEventListener('click', refreshServiceStatus); - P.el('settings-service-start-btn').addEventListener('click', function () { runServiceAction('service_start'); }); + P.el('settings-service-start-btn').addEventListener('click', function () { runServiceAction('service_start', 'Starting Podman'); }); P.el('settings-service-stop-btn').addEventListener('click', function () { if (!confirm('Stop podman? All running containers will be stopped first (each with its own configured grace period).')) return; - runServiceAction('service_stop'); + runServiceAction('service_stop', 'Stopping Podman'); }); P.el('settings-service-restart-btn').addEventListener('click', function () { if (!confirm('Restart podman? All running containers will be stopped and podman.sock will be unavailable until it comes back up.')) return; - runServiceAction('service_restart'); + runServiceAction('service_restart', 'Restarting Podman'); }); P.el('settings-format-disk-btn').addEventListener('click', openFormatDiskModal);