From ba00fe3efc420108a7eacd744ddd9075c2e97a52 Mon Sep 17 00:00:00 2001
From: unknown
Date: Thu, 5 Dec 2024 19:04:09 +0200
Subject: [PATCH] GrblHal Build date on Troubleshooting tab, and Restore
AutoBackups
---
app/js/grbl-settings.js | 45 ++++++++++++++++++++++++++++++++++++-----
app/js/websocket.js | 8 +++++---
index.js | 15 ++++++++++----
3 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/app/js/grbl-settings.js b/app/js/grbl-settings.js
index 1ba01702..e43a40f9 100644
--- a/app/js/grbl-settings.js
+++ b/app/js/grbl-settings.js
@@ -36,6 +36,7 @@ function loadGrblBackupFile(f) {
checkifchanged();
enableLimits(); // Enable or Disable
displayDirInvert();
+ $("#grblSettingsAdvTab").click();
}
}
}
@@ -78,6 +79,40 @@ function restoreAutoBackup(index) {
console.log('Restoring backup:', selectedBackup);
// Call your function to restore the backup here, e.g., update grblParams
// Example: grblParams = selectedBackup.grblParams;
+
+ // Retrieve grblParams from the backup
+ const grblParamsBackup = selectedBackup.grblParams;
+
+ // Iterate through the keys in the grblParams object and apply them using jQuery
+ for (const key in grblParamsBackup) {
+ if (grblParamsBackup.hasOwnProperty(key)) {
+ const paramValue = grblParamsBackup[key];
+ const parsedValue = parseFloat(paramValue);
+
+ // Check if the parsed value is a valid number
+ if (!isNaN(parsedValue)) {
+ // Update the input field based on the parameter using jQuery
+ const inputElement = $("#val-" + key.substring(1) + "-input");
+
+ if (inputElement.length) {
+ inputElement.val(parsedValue); // Apply the value to the input field
+ }
+ } else {
+ console.warn(`Invalid value for ${key}: ${paramValue}`);
+ }
+
+ // Optionally, fix or apply any GrblHAL-specific settings
+ fixGrblHALSettings(key.substring(1)); // Adjust as needed
+
+ // Optionally, other functions you might call for updating the machine state
+ // Example: checkifchanged(); enableLimits(); displayDirInvert();
+ }
+ }
+ // Call any post-restoration functions you need (e.g., re-enable limits, etc.)
+ checkifchanged();
+ enableLimits();
+ displayDirInvert();
+ $("#grblSettingsAdvTab").click();
}
@@ -189,8 +224,8 @@ function grblPopulate() {