Skip to content

Commit e726fc0

Browse files
Merge pull request #397 from Martinski4GitHub/WebFun
Fixes to handle AMTM Email Config File NOT found
2 parents 0562391 + 6393718 commit e726fc0

File tree

2 files changed

+141
-100
lines changed

2 files changed

+141
-100
lines changed

MerlinAU.asp

Lines changed: 102 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<script language="JavaScript" type="text/javascript">
3030
3131
/**----------------------------**/
32-
/** Last Modified: 2025-Jan-26 **/
32+
/** Last Modified: 2025-Jan-27 **/
3333
/** Intended for 1.4.0 Release **/
3434
/**----------------------------**/
3535
@@ -56,6 +56,16 @@ const InvYLWct = '<span style="margin-left:4px; background-color:yellow; color:b
5656
const InvCYNct = '<span style="margin-left:4px; background-color:cyan; color:black;">&nbsp;'
5757
const InvCLEAR = '&nbsp;</span>'
5858
59+
/**----------------------------------------**/
60+
/** Modified by Martinski W. [2025-Jan-27] **/
61+
/**----------------------------------------**/
62+
var externalCheckID = 0x00;
63+
var externalCheckOK = true;
64+
var externalCheckMsg = '';
65+
var isEMailConfigEnabledInAMTM = false;
66+
var scriptAutoUpdateCronSchedHR = 'TBD';
67+
var fwAutoUpdateCheckCronSchedHR = 'TBD';
68+
5969
/**-------------------------------------**/
6070
/** Added by Martinski W. [2025-Jan-13] **/
6171
/**-------------------------------------**/
@@ -737,21 +747,8 @@ function ValidateDirectoryPath (formField)
737747
}
738748
}
739749
740-
/**-------------------------------------**/
741-
/** Added by Martinski W. [2025-Jan-16] **/
742-
/**-------------------------------------**/
743-
var externalCheckID = 0x00;
744-
var externalCheckOK = true;
745-
var externalCheckMsg = '';
746-
747-
/**-------------------------------------**/
748-
/** Added by Martinski W. [2025-Jan-20] **/
749-
/**-------------------------------------**/
750-
var scriptAutoUpdateCronSchedHR = 'TBD';
751-
var fwAutoUpdateCheckCronSchedHR = 'TBD';
752-
753750
/**----------------------------------------**/
754-
/** Modified by Martinski W. [2025-Jan-20] **/
751+
/** Modified by Martinski W. [2025-Jan-27] **/
755752
/**----------------------------------------**/
756753
function GetExternalCheckResults()
757754
{
@@ -766,6 +763,7 @@ function GetExternalCheckResults()
766763
{
767764
document.getElementById('Script_AutoUpdate_SchedText').textContent = 'Schedule: '+scriptAutoUpdateCronSchedHR;
768765
document.getElementById('FW_AutoUpdate_CheckSchedText').textContent = 'Schedule: '+fwAutoUpdateCheckCronSchedHR;
766+
SetUpEmailNotificationFields();
769767
770768
// Skip during form submission //
771769
if (isFormSubmitting) { return true ; }
@@ -989,8 +987,62 @@ function handleROGFWBuildTypeVisibility()
989987
}
990988
}
991989
990+
/**-------------------------------------**/
991+
/** Added by Martinski W. [2025-Jan-27] **/
992+
/**-------------------------------------**/
993+
function ToggleEmailDependents (isEmailNotifyChecked)
994+
{
995+
let emailFormat = document.getElementById('emailFormat');
996+
let secondaryEmail = document.getElementById('secondaryEmail');
997+
998+
if (isEmailNotifyChecked)
999+
{
1000+
emailFormat.disabled = false;
1001+
secondaryEmail.disabled = false;
1002+
SetStatus ('emailNotificationsStatus', 'ENABLED');
1003+
}
1004+
else
1005+
{
1006+
emailFormat.disabled = true;
1007+
secondaryEmail.disabled = true;
1008+
SetStatus ('emailNotificationsStatus', 'DISABLED');
1009+
}
1010+
}
1011+
1012+
/**-------------------------------------**/
1013+
/** Added by Martinski W. [2025-Jan-27] **/
1014+
/**-------------------------------------**/
1015+
function SetUpEmailNotificationFields()
1016+
{
1017+
let emailFormat = document.getElementById('emailFormat');
1018+
let secondaryEmail = document.getElementById('secondaryEmail');
1019+
let emailNotificationsEnabled = document.getElementById('emailNotificationsEnabled');
1020+
1021+
if (emailFormat)
1022+
{ emailFormat.value = custom_settings.FW_New_Update_EMail_FormatType || 'HTML'; }
1023+
if (secondaryEmail)
1024+
{ secondaryEmail.value = custom_settings.FW_New_Update_EMail_CC_Address || 'TBD'; }
1025+
1026+
if (emailNotificationsEnabled && emailFormat && secondaryEmail)
1027+
{
1028+
if (isEMailConfigEnabledInAMTM &&
1029+
custom_settings.hasOwnProperty('FW_New_Update_EMail_Notification'))
1030+
{
1031+
emailNotificationsEnabled.disabled = false;
1032+
emailNotificationsEnabled.checked = (custom_settings.FW_New_Update_EMail_Notification === 'ENABLED');
1033+
ToggleEmailDependents (emailNotificationsEnabled.checked);
1034+
}
1035+
else
1036+
{
1037+
emailNotificationsEnabled.disabled = true;
1038+
emailNotificationsEnabled.checked = false;
1039+
ToggleEmailDependents (false);
1040+
}
1041+
}
1042+
}
1043+
9921044
/**----------------------------------------**/
993-
/** Modified by Martinski W. [2025-Jan-26] **/
1045+
/** Modified by Martinski W. [2025-Jan-27] **/
9941046
/**----------------------------------------**/
9951047
function InitializeFields()
9961048
{
@@ -999,10 +1051,7 @@ function InitializeFields()
9991051
let fwNotificationsDate = document.getElementById('fwNotificationsDate');
10001052
let routerPassword = document.getElementById('routerPassword');
10011053
let fwUpdatePostponement = document.getElementById('fwUpdatePostponement');
1002-
let emailNotificationsEnabled = document.getElementById('emailNotificationsEnabled');
10031054
let autobackupEnabled = document.getElementById('autobackupEnabled');
1004-
let secondaryEmail = document.getElementById('secondaryEmail');
1005-
let emailFormat = document.getElementById('emailFormat');
10061055
let rogFWBuildType = document.getElementById('rogFWBuildType');
10071056
let tuffFWBuildType = document.getElementById('tuffFWBuildType');
10081057
let tailscaleVPNEnabled = document.getElementById('tailscaleVPNEnabled');
@@ -1026,8 +1075,8 @@ function InitializeFields()
10261075
10271076
// Update the Firmware Status display //
10281077
if (fwUpdateCheckStatus)
1029-
{ // Pass the raw string ('ENABLED', 'DISABLED', or 'TBD') to our setStatus function
1030-
setStatus('fwUpdateCheckStatus', storedFwUpdateEnabled);
1078+
{ // Pass the raw string ('ENABLED', 'DISABLED', or 'TBD') //
1079+
SetStatus('fwUpdateCheckStatus', storedFwUpdateEnabled);
10311080
}
10321081
10331082
// Safe value assignments //
@@ -1046,11 +1095,7 @@ function InitializeFields()
10461095
let fwUpdateRawCronSchedule = custom_settings.FW_New_Update_Cron_Job_Schedule || 'TBD';
10471096
FWConvertCronScheduleToWebUISettings (fwUpdateRawCronSchedule);
10481097
1049-
if (secondaryEmail)
1050-
{ secondaryEmail.value = custom_settings.FW_New_Update_EMail_CC_Address || ''; }
1051-
1052-
if (emailFormat)
1053-
{ emailFormat.value = custom_settings.FW_New_Update_EMail_FormatType || 'HTML'; }
1098+
SetUpEmailNotificationFields();
10541099
10551100
if (rogFWBuildType)
10561101
{ rogFWBuildType.value = custom_settings.FW_New_Update_ROGFWBuildType || 'ROG'; }
@@ -1078,32 +1123,7 @@ function InitializeFields()
10781123
autobackupEnabled.style.opacity = '0.5'; // Grayed out appearance
10791124
}
10801125
}
1081-
if (emailNotificationsEnabled && emailFormat && secondaryEmail)
1082-
{
1083-
// Check if 'FW_New_Update_EMail_Notification' is present in custom_settings
1084-
if (custom_settings.hasOwnProperty('FW_New_Update_EMail_Notification'))
1085-
{
1086-
// If the setting exists, enable the checkbox and controls
1087-
emailNotificationsEnabled.disabled = false;
1088-
emailNotificationsEnabled.checked = (custom_settings.FW_New_Update_EMail_Notification === 'ENABLED');
1089-
emailNotificationsEnabled.style.opacity = '1';
1090-
emailFormat.disabled = false;
1091-
emailFormat.style.opacity = '1';
1092-
secondaryEmail.disabled = false;
1093-
secondaryEmail.style.opacity = '1';
1094-
}
1095-
else
1096-
{
1097-
// If the setting is missing, disable and gray out the checkbox, dropdown, and email input
1098-
emailNotificationsEnabled.disabled = true;
1099-
emailNotificationsEnabled.checked = false;
1100-
emailNotificationsEnabled.style.opacity = '0.5';
1101-
emailFormat.disabled = true;
1102-
emailFormat.style.opacity = '0.5';
1103-
secondaryEmail.disabled = true;
1104-
secondaryEmail.style.opacity = '0.5';
1105-
}
1106-
}
1126+
11071127
if (tailscaleVPNEnabled)
11081128
{ tailscaleVPNEnabled.checked = (custom_settings.Allow_Updates_OverVPN === 'ENABLED'); }
11091129
@@ -1117,12 +1137,11 @@ function InitializeFields()
11171137
{ fwUpdateDirectory.value = custom_settings.FW_New_Update_ZIP_Directory_Path || ''; }
11181138
11191139
// Update Settings Status Table //
1120-
setStatus('changelogCheckStatus', custom_settings.CheckChangeLog);
1121-
setStatus('betaToReleaseUpdatesStatus', custom_settings.FW_Allow_Beta_Production_Up);
1122-
setStatus('tailscaleVPNAccessStatus', custom_settings.Allow_Updates_OverVPN);
1123-
setStatus('autoUpdatesScriptEnabledStatus', custom_settings.Allow_Script_Auto_Update);
1124-
setStatus('autobackupEnabledStatus', custom_settings.FW_Auto_Backupmon);
1125-
setStatus('emailNotificationsStatus', custom_settings.FW_New_Update_EMail_Notification);
1140+
SetStatus('changelogCheckStatus', custom_settings.CheckChangeLog);
1141+
SetStatus('betaToReleaseUpdatesStatus', custom_settings.FW_Allow_Beta_Production_Up);
1142+
SetStatus('tailscaleVPNAccessStatus', custom_settings.Allow_Updates_OverVPN);
1143+
SetStatus('autoUpdatesScriptEnabledStatus', custom_settings.Allow_Script_Auto_Update);
1144+
SetStatus('autobackupEnabledStatus', custom_settings.FW_Auto_Backupmon);
11261145
11271146
// Handle fwNotificationsDate as a date //
11281147
let notifyFullDateStr, notifyDateTimeStr;
@@ -1447,7 +1466,7 @@ function AssignAjaxSetting (keyName, keyValue)
14471466
/** Modified by Martinski W. [2025-Jan-05] **/
14481467
/**----------------------------------------**/
14491468
// Helper function to set status with color //
1450-
function setStatus(elementId, statusValue)
1469+
function SetStatus (elementId, statusValue)
14511470
{
14521471
let element = document.getElementById(elementId);
14531472
if (element)
@@ -1634,10 +1653,10 @@ function SaveAdvancedConfig()
16341653
// Clear amng_custom for any existing content before saving //
16351654
document.getElementById('amng_custom').value = '';
16361655
1637-
// 1) F/W Update Email Notifications - only if not disabled
1638-
let emailNotificationsEnabled = document.getElementById('emailNotificationsEnabled');
1656+
// 1) F/W Update Email Notifications - only if NOT disabled //
16391657
let emailFormat = document.getElementById('emailFormat');
16401658
let secondaryEmail = document.getElementById('secondaryEmail');
1659+
let emailNotificationsEnabled = document.getElementById('emailNotificationsEnabled');
16411660
16421661
// If the box is enabled, we save these fields //
16431662
if (emailNotificationsEnabled && !emailNotificationsEnabled.disabled)
@@ -1883,25 +1902,26 @@ document.addEventListener("DOMContentLoaded", function()
18831902
18841903
function initializeCollapsibleSections()
18851904
{
1886-
if (typeof jQuery !== 'undefined')
1905+
if (typeof jQuery !== 'undefined')
1906+
{
1907+
$('.collapsible-jquery').each(function()
18871908
{
1888-
$('.collapsible-jquery').each(function() {
1889-
// Ensure sections are expanded by default
1890-
$(this).addClass('active'); // Add 'active' class to indicate expanded state
1891-
$(this).next('tbody').show(); // Make sure content is visible
1892-
1893-
// Add a cursor pointer for better UX
1894-
$(this).css('cursor', 'pointer');
1895-
1896-
// Toggle logic on click
1897-
$(this).on('click', function() {
1898-
$(this).toggleClass('active');
1899-
$(this).next('tbody').slideToggle();
1900-
});
1909+
// Ensure sections are expanded by default //
1910+
$(this).addClass('active'); // Add 'active' class to indicate expanded state
1911+
$(this).next('tbody').show(); // Make sure content is visible
1912+
1913+
// Add a cursor pointer for better UX
1914+
$(this).css('cursor', 'pointer');
1915+
1916+
// Toggle logic on click
1917+
$(this).on('click', function() {
1918+
$(this).toggleClass('active');
1919+
$(this).next('tbody').slideToggle();
19011920
});
1902-
} else {
1903-
console.error("jQuery is not loaded. Collapsible sections will not work.");
1904-
}
1921+
});
1922+
}
1923+
else
1924+
{ console.error("jQuery is not loaded. Collapsible sections will not work."); }
19051925
}
19061926
</script>
19071927
</head>
@@ -2164,10 +2184,10 @@ function initializeCollapsibleSections()
21642184
<span style="margin-left:1px; margin-top:5px; font-size: 12px; font-weight: bolder;">Days:</span>
21652185
<label style="margin-left:-3px;">
21662186
<input type="checkbox" name="fwSchedDAYWEEK" id="fwSchedBoxDAYS1" value="Every day" class="input"
2167-
style="margin-left:22px; margin-top:1px;" onclick="ToggleDaysOfWeek(this.checked,'1')"/>Every day</label>
2187+
style="margin-left:22px; margin-top:1px;" onclick="ToggleDaysOfWeek(this.checked,'1');"/>Every day</label>
21682188
<label style="margin-left:-3px;">
21692189
<input type="checkbox" name="fwSchedDAYWEEK" id="fwSchedBoxDAYSX" value="Every X Days" class="input"
2170-
style="margin-left:28px; margin-top:1px;" onclick="ToggleDaysOfWeek(this.checked,'X')"/>Every</label>
2190+
style="margin-left:28px; margin-top:1px;" onclick="ToggleDaysOfWeek(this.checked,'X');"/>Every</label>
21712191
<input type="text" autocomplete="off" autocapitalize="off" data-lpignore="true"
21722192
style="width: 5%; margin-left: 2px; margin-top:3px; margin-bottom:7px" maxlength="2"
21732193
id="fwScheduleXDAYS" name="fwScheduleXDAYS" value="2"
@@ -2298,7 +2318,8 @@ function initializeCollapsibleSections()
22982318
</tr>
22992319
<tr>
23002320
<td style="text-align: left;"><label for="emailNotificationsEnabled">Enable F/W Update Email Notifications</label></td>
2301-
<td><input type="checkbox" id="emailNotificationsEnabled" name="emailNotificationsEnabled" /></td>
2321+
<td><input type="checkbox" id="emailNotificationsEnabled" name="emailNotificationsEnabled"
2322+
onclick="ToggleEmailDependents(this.checked);"/></td>
23022323
</tr>
23032324
<tr>
23042325
<td style="text-align: left;"><label for="emailFormat">Email Notification Format</label></td>

0 commit comments

Comments
 (0)