diff --git a/LibreHardwareMonitor/UI/MainForm.cs b/LibreHardwareMonitor/UI/MainForm.cs index 45bacab..6864bef 100644 --- a/LibreHardwareMonitor/UI/MainForm.cs +++ b/LibreHardwareMonitor/UI/MainForm.cs @@ -244,6 +244,7 @@ public sealed partial class MainForm : Form fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked; Server = new HttpServer(_root, + _computer, _settings.GetValue("listenerIp", "?"), _settings.GetValue("listenerPort", 8085), _settings.GetValue("authenticationEnabled", false), diff --git a/LibreHardwareMonitor/Utilities/HttpServer.cs b/LibreHardwareMonitor/Utilities/HttpServer.cs index a975ffa..91fe5b0 100644 --- a/LibreHardwareMonitor/Utilities/HttpServer.cs +++ b/LibreHardwareMonitor/Utilities/HttpServer.cs @@ -29,11 +29,13 @@ public class HttpServer { private readonly HttpListener _listener; private readonly Node _root; + private readonly IElement _rootElement; private Thread _listenerThread; - public HttpServer(Node node, string ip, int port, bool authEnabled = false, string userName = "", string password = "") + public HttpServer(Node node, IElement rootElement, string ip, int port, bool authEnabled = false, string userName = "", string password = "") { _root = node; + _rootElement = rootElement; ListenerIp = ip; ListenerPort = port; AuthEnabled = authEnabled; @@ -241,6 +243,14 @@ public class HttpServer throw new ArgumentException("Unknown id " + dict["id"] + " specified"); } + if (dict["action"] == "ResetMinMax") + { + // Reset Min/Max, then return Sensor values... + sNode.Sensor.ResetMin(); + sNode.Sensor.ResetMax(); + dict["action"] = "Get"; + } + switch (dict["action"]) { case "Set" when dict.ContainsKey("value"): @@ -387,6 +397,17 @@ public class HttpServer return; } + if (requestedFile.Contains("ResetAllMinMax")) + { + _rootElement.Accept(new SensorVisitor(delegate (ISensor sensor) + { + sensor.ResetMin(); + sensor.ResetMax(); + })); + SendJson(context.Response, request); + return; + } + // default file to be served if (string.IsNullOrEmpty(requestedFile)) requestedFile = "index.html";