/* portal/usage/public/usage.js — 사용량 화면(§13.2·§13.4). /api/usage 를 그려 준다. */ (() => { const el = document.getElementById('usage'); const esc = aw.esc; const bar = (pct, lvl) => `
`; const lvlOf = (p) => (p >= 100 ? 100 : p >= 95 ? 95 : p >= 90 ? 90 : p >= 80 ? 80 : p >= 70 ? 70 : 0); async function load() { try { const d = await aw.api('GET', '/api/usage'); if (!d.product) { aw.state(el, 'empty', '활성 상품이 없습니다. 상품을 주문하면 사용량이 표시됩니다', { href: '/products', hrefLabel: '상품 보기' }); return; } let h = `| 자원 | 구매 총량 | 배정 | 예약(진행 중 작업) | 미배정 | 실제 사용 | 사용률 |
|---|---|---|---|---|---|---|
| ${esc(r.label)}${r.monthly ? ' (월간)' : ''} | ${fmt(r.purchased, r.unit)} | ${fmt(r.allocated, r.unit)} | ${fmt(r.reserved, r.unit)} | ${fmt(r.unallocated, r.unit)} | ${fmt(r.used, r.unit)} | ${bar(r.usedPercent, lvlOf(r.usedPercent))} ${r.usedPercent}% |
| 서비스 | 자원 | 배정 | 상태 | 사용 | 계측 | |
|---|---|---|---|---|---|---|
| ${esc(a.subjectLabel)} · ${esc(a.subjectName)} | ${esc(a.label)} | ${esc(a.amountText)} | ○ ${esc(a.stateLabel)} | ${esc(a.usedText)} ${a.percent != null ? bar(a.percent, lvlOf(a.percent)) + a.percent + '%' : ''} | ${a.measured_at ? aw.fmt(a.measured_at) : '계측 전'}${a.stale ? ' ! 지연' : ''} | 배정 변경 |
아직 배정된 서비스가 없습니다. 사이트나 메일 서비스를 만들면 여기에 표시됩니다.
'}| 자원 | 양 | 상태 | 사유 | 만료·반환 예정 |
|---|---|---|---|---|
| ${esc(r.label)} | ${r.amount} | ${esc(r.stateLabel)} | ${esc(r.reason || '')} | ${r.return_due_at ? aw.fmt(r.return_due_at) : r.expires_at ? aw.fmt(r.expires_at) : ''} |