mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-09 17:34:25 +03:00
Merge remote-tracking branch 'origin/master' into clients-patch
This commit is contained in:
commit
4608ced961
10 changed files with 98 additions and 38 deletions
|
@ -386,7 +386,7 @@
|
|||
$("#modal_new_client").modal('hide');
|
||||
toastr.success('Created new client successfully');
|
||||
// Update the home page (clients page) after adding successfully
|
||||
if (window.location.pathname === "/") {
|
||||
if (window.location.pathname === "{{.basePath}}/") {
|
||||
populateClient(resp.id);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -68,7 +68,18 @@ Wireguard Clients
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<img id="qr_code" class="w-100" style="image-rendering: pixelated;" src="" alt="QR code" />
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="qr_client_id" name="qr_client_id">
|
||||
<img id="qr_code" class="w-100" style="image-rendering: pixelated;" src="" alt="QR code" />
|
||||
<div class="form-group">
|
||||
<div class="icheck-primary d-inline">
|
||||
<input type="checkbox" id="qr_include_fwmark" onchange="regenerateQRCode()">
|
||||
<label for="qr_include_fwmark">
|
||||
Include FwMark
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
|
@ -387,6 +398,37 @@ Wireguard Clients
|
|||
});
|
||||
});
|
||||
|
||||
// regenerateQRCode function for regenerating QR Code adding/removing some parts of configuration because of compatibility issues with some clients
|
||||
function regenerateQRCode() {
|
||||
const client_id = $("#qr_client_id").val();
|
||||
const QRCodeImg = $("#qr_code");
|
||||
let include_fwmark = false;
|
||||
if ($("#qr_include_fwmark").is(':checked')){
|
||||
include_fwmark = true;
|
||||
}
|
||||
QRCodeImg.hide();
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'GET',
|
||||
url: '{{.basePath}}/api/client/' + client_id,
|
||||
data: {
|
||||
qrCodeIncludeFwMark: include_fwmark
|
||||
},
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
success: function (resp) {
|
||||
const client = resp.Client;
|
||||
|
||||
$(".modal-title").text("Scan QR Code for " + client.name + " profile");
|
||||
QRCodeImg.attr('src', resp.QRCode).show();
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// submitEmailClient function for sending an email to the client with the configuration
|
||||
function submitEmailClient() {
|
||||
const client_id = $("#e_client_id").val();
|
||||
|
@ -467,7 +509,7 @@ Wireguard Clients
|
|||
const formId = $(form).attr('id');
|
||||
if (formId === "frm_edit_client") {
|
||||
submitEditClient();
|
||||
}else if (formId === "frm_email_client") {
|
||||
} else if (formId === "frm_email_client") {
|
||||
submitEmailClient();
|
||||
}
|
||||
}
|
||||
|
@ -500,31 +542,14 @@ Wireguard Clients
|
|||
let modal = $(this);
|
||||
const button = $(event.relatedTarget);
|
||||
const client_id = button.data('clientid');
|
||||
const QRCodeImg = modal.find("#qr_code");
|
||||
QRCodeImg.hide();
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'GET',
|
||||
url: '{{.basePath}}/api/client/' + client_id,
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
success: function (resp) {
|
||||
const client = resp.Client;
|
||||
|
||||
modal.find(".modal-title").text("Scan QR Code for " + client.name + " profile");
|
||||
QRCodeImg.attr('src', resp.QRCode).show();
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
modal.find("#qr_client_id").val(client_id);
|
||||
regenerateQRCode();
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$.validator.setDefaults({
|
||||
submitHandler: function (form) {
|
||||
//submitEditClient();
|
||||
submitHandler(form);
|
||||
}
|
||||
});
|
||||
|
@ -577,6 +602,7 @@ Wireguard Clients
|
|||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
//
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
|
@ -172,7 +172,7 @@ Global Settings
|
|||
}
|
||||
|
||||
function updateEndpointSuggestionIP() {
|
||||
$.getJSON("/api/machine-ips", null, function(data) {
|
||||
$.getJSON("{{.basePath}}/api/machine-ips", null, function(data) {
|
||||
$("#ip_suggestion option").remove();
|
||||
$.each(data, function(index, item) {
|
||||
$("#ip_suggestion").append(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue