import { api } from '../api.js'; import { on, off, requestScreenshot } from '../socket.js'; import { showToast } from '../components/toast.js'; import { esc } from '../utils.js'; const DESTRUCTIVE_COMMANDS = ['reboot', 'shutdown']; const GROUP_COMMANDS = [ { type: 'screen_on', label: 'Screen On' }, { type: 'screen_off', label: 'Screen Off' }, { type: 'launch', label: 'Restart App' }, { type: 'update', label: 'Check Update' }, { type: 'reboot', label: 'Reboot', destructive: true }, { type: 'shutdown', label: 'Shutdown', destructive: true }, ]; let statusHandler = null; let screenshotHandler = null; let refreshInterval = null; function formatTimeAgo(timestamp) { if (!timestamp) return 'Never'; const seconds = Math.floor(Date.now() / 1000 - timestamp); if (seconds < 60) return 'Just now'; if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`; if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`; return `${Math.floor(seconds / 86400)}d ago`; } function formatBytes(mb) { if (mb === null || mb === undefined) return '--'; if (mb >= 1024) return `${(mb / 1024).toFixed(1)} GB`; return `${mb} MB`; } function renderDeviceCard(device) { const token = localStorage.getItem('token'); const screenshotUrl = device.screenshot_path ? `/api/devices/${device.id}/screenshot?t=${device.screenshot_at || ''}&token=${token}` : null; return `
Install the ScreenTinker app on your Apolosign TV and pair it using the button above.
${esc(err.message)}
Check devices to add them to this group