mirror of
https://github.com/swissmakers/wireguard-manager.git
synced 2026-04-05 10:47:05 +02:00
move updateSubnetRangesList() to base-template for calling it from every page
This commit is contained in:
@@ -433,6 +433,12 @@
|
|||||||
// Initial call, and then poll every 5 seconds for config changes
|
// Initial call, and then poll every 5 seconds for config changes
|
||||||
updateApplyConfigVisibility();
|
updateApplyConfigVisibility();
|
||||||
setInterval(updateApplyConfigVisibility, 5000);
|
setInterval(updateApplyConfigVisibility, 5000);
|
||||||
|
|
||||||
|
// Only poll for updates if the current page is the status page.
|
||||||
|
if (window.location.pathname === "{{.basePath}}/status") {
|
||||||
|
updateStatusTable();
|
||||||
|
setInterval(updateStatusTable, 5000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addGlobalStyle(css, id) {
|
function addGlobalStyle(css, id) {
|
||||||
@@ -660,6 +666,28 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function updateSubnetRangesList(elementID, preselectedVal) {
|
||||||
|
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
|
||||||
|
$(`${elementID} option`).remove();
|
||||||
|
$(elementID).append(
|
||||||
|
$("<option></option>")
|
||||||
|
.text("Any")
|
||||||
|
.val("__default_any__")
|
||||||
|
);
|
||||||
|
$.each(data, function(index, item) {
|
||||||
|
$(elementID).append(
|
||||||
|
$("<option></option>")
|
||||||
|
.text(item)
|
||||||
|
.val(item)
|
||||||
|
);
|
||||||
|
if (item === preselectedVal) {
|
||||||
|
console.log(preselectedVal);
|
||||||
|
$(elementID).val(preselectedVal).trigger('change')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// New Client modal event.
|
// New Client modal event.
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#modal_new_client").on('shown.bs.modal', function () {
|
$("#modal_new_client").on('shown.bs.modal', function () {
|
||||||
|
|||||||
@@ -312,28 +312,6 @@ VPN WireGuard Clients
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSubnetRangesList(elementID, preselectedVal) {
|
|
||||||
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
|
|
||||||
$(`${elementID} option`).remove();
|
|
||||||
$(elementID).append(
|
|
||||||
$("<option></option>")
|
|
||||||
.text("Any")
|
|
||||||
.val("__default_any__")
|
|
||||||
);
|
|
||||||
$.each(data, function(index, item) {
|
|
||||||
$(elementID).append(
|
|
||||||
$("<option></option>")
|
|
||||||
.text(item)
|
|
||||||
.val(item)
|
|
||||||
);
|
|
||||||
if (item === preselectedVal) {
|
|
||||||
console.log(preselectedVal);
|
|
||||||
$(elementID).val(preselectedVal).trigger('change')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSearchList() {
|
function updateSearchList() {
|
||||||
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
|
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
|
||||||
$("#status-selector option").remove();
|
$("#status-selector option").remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user