diff --git a/docs/releases/console-3.1.17.md b/docs/releases/console-3.1.17.md new file mode 100644 index 0000000..9789105 --- /dev/null +++ b/docs/releases/console-3.1.17.md @@ -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. diff --git a/offline/stage_versions.py b/offline/stage_versions.py index ec556c9..f67b48a 100644 --- a/offline/stage_versions.py +++ b/offline/stage_versions.py @@ -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.""" job = read_json(STATE / 'job.json') 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: stream.seek(0, 2) size = stream.tell() - stream.seek(max(0, size - 65536)) - text = stream.read(65536).decode('utf-8', errors='replace') + stream.seek(0 if full else max(0, size - 65536)) + text = (stream.read() if full else stream.read(65536)).decode('utf-8', errors='replace') except OSError: text = '' latest_job = read_json(STATE / 'job.json') @@ -198,10 +198,10 @@ def installation_log(stage, unit=""): # Installer output can include URLs and environment diagnostics. 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) - lines = text.splitlines()[-300:] + lines = text.splitlines() if full else text.splitlines()[-300:] return {'ok': True, 'stage': stage, 'unit': job.get('unit'), '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'), 'reason': reason, 'lines': [], 'truncated': False} diff --git a/offline/test_stage_versions.py b/offline/test_stage_versions.py index 7fbc973..b294947 100644 --- a/offline/test_stage_versions.py +++ b/offline/test_stage_versions.py @@ -65,6 +65,18 @@ class StageVersionsTest(unittest.TestCase): with self.assertRaises(ValueError): 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): versions.delivery.write_json(versions.STATE / 'job.json', { 'stage': 'stage_ip_stream', 'unit': 'job-1', 'state': 'failed'}) diff --git a/stage-releases.json b/stage-releases.json index 079adc0..86e6337 100644 --- a/stage-releases.json +++ b/stage-releases.json @@ -14,7 +14,7 @@ "version": "1.0.0" }, "stage_ui": { - "version": "3.1.16" + "version": "3.1.17" }, "stage_avahi": { "version": "1.0.0" diff --git a/stage_ui/console_core/backend/app.py b/stage_ui/console_core/backend/app.py index e1c1aaf..23d855f 100644 --- a/stage_ui/console_core/backend/app.py +++ b/stage_ui/console_core/backend/app.py @@ -54,7 +54,7 @@ APP_DIR = "/opt/iomatex-console" PUBLIC_DIR = os.path.join(APP_DIR, "public") PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d") 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" ZONEINFO_ROOT = "/usr/share/zoneinfo" @@ -3375,7 +3375,8 @@ class Handler(BaseHTTPRequestHandler): query = parse_qs(parsed.query) try: 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: self.send_json({"ok": False, "error": str(exc)}, code=409) return diff --git a/stage_ui/console_core/backend/test_installation_log_copy_browser.cjs b/stage_ui/console_core/backend/test_installation_log_copy_browser.cjs new file mode 100644 index 0000000..735378e --- /dev/null +++ b/stage_ui/console_core/backend/test_installation_log_copy_browser.cjs @@ -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)}); diff --git a/stage_ui/console_core/backend/test_installation_log_layout_browser.cjs b/stage_ui/console_core/backend/test_installation_log_layout_browser.cjs index 3577816..b4473b5 100644 --- a/stage_ui/console_core/backend/test_installation_log_layout_browser.cjs +++ b/stage_ui/console_core/backend/test_installation_log_layout_browser.cjs @@ -1,2 +1,2 @@ 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)}); diff --git a/stage_ui/console_core/frontend/console.css b/stage_ui/console_core/frontend/console.css index 9202803..9da732a 100644 --- a/stage_ui/console_core/frontend/console.css +++ b/stage_ui/console_core/frontend/console.css @@ -1594,9 +1594,15 @@ html[dir="rtl"] .timezoneOption{text-align:right} width:min(1000px,100%); } .platformDialog--details .diagBlock{ - text-align:right; + text-align:left; direction:ltr; } +.platformDialogTools{ + position:sticky; + top:0; + padding:10px 0; + background:var(--panel); +} .platformDialogIcon{ display:grid; place-items:center; diff --git a/stage_ui/console_core/frontend/console.i18n.js b/stage_ui/console_core/frontend/console.i18n.js index cd80718..c5e7c3d 100644 --- a/stage_ui/console_core/frontend/console.i18n.js +++ b/stage_ui/console_core/frontend/console.i18n.js @@ -2126,5 +2126,5 @@ "Critical": "गंभीर", "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": "Лог установки пока пуст"}); })(); diff --git a/stage_ui/console_core/frontend/console.js b/stage_ui/console_core/frontend/console.js index 67debd8..1ee8091 100644 --- a/stage_ui/console_core/frontend/console.js +++ b/stage_ui/console_core/frontend/console.js @@ -49,7 +49,7 @@ { mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" }, { 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_BUFFER_LIMIT = 300; const ITSCREEN_LOG_BATCH_MS = 250; @@ -1215,7 +1215,7 @@
${esc(message)}
- ${details ? `${esc(details)}` : ""}
+ ${details ? `${esc(details)}` : ""}