Left-align logs and add sticky full-log clipboard action

This commit is contained in:
Andrei Smaliak 2026-10-06 06:11:30 +02:00
parent 147eaa55e2
commit 4c09f24408
12 changed files with 61 additions and 20 deletions

View File

@ -0,0 +1,9 @@
# Console 3.1.17
Release date: 2026-10-06.
- Left-align installation-log output, retaining the wider dialog.
- Add a prominent sticky Copy entire log button above the output, with Copied feedback. Reuse the existing clipboard helper, including the HTTP fallback, and preserve whitespace.
- Load all available lines on explicit log opening through the authenticated, job-bound log endpoint; retain credential redaction. Background health diagnostics still use the bounded tail.
Validation: full-log tests beyond 64 KB and 300 lines, redaction/job ownership tests, browser copy/paste round-trip on HTTP, sticky-button visibility, and responsive layout checks.

View File

@ -174,7 +174,7 @@ def job_status():
def installation_log(stage, unit=""): def installation_log(stage, unit="", full=False):
"""Only the latest job owns install.log; never accept a filesystem path.""" """Only the latest job owns install.log; never accept a filesystem path."""
job = read_json(STATE / 'job.json') job = read_json(STATE / 'job.json')
if stage not in STAGES or job.get('stage') != stage or (unit and job.get('unit') != unit): if stage not in STAGES or job.get('stage') != stage or (unit and job.get('unit') != unit):
@ -183,8 +183,8 @@ def installation_log(stage, unit=""):
with (STATE / 'install.log').open('rb') as stream: with (STATE / 'install.log').open('rb') as stream:
stream.seek(0, 2) stream.seek(0, 2)
size = stream.tell() size = stream.tell()
stream.seek(max(0, size - 65536)) stream.seek(0 if full else max(0, size - 65536))
text = stream.read(65536).decode('utf-8', errors='replace') text = (stream.read() if full else stream.read(65536)).decode('utf-8', errors='replace')
except OSError: except OSError:
text = '' text = ''
latest_job = read_json(STATE / 'job.json') latest_job = read_json(STATE / 'job.json')
@ -198,10 +198,10 @@ def installation_log(stage, unit=""):
# Installer output can include URLs and environment diagnostics. # Installer output can include URLs and environment diagnostics.
text = re.sub(r'(?i)(https?://|rtsp://)[^/\s@]+@', r'\1[redacted]@', text) text = re.sub(r'(?i)(https?://|rtsp://)[^/\s@]+@', r'\1[redacted]@', text)
text = re.sub(r'(?im)^.*(?:password|passwd|authorization|secret|token|credential|private.key).*$','[sensitive line hidden]',text) text = re.sub(r'(?im)^.*(?:password|passwd|authorization|secret|token|credential|private.key).*$','[sensitive line hidden]',text)
lines = text.splitlines()[-300:] lines = text.splitlines() if full else text.splitlines()[-300:]
return {'ok': True, 'stage': stage, 'unit': job.get('unit'), return {'ok': True, 'stage': stage, 'unit': job.get('unit'),
'state': job.get('state'), 'reason': reason, 'lines': lines, 'state': job.get('state'), 'reason': reason, 'lines': lines,
'truncated': size > 65536 or len(text.splitlines()) > 300} if text else { 'truncated': not full and (size > 65536 or len(text.splitlines()) > 300)} if text else {
'ok': True, 'stage': stage, 'unit': job.get('unit'), 'state': job.get('state'), 'ok': True, 'stage': stage, 'unit': job.get('unit'), 'state': job.get('state'),
'reason': reason, 'lines': [], 'truncated': False} 'reason': reason, 'lines': [], 'truncated': False}

View File

