From b7ed2960c129b56e8f52d41d02d41011e69a93fc Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 24 Feb 2021 10:32:07 +0000 Subject: [PATCH] Update wg-keygen for server + peer --- app/js/custom.js | 15 +++++++-------- templates/wg/general.php | 2 +- templates/wg/peers.php | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index e2c89ac6..e0bb6134 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -350,16 +350,15 @@ function clearBlocklistStatus() { } // Handler for the wireguard generate key button -function generateWgKey() { - var entity = $('#wg-srvpubkey').attr('name'); - console.log(entity); - $.post('ajax/networking/get_wgkey.php',{'entity':entity },function(data){ +$('.wg-keygen').click(function(){ + var entity = $(this).parent('div').prev('input[type="text"]'); + var updated = entity.attr('name')+"-pubkey-status"; + $.post('ajax/networking/get_wgkey.php',{'entity':entity.attr('name') },function(data){ var jsonData = JSON.parse(data); - console.log(jsonData); - $('#wg-srvpubkey').val(jsonData); - $('#wg-server-pubkey-status').removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); + entity.val(jsonData); + $('#' + updated).removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); }) -} +}) // Static Array method Array.range = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start); diff --git a/templates/wg/general.php b/templates/wg/general.php index 3be32e45..5f5417b1 100644 --- a/templates/wg/general.php +++ b/templates/wg/general.php @@ -27,7 +27,7 @@
- +
diff --git a/templates/wg/peers.php b/templates/wg/peers.php index 2b70680a..e2ff5c6f 100644 --- a/templates/wg/peers.php +++ b/templates/wg/peers.php @@ -41,8 +41,8 @@
- - + +