From 6dcfbfb62489a4ddab4c8931258843ad1f4451ee Mon Sep 17 00:00:00 2001 From: rmm Date: Thu, 25 Apr 2024 19:13:23 +0200 Subject: [PATCH] Add missing JS code escaping for the fan speeds --- pve-mod-gui-temp.sh | 80 ++++++++++++++++++++++----------------------- readme.md | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pve-mod-gui-temp.sh b/pve-mod-gui-temp.sh index 3cdcee7..4597c53 100644 --- a/pve-mod-gui-temp.sh +++ b/pve-mod-gui-temp.sh @@ -163,7 +163,7 @@ function configure { msg "Fan speeds detected:\n$(echo "$sensorsOutput" | grep -o 'fan[0-9]*_input[^"]*')" enableFanSpeed=true else - warn "No Fan speeds found." + warn "No fan speeds found." enableFanSpeed=false fi @@ -373,45 +373,45 @@ function install_mod { /'thermal.*},/!{N;bb;} a\ \\ - { - xtype: 'box', - colspan: 2, - html: gettext('Fan Speed(s)'), - }, - { - itemId: 'speedFan', - colspan: 2, - printBar: false, - title: gettext(' '), - iconCls: 'fa fa-fw fa-solid fa-fan', - textField: 'sensorsOutput', - renderer: function(value){ - const objValue = JSON.parse(value); - - let speeds = []; - - // Loop through the parent keys - Object.keys(objValue).forEach(parentKey => { - const parentObj = objValue[parentKey]; - - // Filter and sort fan keys for each parent object - const fanKeys = Object.keys(parentObj).filter(item => /^fan[0-9]+$/.test(item)).sort(); - - fanKeys.forEach((fanKey) => { - try { - const fanSpeed = parentObj[fanKey][`${fanKey}_input`]; - const fanNumber = fanKey.replace('fan', ''); // Extract fan number from the key - if (fanSpeed !== undefined) { - speeds.push(`Fan ${fanNumber}: ${fanSpeed} RPM`); - } - } catch(e) { - console.error(`Error retrieving fan speed for ${fanKey} in ${parentKey}:`, e); // Debug: Log specific error - } - }); - }); - - return '
' + (speeds.length > 0 ? speeds.join(' | ') : 'N/A') + '
'; - } + {\n\ + xtype: 'box',\n\ + colspan: 2,\n\ + html: gettext('Cooling'),\n\ + },\n\ + {\n\ + itemId: 'speedFan',\n\ + colspan: 2,\n\ + printBar: false,\n\ + title: gettext('Fan Speed(s)'),\n\ + iconCls: 'fa fa-fw fa-snowflake-o',\n\ + textField: 'sensorsOutput',\n\ + renderer: function(value) {\n\ + const objValue = JSON.parse(value);\n\ +\n\ + let speeds = [];\n\ +\n\ + // Loop through the parent keys\n\ + Object.keys(objValue).forEach(parentKey => {\n\ + const parentObj = objValue[parentKey];\n\ +\n\ + // Filter and sort fan keys for each parent object\n\ + const fanKeys = Object.keys(parentObj).filter(item => /^fan[0-9]+$/.test(item)).sort();\n\ +\n\ + fanKeys.forEach((fanKey) => {\n\ + try {\n\ + const fanSpeed = parentObj[fanKey][\`\${fanKey}_input\`];\n\ + const fanNumber = fanKey.replace('fan', ''); // Extract fan number from the key\n\ + if (fanSpeed !== undefined) {\n\ + speeds.push(\`Fan \${fanNumber}: \${fanSpeed} RPM\`);\n\ + }\n\ + } catch(e) {\n\ + console.error(\`Error retrieving fan speed for \${fanKey} in \${parentKey}:\`, e); // Debug: Log specific error\n\ + }\n\ + });\n\ + });\n\ +\n\ + return '
' + (speeds.length > 0 ? speeds.join(' | ') : 'N/A') + '
';\n\ + }\n\ }, }" "$pvemanagerlibjs" fi diff --git a/readme.md b/readme.md index 13f4961..94ce2ac 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ If you find this helpful, a small donation is appreciated, [![Donate](https://ww ## Node temperature view (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: