mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-02 16:38:47 +03:00
add private subnets
This commit is contained in:
parent
c205a04443
commit
453e9fcf5d
5 changed files with 63 additions and 15 deletions
|
@ -58,6 +58,10 @@ Wireguard Clients
|
|||
<label for="_client_allowed_ips" class="control-label">Allowed IPs</label>
|
||||
<input type="text" data-role="tagsinput" class="form-control" id="_client_allowed_ips">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="_client_private_subnets" class="control-label">Private Subnet</label>
|
||||
<input type="text" data-role="tagsinput" class="form-control" id="_client_private_subnets">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="icheck-primary d-inline">
|
||||
<input type="checkbox" id="_enabled">
|
||||
|
@ -266,6 +270,18 @@ Wireguard Clients
|
|||
'placeholderColor': '#666666'
|
||||
});
|
||||
|
||||
// PrivateSubnet tag input
|
||||
modal.find("#_client_private_subnets").tagsInput({
|
||||
'width': '100%',
|
||||
'height': '75%',
|
||||
'interactive': true,
|
||||
'defaultText': 'Add More',
|
||||
'removeWithBackspace': true,
|
||||
'minChars': 0,
|
||||
'maxChars': 18,
|
||||
'placeholderColor': '#666666'
|
||||
});
|
||||
|
||||
// update client modal data
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -291,6 +307,11 @@ Wireguard Clients
|
|||
modal.find("#_client_allowed_ips").addTag(obj);
|
||||
});
|
||||
|
||||
modal.find("#_client_private_subnets").importTags('');
|
||||
client.private_subnets.forEach(function (obj) {
|
||||
modal.find("#_client_private_subnets").addTag(obj);
|
||||
});
|
||||
|
||||
modal.find("#_enabled").prop("checked", client.enabled);
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
|
@ -306,15 +327,16 @@ Wireguard Clients
|
|||
const client_id = $("#_client_id").val();
|
||||
const name = $("#_client_name").val();
|
||||
const email = $("#_client_email").val();
|
||||
const allocated_ips = $("#_client_allocated_ips").val().split(",");
|
||||
const allocated_ips = $("#1").val().split(",");
|
||||
const allowed_ips = $("#_client_allowed_ips").val().split(",");
|
||||
const private_subnets = $("#_client_private_subnets").val().split(",");
|
||||
let enabled = false;
|
||||
|
||||
if ($("#_enabled").is(':checked')){
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
const data = {"id": client_id, "name": name, "email": email, "allocated_ips": allocated_ips,
|
||||
const data = {"id": client_id, "name": name, "email": email, "allocated_ips": allocated_ips, "private_subnets": private_subnets,
|
||||
"allowed_ips": allowed_ips, "enabled": enabled};
|
||||
|
||||
$.ajax({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue