Dashboard: show color strip source type in target subtitle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -295,10 +295,11 @@ export async function loadDashboard(forceFullRender = false) {
|
|||||||
if (!container) { set_dashboardLoading(false); return; }
|
if (!container) { set_dashboardLoading(false); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [targetsResp, profilesResp, devicesResp] = await Promise.all([
|
const [targetsResp, profilesResp, devicesResp, cssResp] = await Promise.all([
|
||||||
fetchWithAuth('/picture-targets'),
|
fetchWithAuth('/picture-targets'),
|
||||||
fetchWithAuth('/profiles').catch(() => null),
|
fetchWithAuth('/profiles').catch(() => null),
|
||||||
fetchWithAuth('/devices').catch(() => null),
|
fetchWithAuth('/devices').catch(() => null),
|
||||||
|
fetchWithAuth('/color-strip-sources').catch(() => null),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const targetsData = await targetsResp.json();
|
const targetsData = await targetsResp.json();
|
||||||
@@ -308,6 +309,9 @@ export async function loadDashboard(forceFullRender = false) {
|
|||||||
const devicesData = devicesResp && devicesResp.ok ? await devicesResp.json() : { devices: [] };
|
const devicesData = devicesResp && devicesResp.ok ? await devicesResp.json() : { devices: [] };
|
||||||
const devicesMap = {};
|
const devicesMap = {};
|
||||||
for (const d of (devicesData.devices || [])) { devicesMap[d.id] = d; }
|
for (const d of (devicesData.devices || [])) { devicesMap[d.id] = d; }
|
||||||
|
const cssData = cssResp && cssResp.ok ? await cssResp.json() : { sources: [] };
|
||||||
|
const cssSourceMap = {};
|
||||||
|
for (const s of (cssData.sources || [])) { cssSourceMap[s.id] = s; }
|
||||||
|
|
||||||
// Build dynamic HTML (targets, profiles)
|
// Build dynamic HTML (targets, profiles)
|
||||||
let dynamicHtml = '';
|
let dynamicHtml = '';
|
||||||
@@ -367,7 +371,7 @@ export async function loadDashboard(forceFullRender = false) {
|
|||||||
if (running.length > 0) {
|
if (running.length > 0) {
|
||||||
runningIds = running.map(t => t.id);
|
runningIds = running.map(t => t.id);
|
||||||
const stopAllBtn = `<button class="btn btn-sm btn-danger dashboard-stop-all" onclick="event.stopPropagation(); dashboardStopAll()" title="${t('dashboard.stop_all')}">⏹️ ${t('dashboard.stop_all')}</button>`;
|
const stopAllBtn = `<button class="btn btn-sm btn-danger dashboard-stop-all" onclick="event.stopPropagation(); dashboardStopAll()" title="${t('dashboard.stop_all')}">⏹️ ${t('dashboard.stop_all')}</button>`;
|
||||||
const runningItems = running.map(target => renderDashboardTarget(target, true, devicesMap)).join('');
|
const runningItems = running.map(target => renderDashboardTarget(target, true, devicesMap, cssSourceMap)).join('');
|
||||||
|
|
||||||
targetsInner += `<div class="dashboard-subsection">
|
targetsInner += `<div class="dashboard-subsection">
|
||||||
${_sectionHeader('running', t('dashboard.section.running'), running.length, stopAllBtn)}
|
${_sectionHeader('running', t('dashboard.section.running'), running.length, stopAllBtn)}
|
||||||
@@ -376,7 +380,7 @@ export async function loadDashboard(forceFullRender = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stopped.length > 0) {
|
if (stopped.length > 0) {
|
||||||
const stoppedItems = stopped.map(target => renderDashboardTarget(target, false, devicesMap)).join('');
|
const stoppedItems = stopped.map(target => renderDashboardTarget(target, false, devicesMap, cssSourceMap)).join('');
|
||||||
|
|
||||||
targetsInner += `<div class="dashboard-subsection">
|
targetsInner += `<div class="dashboard-subsection">
|
||||||
${_sectionHeader('stopped', t('dashboard.section.stopped'), stopped.length)}
|
${_sectionHeader('stopped', t('dashboard.section.stopped'), stopped.length)}
|
||||||
@@ -421,7 +425,7 @@ export async function loadDashboard(forceFullRender = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDashboardTarget(target, isRunning, devicesMap = {}) {
|
function renderDashboardTarget(target, isRunning, devicesMap = {}, cssSourceMap = {}) {
|
||||||
const state = target.state || {};
|
const state = target.state || {};
|
||||||
const metrics = target.metrics || {};
|
const metrics = target.metrics || {};
|
||||||
const isLed = target.target_type === 'led' || target.target_type === 'wled';
|
const isLed = target.target_type === 'led' || target.target_type === 'wled';
|
||||||
@@ -434,6 +438,10 @@ function renderDashboardTarget(target, isRunning, devicesMap = {}) {
|
|||||||
if (device) {
|
if (device) {
|
||||||
subtitleParts.push((device.device_type || '').toUpperCase());
|
subtitleParts.push((device.device_type || '').toUpperCase());
|
||||||
}
|
}
|
||||||
|
const cssSource = target.color_strip_source_id ? cssSourceMap[target.color_strip_source_id] : null;
|
||||||
|
if (cssSource) {
|
||||||
|
subtitleParts.push(t(`color_strip.type.${cssSource.source_type}`) || cssSource.source_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
|
|||||||
Reference in New Issue
Block a user