diff --git a/source/Styles/xb3/jst/connected_devices_computers.jst b/source/Styles/xb3/jst/connected_devices_computers.jst index f007cc4..bd8ea12 100644 --- a/source/Styles/xb3/jst/connected_devices_computers.jst +++ b/source/Styles/xb3/jst/connected_devices_computers.jst @@ -419,32 +419,34 @@ $(document).ready(function() { }); } $("input:checked[name='ip']").trigger("click"); - // activate validation plugin - $(".pageForm").validate({ - rules : { - host_name: { - allowed_char: true - }, - staticIPAddress: { - ipv4 : { - depends : function() { - return ("static" == $("input:radio[name=ip]:checked").val()); - } - }, - required : { - depends : function() { - return ("static" == $("input:radio[name=ip]:checked").val()); - } - } - } - ,mac_address:{ - required: true, - mac: true - }, - comments:{ - allowed_char: true - } - } + // activate validation plugin for each edit form + $(".pageForm").each(function() { + $(this).validate({ + rules : { + host_name: { + allowed_char: true + }, + staticIPAddress: { + ipv4 : { + depends : function() { + return ("static" == $(this).closest('form').find("input:radio[name=ip]:checked").val()); + } + }, + required : { + depends : function() { + return ("static" == $(this).closest('form').find("input:radio[name=ip]:checked").val()); + } + } + }, + mac_address:{ + required: true, + mac: true + }, + comments:{ + allowed_char: true + } + } + }); }); $(".edit-device").hide(); $('.device-info').addClass('device-hide'); @@ -473,179 +475,91 @@ $(document).ready(function() { $("#" + editTarget).show(); } }); - for (var i = 0; i < onlineDeviceNum; i++) { - ( - function(x) { - //alert(onlineDeviceInstanceArr[i]); - var submitEditDevice = "#submit_editDevice-" + onlineDeviceInstanceArr[x]; - var macAddr = "#mac_address-" + onlineDeviceInstanceArr[x]; - var staticIPAddr = "#staticIPAddress-" + onlineDeviceInstanceArr[x]; - var ipDHCP = "#ip_dhcp-" + onlineDeviceInstanceArr[x]; - var ipResv = "#ip_static-" + onlineDeviceInstanceArr[x]; - var comment = "#comment-" + onlineDeviceInstanceArr[x]; - var dhcp_mac = "#dhcp-mac" + onlineDeviceInstanceArr[x]; - var static_ip = "#static-ip" + onlineDeviceInstanceArr[x]; - //alert(onlineDeviceInstanceArr[x]); - var isDHCP = $(ipDHCP).is(":checked"); - if (isDHCP) { - $(static_ip).hide(); - } - else{ - $(static_ip).show(); - } - $(ipResv).click(function(){ - $(static_ip).show(); - }); - $(ipDHCP).click(function(){ - $(static_ip).hide(); - }); - var hostName = onlineHostNameArr[x]; - var macAddress = onlineHostMAC[x]; - $(submitEditDevice).click(function(e){ - e.preventDefault(); - var reseverd_ipAddr = $(staticIPAddr).val(); - var isDHCP = $(ipDHCP).is(":checked"); - var Comments = $(comment).val(); - if (Comments.length > 63) { - alertLocale("The comments should be no more than 63 characters !"); - return; - } - Comments=Comments.replace(/[\r\n]+/gm, "@" ); - if (isDHCP){ - if($(ipDHCP).val() == 'DHCP'){ - //this initial value is DHCP, user is going to modify comments - var editDevInfo = '{"UpdateComments": "true", "Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - else{ - // this is to provide info to remove this device in the static addr list, REservedIP => DHCP - var editDevInfo = '{"delFlag": "true", "Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - } - else{ - //to check if "Reserved IP Address" is in "DHCP Pool range" - if(reseverd_ipAddr==""){ - alertLocale("Please enter Reserved IP Address !"); - return; + function toggleStaticIpInForm($form) { + var isDHCP = $form.find("input[name='ip'][value='DHCP']").is(":checked"); + if (isDHCP) { + $form.find('.static-ip').hide(); + } + else { + $form.find('.static-ip').show(); + } + } + + $('.edit-device-form').each(function(){ + toggleStaticIpInForm($(this)); + }); + + $(document).on('change', '.edit-device-form input[name="ip"]', function(){ + var $form = $(this).closest('.edit-device-form'); + toggleStaticIpInForm($form); + }); + + $(document).on('click', '.btn-save-edit-device', function(e){ + e.preventDefault(); + var $form = $(this).closest('.edit-device-form'); + var hostName = $form.attr('data-host-name'); + var macAddress = $form.attr('data-mac-address'); + var initialAddrSrc = $form.attr('data-initial-addrsrc'); + var reseverd_ipAddr = $form.find('.static-ip-input').val(); + var isDHCP = $form.find("input[name='ip'][value='DHCP']").is(":checked"); + var Comments = $form.find('.comment-input').val(); + var editDevInfo = ""; + if (Comments.length > 63) { + alertLocale("The comments should be no more than 63 characters !"); + return; + } + Comments = Comments.replace(/[\r\n]+/gm, "@"); + + var editDevObj; + var commentsPayload = " " + Comments + " "; + if (isDHCP){ + if(initialAddrSrc == 'DHCP'){ + //this initial value is DHCP, user is going to modify comments + editDevObj = { UpdateComments: "true", Comments: commentsPayload, hostName: hostName, macAddress: macAddress, reseverd_ipAddr: reseverd_ipAddr }; + } + else{ + // this is to provide info to remove this device in the static addr list, REservedIP => DHCP + editDevObj = { delFlag: "true", Comments: commentsPayload, hostName: hostName, macAddress: macAddress, reseverd_ipAddr: reseverd_ipAddr }; + } + } + else{ + //to check if "Reserved IP Address" is in "DHCP Pool range" + if(reseverd_ipAddr==""){ + alertLocale("Please enter Reserved IP Address !"); + return; + } + var validIpaddr = valid_GW_IP(beginAddr, endAddr, reseverd_ipAddr); + if(!validIpaddr){ + jAlert($.i18n('Reserved IP Address is not in valid range:')+"\n"+beginAddr+" ~ "+endAddr); + return; + } + // this is to provide info to edit REservedIP + editDevObj = { Comments: commentsPayload, hostName: hostName, macAddress: macAddress, reseverd_ipAddr: reseverd_ipAddr }; + } + editDevInfo = JSON.stringify(editDevObj); + + if($form.valid()){ + jProgress($.i18n('This may take several seconds'), 60); + $.ajax({ + type: "POST", + url: "actionHandler/ajaxSet_add_device.jst", + data: { DeviceInfo: editDevInfo, csrfp_token: token }, + dataType: "json", + success: function(results){ + setTimeout(function(){ + jHide(); + if (results=="success") { window.location.href="connected_devices_computers.jst";} + else if (results=="") {alertLocale("Failure! Please check your inputs.");} + else alertLocale(results); + }, 15000); + }, + error: function(){ + jHide(); + alertLocale("Failure, Please check your inputs and try again."); } - var validIpaddr = valid_GW_IP(beginAddr, endAddr,reseverd_ipAddr); - if(!validIpaddr){ - jAlert($.i18n('Reserved IP Address is not in valid range:')+"\n"+beginAddr+" ~ "+endAddr); - return; - } - var reseverd_ipArr = reseverd_ipAddr.split("."); - // this is to provide info to edit REservedIP - var editDevInfo = '{"Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - //alert(editDevInfo); - if($(".pageForm").valid()){ - jProgress($.i18n('This may take several seconds'), 60); - $.ajax({ - type: "POST", - url: "actionHandler/ajaxSet_add_device.jst", - data: { DeviceInfo: editDevInfo,csrfp_token: token }, - dataType: "json", - success: function(results){ - setTimeout(function(){ - jHide(); - if (results=='success') { window.location.href="connected_devices_computers.jst";} - else if (results=="") {alertLocale("Failure! Please check your inputs.");} - else alertLocale(results); - }, 15000); - }, - error: function(){ - jHide(); - alertLocale("Failure, Please check your inputs and try again."); - } - }); - } //end of page form valid - }); //end of submit edit device click - }) (i); //end of function(x) - }; // end of for loop - - for (var i = 0; i < offlineDeviceNum; i++) { - ( - function(x) { - //alert(offlineDeviceInstanceArr[i]); - var submitEditDevice = "#submit_editDevice-" + offlineDeviceInstanceArr[x]; - var macAddr = "#mac_address-" + offlineDeviceInstanceArr[x]; - var staticIPAddr = "#staticIPAddress-" + offlineDeviceInstanceArr[x]; - var ipDHCP = "#ip_dhcp-" + offlineDeviceInstanceArr[x]; - var ipResv = "#ip_static-" + offlineDeviceInstanceArr[x]; - var comment = "#comment-" + offlineDeviceInstanceArr[x]; - var dhcp_mac = "#dhcp-mac" + offlineDeviceInstanceArr[x]; - var static_ip = "#static-ip" + offlineDeviceInstanceArr[x]; - //alert(offlineDeviceInstanceArr[x]); - var isDHCP = $(ipDHCP).is(":checked"); - if (isDHCP) { - $(static_ip).hide(); - } - else{ - $(static_ip).show(); - } - $(ipResv).click(function(){ - $(static_ip).show(); - }); - $(ipDHCP).click(function(){ - $(static_ip).hide(); - }); - var hostName = offlineHostNameArr[x]; - var macAddress = offlineHostMAC[x]; - $(submitEditDevice).click(function(e){ - e.preventDefault(); - var reseverd_ipAddr = $(staticIPAddr).val(); - var isDHCP = $(ipDHCP).is(":checked"); - var Comments = $(comment).val(); - Comments=Comments.replace(/[\r\n]+/gm, "@" ); - if (isDHCP){ - if($(ipDHCP).val() == 'DHCP'){ - //this initial value is DHCP, user is going to modify comments - var editDevInfo = '{"UpdateComments": "true", "Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - else{ - // this is to provide info to remove this device in the static addr list, REservedIP => DHCP - var editDevInfo = '{"delFlag": "true", "Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - } - else{ - //to check if "Reserved IP Address" is in "DHCP Pool range" - if(reseverd_ipAddr==""){ - alertLocale("Please enter Reserved IP Address !"); - return; - } - var validIpaddr = valid_GW_IP(beginAddr, endAddr,reseverd_ipAddr); - if(!validIpaddr){ - jAlert($.i18n('Reserved IP Address is not in valid range:')+"\n"+beginAddr+" ~ "+endAddr); - return; - } - var reseverd_ipArr = reseverd_ipAddr.split("."); - // this is to provide info to edit REservedIP - var editDevInfo = '{"Comments": " '+ Comments +' ", "hostName": "' + hostName + '", "macAddress": "' + macAddress + '", "reseverd_ipAddr": "' + reseverd_ipAddr + '"}'; - } - //alert(editDevInfo); - if($(".pageForm").valid()){ - jProgress($.i18n('This may take several seconds'), 60); - $.ajax({ - type: "POST", - url: "actionHandler/ajaxSet_add_device.jst", - data: { DeviceInfo: editDevInfo,csrfp_token: token }, - dataType: "json", - success: function(results){ - setTimeout(function(){ - jHide(); - if (results=="success") { window.location.href="connected_devices_computers.jst";} - else if (results=="") {alertLocale("Failure! Please check your inputs.");} - else alertLocale(results); - }, 15000); - }, - error: function(){ - jHide(); - alertLocale("Failure, Please check your inputs and try again."); - } - }); - } //end of page form valid - }); //end of submit edit device click - }) (i); //end of function(x) - }; // end of for loop + }); + } + }); $('.confirm').off('click').click(function(e){ if(!(privateDisabled && $(this).hasClass("private"))){ @@ -748,7 +662,7 @@ function getTitle(val){ if(($CloudUIEnable == "true" ) || $onlinePrivateNetworkHost[$x.toString()]['Blocked']) $style = " "; else $style = ""; } - $editStyle = ""; + $editStyle = ""; if($k % 2) $odd = ""; else $odd = " class='odd'"; echo( "\ @@ -860,7 +774,7 @@ else if($offlinePrivateNetworkHost[$x.toString()]['Connection']=="Ethernet"){pri if(($CloudUIEnable == "true" ) || $offlinePrivateNetworkHost[$x.toString()]['Blocked']) $style = " "; else $style = ""; } - $editStyle = ""; + $editStyle = ""; if($k % 2) $odd = ""; else $odd = " class='odd'"; echo(''); @@ -1173,9 +1087,7 @@ else if($offlinePrivateNetworkHost[$x.toString()]['Connection']=="Ethernet"){pri \ -

Connected Devices > Devices > Edit Device

\ +
\ +

Connected Devices > Devices > Edit Device

\
\

Change the IP address assignment method for Online Devices.

\

If DHCP is selected, the Gateway\'s DHCP server will automatically assign the IP address.

\

If Reserved IP is selected, the IP address will be fixed without DHCP operation and you\'ll need to manually enter the IP address. The IP address must be within the DHCP IP address pool. To find your IP address range, go to Gateway > Connection > Local IP Network.

\

Reserved IP addresses can be assigned to any device that acts as a server or that requires a fixed IP address.

\
\ -
\ +
\

Edit Device

\ -
\ + \
\ Host Name:\ " + $onlinePrivateNetworkHost[$i.toString()]['HostName'] + "\ @@ -1229,27 +1147,27 @@ for ($i=0; $i < $onlinePrivateNetworkHost['hostNum']; $i++) {
\
\ \ - \ - \ + \ + \
\ - \ - \ + \ + \
\ -
\ +
\ MAC Address:\ "+$onlinePrivateNetworkHost[$i.toString()]['PhysAddress']+"\
\ -
\ - \ - \ +
\ + \ + \
\
\ - \ - \ + \ + \
\
\ - \ - \ + \ + \
\ \
\ @@ -1258,9 +1176,7 @@ for ($i=0; $i < $onlinePrivateNetworkHost['hostNum']; $i++) { } //this part is to populate edit device info on each offline private network host basis for ($i=0; $i < $offlinePrivateNetworkHost['hostNum']; $i++) { - if(!$offlinePrivateNetworkHost[$i.toString()]['ShowActions']) { - continue; - } + $rowKey = $i + 1; $commentOffline1= $offlinePrivateNetworkHost[$i.toString()]['Comments']; $commentOffline1=$commentOffline1.trim(); if($commentOffline1.search('@')!=-1){ @@ -1284,6 +1200,8 @@ for ($i=0; $i < $offlinePrivateNetworkHost['hostNum']; $i++) { $ID = $offlinePrivateNetworkHost[$i.toString()]['instanceID']; $AddrSrc = $offlinePrivateNetworkHost[$i.toString()]['AddressSource']; + $editHostName = htmlspecialchars($offlinePrivateNetworkHost[$i.toString()]['HostName'], ENT_NOQUOTES, 'UTF-8'); + $editMacAddress = $offlinePrivateNetworkHost[$i.toString()]['PhysAddress']; var unknowid=""; if($offlinePrivateNetworkHost[$i.toString()]['Connection']=="Unknown"){ unknowid="unknown"; @@ -1293,19 +1211,23 @@ for ($i=0; $i < $offlinePrivateNetworkHost['hostNum']; $i++) { } else if($offlinePrivateNetworkHost[$i.toString()]['Connection']=="Wi-Fi 5 GHz"){ unknowid ="5_G"; - }else{unknowid ="ethcon";} - echo("\ -
\ -

Connected Devices > Devices > Edit Device

\ + } + else if($offlinePrivateNetworkHost[$i.toString()]['Connection']=="Wi-Fi 6 GHz"){ + unknowid ="6_G"; + } + else{unknowid ="ethcon";} + echo("\ +
\ +

Connected Devices > Devices > Edit Device

\
\

Change the IP address assignment method for Offline Devices

\

If DHCP is selected, the Gateway\'s DHCP server will automatically assign the IP address.

\

If Reserved IP is selected, the IP address will be fixed without DHCP operation and you\'ll need to manually enter the IP address. The IP address must be within the DHCP IP address pool. To find your IP address range, go to Gateway > Connection > Local IP Network.

\

Reserved IP addresses can be assigned to any device that acts as a server or that requires a fixed IP address.

\
\ -
\ +
\

Edit Device

\ -
\ + \
\ Host Name: \ " + $offlinePrivateNetworkHost[$i.toString()]['HostName'] + " \ @@ -1316,27 +1238,27 @@ for ($i=0; $i < $offlinePrivateNetworkHost['hostNum']; $i++) {
\
\ \ - \ - \ + \ + \
\ - \ - \ + \ + \
\ -
\ +
\ MAC Address:\ "+$offlinePrivateNetworkHost[$i.toString()]['PhysAddress']+"\
\ -
\ - \ - \ +
\ + \ + \
\
\ - \ - \ + \ + \
\
\ - \ - \ + \ + \
\ \
\ diff --git a/source/Styles/xb3/jst/locale/global.js b/source/Styles/xb3/jst/locale/global.js index 77946af..3dde4a2 100755 --- a/source/Styles/xb3/jst/locale/global.js +++ b/source/Styles/xb3/jst/locale/global.js @@ -202,7 +202,7 @@ $("#nocyc").text($.i18n("Number of Cycles to date:")); $("#batmodno").text($.i18n("Battery Model Number:")); $("#batserno").text($.i18n("Battery Serial Number:")); $("#connhead").text($.i18n("Connected Devices > Devices")); -$("#conndevedithead,#conndevedithead1").text($.i18n("Connected Devices > Devices > Edit Device")); +$(".conndevedithead").text($.i18n("Connected Devices > Devices > Edit Device")); $("#connhom1").text($.i18n("Managing your home network settings is now easier than ever.")); $("#visithead").text($.i18n("Visit ")); $("#connhom2").text($.i18n(" to view and manage your list of connected/offline devices. You can block access to your home network for any device, among many other features and settings."));