/** * Token Status UI - Standalone * Displays token statuses, expiration times, last 4 digits * No external imports - uses window.JobInfoAuth from global scope */ class TokenStatusUI { constructor() { this.container = null; this.refreshInterval = null; } /** * Create and show token status UI */ create(containerId = 'app') { console.log('[TokenUI] create() called with container:', containerId); this.container = document.getElementById(containerId); if (!this.container) { console.error('[TokenUI] Container not found:', containerId); return; } this.render(); // Refresh UI every second to update expiration countdown this.refreshInterval = window.setInterval(() => { this.render(); }, 1000); console.log('[TokenUI] UI created and refresh interval started'); } /** * Render token status UI */ render() { if (!this.container) return; const state = this.getState(); const pbStatus = state.pbUser.active ? '✓ Active' : '✗ Inactive'; const pbStatusColor = state.pbUser.active ? '#10b981' : '#ef4444'; const graphStatus = state.graphUser.active ? '✓ Active' : '○ Not Required'; const graphStatusColor = state.graphUser.active ? '#10b981' : '#6b7280'; this.container.innerHTML = `
User: ${state.userDisplayName}
Token: ...${state.pbUser.lastFour}
Expires in: ${state.pbUser.expiresIn}
Token: ...${state.graphUser.lastFour}
Expires in: ${state.graphUser.expiresIn}
` : `Graph token is optional. Login proceeded without it.
`}