readd hdd and ssd support (#229)

* re add hdd and ssd support

* fixes

---------

Co-authored-by: Meliox <na>
This commit is contained in:
Meliox 2026-07-05 18:03:53 +02:00 committed by GitHub
parent 679d844e14
commit ac007f5f38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -572,6 +572,84 @@ Ext.define('PVE.node.StatusView', {
: '';
},
},
{
itemId: 'thermalHdd',
colspan: 2,
printBar: false,
title: gettext('HDD/SSD Temperatures'),
iconCls: 'fa fa-fw fa-thermometer-half',
textField: 'PveMod_JsonSensorInfo',
renderer: function(value) {
// sensors configuration
const addressPrefix = "drivetemp-scsi-";
const sensorName = "temp1";
const tempHelper = Ext.create('PVE.mod.TempHelper', {srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: PVE.mod.TempHelper.CELSIUS});
// ---
let objValue;
try {
const parsed = value || {};
if (parsed.disabled === true) {
this.hide();
return '';
} else if (parsed.hdd !== true) {
this.hide();
return '';
}
objValue = (parsed.data && parsed.data[Object.keys(parsed.data)[0]]) || {};
} catch(e) {
objValue = {};
}
const drvKeys = Object.keys(objValue).filter(item => String(item).startsWith(addressPrefix)).sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }));
let drvData = [];
drvKeys.forEach((drvKey) => {
try {
const drv = objValue[drvKey];
let tempVal = NaN, tempMax = NaN, tempCrit = NaN;
Object.keys(drv[sensorName]).forEach((secondLevelKey) => {
if (secondLevelKey.endsWith('_input')) {
tempVal = tempHelper.getTemp(parseFloat(drv[sensorName][secondLevelKey]));
} else if (secondLevelKey.endsWith('_max')) {
tempMax = tempHelper.getTemp(parseFloat(drv[sensorName][secondLevelKey]));
} else if (secondLevelKey.endsWith('_crit')) {
tempCrit = tempHelper.getTemp(parseFloat(drv[sensorName][secondLevelKey]));
}
});
if (!isNaN(tempVal)) {
let tempStyle = '';
if (!isNaN(tempMax) && tempVal >= tempMax) {
tempStyle = 'color: #FFC300; font-weight: bold;';
}
if (!isNaN(tempCrit) && tempVal >= tempCrit) {
tempStyle = 'color: red; font-weight: bold;';
}
drvData.push({
model: drv['model'] || 'Unknown',
serial: drv['serial'] || '',
temp: tempVal,
tempStyle: tempStyle,
unit: tempHelper.getUnit()
});
}
} catch(e) { /*_*/ }
});
if (drvData.length === 0) {
return 'N/A';
}
let html = '<table style="width: 100%; border-collapse: collapse; table-layout: fixed;">';
drvData.forEach((data) => {
let deviceName = data.model;
deviceName += `&nbsp;(${data.serial})`;
html += '<tr>';
html += `<td style="padding: 2px 10px 2px 0; text-align: left; width: 30%; vertical-align: top; overflow-wrap: anywhere; word-break: break-word;">${deviceName}</td>`;
html += `<td style="padding: 2px 0 2px 10px; text-align: right; width: 70%; vertical-align: top; overflow-wrap: anywhere; word-break: break-word; white-space: normal;"><span style="${data.tempStyle}">${Ext.util.Format.number(data.temp, '0.0')}${data.unit}</span></td>`;
html += '</tr>';
});
html += '</table>';
return '<div style="padding-left: 20px; box-sizing: border-box;">' + html + '</div>';
}
},
{
itemId: 'thermalNvme',
colspan: 2,