2018-04-17 20:06:18 +00:00
var awesome = "/inc/fontawesome.min.js"
2018-04-16 07:01:44 +00:00
$ ( function ( ) {
2023-02-13 14:45:45 +00:00
var add _word = $ ( '#translate' ) . attr ( 'data-add' ) ;
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2022-05-05 18:26:14 +00:00
$ ( "#backup_tabs" ) . tabs ( ) ;
2018-04-30 06:04:21 +00:00
$ ( '#install' ) . click ( function ( ) {
$ ( "#ajax" ) . html ( '' )
2018-07-17 03:21:08 +00:00
var syn _flood = 0 ;
2021-10-04 07:40:59 +00:00
var docker = 0 ;
2018-07-17 03:21:08 +00:00
if ( $ ( '#syn_flood' ) . is ( ':checked' ) ) {
syn _flood = '1' ;
}
2021-10-04 07:40:59 +00:00
if ( $ ( '#haproxy_docker' ) . is ( ':checked' ) ) {
docker = '1' ;
}
if ( $ ( '#haproxyaddserv' ) . val ( ) == '------' || $ ( '#haproxyaddserv' ) . val ( ) === null ) {
2023-04-02 16:58:55 +00:00
var select _server = $ ( '#translate' ) . attr ( 'data-select_server' ) ;
toastr . warning ( select _server ) ;
2021-10-04 07:40:59 +00:00
return false
}
2020-04-06 16:38:58 +00:00
$ ( "#ajax" ) . html ( wait _mess ) ;
2018-04-30 06:04:21 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
haproxyaddserv : $ ( '#haproxyaddserv' ) . val ( ) ,
2018-07-17 03:21:08 +00:00
syn _flood : syn _flood ,
2019-10-14 21:41:21 +00:00
hapver : $ ( '#hapver option:selected' ) . val ( ) ,
2021-10-04 07:40:59 +00:00
docker : docker ,
2018-06-01 12:27:58 +00:00
token : $ ( '#token' ) . val ( )
2018-04-30 06:04:21 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2018-04-30 06:04:21 +00:00
data = data . replace ( /\s+/g , ' ' ) ;
2020-11-02 17:01:08 +00:00
$ ( "#ajax" ) . html ( '' )
2021-08-24 10:25:34 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2018-04-30 06:04:21 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . remove ( ) ;
toastr . success ( data ) ;
2021-01-09 15:42:08 +00:00
$ ( "#haproxyaddserv" ) . trigger ( "selectmenuchange" ) ;
2019-09-15 11:51:09 +00:00
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . remove ( ) ;
toastr . info ( data ) ;
2019-11-06 15:15:41 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . remove ( ) ;
toastr . info ( data ) ;
2019-09-15 11:51:09 +00:00
}
2018-04-30 06:04:21 +00:00
}
2022-04-08 18:08:31 +00:00
} ) ;
} ) ;
2020-02-05 08:15:57 +00:00
$ ( '#nginx_install' ) . click ( function ( ) {
2023-01-03 07:54:03 +00:00
installService ( 'nginx' ) ;
2023-01-02 20:01:20 +00:00
} ) ;
$ ( '#apache_install' ) . click ( function ( ) {
installService ( 'apache' ) ;
2022-04-08 18:08:31 +00:00
} ) ;
2020-04-06 16:38:58 +00:00
$ ( '#grafna_install' ) . click ( function ( ) {
2020-11-02 17:01:08 +00:00
$ ( "#ajaxmon" ) . html ( '' ) ;
2020-06-01 16:13:28 +00:00
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
2020-04-06 16:38:58 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
install _grafana : '1' ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2020-04-06 16:38:58 +00:00
data = data . replace ( /\s+/g , ' ' ) ;
2020-11-02 17:01:08 +00:00
$ ( "#ajaxmon" ) . html ( '' ) ;
2022-01-19 14:17:31 +00:00
if ( data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' || data . indexOf ( 'ERROR' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . success ( data ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
}
}
2022-04-08 18:08:31 +00:00
} ) ;
} ) ;
2020-04-06 16:38:58 +00:00
$ ( '#haproxy_exp_install' ) . click ( function ( ) {
2020-06-01 16:13:28 +00:00
$ ( "#ajaxmon" ) . html ( '' )
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
2021-12-20 06:56:56 +00:00
var ext _prom = 0 ;
if ( $ ( '#haproxy_ext_prom' ) . is ( ':checked' ) ) {
ext _prom = '1' ;
}
2020-04-06 16:38:58 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
haproxy _exp _install : $ ( '#haproxy_exp_addserv' ) . val ( ) ,
2021-12-20 06:56:56 +00:00
exporter _v : $ ( '#hapexpver' ) . val ( ) ,
ext _prom : ext _prom ,
2020-04-06 16:38:58 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2020-04-06 16:38:58 +00:00
data = data . replace ( /\s+/g , ' ' ) ;
2020-11-02 17:01:08 +00:00
$ ( "#ajaxmon" ) . html ( '' ) ;
2021-08-24 10:25:34 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . success ( data ) ;
2021-05-02 03:58:22 +00:00
$ ( '#cur_haproxy_exp_ver' ) . text ( 'HAProxy exporter is installed' ) ;
2021-01-09 15:42:08 +00:00
$ ( "#haproxy_exp_addserv" ) . trigger ( "selectmenuchange" ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
}
}
2022-04-08 18:08:31 +00:00
} ) ;
} ) ;
2020-04-06 16:38:58 +00:00
$ ( '#nginx_exp_install' ) . click ( function ( ) {
2020-06-01 16:13:28 +00:00
$ ( "#ajaxmon" ) . html ( '' )
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
2021-12-20 06:56:56 +00:00
var ext _prom = 0 ;
2021-12-27 09:11:19 +00:00
if ( $ ( '#nginx_ext_prom' ) . is ( ':checked' ) ) {
2021-12-20 06:56:56 +00:00
ext _prom = '1' ;
}
2020-04-06 16:38:58 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2022-10-17 10:22:58 +00:00
nginx _exp _install : 1 ,
serv : $ ( '#nginx_exp_addserv' ) . val ( ) ,
2021-12-20 06:56:56 +00:00
exporter _v : $ ( '#nginxexpver' ) . val ( ) ,
ext _prom : ext _prom ,
2020-04-06 16:38:58 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2020-04-06 16:38:58 +00:00
data = data . replace ( /\s+/g , ' ' ) ;
2020-11-02 17:01:08 +00:00
$ ( "#ajaxmon" ) . html ( '' ) ;
2021-08-24 10:25:34 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2022-11-21 08:46:24 +00:00
toastr . success ( data ) ;
2022-10-17 10:22:58 +00:00
$ ( '#cur_nginx_exp_ver' ) . text ( 'NGINX exporter is installed' ) ;
2021-01-09 15:42:08 +00:00
$ ( "#nginx_exp_addserv" ) . trigger ( "selectmenuchange" ) ;
2020-04-06 16:38:58 +00:00
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . info ( data ) ;
2020-04-06 16:38:58 +00:00
}
}
2022-04-08 18:08:31 +00:00
} ) ;
2021-05-02 03:58:22 +00:00
} ) ;
2022-10-17 10:22:58 +00:00
$ ( '#apache_exp_install' ) . click ( function ( ) {
$ ( "#ajaxmon" ) . html ( '' )
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
var ext _prom = 0 ;
if ( $ ( '#apache_ext_prom' ) . is ( ':checked' ) ) {
ext _prom = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
apache _exp _install : 1 ,
serv : $ ( '#apache_exp_addserv' ) . val ( ) ,
exporter _v : $ ( '#apacheexpver' ) . val ( ) ,
ext _prom : ext _prom ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
$ ( "#ajaxmon" ) . html ( '' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2022-10-17 10:22:58 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data ) ;
$ ( '#cur_apache_exp_ver' ) . text ( 'Apache exporter is installed' ) ;
$ ( "#apache_exp_addserv" ) . trigger ( "selectmenuchange" ) ;
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else {
toastr . clear ( ) ;
toastr . info ( data ) ;
}
}
} ) ;
} ) ;
2023-01-18 07:37:23 +00:00
$ ( '#keepalived_exp_install' ) . click ( function ( ) {
$ ( "#ajaxmon" ) . html ( '' )
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
var ext _prom = 0 ;
if ( $ ( '#keepalived_ext_prom' ) . is ( ':checked' ) ) {
ext _prom = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
keepalived _exp _install : $ ( '#keepalived_exp_addserv' ) . val ( ) ,
exporter _v : $ ( '#keepalivedexpver' ) . val ( ) ,
ext _prom : ext _prom ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
$ ( "#ajaxmon" ) . html ( '' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data ) ;
$ ( '#cur_keepalived_exp_ver' ) . text ( 'Keepalived exporter is installed' ) ;
$ ( "#keepalived_exp_addserv" ) . trigger ( "selectmenuchange" ) ;
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else {
toastr . clear ( ) ;
toastr . info ( data ) ;
}
}
} ) ;
} ) ;
2021-05-02 03:58:22 +00:00
$ ( '#node_exp_install' ) . click ( function ( ) {
$ ( "#ajaxmon" ) . html ( '' )
$ ( "#ajaxmon" ) . html ( wait _mess ) ;
2021-12-20 06:56:56 +00:00
var ext _prom = 0 ;
2021-12-27 09:11:19 +00:00
if ( $ ( '#node_ext_prom' ) . is ( ':checked' ) ) {
2021-12-20 06:56:56 +00:00
ext _prom = '1' ;
}
2021-05-02 03:58:22 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
node _exp _install : $ ( '#node_exp_addserv' ) . val ( ) ,
2021-12-20 06:56:56 +00:00
exporter _v : $ ( '#nodeexpver' ) . val ( ) ,
ext _prom : ext _prom ,
2021-05-02 03:58:22 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
$ ( "#ajaxmon" ) . html ( '' ) ;
2021-08-24 10:25:34 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2021-05-02 03:58:22 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data ) ;
$ ( '#cur_node_exp_ver' ) . text ( 'Node exporter is installed' ) ;
$ ( "#node_exp_addserv" ) . trigger ( "selectmenuchange" ) ;
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else {
toastr . clear ( ) ;
toastr . info ( data ) ;
}
}
} ) ;
} ) ;
2020-04-16 13:30:51 +00:00
$ ( "#haproxyaddserv" ) . on ( 'selectmenuchange' , function ( ) {
2023-01-02 20:01:20 +00:00
showServiceVersion ( 'haproxy' ) ;
2020-04-16 13:30:51 +00:00
} ) ;
$ ( "#nginxaddserv" ) . on ( 'selectmenuchange' , function ( ) {
2023-01-02 20:01:20 +00:00
showServiceVersion ( 'nginx' ) ;
} ) ;
$ ( "#apacheaddserv" ) . on ( 'selectmenuchange' , function ( ) {
showServiceVersion ( 'apache' ) ;
2020-04-16 13:30:51 +00:00
} ) ;
$ ( "#haproxy_exp_addserv" ) . on ( 'selectmenuchange' , function ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _exporter _v : 'haproxy_exporter' ,
serv : $ ( '#haproxy_exp_addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2020-04-16 13:30:51 +00:00
data = data . replace ( /^\s+|\s+$/g , '' ) ;
2021-12-20 06:56:56 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
2022-10-18 16:26:20 +00:00
} else if ( data == 'no' || data == '' || data . indexOf ( 'No' ) != '-1' ) {
2021-12-20 06:56:56 +00:00
$ ( '#cur_haproxy_exp_ver' ) . text ( 'HAProxy exporter has been not installed' ) ;
2020-04-16 13:30:51 +00:00
} else {
2021-12-20 06:56:56 +00:00
$ ( '#cur_haproxy_exp_ver' ) . text ( data ) ;
2020-04-16 13:30:51 +00:00
}
}
} ) ;
} ) ;
$ ( "#nginx_exp_addserv" ) . on ( 'selectmenuchange' , function ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _exporter _v : 'nginx_exporter' ,
serv : $ ( '#nginx_exp_addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2022-04-08 18:08:31 +00:00
success : function ( data ) {
2020-04-16 13:30:51 +00:00
data = data . replace ( /^\s+|\s+$/g , '' ) ;
2021-12-20 06:56:56 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
2022-10-18 16:26:20 +00:00
} else if ( data == 'no' || data == '' || data . indexOf ( 'No' ) != '-1' ) {
2022-10-17 10:22:58 +00:00
$ ( '#cur_nginx_exp_ver' ) . text ( 'NGINX exporter has not been installed' ) ;
2020-04-16 13:30:51 +00:00
} else {
2021-12-20 06:56:56 +00:00
$ ( '#cur_nginx_exp_ver' ) . text ( data ) ;
2021-05-02 03:58:22 +00:00
}
}
} ) ;
} ) ;
2022-10-17 10:22:58 +00:00
$ ( "#apache_exp_addserv" ) . on ( 'selectmenuchange' , function ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _exporter _v : 'apache_exporter' ,
serv : $ ( '#apache_exp_addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
2022-10-18 16:26:20 +00:00
} else if ( data == 'no' || data == '' || data . indexOf ( 'No' ) != '-1' ) {
2022-10-17 10:22:58 +00:00
$ ( '#cur_apache_exp_ver' ) . text ( 'Apache exporter has not been installed' ) ;
} else {
$ ( '#cur_apache_exp_ver' ) . text ( data ) ;
}
}
} ) ;
} ) ;
2023-01-18 07:37:23 +00:00
$ ( "#keepalived_exp_addserv" ) . on ( 'selectmenuchange' , function ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _exporter _v : 'keepalived_exporter' ,
serv : $ ( '#keepalived_exp_addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
} else if ( data . indexOf ( 'keepalived_exporter.service' ) != '-1' ) {
$ ( '#cur_keepalived_exp_ver' ) . text ( 'Keepalived exporter has been installed' ) ;
} else if ( data == 'no' || data == '' || data . indexOf ( 'No' ) != '-1' ) {
$ ( '#cur_keepalived_exp_ver' ) . text ( 'Keepalived exporter has not been installed' ) ;
} else {
$ ( '#cur_keepalived_exp_ver' ) . text ( data ) ;
}
}
} ) ;
} ) ;
2021-05-02 03:58:22 +00:00
$ ( "#node_exp_addserv" ) . on ( 'selectmenuchange' , function ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _exporter _v : 'node_exporter' ,
serv : $ ( '#node_exp_addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
2022-04-08 18:08:31 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2021-12-20 06:56:56 +00:00
toastr . clear ( ) ;
toastr . error ( data ) ;
2022-04-08 18:08:31 +00:00
} else if ( data == 'no' || data . indexOf ( 'command' ) != '-1' || data == '' ) {
2021-12-20 06:56:56 +00:00
$ ( '#cur_node_exp_ver' ) . text ( 'Node exporter has not been installed' ) ;
2021-05-02 03:58:22 +00:00
} else {
2021-12-20 06:56:56 +00:00
$ ( '#cur_node_exp_ver' ) . text ( data ) ;
2020-04-16 13:30:51 +00:00
}
}
} ) ;
} ) ;
2020-08-07 15:14:59 +00:00
$ ( '#add-group-button' ) . click ( function ( ) {
addGroupDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var group _tabel _title = $ ( "#group-add-table-overview" ) . attr ( 'title' ) ;
2020-08-07 15:14:59 +00:00
var addGroupDialog = $ ( "#group-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : group _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : {
"Add" : function ( ) {
addGroup ( this ) ;
2018-07-25 05:25:27 +00:00
} ,
2020-08-07 15:14:59 +00:00
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
}
2018-07-25 05:25:27 +00:00
} ) ;
2018-04-16 07:01:44 +00:00
$ ( '#add-user-button' ) . click ( function ( ) {
2018-10-04 04:07:32 +00:00
addUserDialog . dialog ( 'open' ) ;
2018-04-16 07:01:44 +00:00
} ) ;
2023-02-13 14:45:45 +00:00
var user _tabel _title = $ ( "#user-add-table-overview" ) . attr ( 'title' ) ;
var add _word = $ ( '#translate' ) . attr ( 'data-add' ) ;
var canerl _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2018-10-04 04:07:32 +00:00
var addUserDialog = $ ( "#user-add-table" ) . dialog ( {
2020-08-07 15:14:59 +00:00
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : user _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : add _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
addUser ( this ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
2018-10-04 04:07:32 +00:00
}
2023-02-13 14:45:45 +00:00
} ]
2020-08-07 15:14:59 +00:00
} ) ;
$ ( '#add-server-button' ) . click ( function ( ) {
addServerDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var server _tabel _title = $ ( "#server-add-table-overview" ) . attr ( 'title' ) ;
2018-10-04 04:07:32 +00:00
var addServerDialog = $ ( "#server-add-table" ) . dialog ( {
2020-08-07 15:14:59 +00:00
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : server _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : add _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
addServer ( this ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
2018-10-03 10:14:57 +00:00
}
2023-02-13 14:45:45 +00:00
} ]
2018-04-16 07:01:44 +00:00
} ) ;
2018-06-24 09:31:28 +00:00
$ ( '#add-ssh-button' ) . click ( function ( ) {
2020-08-07 15:14:59 +00:00
addCredsDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var ssh _tabel _title = $ ( "#ssh-add-table-overview" ) . attr ( 'title' ) ;
2020-08-07 15:14:59 +00:00
var addCredsDialog = $ ( "#ssh-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : ssh _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : add _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
addCreds ( this ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
2023-02-13 14:45:45 +00:00
} ]
2018-06-24 09:31:28 +00:00
} ) ;
2018-07-25 05:25:27 +00:00
$ ( '#add-telegram-button' ) . click ( function ( ) {
2020-08-07 15:14:59 +00:00
addTelegramDialog . dialog ( 'open' ) ;
2018-07-25 05:25:27 +00:00
} ) ;
2021-04-17 17:38:08 +00:00
$ ( '#add-slack-button' ) . click ( function ( ) {
addSlackDialog . dialog ( 'open' ) ;
} ) ;
2023-04-15 21:26:54 +00:00
$ ( '#add-pd-button' ) . click ( function ( ) {
addPDDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var telegram _tabel _title = $ ( "#telegram-add-table-overview" ) . attr ( 'title' ) ;
2020-08-07 15:14:59 +00:00
var addTelegramDialog = $ ( "#telegram-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : telegram _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : add _word ,
click : function ( ) {
2023-04-15 21:26:54 +00:00
addRecevier ( this , 'telegram' ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2020-08-07 15:14:59 +00:00
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
2020-01-11 21:16:27 +00:00
}
2023-02-13 14:45:45 +00:00
} ]
2020-08-07 15:14:59 +00:00
} ) ;
2023-02-13 14:45:45 +00:00
var slack _tabel _title = $ ( "#slack-add-table-overview" ) . attr ( 'title' ) ;
2021-04-17 17:38:08 +00:00
var addSlackDialog = $ ( "#slack-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : slack _tabel _title ,
2021-04-17 17:38:08 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : add _word ,
click : function ( ) {
2023-04-15 21:26:54 +00:00
addRecevier ( this , 'slack' ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
} ]
} ) ;
var pd _tabel _title = $ ( "#pd-add-table-overview" ) . attr ( 'title' ) ;
var addPDDialog = $ ( "#pd-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
title : pd _tabel _title ,
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : [ {
text : add _word ,
click : function ( ) {
addRecevier ( this , 'pd' ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2021-04-17 17:38:08 +00:00
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
2023-02-13 14:45:45 +00:00
} ]
2021-04-17 17:38:08 +00:00
} ) ;
2020-01-11 21:16:27 +00:00
$ ( '#add-backup-button' ) . click ( function ( ) {
2020-08-07 15:14:59 +00:00
addBackupDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var backup _tabel _title = $ ( "#backup-add-table-overview" ) . attr ( 'title' ) ;
2020-08-07 15:14:59 +00:00
var addBackupDialog = $ ( "#backup-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : backup _tabel _title ,
2020-08-07 15:14:59 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : {
"Add" : function ( ) {
addBackup ( this ) ;
} ,
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
}
} ) ;
2023-01-03 07:54:03 +00:00
$ ( '#add-backup-s3-button' ) . click ( function ( ) {
addBackupDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var s3 _backup _tabel _title = $ ( "#s3-backup-add-table-overview" ) . attr ( 'title' ) ;
2023-01-03 07:54:03 +00:00
var addS3BackupDialog = $ ( "#s3-backup-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : s3 _backup _tabel _title ,
2023-01-03 07:54:03 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : {
"Add" : function ( ) {
addS3Backup ( this ) ;
} ,
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
}
} ) ;
2022-05-05 18:26:14 +00:00
$ ( '#add-git-button' ) . click ( function ( ) {
addGitDialog . dialog ( 'open' ) ;
} ) ;
2023-02-13 14:45:45 +00:00
var git _tabel _title = $ ( "#git-add-table-overview" ) . attr ( 'title' ) ;
2022-05-05 18:26:14 +00:00
var addGitDialog = $ ( "#git-add-table" ) . dialog ( {
autoOpen : false ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : git _tabel _title ,
2022-05-05 18:26:14 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : {
"Add" : function ( ) {
addGit ( this ) ;
} ,
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
}
} ) ;
$ ( '#git-init' ) . click ( function ( ) {
if ( $ ( '#git-init' ) . is ( ':checked' ) ) {
$ ( '.git-init-params' ) . show ( ) ;
} else {
$ ( '.git-init-params' ) . hide ( ) ;
}
} ) ;
2018-04-20 04:39:39 +00:00
$ ( "#ajax-users input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateUser ( id [ 1 ] )
} ) ;
$ ( "#ajax-users select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateUser ( id [ 1 ] )
} ) ;
$ ( "#ajax-group input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateGroup ( id [ 1 ] )
} ) ;
$ ( "#ajax-servers input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServer ( id [ 1 ] )
} ) ;
$ ( "#ajax-servers select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServer ( id [ 1 ] )
} ) ;
2018-05-07 13:24:22 +00:00
$ ( "#ssh_enable_table input" ) . change ( function ( ) {
2018-06-24 09:31:28 +00:00
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateSSH ( id [ 1 ] )
sshKeyEnableShow ( id [ 1 ] )
2018-05-07 13:24:22 +00:00
} ) ;
2018-06-28 05:55:07 +00:00
$ ( "#ssh_enable_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateSSH ( id [ 1 ] )
sshKeyEnableShow ( id [ 1 ] )
} ) ;
2022-06-15 07:34:20 +00:00
$ ( "#settings select" ) . on ( 'select2:select' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) ;
var val = $ ( this ) . val ( ) ;
updateSettings ( id , val ) ;
updateSettings ( id [ 1 ] )
} ) ;
2018-08-11 14:47:47 +00:00
$ ( "#settings input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) ;
var val = $ ( this ) . val ( ) ;
2022-06-15 07:34:20 +00:00
if ( $ ( '#' + id ) . is ( ':checkbox' ) ) {
if ( $ ( '#' + id ) . is ( ':checked' ) ) {
val = 1 ;
} else {
val = 0 ;
}
}
2018-08-11 14:47:47 +00:00
updateSettings ( id , val ) ;
} ) ;
2018-06-24 09:31:28 +00:00
$ ( '#new-ssh_enable' ) . click ( function ( ) {
if ( $ ( '#new-ssh_enable' ) . is ( ':checked' ) ) {
2018-05-07 13:24:22 +00:00
$ ( '#ssh_pass' ) . css ( 'display' , 'none' ) ;
} else {
$ ( '#ssh_pass' ) . css ( 'display' , 'block' ) ;
}
} ) ;
2018-06-24 09:31:28 +00:00
if ( $ ( '#new-ssh_enable' ) . is ( ':checked' ) ) {
2018-05-07 13:24:22 +00:00
$ ( '#ssh_pass' ) . css ( 'display' , 'none' ) ;
} else {
$ ( '#ssh_pass' ) . css ( 'display' , 'block' ) ;
}
2023-04-15 21:26:54 +00:00
$ ( "#checker_telegram_table input" ) . change ( function ( ) {
2018-07-25 05:25:27 +00:00
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
2023-04-15 21:26:54 +00:00
updateReceiver ( id [ 2 ] , 'telegram' )
2018-07-25 05:25:27 +00:00
} ) ;
2023-04-15 21:26:54 +00:00
$ ( "#checker_telegram_table select" ) . on ( 'selectmenuchange' , function ( ) {
2018-07-25 05:25:27 +00:00
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
2023-04-15 21:26:54 +00:00
updateReceiver ( id [ 1 ] , 'telegram' )
2018-07-25 05:25:27 +00:00
} ) ;
2021-04-17 17:38:08 +00:00
$ ( "#checker_slack_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
2023-04-15 21:26:54 +00:00
updateReceiver ( id [ 2 ] , 'slack' )
2021-04-17 17:38:08 +00:00
} ) ;
$ ( "#checker_slack_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
2023-04-15 21:26:54 +00:00
updateReceiver ( id [ 1 ] , 'slack' )
} ) ;
$ ( "#checker_pd_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateReceiver ( id [ 2 ] , 'pd' )
} ) ;
$ ( "#checker_pd_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateReceiver ( id [ 1 ] , 'pd' )
2021-04-17 17:38:08 +00:00
} ) ;
2020-01-11 21:16:27 +00:00
$ ( "#ajax-backup-table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateBackup ( id [ 2 ] )
} ) ;
$ ( "#ajax-backup-table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateBackup ( id [ 2 ] )
} ) ;
2021-06-02 07:28:07 +00:00
$ ( "#scan_server" ) . change ( function ( ) {
if ( $ ( '#scan_server' ) . is ( ':checked' ) ) {
$ ( '.services_for_scan' ) . hide ( ) ;
} else {
$ ( '.services_for_scan' ) . show ( ) ;
}
} ) ;
2022-06-15 07:34:20 +00:00
$ ( "#checker_haproxy_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateHaproxyCheckerSettings ( id [ 1 ] )
} ) ;
$ ( "#checker_haproxy_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateHaproxyCheckerSettings ( id [ 1 ] )
} ) ;
$ ( "#checker_nginx_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServiceCheckerSettings ( id [ 1 ] , 'nginx' )
} ) ;
$ ( "#checker_nginx_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServiceCheckerSettings ( id [ 1 ] , 'nginx' )
} ) ;
$ ( "#checker_apache_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServiceCheckerSettings ( id [ 1 ] , 'apache' )
} ) ;
$ ( "#checker_apache_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateServiceCheckerSettings ( id [ 1 ] , 'apache' )
} ) ;
$ ( "#checker_keepalived_table select" ) . on ( 'selectmenuchange' , function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateKeepalivedCheckerSettings ( id [ 1 ] )
} ) ;
$ ( "#checker_keepalived_table input" ) . change ( function ( ) {
var id = $ ( this ) . attr ( 'id' ) . split ( '-' ) ;
updateKeepalivedCheckerSettings ( id [ 1 ] )
} ) ;
2018-11-08 08:49:03 +00:00
$ ( '#search_ldap_user' ) . click ( function ( ) {
var valid = true ;
2020-07-30 17:28:58 +00:00
toastr . clear ( ) ;
2022-04-27 18:10:26 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#new-username' ) ) ;
2018-11-08 08:49:03 +00:00
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#new-username' ) , "user name" , 1 ) ;
user = $ ( '#new-username' ) . val ( )
if ( valid ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _ldap _email : $ ( '#new-username' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-11-08 08:49:03 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-11-08 08:49:03 +00:00
$ ( '#new-email' ) . val ( '' ) ;
2022-04-08 18:08:31 +00:00
$ ( '#new-password' ) . attr ( 'readonly' , false ) ;
$ ( '#new-password' ) . val ( '' ) ;
2018-11-08 08:49:03 +00:00
} else {
var json = $ . parseJSON ( data ) ;
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2023-02-13 14:45:45 +00:00
if ( ! $ ( '#new-username' ) . val ( ) . includes ( '@' ) ) {
$ ( '#new-username' ) . val ( user + '@' + json [ 1 ] ) ;
}
2018-11-08 08:49:03 +00:00
$ ( '#new-email' ) . val ( json [ 0 ] ) ;
2022-04-08 18:08:31 +00:00
$ ( '#new-password' ) . val ( 'aduser' ) ;
$ ( '#new-password' ) . attr ( 'readonly' , true ) ;
}
2018-11-08 08:49:03 +00:00
}
} ) ;
clearTips ( ) ;
}
} ) ;
2020-12-15 06:34:02 +00:00
$ ( "#geoipserv" ) . on ( 'selectmenuchange' , function ( ) {
2022-10-07 14:40:45 +00:00
if ( $ ( '#geoip_service option:selected' ) . val ( ) != '------' ) {
checkGeoipInstallation ( ) ;
}
} ) ;
$ ( "#geoip_service" ) . on ( 'selectmenuchange' , function ( ) {
if ( $ ( '#geoipserv option:selected' ) . val ( ) != '------' ) {
checkGeoipInstallation ( ) ;
}
2020-12-15 06:34:02 +00:00
} ) ;
2021-01-09 15:42:08 +00:00
$ ( "#geoip_install" ) . click ( function ( ) {
var updating _geoip = 0 ;
if ( $ ( '#updating_geoip' ) . is ( ':checked' ) ) {
updating _geoip = '1' ;
}
$ ( "#ajax-geoip" ) . html ( wait _mess ) ;
$ . ajax ( {
url : "options.py" ,
data : {
geoip _install : $ ( '#geoipserv option:selected' ) . val ( ) ,
2022-10-07 14:40:45 +00:00
geoip _service : $ ( '#geoip_service option:selected' ) . val ( ) ,
2021-01-09 15:42:08 +00:00
geoip _update : updating _geoip ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
$ ( "#ajax-geoip" ) . html ( '' )
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' ) {
toastr . clear ( ) ;
2022-11-20 07:48:15 +00:00
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
2021-01-09 15:42:08 +00:00
} else if ( data . indexOf ( 'success:' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data ) ;
2022-10-09 11:40:36 +00:00
$ ( "#geoip_service" ) . trigger ( "selectmenuchange" ) ;
2021-01-09 15:42:08 +00:00
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else {
toastr . clear ( ) ;
toastr . info ( data ) ;
}
}
} ) ;
} ) ;
2021-02-20 07:47:33 +00:00
$ ( "#tabs ul li" ) . click ( function ( ) {
var activeTab = $ ( this ) . find ( "a" ) . attr ( "href" ) ;
2022-06-15 07:34:20 +00:00
var activeTabClass = activeTab . replace ( '#' , '' ) ;
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . children ( "." + activeTabClass ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( "." + activeTabClass ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
} ) ;
2021-02-20 07:47:33 +00:00
if ( activeTab == '#services' ) {
loadServices ( ) ;
} else if ( activeTab == '#updatehapwi' ) {
loadupdatehapwi ( ) ;
} else if ( activeTab == '#checker' ) {
loadchecker ( ) ;
} else if ( activeTab == '#openvpn' ) {
loadopenvpn ( ) ;
}
} ) ;
2022-06-15 07:34:20 +00:00
$ ( "#checker_tabs ul li" ) . click ( function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . children ( ".checker" ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( ".checker" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
} ) ;
} ) ;
$ ( "#backup_tabs ul li" ) . click ( function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . children ( ".backup" ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( ".backup" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
} ) ;
} ) ;
2018-04-16 07:01:44 +00:00
} ) ;
2021-02-20 07:47:33 +00:00
window . onload = function ( ) {
2022-05-17 09:34:52 +00:00
$ ( '#tabs' ) . tabs ( ) ;
2021-02-20 07:47:33 +00:00
var activeTabIdx = $ ( '#tabs' ) . tabs ( 'option' , 'active' )
if ( cur _url [ 0 ] . split ( '#' ) [ 0 ] == 'users.py' ) {
if ( activeTabIdx == 7 ) {
loadServices ( ) ;
} else if ( activeTabIdx == 8 ) {
loadupdatehapwi ( ) ;
} else if ( activeTabIdx == 4 ) {
loadchecker ( ) ;
} else if ( activeTabIdx == 5 ) {
loadopenvpn ( ) ;
}
} else if ( cur _url [ 0 ] . split ( '#' ) [ 0 ] == 'servers.py' ) {
if ( activeTabIdx == 3 ) {
loadchecker ( ) ;
}
}
}
2020-08-07 15:14:59 +00:00
function common _ajax _action _after _success ( dialog _id , new _group , ajax _append _id , data ) {
toastr . clear ( ) ;
$ ( "#" + ajax _append _id ) . append ( data ) ;
$ ( "." + new _group ) . addClass ( "update" , 1000 ) ;
$ . getScript ( awesome ) ;
clearTips ( ) ;
$ ( dialog _id ) . dialog ( "close" ) ;
setTimeout ( function ( ) {
$ ( "." + new _group ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
function addUser ( dialog _id ) {
2018-10-04 04:07:32 +00:00
var valid = true ;
2020-07-30 17:28:58 +00:00
toastr . clear ( ) ;
2023-05-27 12:26:25 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#new-username' ) ) . add ( $ ( '#new-password' ) ) . add ( $ ( '#new-email' ) )
2018-10-04 04:07:32 +00:00
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#new-username' ) , "user name" , 1 ) ;
valid = valid && checkLength ( $ ( '#new-password' ) , "password" , 1 ) ;
2023-05-27 12:26:25 +00:00
valid = valid && checkLength ( $ ( '#new-email' ) , "Email" , 1 ) ;
2019-01-05 12:36:59 +00:00
var activeuser = 0 ;
if ( $ ( '#activeuser' ) . is ( ':checked' ) ) {
activeuser = '1' ;
}
2018-10-04 04:07:32 +00:00
if ( valid ) {
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-10-04 04:07:32 +00:00
data : {
newuser : "1" ,
newusername : $ ( '#new-username' ) . val ( ) ,
newpassword : $ ( '#new-password' ) . val ( ) ,
newemail : $ ( '#new-email' ) . val ( ) ,
newrole : $ ( '#new-role' ) . val ( ) ,
2019-01-05 12:36:59 +00:00
activeuser : activeuser ,
2020-08-11 09:54:03 +00:00
page : cur _url [ 0 ] . split ( '#' ) [ 0 ] ,
2019-09-27 19:09:49 +00:00
newgroupuser : $ ( '#new-group' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
2018-10-04 04:07:32 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-10-04 04:07:32 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-10-04 04:07:32 +00:00
} else {
2020-05-10 06:17:07 +00:00
var getId = new RegExp ( '[0-9]+' ) ;
var id = data . match ( getId ) ;
2020-08-07 15:14:59 +00:00
common _ajax _action _after _success ( dialog _id , 'user-' + id , 'ajax-users' , data ) ;
2022-04-08 18:08:31 +00:00
}
2018-10-04 04:07:32 +00:00
}
} ) ;
}
}
2020-08-07 15:14:59 +00:00
function addGroup ( dialog _id ) {
toastr . clear ( ) ;
var valid = true ;
allFields = $ ( [ ] ) . add ( $ ( '#new-group-add' ) ) ;
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#new-group-add' ) , "new group name" , 1 ) ;
if ( valid ) {
$ . ajax ( {
url : "options.py" ,
data : {
newgroup : "1" ,
groupname : $ ( '#new-group-add' ) . val ( ) ,
newdesc : $ ( '#new-desc' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
var getId = new RegExp ( '[0-9]+' ) ;
var id = data . match ( getId ) ;
$ ( 'select:regex(id, group)' ) . append ( '<option value=' + id + '>' + $ ( '#new-group-add' ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
common _ajax _action _after _success ( dialog _id , 'newgroup' , 'ajax-group' , data ) ;
}
}
} ) ;
}
}
function addServer ( dialog _id ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( )
2018-10-04 04:07:32 +00:00
var valid = true ;
2018-10-03 10:14:57 +00:00
var servername = $ ( '#new-server-add' ) . val ( ) ;
var newip = $ ( '#new-ip' ) . val ( ) ;
var newservergroup = $ ( '#new-server-group-add' ) . val ( ) ;
var cred = $ ( '#credentials' ) . val ( ) ;
2021-06-02 07:28:07 +00:00
var scan _server = 0 ;
2018-10-03 10:14:57 +00:00
var typeip = 0 ;
var enable = 0 ;
2020-02-06 22:36:58 +00:00
var haproxy = 0 ;
var nginx = 0 ;
2022-04-15 09:49:00 +00:00
var apache = 0 ;
2020-11-18 04:45:34 +00:00
var firewall = 0 ;
2021-06-02 07:28:07 +00:00
if ( $ ( '#scan_server' ) . is ( ':checked' ) ) {
scan _server = '1' ;
}
2018-10-03 10:14:57 +00:00
if ( $ ( '#typeip' ) . is ( ':checked' ) ) {
typeip = '1' ;
}
if ( $ ( '#enable' ) . is ( ':checked' ) ) {
enable = '1' ;
}
2020-02-06 22:36:58 +00:00
if ( $ ( '#haproxy' ) . is ( ':checked' ) ) {
haproxy = '1' ;
}
if ( $ ( '#nginx' ) . is ( ':checked' ) ) {
nginx = '1' ;
}
2022-04-15 09:49:00 +00:00
if ( $ ( '#apache' ) . is ( ':checked' ) ) {
apache = '1' ;
}
2020-11-18 04:45:34 +00:00
if ( $ ( '#firewall' ) . is ( ':checked' ) ) {
firewall = '1' ;
}
2018-10-04 04:07:32 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#new-server-add' ) ) . add ( $ ( '#new-ip' ) ) . add ( $ ( '#new-port' ) )
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#new-server-add' ) , "Hostname" , 1 ) ;
valid = valid && checkLength ( $ ( '#new-ip' ) , "IP" , 1 ) ;
valid = valid && checkLength ( $ ( '#new-port' ) , "Port" , 1 ) ;
2021-06-02 07:28:07 +00:00
if ( cred == null ) {
toastr . error ( 'First select credentials' ) ;
return false ;
}
if ( newservergroup == null ) {
toastr . error ( 'First select a group' ) ;
return false ;
}
2018-10-04 04:07:32 +00:00
if ( valid ) {
2018-10-03 10:14:57 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-10-03 10:14:57 +00:00
data : {
newserver : "1" ,
servername : servername ,
newip : newip ,
newport : $ ( '#new-port' ) . val ( ) ,
newservergroup : newservergroup ,
typeip : typeip ,
2020-02-06 22:36:58 +00:00
haproxy : haproxy ,
nginx : nginx ,
2022-04-15 09:49:00 +00:00
apache : apache ,
2020-11-18 04:45:34 +00:00
firewall : firewall ,
2018-10-03 10:14:57 +00:00
enable : enable ,
slave : $ ( '#slavefor' ) . val ( ) ,
cred : cred ,
2023-04-02 16:58:55 +00:00
page : cur _url ,
2018-11-26 12:55:00 +00:00
desc : $ ( '#desc' ) . val ( ) ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-10-03 10:14:57 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-10-03 10:14:57 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2023-04-02 16:58:55 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-10-03 10:14:57 +00:00
} else {
2020-08-07 15:14:59 +00:00
common _ajax _action _after _success ( dialog _id , 'newserver' , 'ajax-servers' , data ) ;
2018-10-03 10:14:57 +00:00
$ ( "input[type=submit], button" ) . button ( ) ;
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
2018-10-04 04:07:32 +00:00
$ ( ".controlgroup" ) . controlgroup ( ) ;
2018-10-03 10:14:57 +00:00
$ ( "select" ) . selectmenu ( ) ;
2022-05-05 18:26:14 +00:00
var getId = new RegExp ( 'server-[0-9]+' ) ;
var id = data . match ( getId ) + '' ;
id = id . split ( '-' ) . pop ( ) ;
$ ( 'select:regex(id, git-server)' ) . append ( '<option value=' + id + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, backup-server)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, haproxy_exp_addserv)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, nginx_exp_addserv)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2022-10-17 10:22:58 +00:00
$ ( 'select:regex(id, apache_exp_addserv)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2022-05-05 18:26:14 +00:00
$ ( 'select:regex(id, node_exp_addserv)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2023-01-05 08:51:43 +00:00
$ ( 'select:regex(id, geoipserv)' ) . append ( '<option value=' + $ ( '#ip-' + id ) . text ( ) + '>' + $ ( '#hostname-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2023-04-02 16:58:55 +00:00
$ ( 'select:regex(id, haproxyaddserv)' ) . append ( '<option value=' + newip + '>' + servername + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, nginxaddserv)' ) . append ( '<option value=' + newip + '>' + servername + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, apacheaddserv)' ) . append ( '<option value=' + newip + '>' + servername + '</option>' ) . selectmenu ( "refresh" ) ;
after _server _creating ( servername , newip , scan _server ) ;
2018-10-03 10:14:57 +00:00
}
2022-04-08 18:08:31 +00:00
}
2018-10-03 10:14:57 +00:00
} ) ;
}
}
2023-04-02 16:58:55 +00:00
function after _server _creating ( servername , newip , scan _server ) {
$ . ajax ( {
url : "options.py" ,
data : {
act : 'after_adding' ,
servername : servername ,
newip : newip ,
scan _server : scan _server ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'You should install lshw on the server' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
}
}
} ) ;
}
2020-08-07 15:14:59 +00:00
function addCreds ( dialog _id ) {
toastr . clear ( ) ;
var ssh _enable = 0 ;
if ( $ ( '#new-ssh_enable' ) . is ( ':checked' ) ) {
ssh _enable = '1' ;
}
var valid = true ;
allFields = $ ( [ ] ) . add ( $ ( '#new-ssh-add' ) ) . add ( $ ( '#ssh_user' ) )
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#new-ssh-add' ) , "Name" , 1 ) ;
valid = valid && checkLength ( $ ( '#ssh_user' ) , "Credentials" , 1 ) ;
if ( valid ) {
$ . ajax ( {
url : "options.py" ,
data : {
new _ssh : $ ( '#new-ssh-add' ) . val ( ) ,
new _group : $ ( '#new-sshgroup' ) . val ( ) ,
ssh _user : $ ( '#ssh_user' ) . val ( ) ,
ssh _pass : $ ( '#ssh_pass' ) . val ( ) ,
ssh _enable : ssh _enable ,
2020-08-11 09:54:03 +00:00
page : cur _url [ 0 ] . split ( '#' ) [ 0 ] ,
2020-08-07 15:14:59 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
2021-02-03 19:25:37 +00:00
var group _name = getGroupNameById ( $ ( '#new-sshgroup' ) . val ( ) ) ;
2020-08-07 15:14:59 +00:00
var getId = new RegExp ( 'ssh-table-[0-9]+' ) ;
var id = data . match ( getId ) + '' ;
id = id . split ( '-' ) . pop ( ) ;
common _ajax _action _after _success ( dialog _id , 'ssh-table-' + id , 'ssh_enable_table' , data ) ;
$ ( 'select:regex(id, credentials)' ) . append ( '<option value=' + id + '>' + $ ( '#new-ssh-add' ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2021-02-03 19:25:37 +00:00
$ ( 'select:regex(id, ssh-key-name)' ) . append ( '<option value=' + $ ( '#new-ssh-add' ) . val ( ) + '_' + group _name + '>' + $ ( '#new-ssh-add' ) . val ( ) + '_' + group _name + '</option>' ) . selectmenu ( "refresh" ) ;
2020-08-07 15:14:59 +00:00
$ ( "input[type=submit], button" ) . button ( ) ;
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
$ ( "select" ) . selectmenu ( ) ;
}
}
} ) ;
}
}
2021-02-03 19:25:37 +00:00
function getGroupNameById ( group _id ) {
var group _name = ''
$ . ajax ( {
url : "options.py" ,
async : false ,
data : {
get _group _name _by _id : group _id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
group _name = data ;
}
}
} ) ;
return group _name ;
}
2023-04-15 21:26:54 +00:00
function addRecevier ( dialog _id , receiver _name ) {
2020-08-07 15:14:59 +00:00
var valid = true ;
toastr . clear ( ) ;
2023-04-15 21:26:54 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#' + receiver _name + '-token-add' ) ) . add ( $ ( '#' + receiver _name + '-chanel-add' ) ) ;
2020-08-07 15:14:59 +00:00
allFields . removeClass ( "ui-state-error" ) ;
2023-04-15 21:26:54 +00:00
valid = valid && checkLength ( $ ( '#' + receiver _name + '-token-add' ) , "token" , 1 ) ;
valid = valid && checkLength ( $ ( '#' + receiver _name + '-chanel-add' ) , "channel name" , 1 ) ;
2020-08-07 15:14:59 +00:00
if ( valid ) {
toastr . clear ( ) ;
$ . ajax ( {
url : "options.py" ,
data : {
2023-04-15 21:26:54 +00:00
new _receiver : $ ( '#' + receiver _name + '-token-add' ) . val ( ) ,
receiver _name : receiver _name ,
chanel : $ ( '#' + receiver _name + '-chanel-add' ) . val ( ) ,
group _receiver : $ ( '#new-' + receiver _name + '-group-add' ) . val ( ) ,
2020-08-11 09:54:03 +00:00
page : cur _url [ 0 ] . split ( '#' ) [ 0 ] ,
2020-08-07 15:14:59 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
2023-04-15 21:26:54 +00:00
var getId = new RegExp ( receiver _name + '-table-[0-9]+' ) ;
2022-06-15 07:34:20 +00:00
var id = data . match ( getId ) + '' ;
id = id . split ( '-' ) . pop ( ) ;
2023-04-15 21:26:54 +00:00
$ ( 'select:regex(id, ' + receiver _name + '_channel)' ) . append ( '<option value=' + id + '>' + $ ( '#' + receiver _name + '-chanel-add' ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
common _ajax _action _after _success ( dialog _id , 'newgroup' , 'checker_' + receiver _name + '_table' , data ) ;
2021-04-17 17:38:08 +00:00
$ ( "input[type=submit], button" ) . button ( ) ;
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
$ ( "select" ) . selectmenu ( ) ;
}
}
} ) ;
}
}
2020-08-07 15:14:59 +00:00
function addBackup ( dialog _id ) {
2020-01-11 21:16:27 +00:00
var valid = true ;
2020-07-30 17:28:58 +00:00
toastr . clear ( ) ;
2020-01-11 21:16:27 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#backup-server' ) ) . add ( $ ( '#rserver' ) ) . add ( $ ( '#rpath' ) ) . add ( $ ( '#backup-time' ) ) . add ( $ ( '#backup-credentials' ) )
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#backup-server' ) , "backup server " , 1 ) ;
valid = valid && checkLength ( $ ( '#rserver' ) , "remote server" , 1 ) ;
valid = valid && checkLength ( $ ( '#rpath' ) , "remote path" , 1 ) ;
valid = valid && checkLength ( $ ( '#backup-time' ) , "backup time" , 1 ) ;
valid = valid && checkLength ( $ ( '#backup-credentials' ) , "backup credentials" , 1 ) ;
if ( valid ) {
$ . ajax ( {
url : "options.py" ,
data : {
backup : '1' ,
server : $ ( '#backup-server' ) . val ( ) ,
rserver : $ ( '#rserver' ) . val ( ) ,
rpath : $ ( '#rpath' ) . val ( ) ,
type : $ ( '#backup-type' ) . val ( ) ,
time : $ ( '#backup-time' ) . val ( ) ,
cred : $ ( '#backup-credentials' ) . val ( ) ,
description : $ ( '#backup-description' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2020-08-08 06:26:43 +00:00
} else if ( data . indexOf ( 'success: ' ) != '-1' ) {
2020-08-07 15:14:59 +00:00
common _ajax _action _after _success ( dialog _id , 'newbackup' , 'ajax-backup-table' , data ) ;
2020-08-07 17:02:02 +00:00
$ ( "select" ) . selectmenu ( ) ;
2020-08-08 06:26:43 +00:00
} else if ( data . indexOf ( 'info: ' ) != '-1' ) {
2020-08-07 17:02:02 +00:00
toastr . clear ( ) ;
2020-07-26 16:26:04 +00:00
toastr . info ( data ) ;
2020-08-08 06:26:43 +00:00
} else if ( data . indexOf ( 'warning: ' ) != '-1' ) {
toastr . clear ( ) ;
toastr . warning ( data ) ;
}
2020-01-11 21:16:27 +00:00
}
} ) ;
}
}
2022-05-05 18:26:14 +00:00
function addGit ( dialog _id ) {
var valid = true ;
toastr . clear ( ) ;
allFields = $ ( [ ] ) . add ( $ ( '#git-server' ) ) . add ( $ ( '#git-service' ) ) . add ( $ ( '#git-time' ) ) . add ( $ ( '#git-credentials' ) ) . add ( $ ( '#git-branch' ) )
allFields . removeClass ( "ui-state-error" ) ;
valid = valid && checkLength ( $ ( '#git-server' ) , "Server " , 1 ) ;
valid = valid && checkLength ( $ ( '#git-service' ) , "Service" , 1 ) ;
valid = valid && checkLength ( $ ( '#git-credentials' ) , "Credentials" , 1 ) ;
valid = valid && checkLength ( $ ( '#git-branch' ) , "Branch name" , 1 ) ;
var git _init = 0 ;
if ( $ ( '#git-init' ) . is ( ':checked' ) ) {
git _init = '1' ;
}
if ( valid ) {
$ . ajax ( {
url : "options.py" ,
data : {
git _backup : '1' ,
server : $ ( '#git-server' ) . val ( ) ,
git _service : $ ( '#git-service' ) . val ( ) ,
git _init : git _init ,
git _repo : $ ( '#git-repo' ) . val ( ) ,
git _branch : $ ( '#git-branch' ) . val ( ) ,
time : $ ( '#git-time' ) . val ( ) ,
cred : $ ( '#git-credentials' ) . val ( ) ,
description : $ ( '#git-description' ) . val ( ) ,
git _deljob : 0 ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'success: ' ) != '-1' ) {
common _ajax _action _after _success ( dialog _id , 'newgit' , 'ajax-git-table' , data ) ;
$ ( "select" ) . selectmenu ( ) ;
} else if ( data . indexOf ( 'info: ' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else if ( data . indexOf ( 'warning: ' ) != '-1' ) {
toastr . clear ( ) ;
toastr . warning ( data ) ;
}
}
} ) ;
}
}
2018-08-11 14:47:47 +00:00
function updateSettings ( param , val ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-08-11 14:47:47 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-08-11 14:47:47 +00:00
data : {
updatesettings : param ,
2019-09-27 19:09:49 +00:00
val : val ,
token : $ ( '#token' ) . val ( )
2018-08-11 14:47:47 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-08-11 14:47:47 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-08-11 14:47:47 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-08-11 14:47:47 +00:00
$ ( "#" + param ) . parent ( ) . parent ( ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#" + param ) . parent ( ) . parent ( ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
2018-06-24 09:31:28 +00:00
function sshKeyEnableShow ( id ) {
$ ( '#ssh_enable-' + id ) . click ( function ( ) {
if ( $ ( '#ssh_enable-' + id ) . is ( ':checked' ) ) {
$ ( '#ssh_pass-' + id ) . css ( 'display' , 'none' ) ;
} else {
$ ( '#ssh_pass-' + id ) . css ( 'display' , 'block' ) ;
}
} ) ;
if ( $ ( '#ssh_enable-' + id ) . is ( ':checked' ) ) {
$ ( '#ssh_pass-' + id ) . css ( 'display' , 'none' ) ;
} else {
$ ( '#ssh_pass-' + id ) . css ( 'display' , 'block' ) ;
}
}
2018-05-10 17:25:45 +00:00
function confirmDeleteUser ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2018-05-10 17:25:45 +00:00
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
2023-02-14 16:46:41 +00:00
title : delete _word + " " + $ ( '#login-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeUser ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
2018-05-10 17:25:45 +00:00
} ) ;
}
function confirmDeleteGroup ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2018-05-10 17:25:45 +00:00
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
2023-02-14 16:46:41 +00:00
title : delete _word + " " + $ ( '#name-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeGroup ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
2018-05-10 17:25:45 +00:00
} ) ;
}
function confirmDeleteServer ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
title : delete _word + " " + $ ( '#hostname-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeServer ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
2018-05-10 17:25:45 +00:00
}
2018-06-24 09:31:28 +00:00
function confirmDeleteSsh ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
title : delete _word + " " + $ ( '#ssh_name-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeSsh ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
2018-06-24 09:31:28 +00:00
}
2023-04-15 21:26:54 +00:00
function confirmDeleteReceiver ( id , reciever _name ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2018-07-25 05:25:27 +00:00
$ ( "#dialog-confirm" ) . dialog ( {
2023-04-15 21:26:54 +00:00
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
title : delete _word + " " + $ ( '#' + reciever _name + '-chanel-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeReciver ( reciever _name , id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
2021-04-17 17:38:08 +00:00
}
2020-01-11 21:16:27 +00:00
function confirmDeleteBackup ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2020-01-11 21:16:27 +00:00
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
2023-02-14 16:46:41 +00:00
title : delete _word + " " + $ ( '#backup-server-' + id ) . val ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeBackup ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
2020-01-11 21:16:27 +00:00
} ) ;
}
2022-05-05 18:26:14 +00:00
function confirmDeleteGit ( id ) {
2023-02-13 14:45:45 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
2022-05-05 18:26:14 +00:00
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
2023-02-14 16:46:41 +00:00
title : delete _word + " " + $ ( '#git-server-' + id ) . text ( ) + "?" ,
buttons : [ {
text : delete _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeGit ( id ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
2022-05-05 18:26:14 +00:00
} ) ;
}
2019-02-04 06:37:41 +00:00
function cloneServer ( id ) {
$ ( "#add-server-button" ) . trigger ( "click" ) ;
if ( $ ( '#enable-' + id ) . is ( ':checked' ) ) {
$ ( '#enable' ) . prop ( 'checked' , true )
} else {
$ ( '#enable' ) . prop ( 'checked' , false )
}
if ( $ ( '#typeip-' + id ) . is ( ':checked' ) ) {
$ ( '#typeip' ) . prop ( 'checked' , true )
} else {
$ ( '#typeip' ) . prop ( 'checked' , false )
}
2020-02-06 22:36:58 +00:00
if ( $ ( '#haproxy-' + id ) . is ( ':checked' ) ) {
$ ( '#haproxy' ) . prop ( 'checked' , true )
2019-02-04 06:37:41 +00:00
} else {
2020-02-06 22:36:58 +00:00
$ ( '#haproxy' ) . prop ( 'checked' , false )
2019-02-04 06:37:41 +00:00
}
2020-02-06 22:36:58 +00:00
if ( $ ( '#nginx-' + id ) . is ( ':checked' ) ) {
$ ( '#nginx' ) . prop ( 'checked' , true )
2019-02-04 06:37:41 +00:00
} else {
2020-02-06 22:36:58 +00:00
$ ( '#nginx' ) . prop ( 'checked' , false )
2019-02-04 06:37:41 +00:00
}
$ ( '#enable' ) . checkboxradio ( "refresh" ) ;
$ ( '#typeip' ) . checkboxradio ( "refresh" ) ;
2020-02-06 22:36:58 +00:00
$ ( '#haproxy' ) . checkboxradio ( "refresh" ) ;
$ ( '#nginx' ) . checkboxradio ( "refresh" ) ;
2019-02-04 06:37:41 +00:00
$ ( '#new-server-add' ) . val ( $ ( '#hostname-' + id ) . val ( ) )
$ ( '#new-ip' ) . val ( $ ( '#ip-' + id ) . val ( ) )
$ ( '#new-port' ) . val ( $ ( '#port-' + id ) . val ( ) )
$ ( '#desc' ) . val ( $ ( '#desc-' + id ) . val ( ) )
$ ( '#slavefor' ) . val ( $ ( '#slavefor-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#slavefor' ) . selectmenu ( "refresh" ) ;
$ ( '#credentials' ) . val ( $ ( '#credentials-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#credentials' ) . selectmenu ( "refresh" ) ;
2019-10-11 04:49:55 +00:00
cur _url = cur _url [ 0 ] . split ( '#' ) [ 0 ]
if ( cur _url == 'users.py' ) {
2019-10-09 06:35:35 +00:00
$ ( '#new-server-group-add' ) . val ( $ ( '#servergroup-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#new-server-group-add' ) . selectmenu ( "refresh" ) ;
}
2019-02-04 06:37:41 +00:00
}
2023-04-15 21:26:54 +00:00
function cloneReceiver ( id , reciever _name ) {
$ ( '#add-' + reciever _name + '-button' ) . trigger ( "click" ) ;
$ ( '#' + reciever _name + '-token-add' ) . val ( $ ( '#' + reciever _name + '-token-' + id ) . val ( ) ) ;
$ ( '#' + reciever _name + '-chanel-add' ) . val ( $ ( '#' + reciever _name + '-chanel-' + id ) . val ( ) ) ;
2021-04-17 17:38:08 +00:00
}
2020-01-11 21:16:27 +00:00
function cloneBackup ( id ) {
$ ( "#add-backup-button" ) . trigger ( "click" ) ;
$ ( '#rserver' ) . val ( $ ( '#backup-rserver-' + id ) . val ( ) )
$ ( '#rpath' ) . val ( $ ( '#backup-rpath-' + id ) . val ( ) )
$ ( '#backup-type' ) . val ( $ ( '#backup-type-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#backup-type' ) . selectmenu ( "refresh" ) ;
$ ( '#backup-time' ) . val ( $ ( '#backup-time-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#backup-time' ) . selectmenu ( "refresh" ) ;
$ ( '#backup-credentials' ) . val ( $ ( '#backup-credentials-' + id + ' option:selected' ) . val ( ) ) . change ( )
$ ( '#backup-credentials' ) . selectmenu ( "refresh" ) ;
}
2018-04-16 07:01:44 +00:00
function removeUser ( id ) {
2018-04-17 03:46:57 +00:00
$ ( "#user-" + id ) . css ( "background-color" , "#f2dede" ) ;
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-05-10 17:25:45 +00:00
data : {
userdel : id ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-05-10 17:25:45 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-10 17:25:45 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
$ ( "#user-" + id ) . remove ( ) ;
2020-08-07 17:02:02 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
2018-05-10 17:25:45 +00:00
}
2022-04-08 18:08:31 +00:00
}
2018-05-10 17:25:45 +00:00
} ) ;
}
2018-04-16 07:01:44 +00:00
function removeServer ( id ) {
2018-04-17 03:46:57 +00:00
$ ( "#server-" + id ) . css ( "background-color" , "#f2dede" ) ;
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-05-10 17:25:45 +00:00
data : {
serverdel : id ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-05-10 17:25:45 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-10 17:25:45 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
$ ( "#server-" + id ) . remove ( ) ;
2020-08-08 06:26:43 +00:00
} else if ( data . indexOf ( 'error: ' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-08-07 17:02:02 +00:00
toastr . error ( data ) ;
2020-08-08 06:26:43 +00:00
} else if ( data . indexOf ( 'warning: ' ) != '-1' ) {
toastr . clear ( ) ;
toastr . warning ( data ) ;
2018-05-10 17:25:45 +00:00
}
2022-04-08 18:08:31 +00:00
}
} ) ;
2018-05-10 17:25:45 +00:00
}
2018-04-16 07:01:44 +00:00
function removeGroup ( id ) {
2018-04-17 03:46:57 +00:00
$ ( "#group-" + id ) . css ( "background-color" , "#f2dede" ) ;
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-05-10 17:25:45 +00:00
data : {
groupdel : id ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-05-10 17:25:45 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-10 17:25:45 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
$ ( "#group-" + id ) . remove ( ) ;
$ ( 'select:regex(id, group) option[value=' + id + ']' ) . remove ( ) ;
$ ( 'select:regex(id, group)' ) . selectmenu ( "refresh" ) ;
2020-08-07 17:02:02 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
2018-05-10 17:25:45 +00:00
}
2022-04-08 18:08:31 +00:00
}
} ) ;
2018-05-10 17:25:45 +00:00
}
2018-06-24 09:31:28 +00:00
function removeSsh ( id ) {
$ ( "#ssh-table-" + id ) . css ( "background-color" , "#f2dede" ) ;
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-06-24 09:31:28 +00:00
data : {
sshdel : id ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-06-24 09:31:28 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-06-24 09:31:28 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
$ ( "#ssh-table-" + id ) . remove ( ) ;
$ ( 'select:regex(id, credentials) option[value=' + id + ']' ) . remove ( ) ;
$ ( 'select:regex(id, credentials)' ) . selectmenu ( "refresh" ) ;
2020-08-07 17:02:02 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
2018-06-24 09:31:28 +00:00
}
2022-04-08 18:08:31 +00:00
}
} ) ;
2018-06-24 09:31:28 +00:00
}
2023-04-15 21:26:54 +00:00
function removeReciver ( receiver _name , receiver _id ) {
$ ( "#" + receiver _name + "-table-" + receiver _id ) . css ( "background-color" , "#f2dede" ) ;
2021-04-17 17:38:08 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2023-04-15 21:26:54 +00:00
receiver _del : receiver _id ,
receiver _name : receiver _name ,
2021-04-17 17:38:08 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
2023-04-15 21:26:54 +00:00
$ ( "#" + receiver _name + "-table-" + receiver _id ) . remove ( ) ;
2021-04-17 17:38:08 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
}
}
} ) ;
}
2020-01-11 21:16:27 +00:00
function removeBackup ( id ) {
$ ( "#backup-table-" + id ) . css ( "background-color" , "#f2dede" ) ;
$ . ajax ( {
url : "options.py" ,
data : {
deljob : id ,
cred : $ ( '#backup-credentials-' + id ) . val ( ) ,
server : $ ( '#backup-server-' + id ) . text ( ) ,
rserver : $ ( '#backup-rserver-' + id ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'Ok' ) != '-1' ) {
$ ( "#backup-table-" + id ) . remove ( ) ;
2020-08-07 17:02:02 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
2020-01-11 21:16:27 +00:00
}
2022-04-08 18:08:31 +00:00
}
} ) ;
2020-01-11 21:16:27 +00:00
}
2022-05-05 18:26:14 +00:00
function removeGit ( id ) {
$ ( "#git-table-" + id ) . css ( "background-color" , "#f2dede" ) ;
$ . ajax ( {
url : "options.py" ,
data : {
git _backup : id ,
git _deljob : 1 ,
git _init : 0 ,
repo : 0 ,
branch : 0 ,
time : 0 ,
cred : $ ( '#git-credentials-id-' + id ) . text ( ) ,
server : $ ( '#git-server-id-' + id ) . text ( ) ,
git _service : $ ( '#git-service-id-' + id ) . text ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'Ok' ) != '-1' ) {
$ ( "#git-table-" + id ) . remove ( ) ;
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
}
}
} ) ;
}
2018-04-16 07:01:44 +00:00
function updateUser ( id ) {
2020-07-26 16:26:04 +00:00
toastr . remove ( ) ;
2018-11-26 12:55:00 +00:00
cur _url [ 0 ] = cur _url [ 0 ] . split ( '#' ) [ 0 ]
2020-05-10 06:17:07 +00:00
var usergroup = Cookies . get ( 'group' ) ;
2021-08-24 10:12:52 +00:00
var role = $ ( '#role-' + id ) . val ( ) ;
2019-01-05 12:36:59 +00:00
var activeuser = 0 ;
if ( $ ( '#activeuser-' + id ) . is ( ':checked' ) ) {
activeuser = '1' ;
}
2023-03-05 17:20:05 +00:00
if ( role == null && role !== undefined ) {
2021-08-24 10:12:52 +00:00
toastr . warning ( 'Please edit this user only on the Admin area' ) ;
return false ;
}
toastr . remove ( ) ;
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-04-16 07:01:44 +00:00
data : {
updateuser : $ ( '#login-' + id ) . val ( ) ,
email : $ ( '#email-' + id ) . val ( ) ,
2021-08-24 10:12:52 +00:00
role : role ,
2018-09-28 16:10:01 +00:00
usergroup : usergroup ,
2019-01-05 12:36:59 +00:00
activeuser : activeuser ,
2019-09-27 19:09:49 +00:00
id : id ,
token : $ ( '#token' ) . val ( )
2018-04-16 07:01:44 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-16 07:01:44 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-04-20 04:39:39 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . remove ( ) ;
2018-04-20 04:39:39 +00:00
$ ( "#user-" + id ) . addClass ( "update" , 1000 ) ;
2018-08-30 05:21:03 +00:00
setTimeout ( function ( ) {
$ ( "#user-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
2018-04-16 07:01:44 +00:00
}
}
} ) ;
}
function updateGroup ( id ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-04-16 07:01:44 +00:00
data : {
updategroup : $ ( '#name-' + id ) . val ( ) ,
descript : $ ( '#descript-' + id ) . val ( ) ,
2019-09-27 19:09:49 +00:00
id : id ,
token : $ ( '#token' ) . val ( )
2018-04-16 07:01:44 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-16 07:01:44 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-04-20 04:39:39 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-04-20 04:39:39 +00:00
$ ( "#group-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#group-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
$ ( 'select:regex(id, group) option[value=' + id + ']' ) . remove ( ) ;
$ ( 'select:regex(id, group)' ) . append ( '<option value=' + id + '>' + $ ( '#name-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2018-04-16 07:01:44 +00:00
}
}
} ) ;
}
function updateServer ( id ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2022-04-08 18:08:31 +00:00
let typeip = 0 ;
let enable = 0 ;
let firewall = 0 ;
let protected _serv = 0 ;
2018-04-17 20:06:18 +00:00
if ( $ ( '#typeip-' + id ) . is ( ':checked' ) ) {
typeip = '1' ;
}
2018-04-19 05:22:44 +00:00
if ( $ ( '#enable-' + id ) . is ( ':checked' ) ) {
enable = '1' ;
}
2020-11-18 04:45:34 +00:00
if ( $ ( '#firewall-' + id ) . is ( ':checked' ) ) {
firewall = '1' ;
}
2021-05-16 05:27:47 +00:00
if ( $ ( '#protected-' + id ) . is ( ':checked' ) ) {
protected _serv = '1' ;
}
2018-07-25 05:25:27 +00:00
var servergroup = $ ( '#servergroup-' + id + ' option:selected' ) . val ( ) ;
2020-02-06 22:36:58 +00:00
if ( cur _url [ 0 ] . split ( '#' ) [ 0 ] == "servers.py" ) {
servergroup = $ ( '#new-server-group-add' ) . val ( ) ;
2018-07-25 05:25:27 +00:00
}
2018-04-16 07:01:44 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-04-16 07:01:44 +00:00
data : {
updateserver : $ ( '#hostname-' + id ) . val ( ) ,
2018-09-08 04:04:04 +00:00
port : $ ( '#port-' + id ) . val ( ) ,
2018-07-25 05:25:27 +00:00
servergroup : servergroup ,
2018-04-17 20:06:18 +00:00
typeip : typeip ,
2020-11-18 04:45:34 +00:00
firewall : firewall ,
2018-04-19 05:22:44 +00:00
enable : enable ,
2018-04-24 07:38:48 +00:00
slave : $ ( '#slavefor-' + id + ' option:selected' ) . val ( ) ,
2018-06-24 09:31:28 +00:00
cred : $ ( '#credentials-' + id + ' option:selected' ) . val ( ) ,
2018-07-23 07:08:43 +00:00
id : id ,
2018-11-26 12:55:00 +00:00
desc : $ ( '#desc-' + id ) . val ( ) ,
2021-05-16 05:27:47 +00:00
protected : protected _serv ,
2019-09-27 19:09:49 +00:00
token : $ ( '#token' ) . val ( )
2018-04-16 07:01:44 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-16 07:01:44 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-04-20 04:39:39 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-04-20 04:39:39 +00:00
$ ( "#server-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#server-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
2018-04-16 07:01:44 +00:00
}
}
} ) ;
2018-04-21 14:40:59 +00:00
}
2018-04-26 13:03:48 +00:00
function uploadSsh ( ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2023-04-02 16:58:55 +00:00
if ( $ ( "#ssh-key-name option:selected" ) . val ( ) == "------" || $ ( '#ssh_cert' ) . val ( ) == '' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( 'All fields must be completed' ) ;
2018-09-14 14:15:17 +00:00
} else {
$ . ajax ( {
url : "options.py" ,
data : {
ssh _cert : $ ( '#ssh_cert' ) . val ( ) ,
name : $ ( '#ssh-key-name' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-09-14 14:15:17 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-09-14 14:15:17 +00:00
} else if ( data . indexOf ( 'success' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . success ( data )
2018-09-14 14:15:17 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . error ( 'Something wrong, check and try again' ) ;
2018-09-14 14:15:17 +00:00
}
}
} ) ;
}
2018-05-07 13:24:22 +00:00
}
2018-06-24 09:31:28 +00:00
function updateSSH ( id ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-05-07 13:24:22 +00:00
var ssh _enable = 0 ;
2018-06-24 09:31:28 +00:00
if ( $ ( '#ssh_enable-' + id ) . is ( ':checked' ) ) {
2018-05-07 13:24:22 +00:00
ssh _enable = '1' ;
}
2020-04-06 16:38:58 +00:00
var group = $ ( '#sshgroup-' + id ) . val ( ) ;
if ( cur _url [ 0 ] . split ( '#' ) [ 0 ] == "servers.py" ) {
group = $ ( '#new-server-group-add' ) . val ( ) ;
}
2018-05-07 13:24:22 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2018-05-07 13:24:22 +00:00
data : {
updatessh : 1 ,
2018-06-24 09:31:28 +00:00
name : $ ( '#ssh_name-' + id ) . val ( ) ,
2020-04-06 16:38:58 +00:00
group : group ,
2018-05-07 13:24:22 +00:00
ssh _enable : ssh _enable ,
2018-06-24 09:31:28 +00:00
ssh _user : $ ( '#ssh_user-' + id ) . val ( ) ,
ssh _pass : $ ( '#ssh_pass-' + id ) . val ( ) ,
2019-09-27 19:09:49 +00:00
id : id ,
token : $ ( '#token' ) . val ( )
2018-05-07 13:24:22 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-07 13:24:22 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2018-05-07 13:24:22 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2018-06-24 09:31:28 +00:00
$ ( "#ssh-table-" + id ) . addClass ( "update" , 1000 ) ;
2018-05-07 13:24:22 +00:00
setTimeout ( function ( ) {
2018-06-24 09:31:28 +00:00
$ ( "#ssh-table-" + id ) . removeClass ( "update" ) ;
2018-05-07 13:24:22 +00:00
} , 2500 ) ;
2018-06-24 09:31:28 +00:00
$ ( 'select:regex(id, credentials) option[value=' + id + ']' ) . remove ( ) ;
$ ( 'select:regex(id, ssh-key-name) option[value=' + $ ( '#ssh_name-' + id ) . val ( ) + ']' ) . remove ( ) ;
$ ( 'select:regex(id, credentials)' ) . append ( '<option value=' + id + '>' + $ ( '#ssh_name-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
$ ( 'select:regex(id, ssh-key-name)' ) . append ( '<option value=' + $ ( '#ssh_name-' + id ) . val ( ) + '>' + $ ( '#ssh_name-' + id ) . val ( ) + '</option>' ) . selectmenu ( "refresh" ) ;
2018-05-07 13:24:22 +00:00
}
}
} ) ;
2018-05-07 19:09:56 +00:00
}
2023-04-15 21:26:54 +00:00
function updateReceiver ( id , receiver _name ) {
2021-04-17 17:38:08 +00:00
toastr . clear ( ) ;
$ . ajax ( {
url : "options.py" ,
data : {
2023-04-15 21:26:54 +00:00
receiver _name : receiver _name ,
update _receiver _token : $ ( '#' + receiver _name + '-token-' + id ) . val ( ) ,
update _receiver _channel : $ ( '#' + receiver _name + '-chanel-' + id ) . val ( ) ,
update _receiver _group : $ ( '#' + receiver _name + 'group-' + id ) . val ( ) ,
2021-04-17 17:38:08 +00:00
id : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
2023-04-15 21:26:54 +00:00
$ ( "#" + receiver _name + "-table-" + id ) . addClass ( "update" , 1000 ) ;
2021-04-17 17:38:08 +00:00
setTimeout ( function ( ) {
2023-04-15 21:26:54 +00:00
$ ( "#" + receiver _name + "-table-" + id ) . removeClass ( "update" ) ;
2021-04-17 17:38:08 +00:00
} , 2500 ) ;
}
}
} ) ;
}
2020-01-11 21:16:27 +00:00
function updateBackup ( id ) {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2023-04-02 16:58:55 +00:00
if ( $ ( "#backup-type-" + id + " option:selected" ) . val ( ) == "-------" || $ ( '#backup-rserver-' + id ) . val ( ) == '' || $ ( '#backup-rpath-' + id ) . val ( ) == '' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( 'All fields must be completed' ) ;
2020-01-11 21:16:27 +00:00
} else {
$ . ajax ( {
url : "options.py" ,
data : {
backupupdate : id ,
server : $ ( '#backup-server-' + id ) . text ( ) ,
rserver : $ ( '#backup-rserver-' + id ) . val ( ) ,
rpath : $ ( '#backup-rpath-' + id ) . val ( ) ,
type : $ ( '#backup-type-' + id ) . val ( ) ,
time : $ ( '#backup-time-' + id ) . val ( ) ,
cred : $ ( '#backup-credentials-' + id ) . val ( ) ,
description : $ ( '#backup-description-' + id ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-08-07 17:02:02 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2020-01-11 21:16:27 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2020-01-11 21:16:27 +00:00
$ ( "#backup-table-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#backup-table-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
}
2018-07-24 04:08:06 +00:00
function showApacheLog ( serv ) {
2019-09-29 20:16:24 +00:00
var rows = $ ( '#rows' ) . val ( )
var grep = $ ( '#grep' ) . val ( )
2020-06-15 17:29:49 +00:00
var exgrep = $ ( '#exgrep' ) . val ( )
2019-09-29 20:16:24 +00:00
var hour = $ ( '#time_range_out_hour' ) . val ( )
var minut = $ ( '#time_range_out_minut' ) . val ( )
var hour1 = $ ( '#time_range_out_hour1' ) . val ( )
var minut1 = $ ( '#time_range_out_minut1' ) . val ( )
2018-05-07 19:09:56 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2019-09-29 20:16:24 +00:00
rows1 : rows ,
2018-07-24 04:08:06 +00:00
serv : serv ,
2019-09-29 20:16:24 +00:00
grep : grep ,
2020-06-15 17:29:49 +00:00
exgrep : exgrep ,
2019-09-29 20:16:24 +00:00
hour : hour ,
minut : minut ,
hour1 : hour1 ,
minut1 : minut1 ,
2018-06-01 12:27:58 +00:00
token : $ ( '#token' ) . val ( )
2018-05-07 19:09:56 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-07 19:09:56 +00:00
success : function ( data ) {
$ ( "#ajax" ) . html ( data ) ;
2020-07-26 16:26:04 +00:00
window . history . pushState ( "Logs" , "Logs" , cur _url [ 0 ] + "?serv=" + serv + "&rows1=" + rows + "&grep=" + grep +
'&exgrep=' + exgrep +
'&hour=' + hour +
'&minut=' + minut +
'&hour1=' + hour1 +
'&minut1=' + minut1 ) ;
2022-04-08 18:08:31 +00:00
}
2018-05-07 19:09:56 +00:00
} ) ;
2018-10-01 16:51:37 +00:00
}
function checkSshConnect ( ip ) {
$ . ajax ( {
url : "options.py" ,
data : {
checkSshConnect : 1 ,
serv : ip ,
token : $ ( '#token' ) . val ( )
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-10-01 16:51:37 +00:00
success : function ( data ) {
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data )
2021-07-21 04:57:58 +00:00
} else if ( data . indexOf ( 'failed' ) != '-1' ) {
toastr . error ( data )
2021-08-15 09:02:12 +00:00
} else if ( data . indexOf ( 'Errno' ) != '-1' ) {
toastr . error ( data )
2018-10-01 16:51:37 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
toastr . success ( 'Connect is accepted' ) ;
2018-10-01 16:51:37 +00:00
}
2022-04-08 18:08:31 +00:00
}
2018-10-01 16:51:37 +00:00
} ) ;
2019-09-26 15:48:56 +00:00
}
function openChangeUserPasswordDialog ( id ) {
changeUserPasswordDialog ( id ) ;
}
2021-08-15 09:02:12 +00:00
function openChangeUserServiceDialog ( id ) {
changeUserServiceDialog ( id ) ;
}
2019-09-26 15:48:56 +00:00
function changeUserPasswordDialog ( id ) {
2023-02-13 14:45:45 +00:00
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var superAdmin _pass = $ ( '#translate' ) . attr ( 'data-superAdmin_pass' ) ;
var change _word = $ ( '#translate' ) . attr ( 'data-change2' ) ;
var password _word = $ ( '#translate' ) . attr ( 'data-password' ) ;
2022-11-03 08:45:50 +00:00
if ( $ ( '#role-' + id + ' option:selected' ) . val ( ) == 'Select a role' ) {
2023-02-13 14:45:45 +00:00
toastr . warning ( superAdmin _pass ) ;
2022-11-03 08:45:50 +00:00
return false ;
}
2019-09-26 15:48:56 +00:00
$ ( "#user-change-password-table" ) . dialog ( {
autoOpen : true ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2023-02-13 14:45:45 +00:00
title : change _word + " " + $ ( '#login-' + id ) . val ( ) + " " + password _word ,
2019-09-26 15:48:56 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
2023-02-13 14:45:45 +00:00
buttons : [ {
text : change _word ,
click : function ( ) {
2019-09-26 15:48:56 +00:00
changeUserPassword ( id , $ ( this ) ) ;
2023-02-13 14:45:45 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
2019-09-26 15:48:56 +00:00
$ ( '#missmatchpass' ) . hide ( ) ;
}
2023-02-13 14:45:45 +00:00
} ]
2019-09-26 15:48:56 +00:00
} ) ;
}
function changeUserPassword ( id , d ) {
var pass = $ ( '#change-password' ) . val ( ) ;
var pass2 = $ ( '#change2-password' ) . val ( ) ;
if ( pass != pass2 ) {
$ ( '#missmatchpass' ) . show ( ) ;
} else {
$ ( '#missmatchpass' ) . hide ( ) ;
2020-07-30 17:28:58 +00:00
toastr . clear ( ) ;
2019-09-26 15:48:56 +00:00
$ . ajax ( {
2020-01-18 23:50:43 +00:00
url : "options.py" ,
2019-09-26 15:48:56 +00:00
data : {
updatepassowrd : pass ,
2019-09-27 19:09:49 +00:00
id : id ,
token : $ ( '#token' ) . val ( )
2019-09-26 15:48:56 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2019-09-26 15:48:56 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2020-07-30 17:28:58 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
2019-09-26 15:48:56 +00:00
} else {
2020-07-26 16:26:04 +00:00
toastr . clear ( ) ;
2019-09-26 15:48:56 +00:00
$ ( "#user-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#user-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
d . dialog ( "close" ) ;
}
}
} ) ;
}
2020-05-10 06:17:07 +00:00
}
2021-08-15 09:02:12 +00:00
function changeUserServiceDialog ( id ) {
2023-02-13 14:45:45 +00:00
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var manage _word = $ ( '#translate' ) . attr ( 'data-manage' ) ;
var services _word = $ ( '#translate' ) . attr ( 'data-services3' ) ;
var save _word = $ ( '#translate' ) . attr ( 'data-save' ) ;
var superAdmin _services = $ ( '#translate' ) . attr ( 'data-superAdmin_services' ) ;
2022-11-03 08:45:50 +00:00
if ( $ ( '#role-' + id + ' option:selected' ) . val ( ) == 'Select a role' ) {
2023-02-13 14:45:45 +00:00
toastr . warning ( superAdmin _services ) ;
2022-11-03 08:45:50 +00:00
return false ;
}
2021-08-15 09:02:12 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
getuserservices : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'danger' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( '#change-user-service-form' ) . html ( data ) ;
$ ( "#change-user-service-dialog" ) . dialog ( {
resizable : false ,
height : "auto" ,
2023-03-04 07:42:26 +00:00
width : 700 ,
2021-08-15 09:02:12 +00:00
modal : true ,
2023-02-13 14:45:45 +00:00
title : manage _word + " " + $ ( '#login-' + id ) . val ( ) + " " + services _word ,
buttons : [ {
text : save _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
2021-08-15 09:02:12 +00:00
changeUserServices ( id ) ;
}
2023-02-13 14:45:45 +00:00
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
2021-08-15 09:02:12 +00:00
} ) ;
}
}
} ) ;
}
2023-03-04 07:42:26 +00:00
function changeUserServices ( user _id ) {
var jsonData = { } ;
jsonData [ user _id ] = { } ;
$ ( '#checked_services tbody tr' ) . each ( function ( ) {
var this _id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 1 ] ;
jsonData [ user _id ] [ this _id ] = { }
} ) ;
2021-08-15 09:02:12 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2023-03-04 07:42:26 +00:00
changeUserServicesId : user _id ,
jsonDatas : JSON . stringify ( jsonData ) ,
changeUserServicesUser : $ ( '#login-' + user _id ) . val ( ) ,
2021-08-15 09:02:12 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'Failed' ) != '-1' ) {
toastr . error ( data ) ;
} else {
2023-03-04 07:42:26 +00:00
$ ( "#user-" + user _id ) . addClass ( "update" , 1000 ) ;
2021-08-15 09:02:12 +00:00
setTimeout ( function ( ) {
2023-03-04 07:42:26 +00:00
$ ( "#user-" + user _id ) . removeClass ( "update" ) ;
2021-08-15 09:02:12 +00:00
} , 2500 ) ;
}
}
} ) ;
}
2023-03-04 07:42:26 +00:00
function addServiceToUser ( service _id ) {
var service _name = $ ( '#add_service-' + service _id ) . attr ( 'data-service_name' ) ;
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var service _word = $ ( '#translate' ) . attr ( 'data-service' ) ;
var length _tr = $ ( '#checked_services tbody tr' ) . length ;
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="remove_service-' + service _id + '" data-service_name="' + service _name + '">' +
'<td class="padding20" style="width: 100%;">' + service _name + '</td>' +
2023-03-04 12:42:26 +00:00
'<td><span class="add_user_group" onclick="removeServiceFromUser(' + service _id + ')" title="' + delete _word + ' ' + service _word + '">-</span></td></tr>' ;
2023-03-04 07:42:26 +00:00
$ ( '#add_service-' + service _id ) . remove ( ) ;
$ ( "#checked_services tbody" ) . append ( html _tag ) ;
}
function removeServiceFromUser ( service _id ) {
var service _name = $ ( '#remove_service-' + service _id ) . attr ( 'data-service_name' ) ;
var add _word = $ ( '#translate' ) . attr ( 'data-add' ) ;
var service _word = $ ( '#translate' ) . attr ( 'data-service' ) ;
var length _tr = $ ( '#all_services tbody tr' ) . length ;
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="add_service-' + service _id + '" data-service_name="' + service _name + '">' +
'<td class="padding20" style="width: 100%;">' + service _name + '</td>' +
'<td><span class="add_user_group" onclick="addServiceToUser(' + service _id + ')" title="' + add _word + ' ' + service _word + '">+</span></td></tr>' ;
$ ( '#remove_service-' + service _id ) . remove ( ) ;
$ ( "#all_services tbody" ) . append ( html _tag ) ;
2020-05-12 18:57:05 +00:00
}
function confirmAjaxServiceAction ( action , service ) {
2023-03-03 20:03:41 +00:00
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var action _word = $ ( '#translate' ) . attr ( 'data-' + action ) ;
2020-05-12 18:57:05 +00:00
$ ( "#dialog-confirm-services" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
2023-03-03 20:03:41 +00:00
title : action _word + " " + service + "?" ,
buttons : [ {
text : action _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
2020-05-12 18:57:05 +00:00
ajaxActionServies ( action , service )
2023-03-03 20:03:41 +00:00
}
} , {
text : cancel _word ,
click : function ( ) {
2020-05-12 18:57:05 +00:00
$ ( this ) . dialog ( "close" ) ;
}
2023-03-03 20:03:41 +00:00
} ]
2020-05-12 18:57:05 +00:00
} ) ;
}
function ajaxActionServies ( action , service ) {
$ . ajax ( {
url : "options.py" ,
data : {
action _service : action ,
serv : service ,
token : $ ( '#token' ) . val ( )
} ,
success : function ( data ) {
2021-02-20 07:47:33 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'Failed' ) != '-1' ) {
toastr . error ( data ) ;
2022-04-27 18:10:26 +00:00
} else if ( data . indexOf ( 'warning: ' ) != '-1' ) {
toastr . warning ( data ) ;
2021-02-20 07:47:33 +00:00
} else {
window . history . pushState ( "services" , "services" , cur _url [ 0 ] . split ( "#" ) [ 0 ] + "#services" ) ;
2021-04-16 14:09:51 +00:00
toastr . success ( 'The ' + service + ' has been ' + action + 'ed' ) ;
2021-02-20 07:47:33 +00:00
loadServices ( ) ;
}
2020-05-12 18:57:05 +00:00
} ,
error : function ( ) {
alert ( w . data _error ) ;
2022-04-08 18:08:31 +00:00
}
2020-05-12 18:57:05 +00:00
} ) ;
2020-09-24 05:01:48 +00:00
}
2022-06-16 19:58:01 +00:00
function updateService ( service , action = 'update' ) {
2020-09-24 05:01:48 +00:00
$ ( "#ajax-update" ) . html ( '' )
2021-05-16 05:27:47 +00:00
$ ( "#ajax-update" ) . html ( wait _mess ) ;
2020-09-24 05:01:48 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2022-06-15 07:34:20 +00:00
update _roxy _wi : 1 ,
2020-09-24 05:01:48 +00:00
service : service ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2022-06-18 07:49:42 +00:00
if ( data . indexOf ( 'Complete!' ) != '-1' || data . indexOf ( 'Unpacking' ) != '-1' ) {
2020-09-24 05:01:48 +00:00
toastr . clear ( ) ;
2022-06-16 19:58:01 +00:00
toastr . success ( service + ' has been ' + action + 'ed' ) ;
2022-06-18 07:49:42 +00:00
} else if ( data . indexOf ( 'Unauthorized' ) != '-1' || data . indexOf ( 'Status code: 401' ) != '-1' ) {
2020-09-24 05:01:48 +00:00
toastr . clear ( ) ;
2022-06-18 07:49:42 +00:00
toastr . error ( 'It looks like there is no authorization in the Roxy-WI repository. Your subscription may have expired or there is no subscription. How to get the <b><a href="https://roxy-wi.org/pricing.py" title="Pricing" target="_blank">subscription</a></b>' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( 'but not installed' ) != '-1' ) {
toastr . clear ( ) ;
2022-06-16 19:58:01 +00:00
toastr . error ( 'There is setting for Roxy-WI repository, but Roxy-WI is installed without repository. Please reinstall with package manager' ) ;
2022-06-18 07:49:42 +00:00
} else if ( data . indexOf ( 'No Match for argument' ) != '-1' || data . indexOf ( 'Unable to find a match' ) != '-1' ) {
2020-09-24 05:01:48 +00:00
toastr . clear ( ) ;
2022-06-15 07:34:20 +00:00
toastr . error ( 'It seems like Roxy-WI repository is not set. Please read docs for <b><a href="https://roxy-wi.org/updates.py">detail</a></b>' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( 'password for' ) != '-1' ) {
toastr . clear ( ) ;
2022-06-15 07:34:20 +00:00
toastr . error ( 'It seems like apache user needs to be add to sudoers. Please read docs for <b><a href="https://roxy-wi.org/updates.py">detail</a></b>' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( 'No packages marked for update' ) != '-1' ) {
toastr . clear ( ) ;
2021-06-02 07:28:07 +00:00
toastr . info ( 'It seems like the lastest version Roxy-WI is installed' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( 'Connection timed out' ) != '-1' ) {
toastr . clear ( ) ;
2021-06-02 07:28:07 +00:00
toastr . error ( 'Cannot connect to Roxy-WI repository. Connection timed out' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( '--disable' ) != '-1' ) {
toastr . clear ( ) ;
2020-11-19 20:11:08 +00:00
toastr . error ( 'It seems like there is a problem with repositories' ) ;
2020-09-24 05:01:48 +00:00
} else if ( data . indexOf ( 'Error: Package' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
} else if ( data . indexOf ( 'conflicts with file from' ) != '-1' ) {
toastr . clear ( ) ;
toastr . error ( data ) ;
2022-06-18 07:49:42 +00:00
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'Failed' ) != '-1' ) {
toastr . error ( data ) ;
2020-09-24 05:01:48 +00:00
}
2021-02-20 07:47:33 +00:00
$ ( "#ajax-update" ) . html ( '' ) ;
loadupdatehapwi ( ) ;
2020-09-24 05:01:48 +00:00
}
} ) ;
2020-10-09 15:56:16 +00:00
}
function confirmDeleteOpenVpnProfile ( id ) {
$ ( "#dialog-confirm" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 400 ,
modal : true ,
title : "Are you sure you want to delete profile " + id + "?" ,
buttons : {
"Delete" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
removeOpenVpnProfile ( id ) ;
} ,
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
function removeOpenVpnProfile ( id ) {
$ ( "#" + id ) . css ( "background-color" , "#f2dede" ) ;
$ . ajax ( {
url : "options.py" ,
data : {
openvpndel : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data == "Ok " ) {
$ ( "#" + id ) . remove ( ) ;
} else if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
}
}
} ) ;
}
function uploadOvpn ( ) {
toastr . clear ( ) ;
if ( $ ( "#ovpn_upload_name" ) . val ( ) == '' || $ ( '#ovpn_upload_file' ) . val ( ) == '' ) {
toastr . error ( 'All fields must be completed' ) ;
} else {
$ . ajax ( {
url : "options.py" ,
data : {
uploadovpn : $ ( '#ovpn_upload_file' ) . val ( ) ,
ovpnname : $ ( '#ovpn_upload_name' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data )
location . reload ( )
} else {
toastr . error ( 'Something wrong, check and try again' ) ;
}
}
} ) ;
}
}
function OpenVpnSess ( id , action ) {
$ . ajax ( {
url : "options.py" ,
data : {
actionvpn : action ,
openvpnprofile : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data )
location . reload ( )
} else {
toastr . error ( 'Something wrong, check and try again' ) ;
}
}
} ) ;
2020-11-02 17:01:08 +00:00
}
function scanPorts ( id ) {
$ . ajax ( {
url : "options.py" ,
data : {
scan _ports : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#show_scans_ports_body" ) . html ( data ) ;
$ ( "#show_scans_ports" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 360 ,
modal : true ,
title : "Openned ports" ,
buttons : {
Close : function ( ) {
$ ( this ) . dialog ( "close" ) ;
$ ( "#show_scans_ports_body" ) . html ( '' ) ;
}
}
} ) ;
}
}
} ) ;
}
2020-11-19 20:11:08 +00:00
function viewFirewallRules ( id ) {
$ . ajax ( {
url : "options.py" ,
data : {
viewFirewallRules : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2021-01-22 04:01:08 +00:00
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error: ' ) != '-1' ) {
2020-11-19 20:11:08 +00:00
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#firewall_rules_body" ) . html ( data ) ;
$ ( "#firewall_rules" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 860 ,
modal : true ,
title : "Firewall rules" ,
buttons : {
Close : function ( ) {
$ ( this ) . dialog ( "close" ) ;
$ ( "#firewall_rules_body" ) . html ( '' ) ;
}
}
} ) ;
}
}
} ) ;
}
2021-02-20 07:47:33 +00:00
function loadServices ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
loadservices : 1 ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( '#ajax-services-body' ) . html ( data ) ;
$ . getScript ( awesome ) ;
}
}
} ) ;
}
function loadupdatehapwi ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
2021-02-25 04:43:29 +00:00
load _update _hapwi : 1 ,
2021-02-20 07:47:33 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'danger' ) != '-1' || data . indexOf ( 'unique' ) != '-1' || data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( '#ajax-updatehapwi-body' ) . html ( data ) ;
}
}
} ) ;
}
2022-06-15 07:34:20 +00:00
function loadchecker ( tab = 0 ) {
2021-02-20 07:47:33 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
loadchecker : 1 ,
page : cur _url [ 0 ] . split ( '#' ) [ 0 ] ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'group_error' ) == '-1' && data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( '#checker' ) . html ( data ) ;
$ ( "select" ) . selectmenu ( ) ;
2021-03-17 17:19:06 +00:00
$ ( "button" ) . button ( ) ;
2022-06-15 07:34:20 +00:00
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
2021-02-20 07:47:33 +00:00
$ . getScript ( '/inc/users.js' ) ;
$ . getScript ( awesome ) ;
2022-06-15 07:34:20 +00:00
$ ( "#checker_tabs" ) . tabs ( "option" , "active" , tab ) ;
2021-02-20 07:47:33 +00:00
}
}
} ) ;
}
function loadopenvpn ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
loadopenvpn : 1 ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'group_error' ) == '-1' && data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( '#openvpn' ) . html ( data ) ;
$ . getScript ( awesome ) ;
}
}
} ) ;
}
2023-04-15 21:26:54 +00:00
function checkReceiver ( channel _id , receiver _name ) {
2021-04-17 17:38:08 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
2023-04-15 21:26:54 +00:00
check _receiver : 1 ,
receiver _channel _id : channel _id ,
receiver _name : receiver _name ,
2021-04-17 17:38:08 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'error_code' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . success ( 'Test message has been sent' ) ;
}
}
} ) ;
}
2021-12-03 10:39:15 +00:00
function updateServerInfo ( ip , id ) {
$ . ajax ( {
url : "options.py" ,
data : {
act : 'updateSystemInfo' ,
server _ip : ip ,
server _id : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'error_code' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( "#server_info-" + id ) . html ( data ) ;
$ ( '#server_info-' + id ) . show ( ) ;
$ ( '#server_info_link-' + id ) . attr ( 'title' , 'Hide System info' ) ;
$ . getScript ( awesome ) ;
}
}
} ) ;
}
function showServerInfo ( id , ip ) {
2023-02-17 17:21:19 +00:00
var close _word = $ ( '#translate' ) . attr ( 'data-close' ) ;
var server _info = $ ( '#translate' ) . attr ( 'data-server_info' ) ;
2023-01-24 07:34:14 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
act : 'getSystemInfo' ,
server _ip : ip ,
server _id : id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'error_code' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( "#server-info" ) . html ( data ) ;
$ ( "#dialog-server-info" ) . dialog ( {
resizable : false ,
height : "auto" ,
2023-02-17 17:21:19 +00:00
width : 1000 ,
2023-01-24 07:34:14 +00:00
modal : true ,
2023-02-17 17:21:19 +00:00
title : server _info + " (" + ip + ")" ,
buttons : [ {
text : close _word ,
click : function ( ) {
2023-01-24 07:34:14 +00:00
$ ( this ) . dialog ( "close" ) ;
}
2023-02-17 17:21:19 +00:00
} ]
2023-01-24 07:34:14 +00:00
} ) ;
$ . getScript ( awesome ) ;
2021-12-03 10:39:15 +00:00
}
2023-01-24 07:34:14 +00:00
}
} ) ;
2021-12-03 10:39:15 +00:00
}
2022-06-15 07:34:20 +00:00
function updateHaproxyCheckerSettings ( id ) {
toastr . clear ( ) ;
let email = 0 ;
let server = 0 ;
let backend = 0 ;
let maxconn = 0 ;
if ( $ ( '#haproxy_server_email-' + id ) . is ( ':checked' ) ) {
email = '1' ;
}
if ( $ ( '#haproxy_server_status-' + id ) . is ( ':checked' ) ) {
server = '1' ;
}
if ( $ ( '#haproxy_server_backend-' + id ) . is ( ':checked' ) ) {
backend = '1' ;
}
if ( $ ( '#haproxy_server_maxconn-' + id ) . is ( ':checked' ) ) {
maxconn = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
updateHaproxyCheckerSettings : id ,
email : email ,
server : server ,
backend : backend ,
maxconn : maxconn ,
telegram _id : $ ( '#haproxy_server_telegram_channel-' + id + ' option:selected' ) . val ( ) ,
slack _id : $ ( '#haproxy_server_slack_channel-' + id + ' option:selected' ) . val ( ) ,
2023-04-15 21:26:54 +00:00
pd _id : $ ( '#haproxy_server_pd_channel-' + id + ' option:selected' ) . val ( ) ,
2022-06-15 07:34:20 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'ok' ) != '-1' ) {
toastr . clear ( ) ;
$ ( "#haproxy_server_tr_id-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#haproxy_server_tr_id-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
function updateKeepalivedCheckerSettings ( id ) {
toastr . clear ( ) ;
let email = 0 ;
let server = 0 ;
let backend = 0 ;
if ( $ ( '#keepalived_server_email-' + id ) . is ( ':checked' ) ) {
email = '1' ;
}
if ( $ ( '#keepalived_server_status-' + id ) . is ( ':checked' ) ) {
server = '1' ;
}
if ( $ ( '#keepalived_server_backend-' + id ) . is ( ':checked' ) ) {
backend = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
updateKeepalivedCheckerSettings : id ,
email : email ,
server : server ,
backend : backend ,
telegram _id : $ ( '#keepalived_server_telegram_channel-' + id + ' option:selected' ) . val ( ) ,
slack _id : $ ( '#keepalived_server_slack_channel-' + id + ' option:selected' ) . val ( ) ,
2023-04-15 21:26:54 +00:00
pd _id : $ ( '#keepalived_server_pd_channel-' + id + ' option:selected' ) . val ( ) ,
2022-06-15 07:34:20 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'ok' ) != '-1' ) {
toastr . clear ( ) ;
$ ( "#keepalived_server_tr_id-" + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#keepalived_server_tr_id-" + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
function updateServiceCheckerSettings ( id , service _name ) {
toastr . clear ( ) ;
let email = 0 ;
let server = 0 ;
if ( $ ( '#' + service _name + '_server_email-' + id ) . is ( ':checked' ) ) {
email = '1' ;
}
if ( $ ( '#' + service _name + '_server_status-' + id ) . is ( ':checked' ) ) {
server = '1' ;
}
$ . ajax ( {
url : "options.py" ,
data : {
updateServiceCheckerSettings : id ,
email : email ,
server : server ,
telegram _id : $ ( '#' + service _name + '_server_telegram_channel-' + id + ' option:selected' ) . val ( ) ,
slack _id : $ ( '#' + service _name + '_server_slack_channel-' + id + ' option:selected' ) . val ( ) ,
2023-04-15 21:26:54 +00:00
pd _id : $ ( '#' + service _name + '_server_pd_channel-' + id + ' option:selected' ) . val ( ) ,
2022-06-15 07:34:20 +00:00
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'unique' ) != '-1' ) {
toastr . error ( data ) ;
} else if ( data . indexOf ( 'ok' ) != '-1' ) {
toastr . clear ( ) ;
$ ( '#' + service _name + '_server_tr_id-' + id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( '#' + service _name + '_server_tr_id-' + id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
function checkWebPanel ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
check _rabbitmq _alert : 1 ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'error_code' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . success ( 'Test message has been sent' ) ;
}
}
} ) ;
}
function checkEmail ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
check _email _alert : 1 ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'error_code' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . success ( 'Test message has been sent' ) ;
}
}
} ) ;
}
2022-10-07 14:40:45 +00:00
function checkGeoipInstallation ( ) {
$ . ajax ( {
url : "options.py" ,
data : {
geoipserv : $ ( '#geoipserv option:selected' ) . val ( ) ,
geoip _service : $ ( '#geoip_service option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
2023-01-05 08:51:43 +00:00
if ( data . indexOf ( 'No such file or directory' ) != '-1' || data . indexOf ( 'cannot access' ) != '-1' ) {
2022-10-09 20:02:41 +00:00
$ ( '#cur_geoip' ) . html ( '<b style="color: var(--red-color)">GeoIPLite is not installed</b>' ) ;
2022-10-07 14:40:45 +00:00
$ ( '#geoip_install' ) . show ( ) ;
} else {
2022-10-09 20:02:41 +00:00
$ ( '#cur_geoip' ) . html ( '<b style="color: var(--green-color)">GeoIPLite is installed<b>' ) ;
2022-10-07 14:40:45 +00:00
$ ( '#geoip_install' ) . hide ( ) ;
}
}
} ) ;
}
2023-01-02 20:01:20 +00:00
function installService ( service ) {
$ ( "#ajax" ) . html ( '' )
var syn _flood = 0 ;
var docker = 0 ;
if ( $ ( '#' + service + '_syn_flood' ) . is ( ':checked' ) ) {
syn _flood = '1' ;
}
if ( $ ( '#' + service + '_docker' ) . is ( ':checked' ) ) {
docker = '1' ;
}
if ( $ ( '#' + service + 'addserv' ) . val ( ) == '------' ) {
2023-04-02 16:58:55 +00:00
var select _server = $ ( '#translate' ) . attr ( 'data-select_server' ) ;
toastr . warning ( select _server ) ;
2023-01-02 20:01:20 +00:00
return false
}
$ ( "#ajax" ) . html ( wait _mess ) ;
$ . ajax ( {
url : "options.py" ,
data : {
2023-01-03 07:54:03 +00:00
install _service : $ ( '#' + service + 'addserv' ) . val ( ) ,
service : service ,
2023-01-02 20:01:20 +00:00
syn _flood : syn _flood ,
docker : docker ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
$ ( "#ajax" ) . html ( '' )
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'FAILED' ) != '-1' || data . indexOf ( 'UNREACHABLE' ) != '-1' ) {
toastr . clear ( ) ;
var p _err = show _pretty _ansible _error ( data ) ;
toastr . error ( p _err ) ;
} else if ( data . indexOf ( 'success' ) != '-1' ) {
toastr . clear ( ) ;
toastr . success ( data ) ;
$ ( '#' + service + 'addserv' ) . trigger ( "selectmenuchange" ) ;
} else if ( data . indexOf ( 'Info' ) != '-1' ) {
toastr . clear ( ) ;
toastr . info ( data ) ;
} else {
toastr . clear ( ) ;
toastr . info ( data ) ;
}
}
} ) ;
}
function showServiceVersion ( service ) {
$ . ajax ( {
url : "options.py" ,
data : {
get _service _v : service ,
serv : $ ( '#' + service + 'addserv option:selected' ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
if ( data . indexOf ( 'bash' ) != '-1' || data . indexOf ( 'such' ) != '-1' || data . indexOf ( 'command not found' ) != '-1' || data . indexOf ( 'from' ) != '-1' ) {
$ ( '#cur_' + service + '_ver' ) . text ( service + ' has not installed' ) ;
$ ( '#' + service + '_install' ) . text ( 'Install' ) ;
$ ( '#' + service + '_install' ) . attr ( 'title' , 'Install' ) ;
} else if ( data . indexOf ( 'warning: ' ) != '-1' ) {
toastr . warning ( data ) ;
2023-03-19 15:51:58 +00:00
} else if ( data == '' ) {
$ ( '#cur_' + service + '_ver' ) . text ( service + ' has not installed' ) ;
$ ( '#' + service + '_install' ) . text ( 'Install' ) ;
$ ( '#' + service + '_install' ) . attr ( 'title' , 'Install' ) ;
2023-01-02 20:01:20 +00:00
} else {
$ ( '#cur_' + service + '_ver' ) . text ( data ) ;
$ ( '#cur_' + service + '_ver' ) . css ( 'font-weight' , 'bold' ) ;
$ ( '#' + service + '_install' ) . text ( 'Update' ) ;
$ ( '#' + service + '_install' ) . attr ( 'title' , 'Update' ) ;
}
}
} ) ;
}
2023-02-13 14:45:45 +00:00
function serverIsUp ( server _ip , server _id ) {
2023-04-02 16:58:55 +00:00
var cur _url = window . location . href . split ( '/' ) . pop ( ) ;
if ( cur _url . split ( '#' ) [ 1 ] == 'servers' ) {
$ . ajax ( {
url : "options.py" ,
data : {
act : 'server_is_up' ,
server _is _up : server _ip ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
data = data . replace ( /^\s+|\s+$/g , '' ) ;
if ( data . indexOf ( 'up' ) != '-1' ) {
$ ( '#server_status-' + server _id ) . removeClass ( 'serverNone' ) ;
$ ( '#server_status-' + server _id ) . removeClass ( 'serverDown' ) ;
$ ( '#server_status-' + server _id ) . addClass ( 'serverUp' ) ;
$ ( '#server_status-' + server _id ) . attr ( 'title' , 'Server is reachable' ) ;
} else if ( data . indexOf ( 'down' ) != '-1' ) {
$ ( '#server_status-' + server _id ) . removeClass ( 'serverNone' ) ;
$ ( '#server_status-' + server _id ) . removeClass ( 'serverUp' ) ;
$ ( '#server_status-' + server _id ) . addClass ( 'serverDown' ) ;
$ ( '#server_status-' + server _id ) . attr ( 'title' , 'Server is unreachable' ) ;
} else {
$ ( '#server_status-' + server _id ) . removeClass ( 'serverDown' ) ;
$ ( '#server_status-' + server _id ) . removeClass ( 'serverUp' ) ;
$ ( '#server_status-' + server _id ) . addClass ( 'serverNone' ) ;
$ ( '#server_status-' + server _id ) . attr ( 'title' , 'Cannot get server status' ) ;
}
2023-02-13 14:45:45 +00:00
}
2023-04-02 16:58:55 +00:00
} ) ;
}
2023-02-13 14:45:45 +00:00
}
2023-03-03 20:03:41 +00:00
function confirmChangeGroupsAndRoles ( user _id ) {
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var action _word = $ ( '#translate' ) . attr ( 'data-save' ) ;
var user _groups _word = $ ( '#translate' ) . attr ( 'data-user_groups' ) ;
2023-03-04 07:42:26 +00:00
var username = $ ( '#login-' + user _id ) . val ( ) ;
2023-03-03 20:03:41 +00:00
$ . ajax ( {
url : "options.py" ,
data : {
act : 'show_user_group_and_role' ,
user _id : user _id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
$ ( "#groups-roles" ) . html ( data ) ;
$ ( "#groups-roles" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 700 ,
modal : true ,
2023-03-04 07:42:26 +00:00
title : user _groups _word + ' ' + username ,
2023-03-03 20:03:41 +00:00
buttons : [ {
text : action _word ,
click : function ( ) {
saveGroupsAndRoles ( user _id ) ;
$ ( this ) . dialog ( "close" ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
}
} ) ;
}
function addGroupToUser ( group _id ) {
var group _name = $ ( '#add_group-' + group _id ) . attr ( 'data-group_name' ) ;
2023-03-04 12:42:26 +00:00
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var group2 _word = $ ( '#translate' ) . attr ( 'data-group2' ) ;
var length _tr = $ ( '#all_groups tbody tr' ) . length ;
const roles = { 1 : 'superAdmin' , 2 : 'amdin' , 3 : 'user' , 4 : 'guest' } ;
var options _roles = '' ;
for ( const [ role _id , role _name ] of Object . entries ( roles ) ) {
options _roles += '<option value="' + role _id + '">' + role _name + '</option>' ;
}
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="remove_group-' + group _id + '" data-group_name="' + group _name + '">\n' +
' <td class="padding20" style="width: 50%;">' + group _name + '</td>\n' +
' <td style="width: 50%;">\n' +
' <select id="add_role-' + group _id + '">' + options _roles + '</select></td>\n' +
' <td><span class="remove_user_group" onclick="removeGroupFromUser(' + group _id + ')" title="' + delete _word + ' ' + group2 _word + '">-</span></td></tr>'
$ ( '#add_group-' + group _id ) . remove ( ) ;
$ ( "#checked_groups tbody" ) . append ( html _tag ) ;
2023-03-03 20:03:41 +00:00
}
function removeGroupFromUser ( group _id ) {
var group _name = $ ( '#remove_group-' + group _id ) . attr ( 'data-group_name' ) ;
2023-03-04 07:42:26 +00:00
var add _word = $ ( '#translate' ) . attr ( 'data-add' ) ;
var group2 _word = $ ( '#translate' ) . attr ( 'data-group2' ) ;
var length _tr = $ ( '#all_groups tbody tr' ) . length ;
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="add_group-' + group _id + '" data-group_name=' + group _name + '>\n' +
' <td class="padding20" style="width: 100%">' + group _name + '</td>\n' +
2023-03-04 12:42:26 +00:00
' <td><span class="add_user_group" title="' + add _word + ' ' + group2 _word + '" onclick="addGroupToUser(' + group _id + ')">+</span></td></tr>'
2023-03-04 07:42:26 +00:00
$ ( '#remove_group-' + group _id ) . remove ( ) ;
$ ( "#all_groups tbody" ) . append ( html _tag ) ;
2023-03-03 20:03:41 +00:00
}
function saveGroupsAndRoles ( user _id ) {
var length _tr = $ ( '#checked_groups tbody tr' ) . length ;
var jsonData = { } ;
jsonData [ user _id ] = { } ;
$ ( '#checked_groups tbody tr' ) . each ( function ( ) {
var this _id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 1 ] ;
var role _id = $ ( '#add_role-' + this _id ) . val ( ) ;
jsonData [ user _id ] [ this _id ] = { 'role_id' : role _id } ;
} ) ;
$ . ajax ( {
url : "options.py" ,
data : {
act : 'save_user_group_and_role' ,
2023-03-04 07:42:26 +00:00
changeUserGroupsUser : $ ( '#login-' + user _id ) . val ( ) ,
2023-03-03 20:03:41 +00:00
jsonDatas : JSON . stringify ( jsonData ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error: ' ) != '-1' ) {
toastr . warning ( data ) ;
} else {
$ ( "#user-" + user _id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#user-" + user _id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}
2023-04-02 16:58:55 +00:00
function openChangeServerServiceDialog ( server _id ) {
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var action _word = $ ( '#translate' ) . attr ( 'data-save' ) ;
var user _groups _word = $ ( '#translate' ) . attr ( 'data-user_groups' ) ;
var hostname = $ ( '#hostname-' + server _id ) . val ( ) ;
$ . ajax ( {
url : "options.py" ,
data : {
act : 'show_server_services' ,
server _id : server _id ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
$ ( "#groups-roles" ) . html ( data ) ;
$ ( "#groups-roles" ) . dialog ( {
resizable : false ,
height : "auto" ,
width : 700 ,
modal : true ,
title : user _groups _word + ' ' + hostname ,
buttons : [ {
text : action _word ,
click : function ( ) {
changeServerServices ( server _id ) ;
$ ( this ) . dialog ( "close" ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
}
} ) ;
}
function addServiceToServer ( service _id ) {
var service _name = $ ( '#add_service-' + service _id ) . attr ( 'data-service_name' ) ;
var delete _word = $ ( '#translate' ) . attr ( 'data-delete' ) ;
var service _word = $ ( '#translate' ) . attr ( 'data-service' ) ;
var length _tr = $ ( '#checked_services tbody tr' ) . length ;
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="remove_service-' + service _id + '" data-service_name="' + service _name + '">' +
'<td class="padding20" style="width: 100%;">' + service _name + '</td>' +
'<td><span class="add_user_group" onclick="removeServiceFromUser(' + service _id + ')" title="' + delete _word + ' ' + service _word + '">-</span></td></tr>' ;
$ ( '#add_service-' + service _id ) . remove ( ) ;
$ ( "#checked_services tbody" ) . append ( html _tag ) ;
}
function removeServiceFromServer ( service _id ) {
var service _name = $ ( '#remove_service-' + service _id ) . attr ( 'data-service_name' ) ;
var add _word = $ ( '#translate' ) . attr ( 'data-add' ) ;
var service _word = $ ( '#translate' ) . attr ( 'data-service' ) ;
var length _tr = $ ( '#all_services tbody tr' ) . length ;
var tr _class = 'odd' ;
if ( length _tr % 2 != 0 ) {
tr _class = 'even' ;
}
var html _tag = '<tr class="' + tr _class + '" id="add_service-' + service _id + '" data-service_name="' + service _name + '">' +
'<td class="padding20" style="width: 100%;">' + service _name + '</td>' +
'<td><span class="add_user_group" onclick="addServiceToUser(' + service _id + ')" title="' + add _word + ' ' + service _word + '">+</span></td></tr>' ;
$ ( '#remove_service-' + service _id ) . remove ( ) ;
$ ( "#all_services tbody" ) . append ( html _tag ) ;
}
function changeServerServices ( server _id ) {
var jsonData = { } ;
$ ( '#checked_services tbody tr' ) . each ( function ( ) {
var this _id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 1 ] ;
jsonData [ this _id ] = 1
} ) ;
$ ( '#all_services tbody tr' ) . each ( function ( ) {
var this _id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 1 ] ;
jsonData [ this _id ] = 0
} ) ;
$ . ajax ( {
url : "options.py" ,
data : {
changeServerServicesId : server _id ,
jsonDatas : JSON . stringify ( jsonData ) ,
changeServerServicesServer : $ ( '#hostname-' + server _id ) . val ( ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'Failed' ) != '-1' ) {
toastr . error ( data ) ;
} else {
$ ( "#server-" + server _id ) . addClass ( "update" , 1000 ) ;
setTimeout ( function ( ) {
$ ( "#server-" + server _id ) . removeClass ( "update" ) ;
} , 2500 ) ;
}
}
} ) ;
}