@ -65,6 +65,18 @@ class StageVersionsTest(unittest.TestCase):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
versions.installation_log(stage, unit) versions.installation_log(stage, unit)
def test_full_install_log_keeps_all_lines_and_redaction(self):
versions.delivery.write_json(versions.STATE / 'job.json', {'stage': 'stage_ui', 'unit': 'job-full', 'state': 'success'})
rows = [' first line'] + ['output ' + 'x' * 100 for _ in range(800)] + ['password=hidden', 'last line']
(versions.STATE / 'install.log').write_text('\n'.join(rows))
result = versions.installation_log('stage_ui', 'job-full', full=True)
self.assertEqual(len(rows), len(result['lines']))
self.assertEqual(' first line', result['lines'][0])
self.assertEqual('last line', result['lines'][-1])
self.assertEqual('[sensitive line hidden]', result['lines'][-2])
self.assertFalse(result['truncated'])
self.assertTrue(versions.installation_log('stage_ui', 'job-full')['truncated'])
def test_missing_install_log_is_reported_without_read_failure(self): def test_missing_install_log_is_reported_without_read_failure(self):
versions.delivery.write_json(versions.STATE / 'job.json', { versions.delivery.write_json(versions.STATE / 'job.json', {
'stage': 'stage_ip_stream', 'unit': 'job-1', 'state': 'failed'}) 'stage': 'stage_ip_stream', 'unit': 'job-1', 'state': 'failed'})

View File

