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 % //this part is to populate edit device info on each online private network host basis for ($i=0; $i < $onlinePrivateNetworkHost['hostNum']; $i++) { - if(!$onlinePrivateNetworkHost[$i.toString()]['ShowActions']) { - continue; - } + $rowKey = $i + 1; $commentsOnline2= $onlinePrivateNetworkHost[$i.toString()]['Comments']; $commentsOnline2=$commentsOnline2.trim(); if($commentsOnline2.search('@')!=-1){ @@ -1197,6 +1109,8 @@ for ($i=0; $i < $onlinePrivateNetworkHost['hostNum']; $i++) { } $ID = $onlinePrivateNetworkHost[$i.toString()]['instanceID']; $AddrSrc = $onlinePrivateNetworkHost[$i.toString()]['AddressSource']; + $editHostName = htmlspecialchars($onlinePrivateNetworkHost[$i.toString()]['HostName'], ENT_NOQUOTES, 'UTF-8'); + $editMacAddress = $onlinePrivateNetworkHost[$i.toString()]['PhysAddress']; var unknowid=""; if($onlinePrivateNetworkHost[$i.toString()]['Connection']=="Unknown"){ unknowid="unknown"; @@ -1206,19 +1120,23 @@ for ($i=0; $i < $onlinePrivateNetworkHost['hostNum']; $i++) { } else if($onlinePrivateNetworkHost[$i.toString()]['Connection']=="Wi-Fi 5 GHz"){ unknowid ="5_G"; - }else if($onlinePrivateNetworkHost[$i.toString()]['Connection']=="Ethernet"){unknowid ="ethcon";} + } + else if($onlinePrivateNetworkHost[$i.toString()]['Connection']=="Wi-Fi 6 GHz"){ + unknowid ="6_G"; + } + else if($onlinePrivateNetworkHost[$i.toString()]['Connection']=="Ethernet"){unknowid ="ethcon";} echo( "\ -
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.
\