2018-08-20 06:39:52 +00:00
$ ( function ( ) {
$ ( "#ajaxwafstatus input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) ;
metrics _waf ( id ) ;
} ) ;
} ) ;
function metrics _waf ( name ) {
var enable = 0 ;
if ( $ ( '#' + name ) . is ( ':checked' ) ) {
enable = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
metrics _waf : name ,
enable : enable ,
token : $ ( '#token' ) . val ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-08-20 06:39:52 +00:00
success : function ( data ) {
showOverviewWaf ( ) ;
setTimeout ( function ( ) {
$ ( "#" + name ) . parent ( ) . parent ( ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
} ) ;
}
function installWaf ( ip ) {
$ ( "#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 : ip ,
token : $ ( '#token' ) . val ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-08-20 06:39:52 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error' ) != '-1' || data . indexOf ( 'Failed' ) != '-1' ) {
2018-08-29 05:05:11 +00:00
$ ( "#ajax" ) . html ( '<div class="alert alert-danger" style="margin: 15px;">' + data + '</data>' ) ;
$ ( '#errorMess' ) . click ( function ( ) {
$ ( '#error' ) . remove ( ) ;
$ ( '.alert-danger' ) . remove ( ) ;
} ) ;
2018-08-20 06:39:52 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
$ ( '.alert-danger' ) . remove ( ) ;
$ ( '.alert-warning' ) . remove ( ) ;
2018-08-21 10:07:05 +00:00
$ ( "#ajax" ) . html ( '<div class="alert alert-success">' + data + '</data>' ) ;
showOverviewWaf ( )
2018-08-20 06:39:52 +00:00
}
}
} ) ;
2019-10-25 07:18:57 +00:00
}
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 ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2019-10-25 07:18:57 +00:00
success : function ( data ) {
alert ( 'Do not forget restart WAF server: ' + server _hostname )
$ ( '#' + server _hostname + '-select-line' ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( '#' + server _hostname + '-select-line' ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
} ) ;
2018-08-20 06:39:52 +00:00
}