/** * Live progress for the "Cache warming" row of the VITEC SSR module. * Polls the vitec_ssr_health ajax route (GET /__health of the node): * every 2 s while a warm run is active, every 15 s otherwise so runs * started from the CLI or the context menu show up without a reload. * Also refreshes the "Cache: N pages / M MB" line and disables the * "Warm cache" button while a run is active. */ import AjaxRequest from '@typo3/core/ajax/ajax-request.js'; const cell = document.getElementById('ssr-warm-status'); if (cell) { const wrap = document.getElementById('ssr-warm-progress'); const bar = document.getElementById('ssr-warm-bar'); const text = document.getElementById('ssr-warm-text'); const cacheLine = document.getElementById('ssr-cache-line'); const warmButton = document.getElementById('ssr-warm-button'); let timer = null; const num = (v) => (typeof v === 'number' ? v : 0); const render = (h) => { const w = h.warming || {}; const queued = num(w.queued); const handled = num(w.done) + num(w.skipped) + num(w.failed); const pct = queued > 0 ? Math.min(100, Math.round((handled / queued) * 100)) : 0; const failed = num(w.failed) ? '' + num(w.failed) + ' failed' : '0 failed'; if (w.running) { wrap.style.display = ''; bar.style.width = pct + '%'; bar.textContent = pct + ' %'; text.innerHTML = 'running ' + handled + ' of ' + queued + ' pages (' + num(w.done) + ' rendered, ' + num(w.skipped) + ' still fresh, ' + failed + ')' + '