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/waf.js

137 lines
3.4 KiB

var awesome = "/inc/fontawesome.min.js"
function showOverviewWaf(serv, hostnamea) {
$.getScript('/inc/chart.min.js');
showWafMetrics();
var i;
for (i = 0; i < serv.length; i++) {
showOverviewWafCallBack(serv[i], hostnamea[i])
}
$.getScript('/inc/overview.js');
$.getScript('/inc/waf.js');
}
function showOverviewWafCallBack(serv, hostnamea) {
$.ajax( {
url: "options.py",
data: {
act: "overviewwaf",
serv: serv,
token: $('#token').val()
},
beforeSend: function() {
$("#"+hostnamea).html('<img class="loading_small" src="/inc/images/loading.gif" />');
},
type: "POST",
success: function( data ) {
$("#"+hostnamea).empty();
$("#"+hostnamea).html(data)
$( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio();
$.getScript('/inc/overview.js');
$.getScript(awesome);
}
} );
}
6 years ago
function metrics_waf(name) {
var enable = 0;
if ($('#'+name).is(':checked')) {
enable = '1';
}
name = name.split('metrics')[1]
6 years ago
$.ajax( {
url: "options.py",
data: {
metrics_waf: name,
enable: enable,
token: $('#token').val()
},
5 years ago
type: "POST",
6 years ago
success: function( data ) {
showOverviewWaf(ip, hostnamea);
6 years ago
setTimeout(function() {
$( "#"+name ).parent().parent().removeClass( "update" );
}, 2500 );
}
} );
}
function installWaf(ip1) {
6 years ago
$("#ajax").html('')
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$.ajax( {
url: "options.py",
data: {
installwaf: ip1,
6 years ago
token: $('#token').val()
},
5 years ago
type: "POST",
6 years ago
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
6 years ago
} else if (data.indexOf('success') != '-1' ){
toastr.clear();
toastr.success('WAF service has installed');
showOverviewWaf(ip, hostnamea)
6 years ago
}
}
} );
}
function changeWafMode(id) {
var waf_mode = $('#'+id+' option:selected').val();
var server_hostname = id.split('_')[0];
$.ajax( {
url: "options.py",
data: {
change_waf_mode: waf_mode,
server_hostname: server_hostname,
token: $('#token').val()
},
5 years ago
type: "POST",
success: function( data ) {
toastr.info('Do not forget restart WAF service');
$( '#'+server_hostname+'-select-line' ).addClass( "update", 1000 );
setTimeout(function() {
$( '#'+server_hostname+'-select-line' ).removeClass( "update" );
}, 2500 );
}
} );
}
$( function() {
$( "#waf_rules input" ).change(function() {
var id = $(this).attr('id').split('-');
waf_rules_en(id[1])
});
});
function waf_rules_en(id) {
var enable = 0;
if ($('#rule_id-'+id).is(':checked')) {
enable = '1';
}
var serv = findGetParameter('serv')
console.log(serv)
console.log(id)
console.log(enable)
$.ajax( {
url: "options.py",
data: {
waf_rule_id: id,
waf_en: enable,
serv: serv,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('sed:') != '-1' || data.indexOf('error: ') != '-1' ) {
toastr.error(data);
} else {
toastr.info('Do not forget restart WAF service');
$('#rule-' + id).addClass("update", 1000);
setTimeout(function () {
$('#rule-' + id).removeClass("update");
}, 2500);
}
}
} );
6 years ago
}