Added wireguard service in container

This commit is contained in:
Capdeveloping 2022-06-25 16:33:48 +02:00
parent f43c59c043
commit a13b78b1f5
6 changed files with 212 additions and 89 deletions

View file

@ -64,6 +64,12 @@
<button style="margin-left: 0.5em;" type="button" class="btn btn-outline-danger btn-sm" data-toggle="modal"
data-target="#modal_apply_config"><i class="nav-icon fas fa-check"></i> Apply
Config</button>
<button id="start-wg" style="margin-left: 0.5em;" type="button"
class="btn btn-outline-success btn-sm"><i class="nav-icon fa fa-play"></i> Start</button>
<button id="stop-wg" style="margin-left: 0.5em;" type="button"
class="btn btn-outline-danger btn-sm"><i class="nav-icon fa fa-stop"></i> Stop</button>
<button id="restart-wg" style="margin-left: 0.5em;" type="button"
class="btn btn-outline-success btn-sm"><i class="nav-icon fa fa-retweet"></i> Restart</button>
{{if .baseData.CurrentUser}}
<button onclick="location.href='{{.basePath}}/logout';" style="margin-left: 0.5em;" type="button"
class="btn btn-outline-danger btn-sm"><i class="nav-icon fas fa-sign-out-alt"></i> Logout</button>
@ -246,7 +252,7 @@
</button>
</div>
<div class="modal-body">
<p>Do you want to write config file and restart WireGuard server?</p>
<p>Do you want to write config file?</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@ -489,6 +495,66 @@
});
});
// restart wireguard button event
$(document).ready(function () {
$("#restart-wg").click(function () {
$.ajax({
cache: false,
method: 'GET',
url: '{{.basePath}}/api/restart-wg',
dataType: 'json',
contentType: "application/json",
success: function(data) {
toastr.success('Wireguard restart successfully');
},
error: function(jqXHR, exception) {
const responseJson = jQuery.parseJSON(jqXHR.responseText);
toastr.error(responseJson['message']);
}
});
});
});
// stop wireguard button event
$(document).ready(function () {
$("#stop-wg").click(function () {
$.ajax({
cache: false,
method: 'GET',
url: '{{.basePath}}/api/stop-wg',
dataType: 'json',
contentType: "application/json",
success: function(data) {
toastr.success('Wireguard stopped successfully');
},
error: function(jqXHR, exception) {
const responseJson = jQuery.parseJSON(jqXHR.responseText);
toastr.error(responseJson['message']);
}
});
});
});
// start wireguard button event
$(document).ready(function () {
$("#start-wg").click(function () {
$.ajax({
cache: false,
method: 'GET',
url: '{{.basePath}}/api/start-wg',
dataType: 'json',
contentType: "application/json",
success: function(data) {
toastr.success('Wireguard started successfully');
},
error: function(jqXHR, exception) {
const responseJson = jQuery.parseJSON(jqXHR.responseText);
toastr.error(responseJson['message']);
}
});
});
});
// apply_config_confirm button event
$(document).ready(function () {
$("#apply_config_confirm").click(function () {