@ -14,7 +14,7 @@
"version": "1.0.0" "version": "1.0.0"
}, },
"stage_ui": { "stage_ui": {
"version": "3.1.16" "version": "3.1.17"
}, },
"stage_avahi": { "stage_avahi": {
"version": "1.0.0" "version": "1.0.0"

View File

@ -54,7 +54,7 @@ APP_DIR = "/opt/iomatex-console"
PUBLIC_DIR = os.path.join(APP_DIR, "public") PUBLIC_DIR = os.path.join(APP_DIR, "public")
PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d") PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d")
CONFIG_PATH = "/etc/iomatex/console.json" CONFIG_PATH = "/etc/iomatex/console.json"
UI_VERSION = "V 3.1.16" UI_VERSION = "V 3.1.17"
STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health" STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health"
ZONEINFO_ROOT = "/usr/share/zoneinfo" ZONEINFO_ROOT = "/usr/share/zoneinfo"
@ -3375,7 +3375,8 @@ class Handler(BaseHTTPRequestHandler):
query = parse_qs(parsed.query) query = parse_qs(parsed.query)
try: try:
self.send_json(stage_versions.installation_log( self.send_json(stage_versions.installation_log(
query.get("stage", [""])[0], query.get("unit", [""])[0])) query.get("stage", [""])[0], query.get("unit", [""])[0],
full=query.get("full", ["0"])[0] == "1"))
except ValueError as exc: except ValueError as exc:
self.send_json({"ok": False, "error": str(exc)}, code=409) self.send_json({"ok": False, "error": str(exc)}, code=409)
return return

View File

@ -0,0 +1,2 @@
const {chromium}=require('playwright');
(async()=>{const base='http://192.168.0.109';const b=await chromium.launch({args:['--unsafely-treat-insecure-origin-as-secure='+base]});const c=await b.newContext({permissions:['clipboard-read','clipboard-write']});await c.request.post(base+'/api/auth/login',{data:{username:'iomatex',password:process.env.EDGE_PASSWORD}});const p=await c.newPage();if(process.env.LOCAL_JS){for(const name of ['console.js','console.css'])await p.route('**/'+name+'*',r=>r.fulfill({path:'/repo/stage_ui/console_core/frontend/'+name}));await p.route('**/api/stages/log?*',r=>{if(new URL(r.request().url()).searchParams.get('full')!=='1')throw Error('Full log not requested');return r.fulfill({json:{state:'success',lines:[' first line',...Array(800).fill('long output'),'last line'],truncated:false}})})}await p.goto(base,{waitUntil:'networkidle'});await p.evaluate(()=>{void window.__stageInstallLog('stage_ui','')});const dialog=p.locator('.platformDialog--details');await dialog.waitFor();const button=dialog.locator('[data-dialog-copy]');await button.click();const expected=await dialog.locator('pre').textContent();await p.evaluate(()=>{const input=document.createElement('textarea');input.id='clipboard-check';document.body.appendChild(input);input.focus()});await p.keyboard.press('Control+V');if(await p.locator('#clipboard-check').inputValue()!==expected)throw Error('Pasted clipboard differs from full log');await p.locator('#clipboard-check').evaluate(e=>e.remove());await dialog.evaluate(e=>e.scrollTop=e.scrollHeight);const r=await button.boundingBox();if(!r||r.y<0||r.y>900)throw Error('Copy button scrolled away');console.log('Full log copied and pasted exactly on HTTP; button remains visible');await c.request.post(base+'/api/auth/logout',{data:{}});await b.close()})().catch(e=>{console.error(e);process.exit(1)});

View File

@ -1,2 +1,2 @@
const {chromium}=require('playwright'); const {chromium}=require('playwright');
(async()=>{const b=await chromium.launch();const c=await b.newContext();const base='http://192.168.0.109';await c.request.post(base+'/api/auth/login',{data:{username:'iomatex',password:process.env.EDGE_PASSWORD}});const p=await c.newPage();if(process.env.LOCAL_JS)for(const name of ['console.js','console.css'])await p.route('**/'+name+'*',r=>r.fulfill({path:'/repo/stage_ui/console_core/frontend/'+name}));await p.goto(base,{waitUntil:'networkidle'});for(const width of [360,768,1024,1440]){await p.setViewportSize({width,height:900});await p.evaluate(()=>{void window.__stageInstallLog('stage_ui','')});const dialog=p.locator('.platformDialog--details');await dialog.waitFor();const result=await dialog.evaluate(e=>{const r=e.getBoundingClientRect();return {x:r.x,y:r.y,width:r.width,bottom:r.bottom,scroll:e.scrollTop,align:getComputedStyle(e.querySelector('pre')).textAlign}});if(result.align!=='right'||result.scroll!==0||result.x<19||result.y<19||result.bottom>881||result.width>width-39)throw Error(JSON.stringify(result));if(width===1440&&result.width<990)throw Error('Dialog not widened');await p.keyboard.press('Escape');await dialog.waitFor({state:'detached'});console.log(width,result);}await c.request.post(base+'/api/auth/logout',{data:{}});await b.close()})().catch(e=>{console.error(e);process.exit(1)}); (async()=>{const b=await chromium.launch();const c=await b.newContext();const base='http://192.168.0.109';await c.request.post(base+'/api/auth/login',{data:{username:'iomatex',password:process.env.EDGE_PASSWORD}});const p=await c.newPage();if(process.env.LOCAL_JS)for(const name of ['console.js','console.css'])await p.route('**/'+name+'*',r=>r.fulfill({path:'/repo/stage_ui/console_core/frontend/'+name}));await p.goto(base,{waitUntil:'networkidle'});for(const width of [360,768,1024,1440]){await p.setViewportSize({width,height:900});await p.evaluate(()=>{void window.__stageInstallLog('stage_ui','')});const dialog=p.locator('.platformDialog--details');await dialog.waitFor();const result=await dialog.evaluate(e=>{const r=e.getBoundingClientRect();return {x:r.x,y:r.y,width:r.width,bottom:r.bottom,scroll:e.scrollTop,align:getComputedStyle(e.querySelector('pre')).textAlign}});if(result.align!=='left'||result.scroll!==0||result.x<19||result.y<19||result.bottom>881||result.width>width-39)throw Error(JSON.stringify(result));if(width===1440&&result.width<990)throw Error('Dialog not widened');await p.keyboard.press('Escape');await dialog.waitFor({state:'detached'});console.log(width,result);}await c.request.post(base+'/api/auth/logout',{data:{}});await b.close()})().catch(e=>{console.error(e);process.exit(1)});

View File

@ -1594,9 +1594,15 @@ html[dir="rtl"] .timezoneOption{text-align:right}
width:min(1000px,100%); width:min(1000px,100%);
} }
.platformDialog--details .diagBlock{ .platformDialog--details .diagBlock{
text-align:right; text-align:left;
direction:ltr; direction:ltr;
} }
.platformDialogTools{
position:sticky;
top:0;
padding:10px 0;
background:var(--panel);
}
.platformDialogIcon{ .platformDialogIcon{
display:grid; display:grid;
place-items:center; place-items:center;

View File

@ -2126,5 +2126,5 @@
"Critical": "गंभीर", "Critical": "गंभीर",
"Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "घिसाव एक मोटा JEDEC अनुमान है। यह eMMC सटीक चालू घंटे या लेखन चक्र नहीं बताती।" "Wear is a coarse JEDEC estimate. This eMMC does not expose exact power-on hours or write cycles.": "घिसाव एक मोटा JEDEC अनुमान है। यह eMMC सटीक चालू घंटे या लेखन चक्र नहीं बताती।"
}); });
Object.assign(window.ConsoleI18n.translations.ru, {"Installation log": "Лог установки", "FFmpeg is required for camera video and snapshots.": "Для видео и снимков камер необходим FFmpeg.", "FFmpeg is missing. The streaming installer stopped before creating the service.": "FFmpeg отсутствует. Установка видеосервиса остановилась до создания службы.", "Installation did not complete. Open the installation log for details.": "Установка не завершена. Откройте лог установки для выяснения причины.", "Installed but unavailable": "Установлен, но не работает", "Showing the last 300 lines (maximum 64 KB).": "Показаны последние 300 строк (не более 64 КБ).", "Installation log is empty": "Лог установки пока пуст"}); Object.assign(window.ConsoleI18n.translations.ru, {"Copy entire log": "Копировать весь лог", "Copied": "Скопировано", "Installation log": "Лог установки", "FFmpeg is required for camera video and snapshots.": "Для видео и снимков камер необходим FFmpeg.", "FFmpeg is missing. The streaming installer stopped before creating the service.": "FFmpeg отсутствует. Установка видеосервиса остановилась до создания службы.", "Installation did not complete. Open the installation log for details.": "Установка не завершена. Откройте лог установки для выяснения причины.", "Installed but unavailable": "Установлен, но не работает", "Showing the last 300 lines (maximum 64 KB).": "Показаны последние 300 строк (не более 64 КБ).", "Installation log is empty": "Лог установки пока пуст"});
})(); })();

