mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 03:33:53 +00:00
fix: merge temperature data from WebSocket state into Settings node list
- Settings page now merges live temperature data from WebSocket state - Temperature badge will now appear when SSH monitoring is active - Fix missing onMount import in GuestRow.tsx The Settings page loads node config from /api/config/nodes which doesn't include runtime temperature data. This change merges temperature from the WebSocket state (which has live monitoring data) so the temperature badge displays correctly.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Show, createMemo, createSignal, createEffect } from 'solid-js';
|
||||
import { Show, createMemo, createSignal, createEffect, onMount } from 'solid-js';
|
||||
import type { VM, Container } from '@/types/api';
|
||||
import { formatBytes, formatUptime } from '@/utils/format';
|
||||
import { MetricBar } from './MetricBar';
|
||||
|
||||
@@ -258,14 +258,24 @@ const Settings: Component = () => {
|
||||
const loadNodes = async () => {
|
||||
try {
|
||||
const nodesList = await NodesAPI.getNodes();
|
||||
// Add status and other UI fields
|
||||
const nodesWithStatus = nodesList.map((node) => ({
|
||||
...node,
|
||||
// Use the hasPassword/hasToken from the API if available, otherwise check local fields
|
||||
hasPassword: node.hasPassword ?? !!node.password,
|
||||
hasToken: node.hasToken ?? !!node.tokenValue,
|
||||
status: node.status || ('pending' as const),
|
||||
}));
|
||||
// Merge temperature data from WebSocket state
|
||||
const currentState = state();
|
||||
const nodesWithStatus = nodesList.map((node) => {
|
||||
// Find matching node in state to get temperature data
|
||||
const stateNode =
|
||||
currentState?.pveNodes?.find((n) => n.id === node.id || n.name === node.name) ||
|
||||
currentState?.pbsNodes?.find((n) => n.id === node.id || n.name === node.name);
|
||||
|
||||
return {
|
||||
...node,
|
||||
// Use the hasPassword/hasToken from the API if available, otherwise check local fields
|
||||
hasPassword: node.hasPassword ?? !!node.password,
|
||||
hasToken: node.hasToken ?? !!node.tokenValue,
|
||||
status: node.status || ('pending' as const),
|
||||
// Merge temperature data from state
|
||||
temperature: stateNode?.temperature || node.temperature,
|
||||
};
|
||||
});
|
||||
setNodes(nodesWithStatus);
|
||||
} catch (error) {
|
||||
console.error('Failed to load nodes:', error);
|
||||
|
||||
Reference in New Issue
Block a user