diff --git a/src/usr/local/www/widgets/javascript/thermal_sensors.js b/src/usr/local/www/widgets/javascript/thermal_sensors.js
index 5193c9c0ed9..7eaee679295 100644
--- a/src/usr/local/www/widgets/javascript/thermal_sensors.js
+++ b/src/usr/local/www/widgets/javascript/thermal_sensors.js
@@ -18,8 +18,9 @@
* limitations under the License.
*/
-warningTemp = 9999;
-criticalTemp = 100;
+var warningTemp = 9999;
+var criticalTemp = 100;
+var widgetUnit = 'C';
ajaxBusy = false;
function buildThermalSensorsData(thermalSensorsData, widgetKey, tsParams, firstTime) {
@@ -86,14 +87,19 @@ function buildThermalSensorsDataGraph(thermalSensorsData, tsParams, widgetKey) {
sensorName = getSensorFriendlyName(sensorName);
}
+ if (tsParams.showFahrenheit) {
+ widgetUnit = 'F';
+ thermalSensorValue = getFahrenheitValue(thermalSensorValue);
+ }
+
//build temperature item/row for a sensor
var thermalSensorRow = '
@@ -354,16 +356,16 @@
if (!in_array('temperature', $skipsysinfoitems)):
$rows_displayed = true;
?>
-
+
=gettext("Temperature");?> |
-
+
-
- = $temp_deg_c . "°C"; ?>
+ =$display_temp?>°=$temp_use_f ? 'F' : 'C';?>
|
@@ -608,12 +610,10 @@ function updateCPU(total, used) {
}
function updateTemp(x) {
- if ($("#tempmeter")) {
- $('[id="tempmeter"]').html(x + '°' + 'C');
- }
- if ($('#tempPB')) {
- setProgress('tempPB', parseInt(x));
- }
+ $("#tempmeter").html(function() {
+ return this.dataset.units === "F" ? parseInt(x * 1.8 + 32, 10) : x;
+ });
+ setProgress('tempPB', parseInt(x));
}
function updateDateTime(x) {
diff --git a/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php b/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
index df3ed418c4f..e3b509df948 100644
--- a/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
+++ b/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
@@ -110,6 +110,14 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widget
//=========================================================================
//save widget config settings on POST
if ($_POST['widgetkey']) {
+ if (isset($_POST["thermal_sensors_widget_show_fahrenheit"])) {
+ // convert back to celcius
+ $_POST["thermal_sensors_widget_zone_warning_threshold"] = floor(($_POST["thermal_sensors_widget_zone_warning_threshold"] - 32) / 1.8);
+ $_POST["thermal_sensors_widget_zone_critical_threshold"] = floor(($_POST["thermal_sensors_widget_zone_critical_threshold"] - 32) / 1.8);
+ $_POST["thermal_sensors_widget_core_warning_threshold"] = floor(($_POST["thermal_sensors_widget_core_warning_threshold"] - 32) / 1.8);
+ $_POST["thermal_sensors_widget_core_critical_threshold"] = floor(($_POST["thermal_sensors_widget_core_critical_threshold"] - 32) / 1.8);
+ }
+
set_customwidgettitle($user_settings);
saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_zone_warning_threshold", "thermal_sensors_widget_zone_critical_threshold");
saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_core_warning_threshold", "thermal_sensors_widget_core_critical_threshold");
@@ -119,6 +127,7 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widget
saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_show_full_sensor_name");
saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_pulsate_warning");
saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_pulsate_critical");
+ saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_show_fahrenheit");
//write settings to config file
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved thermal_sensors_widget settings via Dashboard."));
@@ -139,6 +148,7 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widget
$thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_full_sensor_name", false, $widgetkey);
$thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_warning", true, $widgetkey);
$thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_critical", true, $widgetkey);
+$thermal_sensors_widget_showFahrenheit = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_fahrenheit", false, $widgetkey);
//=========================================================================
?>
@@ -156,40 +166,67 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widget
showRawOutput:= $thermal_sensors_widget_showRawOutput ? "true" : "false"; ?>,
showFullSensorName:= $thermal_sensors_widget_showFullSensorName ? "true" : "false"; ?>,
pulsateWarning:= $thermal_sensors_widget_pulsateWarning ? "true" : "false"; ?>,
- pulsateCritical:= $thermal_sensors_widget_pulsateCritical ? "true" : "false"; ?>
+ pulsateCritical:= $thermal_sensors_widget_pulsateCritical ? "true" : "false"; ?>,
+ showFahrenheit:= $thermal_sensors_widget_showFahrenheit ? "true" : "false"; ?>
+
};
- // --------------------- Centralized widget refresh system ------------------------------
-
- // Callback function called by refresh system when data is retrieved
- function ts_callback(s) {
+ $("#thermal_sensors_widget_show_fahrenheit").on("change", function(e) {
+ if (this.checked) {
+ $(".thermal_sensors_widget_unit").html('=gettext("°F")?>');
+ $(".thermal_sensors_widget_range").html('=gettext("(1–212)")?>');
+ $("#thermal_sensors_widget_zone_warning_threshold").val(function(){return getFahrenheitValue(this.value);});
+ $("#thermal_sensors_widget_zone_critical_threshold").val(function(){return getFahrenheitValue(this.value);});
+ $("#thermal_sensors_widget_core_warning_threshold").val(function(){return getFahrenheitValue(this.value);});
+ $("#thermal_sensors_widget_core_critical_threshold").val(function(){return getFahrenheitValue(this.value);});
+ } else {
+ $(".thermal_sensors_widget_unit").html('=gettext("°C")?>');
+ $(".thermal_sensors_widget_range").html('=gettext("(1–100)")?>');
+ $("#thermal_sensors_widget_zone_warning_threshold").val(function(){return getCelsiusValue(this.value);});
+ $("#thermal_sensors_widget_zone_critical_threshold").val(function(){return getCelsiusValue(this.value);});
+ $("#thermal_sensors_widget_core_warning_threshold").val(function(){return getCelsiusValue(this.value);});
+ $("#thermal_sensors_widget_core_critical_threshold").val(function(){return getCelsiusValue(this.value);});
+ }
+ });
+ // --------------------- Centralized widget refresh system ------------------------------
+
+ // Callback function called by refresh system when data is retrieved
+ function ts_callback(s) {
var thermalSensorsData = s || "";
buildThermalSensorsData(thermalSensorsData, "=htmlspecialchars($widgetkey)?>", tsParams, true);
firstTime = false;
- }
-
- // POST data to send via AJAX
- var postdata = {
- ajax: "ajax",
- getThermalSensorsData : "1"
- };
+ }
- // Create an object defining the widget refresh AJAX call
- var tsObject = new Object();
- tsObject.name = "Gateways";
- tsObject.url = "/widgets/widgets/thermal_sensors.widget.php";
- tsObject.callback = ts_callback;
- tsObject.parms = postdata;
- tsObject.freq = 1;
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax",
+ getThermalSensorsData : "1"
+ };
- // Register the AJAX object
- register_ajax(tsObject);
+ // Create an object defining the widget refresh AJAX call
+ var tsObject = new Object();
+ tsObject.name = "thermal-sensors";
+ tsObject.url = "/widgets/widgets/thermal_sensors.widget.php";
+ tsObject.callback = ts_callback;
+ tsObject.parms = postdata;
+ tsObject.freq = 5;
- // ---------------------------------------------------------------------------------------------------
+ // Register the AJAX object
+ register_ajax(tsObject);
+ // ---------------------------------------------------------------------------------------------------
});
//]]>
+