View File

@ -49,7 +49,7 @@
{ mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" }, { mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" },
{ mode: "custom", label: "Custom", host: "" } { mode: "custom", label: "Custom", host: "" }
]; ];
const UI_VERSION = "V 3.1.16"; const UI_VERSION = "V 3.1.17";
const ITSCREEN_LOG_INITIAL_LINES = 50; const ITSCREEN_LOG_INITIAL_LINES = 50;
const ITSCREEN_LOG_BUFFER_LIMIT = 300; const ITSCREEN_LOG_BUFFER_LIMIT = 300;
const ITSCREEN_LOG_BATCH_MS = 250; const ITSCREEN_LOG_BATCH_MS = 250;
@ -1215,7 +1215,7 @@
<div class="platformDialogIcon" aria-hidden="true">${tone === "success" ? "✓" : "!"}</div> <div class="platformDialogIcon" aria-hidden="true">${tone === "success" ? "✓" : "!"}</div>
<h3>${esc(title)}</h3> <h3>${esc(title)}</h3>
<p>${esc(message)}</p> <p>${esc(message)}</p>
${details ? `<pre class="diagBlock testOutput">${esc(details)}</pre>` : ""} ${details ? `<div class="actionRow platformDialogTools"><button class="actionBtn" type="button" data-dialog-copy>${esc(t("Copy entire log"))}</button></div><pre class="diagBlock testOutput">${esc(details)}</pre>` : ""}
<div class="actionRow"> <div class="actionRow">
${secondaryLabel ? `<button class="actionBtn secondary" type="button" data-dialog-secondary>${esc(secondaryLabel)}</button>` : ""} ${secondaryLabel ? `<button class="actionBtn secondary" type="button" data-dialog-secondary>${esc(secondaryLabel)}</button>` : ""}
<button class="actionBtn" type="button" data-dialog-primary>${esc(primaryLabel)}</button> <button class="actionBtn" type="button" data-dialog-primary>${esc(primaryLabel)}</button>
@ -1244,6 +1244,17 @@
backdrop.addEventListener("click", (event) => { backdrop.addEventListener("click", (event) => {
if (event.target === backdrop) finish(false); if (event.target === backdrop) finish(false);
}); });
const copyButton = backdrop.querySelector("[data-dialog-copy]");
if (copyButton) copyButton.addEventListener("click", async () => {
if (!isTopmost()) return;
try {
await copyTextToClipboard(details);
copyButton.textContent = t("Copied");
copyButton.focus({ preventScroll: true });
} catch (error) {
showToast("error", error.message || t("Clipboard is unavailable"));
}
});
const secondaryButton = backdrop.querySelector("[data-dialog-secondary]"); const secondaryButton = backdrop.querySelector("[data-dialog-secondary]");
if (secondaryButton) secondaryButton.addEventListener("click", () => finish(false)); if (secondaryButton) secondaryButton.addEventListener("click", () => finish(false));
backdrop.querySelector("[data-dialog-primary]").addEventListener("click", () => finish(true)); backdrop.querySelector("[data-dialog-primary]").addEventListener("click", () => finish(true));
@ -1275,8 +1286,8 @@
} }
async function copyTextToClipboard(text) { async function copyTextToClipboard(text) {
const value = textValue(text, ""); const value = text == null ? "" : String(text);
if (!value) throw new Error(t("Nothing to copy")); if (!value.trim()) throw new Error(t("Nothing to copy"));
if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") { if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
await navigator.clipboard.writeText(value); await navigator.clipboard.writeText(value);
return; return;
@ -5479,7 +5490,7 @@
window.__stageInstallLog = async function (stage, unit) { window.__stageInstallLog = async function (stage, unit) {
try { try {
const log = await fetchJson(`/api/stages/log?stage=${encodeURIComponent(stage)}&unit=${encodeURIComponent(unit)}`, {cache: "no-store"}); const log = await fetchJson(`/api/stages/log?stage=${encodeURIComponent(stage)}&unit=${encodeURIComponent(unit)}&full=1`, {cache: "no-store"});
await platformDialog({title: t("Installation log"), await platformDialog({title: t("Installation log"),
message: [stage, t(log.state || ""), t(log.reason || ""), log.truncated ? t("Showing the last 300 lines (maximum 64 KB).") : ""].filter(Boolean).join(" · "), message: [stage, t(log.state || ""), t(log.reason || ""), log.truncated ? t("Showing the last 300 lines (maximum 64 KB).") : ""].filter(Boolean).join(" · "),
details: (log.lines || []).join("\n") || t("Installation log is empty"), primaryLabel: t("Close")}); details: (log.lines || []).join("\n") || t("Installation log is empty"), primaryLabel: t("Close")});

View File

@ -23,7 +23,7 @@
} catch (error) {} } catch (error) {}
})(); })();
</script> </script>
<link rel="stylesheet" href="/console.css?v=3.1.16&amp;rev=camera-snapshot-1"> <link rel="stylesheet" href="/console.css?v=3.1.17&amp;rev=camera-snapshot-1">
</head> </head>
<body> <body>
<main class="shell"> <main class="shell">
@ -109,7 +109,7 @@
</main> </main>
<div id="menuBackdrop" class="menuBackdrop" hidden></div> <div id="menuBackdrop" class="menuBackdrop" hidden></div>
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div> <div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
<script src="/console.i18n.js?v=3.1.16&amp;rev=camera-snapshot-1"></script> <script src="/console.i18n.js?v=3.1.17&amp;rev=camera-snapshot-1"></script>
<script src="/console.js?v=3.1.16&amp;rev=camera-snapshot-1"></script> <script src="/console.js?v=3.1.17&amp;rev=camera-snapshot-1"></script>
</body> </body>
</html> </html>

View File

@ -1,3 +1,3 @@
{ {
"version": "3.1.16" "version": "3.1.17"
} }