Feature: Priority-based sorting and display limit optimization
Backend (server.js): - Implemented severity-based sorting for current events - Priority hierarchy: Incident > Change > Awareness > TBD - Events with same severity sorted by starttime (earliest first) - Upcoming events remain sorted by starttime only - Added severityPriority mapping for consistent ordering Frontend (index.html): - Reduced display limits for 1080p TVs: 2 current + 2 upcoming = 4 total - Prevents content overflow on 1080p displays - 4K displays still auto-scale content appropriately - Ensures critical incidents always appear first in current events Testing: - Verified Incident appears before Change before Awareness - Verified all 4 events fit on 1080p screen without scrolling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -463,8 +463,10 @@
|
||||
let html = '';
|
||||
|
||||
// Limit display to fit on TV screen without scrolling
|
||||
const MAX_CURRENT = 3;
|
||||
const MAX_UPCOMING = 3;
|
||||
// 1080p: 2+2 = 4 events max
|
||||
// 4K: Will scale up automatically via CSS
|
||||
const MAX_CURRENT = 2;
|
||||
const MAX_UPCOMING = 2;
|
||||
|
||||
// Current Events (limit to MAX_CURRENT)
|
||||
if (data.current && data.current.length > 0) {
|
||||
|
||||
27
server.js
27
server.js
@@ -59,6 +59,33 @@ app.get('/api/notifications', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Sort current events by severity priority, then by starttime
|
||||
// Priority: Incident (danger) > Change (warning) > Awareness/TBD (success)
|
||||
const severityPriority = {
|
||||
'danger': 1, // Incident - highest priority
|
||||
'warning': 2, // Change
|
||||
'success': 3, // Awareness/TBD - lowest priority
|
||||
'secondary': 4 // Fallback
|
||||
};
|
||||
|
||||
currentEvents.sort((a, b) => {
|
||||
const priorityA = severityPriority[a.typecolor] || 4;
|
||||
const priorityB = severityPriority[b.typecolor] || 4;
|
||||
|
||||
// First sort by priority
|
||||
if (priorityA !== priorityB) {
|
||||
return priorityA - priorityB;
|
||||
}
|
||||
|
||||
// If same priority, sort by starttime (earliest first)
|
||||
return new Date(a.starttime) - new Date(b.starttime);
|
||||
});
|
||||
|
||||
// Upcoming events stay sorted by starttime only
|
||||
upcomingEvents.sort((a, b) => {
|
||||
return new Date(a.starttime) - new Date(b.starttime);
|
||||
});
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
timestamp: new Date().toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user