Add missing JS code escaping for the fan speeds

This commit is contained in:
rmm 2024-04-25 19:13:23 +02:00
parent bfee536031
commit 6dcfbfb624
2 changed files with 41 additions and 41 deletions

View File

@ -163,7 +163,7 @@ function configure {
msg "Fan speeds detected:\n$(echo "$sensorsOutput" | grep -o 'fan[0-9]*_input[^"]*')" msg "Fan speeds detected:\n$(echo "$sensorsOutput" | grep -o 'fan[0-9]*_input[^"]*')"
enableFanSpeed=true enableFanSpeed=true
else else
warn "No Fan speeds found." warn "No fan speeds found."
enableFanSpeed=false enableFanSpeed=false
fi fi
@ -373,45 +373,45 @@ function install_mod {
/'thermal.*},/!{N;bb;} /'thermal.*},/!{N;bb;}
a\ a\
\\ \\
{ {\n\
xtype: 'box', xtype: 'box',\n\
colspan: 2, colspan: 2,\n\
html: gettext('Fan Speed(s)'), html: gettext('Cooling'),\n\
}, },\n\
{ {\n\
itemId: 'speedFan', itemId: 'speedFan',\n\
colspan: 2, colspan: 2,\n\
printBar: false, printBar: false,\n\
title: gettext(' '), title: gettext('Fan Speed(s)'),\n\
iconCls: 'fa fa-fw fa-solid fa-fan', iconCls: 'fa fa-fw fa-snowflake-o',\n\
textField: 'sensorsOutput', textField: 'sensorsOutput',\n\
renderer: function(value){ renderer: function(value) {\n\
const objValue = JSON.parse(value); const objValue = JSON.parse(value);\n\
\n\
let speeds = []; let speeds = [];\n\
\n\
// Loop through the parent keys // Loop through the parent keys\n\
Object.keys(objValue).forEach(parentKey => { Object.keys(objValue).forEach(parentKey => {\n\
const parentObj = objValue[parentKey]; const parentObj = objValue[parentKey];\n\
\n\
// Filter and sort fan keys for each parent object // Filter and sort fan keys for each parent object\n\
const fanKeys = Object.keys(parentObj).filter(item => /^fan[0-9]+$/.test(item)).sort(); const fanKeys = Object.keys(parentObj).filter(item => /^fan[0-9]+$/.test(item)).sort();\n\
\n\
fanKeys.forEach((fanKey) => { fanKeys.forEach((fanKey) => {\n\
try { try {\n\
const fanSpeed = parentObj[fanKey][`${fanKey}_input`]; const fanSpeed = parentObj[fanKey][\`\${fanKey}_input\`];\n\
const fanNumber = fanKey.replace('fan', ''); // Extract fan number from the key const fanNumber = fanKey.replace('fan', ''); // Extract fan number from the key\n\
if (fanSpeed !== undefined) { if (fanSpeed !== undefined) {\n\
speeds.push(`Fan ${fanNumber}: ${fanSpeed} RPM`); speeds.push(\`Fan \${fanNumber}: \${fanSpeed} RPM\`);\n\
} }\n\
} catch(e) { } catch(e) {\n\
console.error(`Error retrieving fan speed for ${fanKey} in ${parentKey}:`, e); // Debug: Log specific error console.error(\`Error retrieving fan speed for \${fanKey} in \${parentKey}:\`, e); // Debug: Log specific error\n\
} }\n\
}); });\n\
}); });\n\
\n\
return '<div style="text-align: left; margin-left: 28px;">' + (speeds.length > 0 ? speeds.join(' | ') : 'N/A') + '</div>'; return '<div style=\"text-align: left; margin-left: 28px;\">' + (speeds.length > 0 ? speeds.join(' | ') : 'N/A') + '</div>';\n\
} }\n\
}, },
}" "$pvemanagerlibjs" }" "$pvemanagerlibjs"
fi fi

View File

@ -6,7 +6,7 @@ If you find this helpful, a small donation is appreciated, [![Donate](https://ww
## Node temperature view ## Node temperature view
(Tested compatibility: 7.x, 8.0.x, 8.1.x, 8.2.x) (Tested compatibility: 7.x, 8.0.x, 8.1.x, 8.2.x)
This bash script installs a modification to the Proxmox Virtual Environment (PVE) web user interface (UI) to display temperature information in a flexible manner for CPU, NVME and HDDs/SSDs. Fanspeeds are also displayed, if available. This bash script installs a modification to the Proxmox Virtual Environment (PVE) web user interface (UI) to display temperature information in a flexible manner for CPU, NVME and HDDs/SSDs. Fan speeds are also displayed, if available.
The modification includes three main steps: The modification includes three main steps: