Add visual display layout and enhanced display information in Web UI
Some checks failed
Validate / validate (push) Failing after 14s

- Visual display layout visualization showing all monitors in their relative positions
- Displays are scaled proportionally and positioned based on actual coordinates
- Primary displays marked with star icon and green borders
- Secondary displays with gray borders
- Hover effects on display visualization with detailed tooltips
- Color-coded legend explaining primary/secondary displays
- Enhanced display cards with primary/secondary badges
- Added display index to display cards for clarity
- Added lightbulb emoji favicon for browser tab

This makes it much easier to understand multi-monitor setups and identify
which physical monitor corresponds to which display index when configuring
WLED devices.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 17:03:20 +03:00
parent d471a40234
commit 6a0cc12ca1
3 changed files with 230 additions and 5 deletions

View File

@@ -125,29 +125,101 @@ async function loadDisplays() {
if (!data.displays || data.displays.length === 0) {
container.innerHTML = '<div class="loading">No displays available</div>';
document.getElementById('display-layout-canvas').innerHTML = '<div class="loading">No displays available</div>';
return;
}
// Render display cards with enhanced information
container.innerHTML = data.displays.map(display => `
<div class="display-card">
<div class="display-index">${display.name}</div>
<div class="display-header">
<div class="display-index">${display.name}</div>
${display.is_primary ? '<span class="badge badge-primary">Primary</span>' : '<span class="badge badge-secondary">Secondary</span>'}
</div>
<div class="info-row">
<span class="info-label">Resolution:</span>
<span class="info-value">${display.width} × ${display.height}</span>
</div>
<div class="info-row">
<span class="info-label">Position:</span>
<span class="info-value">${display.x}, ${display.y}</span>
<span class="info-value">(${display.x}, ${display.y})</span>
</div>
<div class="info-row">
<span class="info-label">Display Index:</span>
<span class="info-value">${display.index}</span>
</div>
</div>
`).join('');
// Render visual layout
renderDisplayLayout(data.displays);
} catch (error) {
console.error('Failed to load displays:', error);
document.getElementById('displays-list').innerHTML =
'<div class="loading">Failed to load displays</div>';
document.getElementById('display-layout-canvas').innerHTML =
'<div class="loading">Failed to load layout</div>';
}
}
function renderDisplayLayout(displays) {
const canvas = document.getElementById('display-layout-canvas');
if (!displays || displays.length === 0) {
canvas.innerHTML = '<div class="loading">No displays to visualize</div>';
return;
}
// Calculate bounding box for all displays
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
displays.forEach(display => {
minX = Math.min(minX, display.x);
minY = Math.min(minY, display.y);
maxX = Math.max(maxX, display.x + display.width);
maxY = Math.max(maxY, display.y + display.height);
});
const totalWidth = maxX - minX;
const totalHeight = maxY - minY;
// Scale factor to fit in canvas (600px wide max, maintain aspect ratio)
const maxCanvasWidth = 600;
const maxCanvasHeight = 350;
const scaleX = maxCanvasWidth / totalWidth;
const scaleY = maxCanvasHeight / totalHeight;
const scale = Math.min(scaleX, scaleY, 0.3); // Max 0.3 scale to keep monitors reasonably sized
const canvasWidth = totalWidth * scale;
const canvasHeight = totalHeight * scale;
// Create display elements
const displayElements = displays.map(display => {
const left = (display.x - minX) * scale;
const top = (display.y - minY) * scale;
const width = display.width * scale;
const height = display.height * scale;
return `
<div class="layout-display ${display.is_primary ? 'primary' : 'secondary'}"
style="left: ${left}px; top: ${top}px; width: ${width}px; height: ${height}px;"
title="${display.name}\n${display.width}×${display.height}\nPosition: (${display.x}, ${display.y})">
<div class="layout-display-label">
<strong>${display.name}</strong>
<small>${display.width}×${display.height}</small>
</div>
${display.is_primary ? '<div class="primary-indicator">★</div>' : ''}
</div>
`;
}).join('');
canvas.innerHTML = `
<div class="layout-container" style="width: ${canvasWidth}px; height: ${canvasHeight}px; margin: 0 auto; position: relative;">
${displayElements}
</div>
`;
}
// Load devices
async function loadDevices() {
try {