diff --git a/DnsServerCore/www/js/dhcp.js b/DnsServerCore/www/js/dhcp.js
index 8d85f42f..f5c49563 100644
--- a/DnsServerCore/www/js/dhcp.js
+++ b/DnsServerCore/www/js/dhcp.js
@@ -17,6 +17,16 @@ along with this program. If not, see .
*/
+function refreshDhcpTab() {
+
+ if ($("#dhcpTabListLeases").hasClass("active"))
+ refreshDhcpLeases();
+ else if ($("#dhcpTabListScopes").hasClass("active"))
+ refreshDhcpScopes();
+ else
+ refreshDhcpLeases();
+}
+
function refreshDhcpLeases() {
var divDhcpLeasesLoader = $("#divDhcpLeasesLoader");
@@ -32,14 +42,16 @@ function refreshDhcpLeases() {
var tableHtmlRows;
if (dhcpLeases.length < 1) {
- tableHtmlRows = "
| No Lease Found |
";
+ tableHtmlRows = "| No Lease Found |
";
}
else {
tableHtmlRows = "";
for (var i = 0; i < dhcpLeases.length; i++) {
- tableHtmlRows += "| " + htmlEncode(dhcpLeases[i].scope) + " | " + dhcpLeases[i].hardwareAddress + " | " + dhcpLeases[i].address + " | " + htmlEncode(dhcpLeases[i].hostName) + " | " + dhcpLeases[i].leaseObtained + " | " + dhcpLeases[i].leaseExpires + " |
";
+ tableHtmlRows += "| " + htmlEncode(dhcpLeases[i].scope) + " | " + dhcpLeases[i].hardwareAddress + " | " + dhcpLeases[i].address + " | " + dhcpLeases[i].type + " | " + htmlEncode(dhcpLeases[i].hostName) + " | " + dhcpLeases[i].leaseObtained + " | " + dhcpLeases[i].leaseExpires + " |
";
}
+
+ tableHtmlRows += "| Total Leases: " + dhcpLeases.length + " |
";
}
$("#tableDhcpLeases").html(tableHtmlRows);
@@ -78,7 +90,7 @@ function refreshDhcpScopes() {
for (var i = 0; i < dhcpScopes.length; i++) {
tableHtmlRows += "| " + htmlEncode(dhcpScopes[i].name) + " | " + dhcpScopes[i].startingAddress + " - " + dhcpScopes[i].endingAddress + " " + dhcpScopes[i].subnetMask + " | " + dhcpScopes[i].networkAddress + " " + dhcpScopes[i].broadcastAddress + " | " + (dhcpScopes[i].interfaceAddress == null ? "" : dhcpScopes[i].interfaceAddress) + " | ";
- tableHtmlRows += "";
+ tableHtmlRows += " | ";
if (dhcpScopes[i].enabled)
tableHtmlRows += "";
@@ -87,6 +99,8 @@ function refreshDhcpScopes() {
tableHtmlRows += " |
";
}
+
+ tableHtmlRows += "| Total Scopes: " + dhcpScopes.length + " |
";
}
$("#tableDhcpScopes").html(tableHtmlRows);
@@ -124,12 +138,13 @@ function addDhcpScopeExclusionRow(startingAddress, endingAddress) {
$("#tableDhcpScopeExclusions").append(tableHtmlRows);
}
-function addDhcpScopeReservedLeaseRow(startingAddress, endingAddress) {
+function addDhcpScopeReservedLeaseRow(hostName, hardwareAddress, address) {
var id = Math.floor(Math.random() * 10000);
- var tableHtmlRows = " | ";
- tableHtmlRows += " | ";
+ var tableHtmlRows = "
| ";
+ tableHtmlRows += " | ";
+ tableHtmlRows += " | ";
tableHtmlRows += " |
";
$("#tableDhcpScopeReservedLeases").append(tableHtmlRows);
@@ -157,7 +172,7 @@ function getTableCsv(table, columns) {
return false;
}
- csv += cellValue;
+ csv += htmlDecode(cellValue);
}
}
@@ -177,6 +192,8 @@ function clearDhcpScopeForm() {
$("#txtDhcpScopeDomainName").val("");
$("#txtDhcpScopeDnsTtl").val("900");
$("#txtDhcpScopeRouterAddress").val("");
+ $("#chkUseThisDnsServer").prop("checked", false);
+ $('#txtDhcpScopeDnsServers').prop('disabled', false);
$("#txtDhcpScopeDnsServers").val("");
$("#txtDhcpScopeWinsServers").val("");
$("#txtDhcpScopeNtpServers").val("");
@@ -192,6 +209,8 @@ function showAddDhcpScope() {
clearDhcpScopeForm();
$("#titleDhcpEditScope").html("Add Scope");
+ $("#chkUseThisDnsServer").prop("checked", true);
+ $('#txtDhcpScopeDnsServers').prop('disabled', true);
$("#divDhcpViewScopes").hide();
$("#divDhcpViewScopesLoader").hide();
$("#divDhcpEditScope").show();
@@ -231,6 +250,9 @@ function showEditDhcpScope(scopeName) {
if (responseJSON.response.routerAddress != null)
$("#txtDhcpScopeRouterAddress").val(responseJSON.response.routerAddress);
+ $("#chkUseThisDnsServer").prop("checked", responseJSON.response.useThisDnsServer);
+ $('#txtDhcpScopeDnsServers').prop('disabled', responseJSON.response.useThisDnsServer);
+
if (responseJSON.response.dnsServers != null)
$("#txtDhcpScopeDnsServers").val(responseJSON.response.dnsServers.join("\n"));
@@ -254,7 +276,7 @@ function showEditDhcpScope(scopeName) {
if (responseJSON.response.reservedLeases != null) {
for (var i = 0; i < responseJSON.response.reservedLeases.length; i++) {
- addDhcpScopeReservedLeaseRow(responseJSON.response.reservedLeases[i].hardwareAddress, responseJSON.response.reservedLeases[i].address);
+ addDhcpScopeReservedLeaseRow(responseJSON.response.reservedLeases[i].hostName, responseJSON.response.reservedLeases[i].hardwareAddress, responseJSON.response.reservedLeases[i].address);
}
}
@@ -295,6 +317,7 @@ function saveDhcpScope() {
var routerAddress = $("#txtDhcpScopeRouterAddress").val();
+ var useThisDnsServer = $("#chkUseThisDnsServer").prop('checked');
var dnsServers = cleanTextList($("#txtDhcpScopeDnsServers").val());
var winsServers = cleanTextList($("#txtDhcpScopeWinsServers").val());
var ntpServers = cleanTextList($("#txtDhcpScopeNtpServers").val());
@@ -307,19 +330,19 @@ function saveDhcpScope() {
if (exclusions === false)
return;
- var reservedLeases = getTableCsv($("#tableDhcpScopeReservedLeases"), 2);
+ var reservedLeases = getTableCsv($("#tableDhcpScopeReservedLeases"), 3);
if (reservedLeases === false)
return;
- var chkAllowOnlyReservedLeases = $("#chkAllowOnlyReservedLeases").prop('checked');
+ var allowOnlyReservedLeases = $("#chkAllowOnlyReservedLeases").prop('checked');
var btn = $("#btnSaveDhcpScope").button('loading');
HTTPRequest({
url: "/api/setDhcpScope?token=" + token + "&name=" + encodeURIComponent(name) + (newName == null ? "" : "&newName=" + encodeURIComponent(newName)) + "&startingAddress=" + encodeURIComponent(startingAddress) + "&endingAddress=" + encodeURIComponent(endingAddress) + "&subnetMask=" + encodeURIComponent(subnetMask) +
"&leaseTimeDays=" + leaseTimeDays + "&leaseTimeHours=" + leaseTimeHours + "&leaseTimeMinutes=" + leaseTimeMinutes + "&offerDelayTime=" + offerDelayTime + "&domainName=" + encodeURIComponent(domainName) + "&dnsTtl=" + dnsTtl + "&routerAddress=" + encodeURIComponent(routerAddress) +
- "&dnsServers=" + encodeURIComponent(dnsServers) + "&winsServers=" + encodeURIComponent(winsServers) + "&ntpServers=" + encodeURIComponent(ntpServers) +
- "&staticRoutes=" + encodeURIComponent(staticRoutes) + "&exclusions=" + encodeURIComponent(exclusions) + "&reservedLeases=" + encodeURIComponent(reservedLeases) + "&chkAllowOnlyReservedLeases=" + chkAllowOnlyReservedLeases,
+ "&useThisDnsServer=" + useThisDnsServer + (useThisDnsServer ? "" : "&dnsServers=" + encodeURIComponent(dnsServers)) + "&winsServers=" + encodeURIComponent(winsServers) + "&ntpServers=" + encodeURIComponent(ntpServers) +
+ "&staticRoutes=" + encodeURIComponent(staticRoutes) + "&exclusions=" + encodeURIComponent(exclusions) + "&reservedLeases=" + encodeURIComponent(reservedLeases) + "&allowOnlyReservedLeases=" + allowOnlyReservedLeases,
success: function (responseJSON) {
refreshDhcpScopes();
btn.button('reset');
@@ -354,6 +377,10 @@ function disableDhcpScope(scopeName) {
refreshDhcpScopes();
showAlert("success", "Scope Disabled!", "DHCP Scope was disabled successfully.");
},
+ error: function () {
+ divDhcpViewScopesLoader.hide();
+ divDhcpViewScopes.show();
+ },
invalidToken: function () {
showPageLogin();
},
@@ -377,6 +404,10 @@ function enableDhcpScope(scopeName) {
refreshDhcpScopes();
showAlert("success", "Scope Enabled!", "DHCP Scope was enabled successfully.");
},
+ error: function () {
+ divDhcpViewScopesLoader.hide();
+ divDhcpViewScopes.show();
+ },
invalidToken: function () {
showPageLogin();
},
@@ -403,6 +434,10 @@ function deleteDhcpScope(scopeName) {
refreshDhcpScopes();
showAlert("success", "Scope Deleted!", "DHCP Scope was deleted successfully.");
},
+ error: function () {
+ divDhcpViewScopesLoader.hide();
+ divDhcpViewScopes.show();
+ },
invalidToken: function () {
showPageLogin();
},