You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haproxy-wi/inc/overview.js

106 lines
2.6 KiB

7 years ago
var cur_url = window.location.href.split('/').pop();
cur_url = cur_url.split('?');
function ajaxActionServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_hap: action,
serv: id,
token: $('#token').val()
7 years ago
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
setTimeout(showOverview, 2000)
}
},
error: function(){
alert(w.data_error);
}
} );
}
function ajaxActionWafServers(action, id) {
var bad_ans = 'Bad config, check please';
$.ajax( {
url: "options.py",
data: {
action_waf: action,
serv: id,
token: $('#token').val()
},
success: function( data ) {
data = data.replace(/\s+/g,' ');
if( data == 'Bad config, check please ' ) {
alert(data);
} else {
setTimeout(showOverviewWaf, 2000)
7 years ago
}
},
error: function(){
alert(w.data_error);
}
} );
}
$( function() {
$('.start').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("start", "hap", id);
7 years ago
});
$('.stop').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("stop", "hap", id);
7 years ago
});
$('.restart').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("restart", "hap", id);
});
$('.start-waf').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("start", "waf", id);
});
$('.stop-waf').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("stop", "waf", id);
});
$('.restart-waf').click(function() {
var id = $(this).attr('id');
confirmAjaxAction("restart", "waf", id);
7 years ago
});
$( "#show-all-users" ).click( function() {
7 years ago
if($( "#show-all-users" ).text() == "Show all") {
$( ".show-users" ).show("fast");
$( "#show-all-users" ).text("Hide");
$( "#show-all-users" ).attr("title", "Hide all users");
} else {
$( ".show-users" ).hide("fast");
$( "#show-all-users" ).attr("title", "Show all users");
$( "#show-all-users" ).text("Show all");
}
});
$('#secIntervals').css('display', 'none');
});
function confirmAjaxAction(action, service, id) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
title: "Are you sure you want "+ action + " " + id + "?",
buttons: {
"Sure": function() {
$( this ).dialog( "close" );
if(service == "hap") {
ajaxActionServers(action, id);
} else if (service == "waf") {
ajaxActionWafServers(action, id)
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}