diff --git a/MerlinAU.asp b/MerlinAU.asp index 893c27b2..cbdb051e 100644 --- a/MerlinAU.asp +++ b/MerlinAU.asp @@ -2019,221 +2019,170 @@ function initial() /**----------------------------------------**/ /** Modified by Martinski W. [2025-Mar-07] **/ /**----------------------------------------**/ -function SaveActionsConfig() -{ - // Clear amng_custom for any existing content before saving +function SaveCombinedConfig() { + // Clear the hidden field before saving document.getElementById('amng_custom').value = ''; - // Collect Action form-specific settings // + /*============================== + ACTIONS CONFIG SECTION + ==============================*/ var passwordElem = document.getElementById('routerPassword'); var usernameElem = document.getElementById('http_username'); var usernameStr = usernameElem ? usernameElem.value.trim() : 'admin'; - // Validate that Username is not empty // - if (usernameStr === null || usernameStr.length === 0) - { + // Validate that Username is not empty + if (usernameStr === null || usernameStr.length === 0) { console.error("HTTP Username is missing."); alert("HTTP Username is not set. Please contact your administrator."); return false; } - if (!ValidatePasswordString (passwordElem, 'onSAVE')) - { + if (!ValidatePasswordString(passwordElem, 'onSAVE')) { alert(`${validationErrorMsg}\n\n` + loginPassword.ErrorMsg()); return false; } - if (!ValidatePostponedDays (document.form.fwUpdatePostponement)) - { + if (!ValidatePostponedDays(document.form.fwUpdatePostponement)) { alert(`${validationErrorMsg}\n\n` + fwPostponedDays.ErrorMsg()); return false; } if (document.form.fwScheduleHOUR.disabled === false && - !ValidateFWUpdateTime (document.form.fwScheduleHOUR, 'HOUR')) - { + !ValidateFWUpdateTime(document.form.fwScheduleHOUR, 'HOUR')) { alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('HOUR')); return false; } if (document.form.fwScheduleMINS.disabled === false && - !ValidateFWUpdateTime (document.form.fwScheduleMINS, 'MINS')) - { + !ValidateFWUpdateTime(document.form.fwScheduleMINS, 'MINS')) { alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('MINS')); return false; } if (document.getElementById('fwSchedBoxDAYSX').checked && - !ValidateFWUpdateXDays (document.form.fwScheduleXDAYS, 'DAYS')) - { + !ValidateFWUpdateXDays(document.form.fwScheduleXDAYS, 'DAYS')) { alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('DAYS')); return false; } + + // Process FW update cron schedule conversion let fwUpdateRawCronSchedule = custom_settings.FW_New_Update_Cron_Job_Schedule; - fwUpdateRawCronSchedule = FWConvertWebUISettingsToCronSchedule (fwUpdateRawCronSchedule); + fwUpdateRawCronSchedule = FWConvertWebUISettingsToCronSchedule(fwUpdateRawCronSchedule); - // Encode credentials in Base64 // + // Encode credentials in Base64 var credentials = usernameStr + ':' + passwordElem.value; var encodedCredentials = btoa(credentials); - // Collect only Action form-specific settings // - var action_settings = - { + // Build the Actions settings object + var action_settings = { credentials_base64: encodedCredentials, FW_New_Update_Cron_Job_Schedule: fwUpdateRawCronSchedule, FW_New_Update_Postponement_Days: document.getElementById('fwUpdatePostponement')?.value || '0', CheckChangeLog: document.getElementById('changelogCheckEnabled').checked ? 'ENABLED' : 'DISABLED', FW_Update_Check: document.getElementById('FW_AutoUpdate_Check').checked ? 'ENABLED' : 'DISABLED' }; - // Prefix only Action settings // - var prefixedActionSettings = PrefixCustomSettings(action_settings, 'MerlinAU_'); - - // ***** FIX BUG WHERE MerlinAU_FW_Auto_Backupmon is saved from the wrong button ***** - // ***** Only when the Advanced Options section is saved first, and then Actions Section is saved second ***** - var ADVANCED_KEYS = [ - "MerlinAU_FW_Auto_Backupmon", - "MerlinAU_FW_Allow_Beta_Production_Up", - "MerlinAU_FW_New_Update_ZIP_Directory_Path", - "MerlinAU_FW_New_Update_LOG_Directory_Path", - "MerlinAU_FW_New_Update_EMail_Notification", - "MerlinAU_FW_New_Update_EMail_FormatType", - "MerlinAU_FW_New_Update_EMail_CC_Address", - "MerlinAU_Allow_Updates_OverVPN", - "MerlinAU_Allow_Script_Auto_Update", - "MerlinAU_ROGBuild", - "MerlinAU_TUFBuild" - ]; - ADVANCED_KEYS.forEach(function (key){ - if (shared_custom_settings.hasOwnProperty(key)) - { delete shared_custom_settings[key]; } - }); - - // Merge Server Custom Settings and prefixed Action form settings // - var updatedSettings = Object.assign({}, shared_custom_settings, prefixedActionSettings); - ConsoleLogDEBUG("Actions Config Form submitted with settings:", updatedSettings); - - // Save merged settings to the hidden input field // - document.getElementById('amng_custom').value = JSON.stringify(updatedSettings); - let actionScriptValue; - if (!document.getElementById('RunLoginTestOnSave').checked) - { actionScriptValue = 'start_MerlinAUconfig'; } - else - { actionScriptValue = 'start_MerlinAUconfig_runLoginTest'; } - - // Apply the settings // - document.form.action_script.value = actionScriptValue; - document.form.action_wait.value = 10; - showLoading(); - document.form.submit(); - isFormSubmitting = true; -} - -/**----------------------------------------**/ -/** Modified by Martinski W. [2025-Feb-23] **/ -/**----------------------------------------**/ -function SaveAdvancedConfig() -{ - // Clear amng_custom for any existing content before saving // - document.getElementById('amng_custom').value = ''; + // Prefix the Actions settings + var prefixedActionSettings = PrefixCustomSettings(action_settings, 'MerlinAU_'); - // F/W Update Email Notifications - only if NOT disabled // + /*============================== + ADVANCED CONFIG SECTION + ==============================*/ + // Process Email Notification settings (only if enabled) let emailFormat = document.getElementById('emailFormat'); let secondaryEmail = document.getElementById('secondaryEmail'); let emailNotificationsEnabled = document.getElementById('emailNotificationsEnabled'); - // If the box is enabled, we save these fields // - if (emailNotificationsEnabled && !emailNotificationsEnabled.disabled) - { advanced_settings.FW_New_Update_EMail_Notification = emailNotificationsEnabled.checked ? 'ENABLED' : 'DISABLED'; } - - if (emailFormat && !emailFormat.disabled) - { advanced_settings.FW_New_Update_EMail_FormatType = emailFormat.value || 'HTML'; } - - if (secondaryEmail && !secondaryEmail.disabled) - { advanced_settings.FW_New_Update_EMail_CC_Address = secondaryEmail.value || 'TBD'; } + if (emailNotificationsEnabled && !emailNotificationsEnabled.disabled) { + advanced_settings.FW_New_Update_EMail_Notification = emailNotificationsEnabled.checked ? 'ENABLED' : 'DISABLED'; + } + if (emailFormat && !emailFormat.disabled) { + advanced_settings.FW_New_Update_EMail_FormatType = emailFormat.value || 'HTML'; + } + if (secondaryEmail && !secondaryEmail.disabled) { + advanced_settings.FW_New_Update_EMail_CC_Address = secondaryEmail.value || 'TBD'; + } - // F/W Update ZIP Directory (more checks are made in the shell script) // + // Process F/W Update ZIP Directory let fwUpdateZIPdirectory = document.getElementById('fwUpdateZIPDirectory'); - if (fwUpdateZIPdirectory !== null && typeof fwUpdateZIPdirectory !== 'undefined') - { - if (ValidateDirectoryPath (fwUpdateZIPdirectory, 'ZIP')) - { advanced_settings.FW_New_Update_ZIP_Directory_Path = fwUpdateZIPdirectory.value; } - else - { + if (fwUpdateZIPdirectory !== null && typeof fwUpdateZIPdirectory !== 'undefined') { + if (ValidateDirectoryPath(fwUpdateZIPdirectory, 'ZIP')) { + advanced_settings.FW_New_Update_ZIP_Directory_Path = fwUpdateZIPdirectory.value; + } else { alert(`${validationErrorMsg}\n\n` + fwUpdateDirPath.ErrorMsg('ZIP')); return false; } } - // F/W Update LOG Directory (more checks are made in the shell script) // + // Process F/W Update LOG Directory let fwUpdateLOGdirectory = document.getElementById('fwUpdateLOGDirectory'); - if (fwUpdateLOGdirectory !== null && typeof fwUpdateLOGdirectory !== 'undefined') - { - if (ValidateDirectoryPath (fwUpdateLOGdirectory, 'LOG')) - { advanced_settings.FW_New_Update_LOG_Directory_Path = fwUpdateLOGdirectory.value; } - else - { + if (fwUpdateLOGdirectory !== null && typeof fwUpdateLOGdirectory !== 'undefined') { + if (ValidateDirectoryPath(fwUpdateLOGdirectory, 'LOG')) { + advanced_settings.FW_New_Update_LOG_Directory_Path = fwUpdateLOGdirectory.value; + } else { alert(`${validationErrorMsg}\n\n` + fwUpdateDirPath.ErrorMsg('LOG')); return false; } } - // Tailscale/ZeroTier VPN Access - only if not disabled // + // Process Tailscale/ZeroTier VPN Access let tailscaleVPNEnabled = document.getElementById('tailscaleVPNEnabled'); - if (tailscaleVPNEnabled && !tailscaleVPNEnabled.disabled) - { advanced_settings.Allow_Updates_OverVPN = tailscaleVPNEnabled.checked ? 'ENABLED' : 'DISABLED'; } + if (tailscaleVPNEnabled && !tailscaleVPNEnabled.disabled) { + advanced_settings.Allow_Updates_OverVPN = tailscaleVPNEnabled.checked ? 'ENABLED' : 'DISABLED'; + } - // Automatic Updates for Script - only if not disabled // + // Process Automatic Script Updates let script_AutoUpdate_Check = document.getElementById('Script_AutoUpdate_Check'); - if (script_AutoUpdate_Check && !script_AutoUpdate_Check.disabled) - { advanced_settings.Allow_Script_Auto_Update = script_AutoUpdate_Check.checked ? 'ENABLED' : 'DISABLED'; } + if (script_AutoUpdate_Check && !script_AutoUpdate_Check.disabled) { + advanced_settings.Allow_Script_Auto_Update = script_AutoUpdate_Check.checked ? 'ENABLED' : 'DISABLED'; + } - // Beta-to-Release Updates - only if not disabled // + // Process Beta-to-Release Updates let betaToReleaseUpdatesEnabled = document.getElementById('betaToReleaseUpdatesEnabled'); - if (betaToReleaseUpdatesEnabled && !betaToReleaseUpdatesEnabled.disabled) - { advanced_settings.FW_Allow_Beta_Production_Up = betaToReleaseUpdatesEnabled.checked ? 'ENABLED' : 'DISABLED'; } + if (betaToReleaseUpdatesEnabled && !betaToReleaseUpdatesEnabled.disabled) { + advanced_settings.FW_Allow_Beta_Production_Up = betaToReleaseUpdatesEnabled.checked ? 'ENABLED' : 'DISABLED'; + } - // Automatic Backups - only if not disabled // + // Process Automatic Backups let autobackupEnabled = document.getElementById('autobackupEnabled'); - if (autobackupEnabled && !autobackupEnabled.disabled) - { advanced_settings.FW_Auto_Backupmon = autobackupEnabled.checked ? 'ENABLED' : 'DISABLED'; } + if (autobackupEnabled && !autobackupEnabled.disabled) { + advanced_settings.FW_Auto_Backupmon = autobackupEnabled.checked ? 'ENABLED' : 'DISABLED'; + } - // ROG/TUF F/W Build Type - handle conditional rows if visible // + // Process ROG/TUF F/W Build Types (if the rows are visible) let rogFWBuildRow = document.getElementById('rogFWBuildRow'); let rogFWBuildType = document.getElementById('rogFWBuildType'); - if (rogFWBuildRow && rogFWBuildRow.style.display !== 'none' && rogFWBuildType) - { advanced_settings.ROGBuild = (rogFWBuildType.value === 'ROG') ? 'ENABLED' : 'DISABLED'; } - + if (rogFWBuildRow && rogFWBuildRow.style.display !== 'none' && rogFWBuildType) { + advanced_settings.ROGBuild = (rogFWBuildType.value === 'ROG') ? 'ENABLED' : 'DISABLED'; + } let tufFWBuildRow = document.getElementById('tuffFWBuildRow'); let tuffFWBuildType = document.getElementById('tuffFWBuildType'); - if (tufFWBuildRow && tufFWBuildRow.style.display !== 'none' && tuffFWBuildType) - { advanced_settings.TUFBuild = (tuffFWBuildType.value === 'TUF') ? 'ENABLED' : 'DISABLED'; } + if (tufFWBuildRow && tufFWBuildRow.style.display !== 'none' && tuffFWBuildType) { + advanced_settings.TUFBuild = (tuffFWBuildType.value === 'TUF') ? 'ENABLED' : 'DISABLED'; + } - // Prefix only Advanced settings // + // Prefix the Advanced settings var prefixedAdvancedSettings = PrefixCustomSettings(advanced_settings, 'MerlinAU_'); - // Remove any action keys from shared_custom_settings to avoid overwriting // - var ACTION_KEYS = [ - "MerlinAU_credentials_base64", - "MerlinAU_FW_New_Update_Postponement_Days", - "MerlinAU_CheckChangeLog", - "MerlinAU_FW_Update_Check", - "FW_New_Update_Cron_Job_Schedule" - ]; - ACTION_KEYS.forEach(function (key){ - if (shared_custom_settings.hasOwnProperty(key)) - { delete shared_custom_settings[key]; } - }); - - // Merge Server Custom Settings and prefixed Advanced settings - var updatedSettings = Object.assign({}, shared_custom_settings, prefixedAdvancedSettings); - ConsoleLogDEBUG("Advanced Config Form submitted with settings:", updatedSettings); + /*============================== + MERGE SETTINGS & SUBMIT FORM + ==============================*/ + // Merge shared settings with both prefixed Action and Advanced settings + var updatedSettings = Object.assign({}, shared_custom_settings, prefixedActionSettings, prefixedAdvancedSettings); + ConsoleLogDEBUG("Combined Config Form submitted with settings:", updatedSettings); - // Save merged settings to the hidden input field // + // Save merged settings to the hidden input field document.getElementById('amng_custom').value = JSON.stringify(updatedSettings); - // Apply the settings // - document.form.action_script.value = 'start_MerlinAUconfig'; + // Determine action script based on the RunLoginTestOnSave checkbox + let actionScriptValue; + if (!document.getElementById('RunLoginTestOnSave').checked) { + actionScriptValue = 'start_MerlinAUconfig'; + } else { + actionScriptValue = 'start_MerlinAUconfig_runLoginTest'; + } + document.form.action_script.value = actionScriptValue; document.form.action_wait.value = 10; + showLoading(); document.form.submit(); isFormSubmitting = true; - setTimeout(GetExternalCheckResults,4000); + setTimeout(GetExternalCheckResults, 4000); } /**----------------------------------------**/ @@ -2503,7 +2452,7 @@ function initializeCollapsibleSections()
MerlinAU
This is the MerlinAU add-on integrated into the router WebUI -[ +[ Wiki ] @@ -2648,185 +2597,172 @@ function initializeCollapsibleSections() Keep configuration file
- - - -
-
- +
+ +
 
+ + + + + + + + + + + +
+ + + + + + + +
+ +
+ Hour: + +
+
+ Minutes: + +
+ - -
Configuration (click to expand/collapse)
+ + - - - + + + - - + + - - + + - - + + - - + + - + - - + - -
- -
- -
-
-
- -
-
-
- -
-
+ +
+ +
+
+
+ +
+
+
+
+ +
+
- - - + + +
- - - - + + + +
- - - - + + + +
- - -
- Days: - - - +
+ + +
+ Days: + + + -
- - - - - - - -
-
-
- Hour: - -
-
- Minutes: - -
-
-
- -
- -
- -
 
- - - - - - - - -
Advanced Options (click to expand/collapse)
-
- -- - -