This commit is contained in:
Xavier Henner 2019-08-17 13:39:39 +02:00
parent 9a1a609fcd
commit 1926c3bcd6
2 changed files with 11 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -104,20 +104,20 @@ select.interface {
<script type="text/javascript">
last_change="";
$(function() {
ajax("ajax", {"action":"get-remotes"} );
ajax({"action":"get-remotes"} );
});
function ajax(server, action){
function ajax(action){
$.ajax({
type: 'post',
url: 'http://'+server+'/ajax',
url: '/ajax',
data: JSON.stringify(action),
error:function(msg){
console.log( 'Error !: (' + msg.responseText + ')' );
},
success:function(data){
if (action["action"] == "get-remotes") {
refresh(server, data);
refresh(data);
}
}
});
@ -125,28 +125,28 @@ select.interface {
function vpn_restart(pid) {
if(confirm("are you sure you want to restart this session ?")) {
ajax(server, {action: 'restart', params: {session: pid}});
ajax({action: 'restart', params: {session: pid}});
}
}
function vpn_kill(pid) {
if(confirm("are you sure you want to kill this openvpn client ?")) {
ajax(server, {action: 'kill', params: {session: pid}});
ajax({action: 'kill', params: {session: pid}});
}
}
function server_change(pid) {
ajax(server, {action: 'set-remote', params: {server: $('#server_'+pid).val() , session: pid}});
ajax({action: 'set-remote', params: {server: $('#server_'+pid).val() , session: pid}});
}
function auth(pid) {
ajax(server, {action: "auth-user-pass", params:{session: pid,
ajax({action: "auth-user-pass", params:{session: pid,
user:$('#auth_'+pid+'>input.user').val(),
password:$('#auth_'+pid+'>input.pass').val()}});
}
function refresh(server, data) {
setTimeout(function(){ ajax(server, {"action":"get-remotes"} )}, 3000);
function refresh(data) {
setTimeout(function(){ ajax({"action":"get-remotes"} )}, 3000);
if (data["last_change"] == last_change) {
return;
}