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-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 {

View File

@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WLED Screen Controller</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='0.9em' font-size='90'>💡</text></svg>">
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
@@ -30,6 +31,21 @@
<section class="displays-section">
<h2>Available Displays</h2>
<!-- Visual Layout Preview -->
<div class="display-layout-preview">
<h3>Display Layout</h3>
<div id="display-layout-canvas" class="display-layout-canvas">
<div class="loading">Loading layout...</div>
</div>
<div class="layout-legend">
<span class="legend-item"><span class="legend-dot primary"></span> Primary Display</span>
<span class="legend-item"><span class="legend-dot secondary"></span> Secondary Display</span>
</div>
</div>
<!-- Display Cards -->
<h3 style="margin-top: 30px;">Display Information</h3>
<div id="displays-list" class="displays-grid">
<div class="loading">Loading displays...</div>
</div>

View File

@@ -223,14 +223,151 @@ section {
border: 1px solid var(--border-color);
border-radius: 8px;
padding: 15px;
text-align: center;
}
.display-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.display-index {
font-size: 2rem;
font-size: 1.3rem;
font-weight: 700;
color: var(--info-color);
margin-bottom: 10px;
}
.badge-primary {
background: var(--primary-color);
color: white;
}
.badge-secondary {
background: var(--border-color);
color: var(--text-secondary);
}
/* Display Layout Visualization */
.display-layout-preview {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 8px;
padding: 20px;
margin-bottom: 20px;
}
.display-layout-preview h3 {
margin: 0 0 15px 0;
font-size: 1.1rem;
color: var(--text-color);
}
.display-layout-canvas {
background: var(--bg-color);
border: 2px dashed var(--border-color);
border-radius: 8px;
padding: 30px;
min-height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.layout-container {
position: relative;
background: transparent;
}
.layout-display {
position: absolute;
border: 3px solid;
border-radius: 8px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
transition: transform 0.2s, box-shadow 0.2s;
cursor: help;
}
.layout-display:hover {
transform: scale(1.05);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
z-index: 10;
}
.layout-display.primary {
border-color: var(--primary-color);
background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.05));
}
.layout-display.secondary {
border-color: var(--border-color);
background: linear-gradient(135deg, rgba(128, 128, 128, 0.1), rgba(128, 128, 128, 0.05));
}
.layout-display-label {
text-align: center;
padding: 5px;
display: flex;
flex-direction: column;
gap: 2px;
}
.layout-display-label strong {
font-size: 0.9rem;
color: var(--text-color);
font-weight: 600;
}
.layout-display-label small {
font-size: 0.75rem;
color: var(--text-secondary);
}
.primary-indicator {
position: absolute;
top: 5px;
right: 5px;
color: var(--primary-color);
font-size: 1.2rem;
text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}
.layout-legend {
display: flex;
gap: 20px;
justify-content: center;
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid var(--border-color);
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.9rem;
color: var(--text-secondary);
}
.legend-dot {
width: 16px;
height: 16px;
border-radius: 3px;
border: 2px solid;
}
.legend-dot.primary {
border-color: var(--primary-color);
background: rgba(76, 175, 80, 0.2);
}
.legend-dot.secondary {
border-color: var(--border-color);
background: rgba(128, 128, 128, 0.2);
}
.add-device-section {