import { renderHeader } from '../components/header.js?v=20260327192619'; import { deviceSessions } from '../mock-data.js?v=20260327192619'; export const pageMeta = { id: 'device-session-view', title: 'Сеанс устройства' }; function formatSessionTime(ms) { return new Date(ms).toLocaleString('ru-RU', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', }); } export function render({ navigate, route }) { const screen = document.createElement('section'); screen.className = 'stack'; const sessionId = route?.params?.sessionId || ''; const session = deviceSessions.find((item) => item.sessionId === sessionId) || deviceSessions[0]; screen.append( renderHeader({ title: 'Сеанс устройства', leftAction: { label: '←', onClick: () => navigate('device-view') }, }), ); const details = document.createElement('div'); details.className = 'card stack'; details.innerHTML = `

sessionId

${session.sessionId}

clientInfoFromClient

${session.clientInfoFromClient}

clientInfoFromRequest

${session.clientInfoFromRequest}

geo

${session.geo}

дата/время

${formatSessionTime(session.lastAuthenticatedAtMs)}

`; const actionBtn = document.createElement('button'); actionBtn.className = 'text-btn'; actionBtn.type = 'button'; actionBtn.textContent = 'Завершить сеанс'; const confirmModal = document.createElement('div'); confirmModal.className = 'modal-shell'; confirmModal.hidden = true; confirmModal.innerHTML = ` `; const openModal = () => { confirmModal.hidden = false; confirmModal.querySelector('.modal-dialog').focus(); }; const closeModal = () => { confirmModal.hidden = true; }; actionBtn.addEventListener('click', openModal); confirmModal.querySelector('#confirm-session-ok').addEventListener('click', closeModal); confirmModal.addEventListener('click', (event) => { const target = event.target; if (target instanceof HTMLElement && target.dataset.close === 'true') { closeModal(); } }); confirmModal.addEventListener('keydown', (event) => { if (event.key === 'Escape') { closeModal(); } }); screen.append(details, actionBtn, confirmModal); return screen; }