import { api } from '../api.js'; import { showToast } from '../components/toast.js'; const API = (url, opts = {}) => fetch('/api' + url, { headers: { Authorization: `Bearer ${localStorage.getItem('token')}`, ...opts.headers }, ...opts }).then(r => r.json()); export async function render(container) { const devices = await api.getDevices(); const today = new Date(); const thirtyDaysAgo = new Date(today); thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); container.innerHTML = `
| Content | Plays | Total Hours | Completion |
|---|---|---|---|
| ${c.content_name || 'Unknown'} | ${c.plays} | ${(c.total_seconds / 3600).toFixed(1)} | ${c.plays > 0 ? Math.round((c.completed_plays / c.plays) * 100) : 0}% |
| No data | |||
| Device | Plays | Total Hours |
|---|---|---|
| ${d.device_name} | ${d.plays} | ${(d.total_seconds / 3600).toFixed(1)} |
| No data | ||
${err.message}