2023-09-17 09:42:39 +00:00
var url = "/inc/script.js" ;
var cur _url = window . location . href . split ( '/app/' ) . pop ( ) ;
cur _url = cur _url . split ( '/' ) ;
2018-05-02 11:11:22 +00:00
var intervalId ;
2020-09-15 05:56:43 +00:00
function validateEmail ( email ) {
const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ;
return re . test ( email ) ;
}
2020-12-01 04:31:50 +00:00
function escapeHtml ( unsafe ) {
return unsafe
. replace ( /&/g , "&" )
. replace ( /</g , "<" )
. replace ( />/g , ">" )
. replace ( /"/g , """ )
. replace ( /'/g , "'" ) ;
}
2023-02-13 14:45:45 +00:00
var wait _mess _word = $ ( '#translate' ) . attr ( 'data-wait_mess' ) ;
var wait _mess = '<div class="alert alert-warning">' + wait _mess _word + '</div>'
2021-08-15 09:02:12 +00:00
function show _current _page ( id ) {
id . parent ( ) . css ( 'display' , 'contents' ) ;
id . parent ( ) . css ( 'font-size' , '13px' ) ;
id . parent ( ) . css ( 'top' , '0' ) ;
id . parent ( ) . css ( 'left' , '0' ) ;
id . parent ( ) . children ( ) . css ( 'margin-left' , '-20px' ) ;
id . parent ( ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2023-04-02 16:58:55 +00:00
id . find ( 'a' ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2021-08-15 09:02:12 +00:00
}
2019-09-20 06:42:19 +00:00
$ ( function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
var link = $ ( this ) . find ( 'a' ) . attr ( 'href' ) ;
2023-04-02 16:58:55 +00:00
var link2 = link . split ( '/' ) [ 2 ] ;
2023-09-17 09:42:39 +00:00
var link3 = link . split ( '/' ) [ 3 ] ;
var link4 = link . split ( '/' ) [ 4 ] ;
2020-02-05 08:15:57 +00:00
if ( cur _url [ 1 ] == null ) {
2023-04-02 16:58:55 +00:00
cur _url [ 1 ] = 'haproxy' ;
2020-02-05 08:15:57 +00:00
}
2023-09-17 09:42:39 +00:00
var full _uri = cur _url [ 0 ] + '/' + cur _url [ 1 ]
var full _uri1 = link2 + '/' + link3
var full _uri2 = cur _url [ 0 ] + '/' + cur _url [ 1 ] + '/' + cur _url [ 2 ]
var full _uri3 = link2 + '/' + link3 + '/' + link4
if ( cur _url [ 0 ] == link2 && link3 == null ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'config/haproxy' && full _uri1 == 'config/haproxy' ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'config/nginx' && full _uri1 == 'config/nginx' ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'config/apache' && full _uri1 == 'config/apache' ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'config/keepalived' && full _uri1 == 'config/keepalived' ) {
2023-06-03 15:04:22 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri2 == 'config/versions/haproxy' && full _uri3 == 'config/versions/haproxy' ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri2 == 'config/versions/nginx' && full _uri3 == 'config/versions/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/versions/keepalived' && full _uri3 == 'config/versions/keepalived' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/versions/apache' && full _uri3 == 'config/versions/apache' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/map/haproxy' && full _uri1 == 'config/haproxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/compare/haproxy' && full _uri1 == 'config/haproxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/compare/nginx' && full _uri1 == 'config/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/compare/keepalived' && full _uri3 == 'config/keepalived' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri2 == 'config/compare/apache' && full _uri3 == 'config/apache' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'logs/haproxy' && full _uri1 == 'logs/haproxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'logs/nginx' && full _uri1 == 'logs/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'logs/keepalived' && full _uri1 == 'logs/keepalived' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'logs/apache' && full _uri1 == 'logs/apache' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'service/haproxy' && full _uri1 == 'service/haproxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'service/nginx' && full _uri1 == 'service/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'service/keepalived' && full _uri1 == 'service/keepalived' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'service/apache' && full _uri1 == 'service/apache' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'stats/haproxy' && full _uri1 == 'stats/haproxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'stats/nginx' && full _uri1 == 'stats/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'stats/apache' && full _uri1 == 'stats/apache' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri . indexOf ( 'add/haproxy#' ) != '-1' && full _uri1 . indexOf ( 'add/haproxy#proxy' ) != '-1' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'add/haproxy#ssl' && full _uri1 == 'add/haproxy#ssl' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'add/nginx#proxy' && full _uri1 == 'add/nginx#proxy' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'smon/dashboard' && full _uri1 == 'smon/dashboard' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'smon/admin' && full _uri1 == 'smon/admin' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'smon/history' && full _uri1 == 'smon/history' ) {
show _current _page ( $ ( this ) )
2023-11-02 12:38:04 +00:00
} else if ( full _uri == 'smon/status-page' && full _uri1 == 'smon/status-page' ) {
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'checker/settings' && full _uri1 == 'checker/settings' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'checker/history' && full _uri1 == 'checker/history' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'add/haproxy?service=nginx#ssl' && cur _url [ 1 ] . split ( '?' ) [ 1 ] == 'service=nginx#ssl' && full _uri1 == 'add/haproxy?service=nginx#ssl' ) {
show _current _page ( $ ( this ) )
} else if ( cur _url [ 0 ] == 'app/logs' && cur _url [ 1 ] . split ( '&' ) [ 0 ] == 'type=2' && link2 == 'viewlogs.py?type=2' ) {
2023-04-02 16:58:55 +00:00
show _current _page ( $ ( this ) ) ;
return false ;
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'metrics/haproxy' && full _uri1 == 'metrics/haproxy' ) {
2022-08-15 08:50:29 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'metrics/nginx' && full _uri1 == 'metrics/nginx' ) {
2021-08-15 09:02:12 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'metrics/apache' && full _uri1 == 'metrics/apache' ) {
2022-07-03 06:11:34 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'add/haproxy?service=apache#ssl' && cur _url [ 1 ] . split ( '?' ) [ 1 ] == 'service=apache#ssl' && full _uri1 == 'add/haproxy?service=apache#ssl' ) {
2022-04-15 09:49:00 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'waf/haproxy' && full _uri1 == 'waf/haproxy' ) {
2022-08-02 08:53:32 +00:00
show _current _page ( $ ( this ) )
2023-09-17 09:42:39 +00:00
} else if ( full _uri == 'waf/nginx' && full _uri1 == 'waf/nginx' ) {
show _current _page ( $ ( this ) )
} else if ( full _uri == 'install/ha' && full _uri1 == 'install/ha' ) {
2022-08-02 08:53:32 +00:00
show _current _page ( $ ( this ) )
2020-07-15 04:16:31 +00:00
}
2019-09-20 06:42:19 +00:00
} ) ;
} ) ;
2018-07-23 07:08:43 +00:00
jQuery . expr [ ':' ] . regex = function ( elem , index , match ) {
var matchParams = match [ 3 ] . split ( ',' ) ,
validLabels = /^(data|css):/ ,
attr = {
method : matchParams [ 0 ] . match ( validLabels ) ?
matchParams [ 0 ] . split ( ':' ) [ 0 ] : 'attr' ,
property : matchParams . shift ( ) . replace ( validLabels , '' )
} ,
regexFlags = 'ig' ,
regex = new RegExp ( matchParams . join ( '' ) . replace ( /^\s+|\s+$/g , '' ) , regexFlags ) ;
return regex . test ( jQuery ( elem ) [ attr . method ] ( attr . property ) ) ;
}
2018-07-27 03:45:49 +00:00
window . onblur = function ( ) {
window . onfocus = function ( ) {
2020-11-04 12:28:51 +00:00
if ( sessionStorage . getItem ( 'auto-refresh-pause' ) == "0" && sessionStorage . getItem ( 'auto-refresh' ) > 5000 ) {
2023-09-17 09:42:39 +00:00
if ( cur _url [ 0 ] == "logs" ) {
2018-07-27 03:45:49 +00:00
showLog ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "stats" ) {
2018-07-27 03:45:49 +00:00
showStats ( )
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "/" ) {
2018-07-27 03:45:49 +00:00
showOverview ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "internal" ) {
2018-07-27 03:45:49 +00:00
viewLogs ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "metrics" ) {
2019-10-06 06:50:12 +00:00
showMetrics ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "smon" && cur _url [ 1 ] == "dasboards" ) {
2020-08-25 12:38:49 +00:00
showSmon ( 'refresh' )
}
2021-02-28 05:55:24 +00:00
}
2018-07-27 03:45:49 +00:00
}
} ;
2020-12-15 06:34:02 +00:00
if ( localStorage . getItem ( 'restart' ) ) {
2021-03-14 04:58:41 +00:00
var ip _for _restart = localStorage . getItem ( 'restart' ) ;
2023-09-17 09:42:39 +00:00
$ . ajax ( {
url : "/app/service/check-restart/" + ip _for _restart ,
// data: {
// token: $('#token').val()
// },
// type: "POST",
success : function ( data ) {
if ( data . indexOf ( 'ok' ) != '-1' ) {
2022-07-06 08:51:02 +00:00
var apply _div = $ . find ( "#apply_div" ) ;
apply _div = apply _div [ 0 ] . id ;
2018-08-28 10:45:09 +00:00
$ ( "#apply" ) . css ( 'display' , 'block' ) ;
2023-09-17 09:42:39 +00:00
$ ( '#' + apply _div ) . css ( 'width' , '850px' ) ;
2022-07-06 09:04:05 +00:00
ip _for _restart = escapeHtml ( ip _for _restart ) ;
2023-09-17 09:42:39 +00:00
if ( cur _url [ 0 ] == "service" ) {
$ ( '#' + apply _div ) . css ( 'width' , '650px' ) ;
$ ( '#' + apply _div ) . addClass ( "alert-one-row" ) ;
$ ( '#' + apply _div ) . html ( "You have made changes to the server: " + ip _for _restart + ". Changes will take effect only after<a id='" + ip _for _restart + "' class='restart' title='Restart HAproxy service' onclick=\"confirmAjaxAction('restart', 'hap', '" + ip _for _restart + "')\">restart</a><a href='#' title='close' id='apply_close' style='float: right'><b>X</b></a>" ) ;
2018-08-28 10:45:09 +00:00
} else {
2023-09-17 09:42:39 +00:00
$ ( '#' + apply _div ) . html ( "You have made changes to the server: " + ip _for _restart + ". Changes will take effect only after restart. <a href='service' title='Overview'>Go to the HAProxy Overview page and restart</a><a href='#' title='close' id='apply_close' style='float: right'><b>X</b></a>" ) ;
2018-08-28 10:45:09 +00:00
}
2023-09-17 09:42:39 +00:00
$ . getScript ( '/inc/overview.js' ) ;
2018-08-28 10:45:09 +00:00
}
2023-09-17 09:42:39 +00:00
}
} ) ;
2018-08-28 10:45:09 +00:00
}
2018-04-09 10:27:01 +00:00
function autoRefreshStyle ( autoRefresh ) {
var margin ;
2023-09-17 09:42:39 +00:00
if ( cur _url [ 0 ] == "/" || cur _url [ 0 ] == "waf" || cur _url [ 0 ] == "metrics" ) {
if ( autoRefresh < 60000 ) {
2018-05-02 11:11:22 +00:00
autoRefresh = 60000 ;
}
}
2018-04-09 10:27:01 +00:00
autoRefresh = autoRefresh / 1000 ;
2023-09-17 09:42:39 +00:00
if ( autoRefresh == 60 ) {
2018-04-09 10:27:01 +00:00
timeRange = " minute"
autoRefresh = autoRefresh / 60 ;
2023-09-17 09:42:39 +00:00
} else if ( autoRefresh > 60 && autoRefresh < 3600 ) {
2018-04-09 10:27:01 +00:00
timeRange = " minutes"
autoRefresh = autoRefresh / 60 ;
2023-09-17 09:42:39 +00:00
} else if ( autoRefresh >= 3600 && autoRefresh < 86401 ) {
2018-04-09 10:27:01 +00:00
timeRange = " hours"
2023-09-17 09:42:39 +00:00
autoRefresh = autoRefresh / 3600 ;
2018-04-09 10:27:01 +00:00
} else {
timeRange = " seconds" ;
}
$ ( '#1' ) . text ( autoRefresh + timeRange ) ;
$ ( '#0' ) . text ( autoRefresh + timeRange ) ;
2023-09-17 09:42:39 +00:00
$ ( '.auto-refresh-pause' ) . css ( 'display' , 'inline' ) ;
$ ( '.auto-refresh-resume' ) . css ( 'display' , 'none' ) ;
$ ( '.auto-refresh-pause' ) . css ( 'margin-left' , "-25px" ) ;
$ ( '.auto-refresh-resume' ) . css ( 'margin-left' , "-25px" ) ;
2023-10-03 19:56:34 +00:00
$ ( '#browse_history' ) . css ( "border-bottom" , "none" ) ;
2018-04-09 10:27:01 +00:00
$ ( '.auto-refresh img' ) . remove ( ) ;
}
2018-04-08 07:33:09 +00:00
function setRefreshInterval ( interval ) {
if ( interval == "0" ) {
2020-11-04 12:28:51 +00:00
var autoRefresh = sessionStorage . getItem ( 'auto-refresh' ) ;
2020-07-02 14:44:13 +00:00
if ( autoRefresh !== undefined ) {
2023-04-02 16:58:55 +00:00
var autorefresh _word = $ ( '#translate' ) . attr ( 'data-autorefresh' ) ;
2020-11-04 12:28:51 +00:00
sessionStorage . removeItem ( 'auto-refresh' ) ;
2020-07-02 14:44:13 +00:00
pauseAutoRefresh ( ) ;
2023-04-02 16:58:55 +00:00
$ ( '#0' ) . html ( '<span class="auto-refresh-reload auto-refresh-reload-icon"></span> ' + autorefresh _word ) ;
2020-11-04 12:28:51 +00:00
$ ( '.auto-refresh' ) . css ( 'display' , 'inline' ) ;
2020-07-02 14:44:13 +00:00
$ ( '.auto-refresh' ) . css ( 'font-size' , '15px' ) ;
2023-04-02 16:58:55 +00:00
$ ( '#1' ) . text ( autorefresh _word ) ;
2020-07-02 14:44:13 +00:00
$ ( '.auto-refresh-resume' ) . css ( 'display' , 'none' ) ;
2023-04-02 16:58:55 +00:00
$ ( '.auto-refresh-pause' ) . css ( 'display' , 'none' ) ;
2021-07-05 14:51:05 +00:00
$ . getScript ( "/inc/fontawesome.min.js" ) ;
2020-07-02 14:44:13 +00:00
}
2018-04-08 07:33:09 +00:00
hideAutoRefreshDiv ( ) ;
} else {
2018-04-09 10:27:01 +00:00
clearInterval ( intervalId ) ;
2020-11-04 12:28:51 +00:00
sessionStorage . setItem ( 'auto-refresh' , interval )
sessionStorage . setItem ( 'auto-refresh-pause' , 0 )
2018-04-08 07:33:09 +00:00
startSetInterval ( interval ) ;
hideAutoRefreshDiv ( ) ;
2018-04-09 10:27:01 +00:00
autoRefreshStyle ( interval ) ;
2018-04-08 07:33:09 +00:00
}
}
2020-08-25 12:38:49 +00:00
function startSetInterval ( interval ) {
2020-11-04 12:28:51 +00:00
if ( sessionStorage . getItem ( 'auto-refresh-pause' ) == "0" ) {
2023-09-17 09:42:39 +00:00
if ( cur _url [ 0 ] == "logs" ) {
2018-08-03 19:17:03 +00:00
intervalId = setInterval ( 'showLog()' , interval ) ;
showLog ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "stats" ) {
2018-08-03 19:17:03 +00:00
intervalId = setInterval ( 'showStats()' , interval ) ;
showStats ( )
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "/" ) {
2018-08-03 19:17:03 +00:00
if ( interval < 60000 ) {
interval = 60000 ;
}
2019-12-30 16:41:16 +00:00
intervalId = setInterval ( 'showOverview(ip, hostnamea)' , interval ) ;
2023-09-17 09:42:39 +00:00
showOverview ( ip , hostnamea ) ;
} else if ( cur _url [ 1 ] == "internal" ) {
2018-08-03 19:17:03 +00:00
intervalId = setInterval ( 'viewLogs()' , interval ) ;
viewLogs ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "metrics" ) {
2018-09-07 07:44:23 +00:00
if ( interval < 60000 ) {
interval = 60000 ;
}
2019-10-06 06:50:12 +00:00
intervalId = setInterval ( 'showMetrics()' , interval ) ;
showMetrics ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "waf" ) {
2018-09-07 07:44:23 +00:00
if ( interval < 60000 ) {
interval = 60000 ;
}
2019-12-30 16:41:16 +00:00
intervalId = setInterval ( 'showOverviewWaf(ip, hostnamea)' , interval ) ;
showOverviewWaf ( ip , hostnamea ) ;
2019-10-06 06:50:12 +00:00
showWafMetrics ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "service" ) {
2019-10-25 07:18:57 +00:00
if ( interval < 60000 ) {
interval = 60000 ;
}
intervalId = setInterval ( 'showMetrics()' , interval ) ;
showMetrics ( ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "smon" && cur _url [ 1 ] == "dashboards" ) {
2020-08-25 12:38:49 +00:00
intervalId = setInterval ( "showSmon('refresh')" , interval ) ;
showSmon ( 'refresh' ) ;
2023-09-17 09:42:39 +00:00
} else if ( cur _url [ 0 ] == "smon" && cur _url [ 1 ] == "history" ) {
2023-07-17 06:15:55 +00:00
if ( interval < 60000 ) {
interval = 60000 ;
}
intervalId = setInterval ( 'showSmonHistory()' , interval ) ;
showSmonHistory ( ) ;
2020-08-25 12:38:49 +00:00
}
2018-08-03 19:17:03 +00:00
} else {
pauseAutoRefresh ( ) ;
}
2018-04-08 07:33:09 +00:00
}
function pauseAutoRefresh ( ) {
clearInterval ( intervalId ) ;
2023-04-02 16:58:55 +00:00
$ ( '.auto-refresh-pause' ) . css ( 'display' , 'none' ) ;
$ ( '.auto-refresh-resume' ) . css ( 'display' , 'inline' ) ;
sessionStorage . setItem ( 'auto-refresh-pause' , '1' ) ;
}
2018-04-08 07:33:09 +00:00
function pauseAutoResume ( ) {
2020-11-04 12:28:51 +00:00
var autoRefresh = sessionStorage . getItem ( 'auto-refresh' ) ;
2018-04-08 07:33:09 +00:00
setRefreshInterval ( autoRefresh ) ;
2020-11-04 12:28:51 +00:00
sessionStorage . setItem ( 'auto-refresh-pause' , '0' ) ;
2018-04-08 07:33:09 +00:00
}
function hideAutoRefreshDiv ( ) {
$ ( function ( ) {
$ ( '.auto-refresh-div' ) . hide ( "blind" , "fast" ) ;
$ ( '#1' ) . css ( "display" , "none" ) ;
$ ( '#0' ) . css ( "display" , "inline" ) ;
} ) ;
}
2018-04-11 03:30:46 +00:00
$ ( document ) . ajaxSend ( function ( event , request , settings ) {
NProgress . start ( ) ;
} ) ;
$ ( document ) . ajaxComplete ( function ( event , request , settings ) {
NProgress . done ( ) ;
} ) ;
2018-04-09 10:27:01 +00:00
function showStats ( ) {
2023-09-17 09:42:39 +00:00
$ . ajax ( {
url : "/app/stats/view/" + $ ( "#service" ) . val ( ) + "/" + $ ( "#serv" ) . val ( ) ,
// data: {
// token: $('#token').val()
// },
// type: "POST",
success : function ( data ) {
2020-11-02 17:01:08 +00:00
if ( data . indexOf ( 'error:' ) != '-1' && data . indexOf ( 'Internal error:' ) == '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Stats" , "Stats" , "/app/stats/" + $ ( "#service" ) . val ( ) + "/" + $ ( "#serv" ) . val ( ) ) ;
2020-07-26 16:26:04 +00:00
wait ( ) ;
}
2023-09-17 09:42:39 +00:00
}
} ) ;
2019-09-08 10:07:58 +00:00
}
function openStats ( ) {
var serv = $ ( "#serv" ) . val ( ) ;
2023-09-17 09:42:39 +00:00
var service _url = cur _url [ 1 ] ;
var url = "/app/stats/" + service _url + "/" + serv
2019-09-08 10:07:58 +00:00
var win = window . open ( url , '_blank' ) ;
win . focus ( ) ;
2018-04-09 10:27:01 +00:00
}
2019-09-15 11:51:09 +00:00
function openVersions ( ) {
var serv = $ ( "#serv" ) . val ( ) ;
2023-09-17 09:42:39 +00:00
var service _url = cur _url [ 1 ] ;
var url = "/app/config/versions/" + service _url + "/" + serv
var win = window . open ( url , "_self" ) ;
win . focus ( ) ;
}
function openSection ( ) {
var serv = $ ( "#serv" ) . val ( ) ;
var section = $ ( "#section" ) . val ( ) ;
var url = "/app/config/section/haproxy/" + serv + "/" + section ;
2019-09-26 15:48:56 +00:00
var win = window . open ( url , "_self" ) ;
2019-09-15 11:51:09 +00:00
win . focus ( ) ;
}
2018-04-09 10:27:01 +00:00
function showLog ( ) {
2023-09-17 09:42:39 +00:00
var waf = cur _url [ 2 ] ;
2022-03-02 20:09:39 +00:00
var file = $ ( '#log_files' ) . val ( ) ;
2023-09-20 10:11:10 +00:00
var serv = $ ( "#serv" ) . val ( ) ;
if ( ( file === undefined || file === null ) && ( waf == '' || waf === undefined ) ) {
2022-08-02 08:53:32 +00:00
var file _from _get = findGetParameter ( 'file' ) ;
if ( file _from _get === undefined || file _from _get === null ) {
toastr . warning ( 'Select a log file first' )
return false ;
} else {
file = file _from _get ;
}
2018-08-17 11:55:17 +00:00
}
2023-09-20 10:11:10 +00:00
var rows = $ ( '#rows' ) . val ( ) ;
var grep = $ ( '#grep' ) . val ( ) ;
var exgrep = $ ( '#exgrep' ) . val ( ) ;
var hour = $ ( '#time_range_out_hour' ) . val ( ) ;
var minute = $ ( '#time_range_out_minut' ) . val ( ) ;
var hour1 = $ ( '#time_range_out_hour1' ) . val ( ) ;
var minute1 = $ ( '#time_range_out_minut1' ) . val ( ) ;
var service = $ ( '#service' ) . val ( ) ;
2020-07-02 14:44:13 +00:00
if ( service == 'None' ) {
service = 'haproxy' ;
}
2023-09-17 09:42:39 +00:00
if ( waf ) {
2023-09-20 10:11:10 +00:00
var url = "/app/logs/" + service + "/waf/" + serv + "/" + rows ;
2023-09-17 09:42:39 +00:00
waf = 1 ;
} else {
2023-09-20 10:11:10 +00:00
var url = "/app/logs/" + service + "/" + serv + "/" + rows ;
2023-09-17 09:42:39 +00:00
}
2018-04-09 10:27:01 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : url ,
2018-04-09 10:27:01 +00:00
data : {
2021-08-08 13:02:00 +00:00
show _log : rows ,
2018-08-17 11:55:17 +00:00
waf : waf ,
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 ,
2023-09-17 09:42:39 +00:00
minute : minute ,
2019-09-29 20:16:24 +00:00
hour1 : hour1 ,
2023-09-17 09:42:39 +00:00
minute1 : minute1 ,
2022-03-02 20:09:39 +00:00
file : file ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
success : function ( data ) {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
2022-09-28 14:18:53 +00:00
}
2022-03-02 20:09:39 +00:00
} ) ;
}
function showRemoteLogFiles ( ) {
let serv = $ ( '#serv' ) . val ( ) ;
if ( serv === undefined || serv === null ) {
toastr . warning ( 'Select a server firts' ) ;
return false ;
}
var rows = $ ( '#rows' ) . val ( )
var grep = $ ( '#grep' ) . val ( )
var exgrep = $ ( '#exgrep' ) . val ( )
var hour = $ ( '#time_range_out_hour' ) . val ( )
2023-09-17 09:42:39 +00:00
var minute = $ ( '#time_range_out_minut' ) . val ( )
2022-03-02 20:09:39 +00:00
var hour1 = $ ( '#time_range_out_hour1' ) . val ( )
2023-09-17 09:42:39 +00:00
var minute1 = $ ( '#time_range_out_minut1' ) . val ( )
2022-03-02 20:09:39 +00:00
var service = $ ( '#service' ) . val ( )
if ( service == 'None' ) {
service = 'haproxy' ;
}
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/logs/" + service + "/" + serv ,
2022-03-02 20:09:39 +00:00
data : {
serv : $ ( "#serv" ) . val ( ) ,
2018-06-01 12:27:58 +00:00
token : $ ( '#token' ) . val ( )
2018-04-09 10:27:01 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-11 03:30:46 +00:00
success : function ( data ) {
2022-03-02 20:09:39 +00:00
if ( data . indexOf ( 'error:' ) != '-1' || data . indexOf ( 'ls: cannot access' ) != '-1' ) {
2020-07-26 16:26:04 +00:00
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
2022-03-02 20:09:39 +00:00
$ ( "#remote_log_files" ) . html ( data ) ;
$ . getScript ( '/inc/configshow.js' ) ;
2020-07-26 16:26:04 +00:00
}
2022-03-02 20:09:39 +00:00
}
2018-04-11 03:30:46 +00:00
} ) ;
2022-03-02 20:09:39 +00:00
2018-04-11 03:30:46 +00:00
}
2022-01-16 13:50:53 +00:00
function clearAllAjaxFields ( ) {
2018-09-27 04:28:10 +00:00
$ ( "#ajax" ) . empty ( ) ;
2020-11-18 04:45:34 +00:00
$ ( '.alert' ) . remove ( ) ;
2020-08-09 07:18:30 +00:00
try {
myCodeMirror . toTextArea ( ) ;
} catch ( e ) {
console . log ( e )
}
$ ( "#saveconfig" ) . remove ( ) ;
$ ( "h4" ) . remove ( ) ;
2018-09-27 04:28:10 +00:00
$ ( "#ajax-compare" ) . empty ( ) ;
$ ( "#config" ) . empty ( ) ;
2022-01-16 13:50:53 +00:00
}
function showMap ( ) {
clearAllAjaxFields ( ) ;
$ ( '#ajax-config_file_name' ) . empty ( ) ;
2018-04-11 03:30:46 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/map/haproxy/" + $ ( "#serv" ) . val ( ) + '/show' ,
2018-04-10 03:58:56 +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 ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Show Map" , "Show Map" , '/app/config/map/' + $ ( "#service" ) . val ( ) + '/' + $ ( "#serv" ) . val ( ) ) ;
2020-07-26 16:26:04 +00:00
}
2022-09-28 14:18:53 +00:00
}
2018-04-10 03:58:56 +00:00
} ) ;
}
function showCompare ( ) {
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/compare/" + $ ( "#service" ) . val ( ) + "/" + $ ( "#serv" ) . val ( ) + "/show" ,
2018-04-10 03:58:56 +00:00
data : {
left : $ ( '#left' ) . val ( ) ,
2018-06-01 12:27:58 +00:00
right : $ ( "#right" ) . val ( ) ,
token : $ ( '#token' ) . val ( )
2018-04-10 03:58:56 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-09 10:27:01 +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 ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
}
2022-09-28 14:18:53 +00:00
}
2018-04-11 09:27:57 +00:00
} ) ;
}
function showCompareConfigs ( ) {
2022-01-16 13:50:53 +00:00
clearAllAjaxFields ( ) ;
$ ( '#ajax-config_file_name' ) . empty ( ) ;
2018-04-11 09:27:57 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/compare/" + $ ( "#service" ) . val ( ) + "/" + $ ( "#serv" ) . val ( ) + "/files" ,
type : "GET" ,
2018-04-11 09:27:57 +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 ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax-compare" ) . html ( data ) ;
$ ( "input[type=submit], button" ) . button ( ) ;
$ ( "select" ) . selectmenu ( ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Show compare config" , "Show compare config" , '/app/config/compare/' + $ ( "#service" ) . val ( ) + '/' + $ ( "#serv" ) . val ( ) ) ;
2020-07-26 16:26:04 +00:00
}
}
2018-04-10 06:10:07 +00:00
} ) ;
}
function showConfig ( ) {
2020-04-16 13:30:51 +00:00
var service = $ ( '#service' ) . val ( ) ;
2022-01-16 13:50:53 +00:00
var config _file _name = encodeURI ( $ ( '#config_file_name' ) . val ( ) ) ;
2022-04-15 09:49:00 +00:00
if ( service == 'nginx' || service == 'apache' ) {
2022-03-02 20:09:39 +00:00
if ( $ ( '#config_file_name' ) . val ( ) === undefined || $ ( '#config_file_name' ) . val ( ) === null ) {
2023-09-17 09:42:39 +00:00
config _file _name = cur _url [ 4 ]
if ( config _file _name == '' ) {
toastr . warning ( 'Select a config file firts' ) ;
return false ;
} else {
showConfigFiles ( true ) ;
}
2022-03-02 20:09:39 +00:00
}
}
2022-01-16 13:50:53 +00:00
clearAllAjaxFields ( ) ;
2018-04-10 06:10:07 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/" + service + "/show" ,
2018-04-10 06:10:07 +00:00
data : {
serv : $ ( "#serv" ) . val ( ) ,
2020-04-16 13:30:51 +00:00
service : service ,
2023-09-17 09:42:39 +00:00
config _file _name : config _file _name
2018-04-10 06:10:07 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-04-10 06:10:07 +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 ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
$ . getScript ( '/inc/configshow.js' ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Show config" , "Show config" , "/app/config/" + service + "/" + $ ( "#serv" ) . val ( ) + "/show/" + config _file _name ) ;
2020-07-26 16:26:04 +00:00
}
2022-09-28 14:18:53 +00:00
}
2018-04-09 10:27:01 +00:00
} ) ;
}
2023-09-17 09:42:39 +00:00
function showConfigFiles ( not _redirect = false ) {
2022-01-16 13:50:53 +00:00
var service = $ ( '#service' ) . val ( ) ;
2023-09-17 09:42:39 +00:00
var server _ip = $ ( "#serv" ) . val ( ) ;
2022-01-16 13:50:53 +00:00
clearAllAjaxFields ( ) ;
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/" + service + "/show-files" ,
2022-01-16 13:50:53 +00:00
data : {
2023-09-17 09:42:39 +00:00
serv : server _ip ,
service : service
2022-01-16 13:50:53 +00:00
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax-config_file_name" ) . html ( data ) ;
2022-04-27 18:10:26 +00:00
if ( findGetParameter ( 'findInConfig' ) === null ) {
2023-09-17 09:42:39 +00:00
if ( not _redirect ) {
window . history . pushState ( "Show config" , "Show config" , "/app/config/" + service + "/" + server _ip + "/show-files" ) ;
}
2022-04-27 18:10:26 +00:00
}
2022-01-16 13:50:53 +00:00
}
}
} ) ;
}
function showConfigFilesForEditing ( ) {
var service = $ ( '#service' ) . val ( ) ;
2023-09-17 09:42:39 +00:00
var server _ip = $ ( "#serv" ) . val ( ) ;
2022-01-16 13:50:53 +00:00
var config _file _name = findGetParameter ( 'config_file_name' )
2022-04-15 09:49:00 +00:00
if ( service == 'nginx' || service == 'apache' ) {
2022-01-16 13:50:53 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/" + service + "/" + server _ip + "/edit/" + config _file _name ,
2022-01-16 13:50:53 +00:00
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax-config_file_name" ) . html ( data ) ;
}
}
} ) ;
}
}
2018-05-05 12:54:33 +00:00
function showUploadConfig ( ) {
2020-02-02 14:23:00 +00:00
var service = $ ( '#service' ) . val ( ) ;
var configver = $ ( '#configver' ) . val ( ) ;
var serv = $ ( "#serv" ) . val ( )
2018-05-05 12:54:33 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/" + service + "/show" ,
2018-05-05 12:54:33 +00:00
data : {
2020-02-02 14:23:00 +00:00
serv : serv ,
2023-09-17 09:42:39 +00:00
configver : configver
2018-05-05 12:54:33 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2018-05-05 12:54:33 +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 ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Show config" , "Show config" , "/app/config/versions/" + service + "/" + serv + "/" + configver ) ;
2020-07-26 16:26:04 +00:00
$ . getScript ( '/inc/configshow.js' ) ;
}
2022-09-28 14:18:53 +00:00
}
2018-05-05 12:54:33 +00:00
} ) ;
}
2021-10-18 15:57:49 +00:00
function showListOfVersion ( for _delver ) {
2023-09-17 09:42:39 +00:00
var cur _url = window . location . href . split ( '/app/' ) . pop ( ) ;
cur _url = cur _url . split ( '/' ) ;
2021-10-18 15:57:49 +00:00
var service = $ ( '#service' ) . val ( ) ;
var serv = $ ( "#serv" ) . val ( ) ;
2023-09-17 09:42:39 +00:00
var configver = cur _url [ 4 ] ;
2022-01-16 13:50:53 +00:00
clearAllAjaxFields ( ) ;
2021-10-18 15:57:49 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/config/version/" + service + "/list" ,
2021-10-18 15:57:49 +00:00
data : {
serv : serv ,
configver : configver ,
2023-09-17 09:42:39 +00:00
for _delver : for _delver
2021-10-18 15:57:49 +00:00
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#config_version_div" ) . html ( data ) ;
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
2023-09-17 09:42:39 +00:00
window . history . pushState ( "Show config" , "Show config" , "/app/config/versions/" + service + "/" + serv ) ;
2021-10-18 15:57:49 +00:00
}
}
} ) ;
}
2020-03-05 18:56:13 +00:00
function findGetParameter ( parameterName ) {
var result = null ,
tmp = [ ] ;
var items = location . search . substr ( 1 ) . split ( "&" ) ;
for ( var index = 0 ; index < items . length ; index ++ ) {
tmp = items [ index ] . split ( "=" ) ;
if ( tmp [ 0 ] === parameterName ) result = decodeURIComponent ( tmp [ 1 ] ) ;
}
return result ;
}
2018-04-21 14:40:59 +00:00
function viewLogs ( ) {
2023-09-20 13:43:15 +00:00
var viewlogs = $ ( '#viewlogs' ) . val ( ) ;
if ( viewlogs == '------' || viewlogs === null ) { return false ; }
if ( viewlogs == 'roxy-wi.error.log' || viewlogs == 'roxy-wi.access.log' || viewlogs == 'fail2ban.log' ) {
showApacheLog ( viewlogs ) ;
2018-07-24 04:08:06 +00:00
} else {
2023-09-20 13:43:15 +00:00
var rows = $ ( '#rows' ) . val ( ) ;
var grep = $ ( '#grep' ) . val ( ) ;
var exgrep = $ ( '#exgrep' ) . val ( ) ;
var hour = $ ( '#time_range_out_hour' ) . val ( ) ;
var minute = $ ( '#time_range_out_minut' ) . val ( ) ;
var hour1 = $ ( '#time_range_out_hour1' ) . val ( ) ;
var minute1 = $ ( '#time_range_out_minut1' ) . val ( ) ;
2020-08-11 06:44:03 +00:00
var type = findGetParameter ( 'type' )
2020-03-05 18:56:13 +00:00
if ( viewlogs == null ) {
viewlogs = findGetParameter ( 'viewlogs' )
2022-09-28 14:18:53 +00:00
}
2023-09-17 09:42:39 +00:00
var url = "/app/logs/internal/" + viewlogs + "/" + rows ;
$ . ajax ( {
url : url ,
2018-07-24 04:08:06 +00:00
data : {
2020-03-05 18:56:13 +00:00
viewlogs : viewlogs ,
2023-09-17 09:42:39 +00:00
serv : viewlogs ,
2019-09-29 20:16:24 +00:00
rows : rows ,
grep : grep ,
2020-06-15 17:29:49 +00:00
exgrep : exgrep ,
2019-09-29 20:16:24 +00:00
hour : hour ,
2023-09-20 13:43:15 +00:00
minute : minute ,
2019-09-29 20:16:24 +00:00
hour1 : hour1 ,
2023-09-20 13:43:15 +00:00
minute1 : minute1 ,
2022-09-28 14:18:53 +00:00
token : $ ( '#token' ) . val ( ) ,
2018-07-24 04:08:06 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2023-09-17 09:42:39 +00:00
success : function ( data ) {
2022-02-16 07:46:30 +00:00
$ ( "#ajax" ) . html ( data ) ;
2022-09-28 14:18:53 +00:00
}
2018-07-24 04:08:06 +00:00
} ) ;
}
2018-04-21 14:40:59 +00:00
}
2018-01-25 09:04:57 +00:00
$ ( function ( ) {
2023-08-03 06:56:25 +00:00
$ ( 'a' ) . click ( function ( e ) {
try {
var cur _path = window . location . pathname ;
var attr = $ ( this ) . attr ( 'href' ) ;
2023-11-06 17:47:27 +00:00
if ( cur _path == '/app/add/haproxy' || cur _path == '/app/add/nginx' || cur _path == '/app/servers' ||
cur _path == '/app/admin' || cur _path == '/app/install' || cur _path == '/app/runtimeapi' ) {
2023-08-03 06:56:25 +00:00
if ( typeof attr !== typeof undefined && attr !== false ) {
$ ( 'title' ) . text ( $ ( this ) . attr ( 'title' ) ) ;
history . pushState ( { } , '' , $ ( this ) . attr ( 'href' ) ) ;
if ( $ ( this ) . attr ( 'href' ) . split ( '#' ) [ 0 ] && $ ( this ) . attr ( 'href' ) . split ( '#' ) [ 0 ] != cur _path ) {
window . history . go ( )
}
}
}
} catch ( err ) {
console . log ( err ) ;
}
} ) ;
2020-07-26 16:26:04 +00:00
toastr . options . closeButton = true ;
toastr . options . progressBar = true ;
toastr . options . positionClass = 'toast-bottom-full-width' ;
toastr . options . timeOut = 25000 ;
toastr . options . extendedTimeOut = 50000 ;
2019-12-27 04:31:09 +00:00
$ ( '#errorMess' ) . click ( function ( ) {
$ ( '#error' ) . remove ( ) ;
} ) ;
2018-04-11 03:30:46 +00:00
$ ( "#serv" ) . on ( 'selectmenuchange' , function ( ) {
$ ( "#show" ) . css ( "pointer-events" , "inherit" ) ;
$ ( "#show" ) . css ( "cursor" , "pointer" ) ;
} ) ;
if ( $ ( "#serv option:selected" ) . val ( ) == "Choose server" ) {
$ ( "#show" ) . css ( "pointer-events" , "none" ) ;
$ ( "#show" ) . css ( "cursor" , "not-allowed" ) ;
}
2022-09-28 14:18:53 +00:00
2018-04-09 10:27:01 +00:00
var pause = '<a onclick="pauseAutoRefresh()" title="Pause auto-refresh" class="auto-refresh-pause"></a>'
2020-11-04 12:28:51 +00:00
var autoRefresh = sessionStorage . getItem ( 'auto-refresh' ) ;
2022-09-28 14:18:53 +00:00
2018-04-09 10:27:01 +00:00
if ( $ ( '.auto-refresh' ) ) {
if ( autoRefresh ) {
startSetInterval ( autoRefresh ) ;
autoRefreshStyle ( autoRefresh ) ;
}
}
2018-01-25 09:04:57 +00:00
$ ( "#tabs" ) . tabs ( ) ;
$ ( "select" ) . selectmenu ( ) ;
2022-09-28 14:18:53 +00:00
2022-11-20 07:48:15 +00:00
$ ( "[title]" ) . tooltip ( {
"content" : function ( ) {
return $ ( this ) . attr ( "data-help" ) ;
2023-04-02 16:58:55 +00:00
} ,
show : { "delay" : 1000 }
2022-11-20 07:48:15 +00:00
} ) ;
2018-01-25 09:04:57 +00:00
$ ( "input[type=submit], button" ) . button ( ) ;
2018-02-07 04:39:42 +00:00
$ ( "input[type=checkbox]" ) . checkboxradio ( ) ;
2018-02-17 17:20:30 +00:00
$ ( ".controlgroup" ) . controlgroup ( ) ;
2022-09-28 14:18:53 +00:00
2019-09-26 15:48:56 +00:00
$ ( "#hide_menu" ) . click ( function ( ) {
$ ( ".top-menu" ) . hide ( "drop" , "fast" ) ;
2019-10-18 17:23:35 +00:00
$ ( ".container" ) . css ( "max-width" , "100%" ) ;
$ ( ".footer" ) . css ( "max-width" , "97%" ) ;
2019-09-26 15:48:56 +00:00
$ ( ".container" ) . css ( "margin-left" , "1%" ) ;
$ ( ".footer" ) . css ( "margin-left" , "1%" ) ;
$ ( ".show_menu" ) . show ( ) ;
$ ( "#hide_menu" ) . hide ( ) ;
2020-11-04 12:28:51 +00:00
sessionStorage . setItem ( 'hide_menu' , 'hide' ) ;
2019-09-26 15:48:56 +00:00
} ) ;
$ ( "#show_menu" ) . click ( function ( ) {
$ ( ".top-menu" ) . show ( "drop" , "fast" ) ;
2019-10-05 20:41:07 +00:00
$ ( ".container" ) . css ( "max-width" , "100%" ) ;
$ ( ".footer" ) . css ( "max-width" , "100%" ) ;
2019-09-26 15:48:56 +00:00
$ ( ".container" ) . css ( "margin-left" , "207px" ) ;
$ ( ".footer" ) . css ( "margin-left" , "207px" ) ;
$ ( ".show_menu" ) . hide ( ) ;
$ ( "#hide_menu" ) . show ( ) ;
2020-11-04 12:28:51 +00:00
sessionStorage . setItem ( 'hide_menu' , 'show' ) ;
} ) ;
var hideMenu = sessionStorage . getItem ( 'hide_menu' ) ;
2019-09-26 15:48:56 +00:00
if ( hideMenu == "show" ) {
$ ( ".top-menu" ) . show ( "drop" , "fast" ) ;
2019-10-05 20:41:07 +00:00
$ ( ".container" ) . css ( "max-width" , "100%" ) ;
2019-09-26 15:48:56 +00:00
$ ( ".container" ) . css ( "margin-left" , "207px" ) ;
2019-11-09 08:44:45 +00:00
$ ( ".footer" ) . css ( "margin-left" , "207px" ) ;
$ ( ".footer" ) . css ( "max-width" , "100%" ) ;
$ ( "#hide_menu" ) . show ( ) ;
$ ( ".show_menu" ) . hide ( ) ;
2019-09-26 15:48:56 +00:00
}
if ( hideMenu == "hide" ) {
$ ( ".top-menu" ) . hide ( ) ;
2019-10-18 17:23:35 +00:00
$ ( ".container" ) . css ( "max-width" , "97%" ) ;
2019-09-26 15:48:56 +00:00
$ ( ".container" ) . css ( "margin-left" , "1%" ) ;
2019-11-09 08:44:45 +00:00
$ ( ".footer" ) . css ( "margin-left" , "1%" ) ;
$ ( ".footer" ) . css ( "max-width" , "97%" ) ;
2019-09-26 15:48:56 +00:00
$ ( ".show_menu" ) . show ( ) ;
2019-11-09 08:44:45 +00:00
$ ( "#hide_menu" ) . hide ( ) ;
2022-09-28 14:18:53 +00:00
}
2018-05-18 18:09:14 +00:00
var now = new Date ( Date . now ( ) ) ;
2019-09-29 20:16:24 +00:00
if ( $ ( '#time_range_out_hour' ) . val ( ) != '' && $ ( '#time_range_out_hour' ) . val ( ) != 'None' ) {
var date1 = parseInt ( $ ( '#time_range_out_hour' ) . val ( ) , 10 ) * 60 + parseInt ( $ ( '#time_range_out_minut' ) . val ( ) , 10 )
} else {
2022-04-27 18:10:26 +00:00
var date1 = now . getHours ( ) * 60 - 3 * 60 ;
2019-09-29 20:16:24 +00:00
}
if ( $ ( '#time_range_out_hour' ) . val ( ) != '' && $ ( '#time_range_out_hour' ) . val ( ) != 'None' ) {
var date2 = parseInt ( $ ( '#time_range_out_hour1' ) . val ( ) , 10 ) * 60 + parseInt ( $ ( '#time_range_out_minut1' ) . val ( ) , 10 )
} else {
var date2 = now . getHours ( ) * 60 + now . getMinutes ( ) ;
}
2022-09-28 14:18:53 +00:00
$ ( "#time-range" ) . slider ( {
2018-05-18 18:09:14 +00:00
range : true ,
min : 0 ,
max : 1440 ,
step : 15 ,
values : [ date1 , date2 ] ,
slide : function ( e , ui ) {
var hours = Math . floor ( ui . values [ 0 ] / 60 ) ;
var minutes = ui . values [ 0 ] - ( hours * 60 ) ;
if ( hours . toString ( ) . length == 1 ) hours = '0' + hours ;
if ( minutes . toString ( ) . length == 1 ) minutes = '0' + minutes ;
2022-09-28 14:18:53 +00:00
2018-05-18 18:09:14 +00:00
var hours1 = Math . floor ( ui . values [ 1 ] / 60 ) ;
var minutes1 = ui . values [ 1 ] - ( hours1 * 60 ) ;
2018-03-30 06:26:22 +00:00
2018-05-18 18:09:14 +00:00
if ( hours1 . toString ( ) . length == 1 ) hours1 = '0' + hours1 ;
if ( minutes1 . toString ( ) . length == 1 ) minutes1 = '0' + minutes1 ;
2019-09-29 20:16:24 +00:00
if ( $ ( '#time_range_out_hour' ) . val ( ) != '' && $ ( '#time_range_out_hour' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_hour' ) . val ( hours ) ;
}
if ( $ ( '#time_range_out_minut' ) . val ( ) != '' && $ ( '#time_range_out_minut' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_minut' ) . val ( minutes ) ;
}
if ( $ ( '#time_range_out_hour1' ) . val ( ) != '' && $ ( '#time_range_out_hour1' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_hour1' ) . val ( hours1 ) ;
}
if ( $ ( '#time_range_out_minut1' ) . val ( ) != '' && $ ( '#time_range_out_minut1' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_minut1' ) . val ( minutes1 ) ;
}
2018-05-18 18:09:14 +00:00
}
} ) ;
2018-06-29 06:07:24 +00:00
var date1 _hours = Math . floor ( date1 / 60 ) ;
var date2 _hours = date1 _hours + 1 ;
2018-07-05 07:03:26 +00:00
var date2 _minute = now . getMinutes ( )
2018-06-29 06:07:24 +00:00
if ( date1 _hours <= 9 ) date1 _hours = '0' + date1 _hours ;
if ( date2 _hours <= 9 ) date2 _hours = '0' + date2 _hours ;
2018-07-05 07:03:26 +00:00
if ( date2 _minute <= 9 ) date2 _minute = '0' + date2 _minute ;
2019-09-29 20:16:24 +00:00
if ( $ ( '#time_range_out_hour' ) . val ( ) != '' && $ ( '#time_range_out_hour' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_hour' ) . val ( $ ( '#time_range_out_hour' ) . val ( ) ) ;
} else {
$ ( '#time_range_out_hour' ) . val ( date1 _hours ) ;
}
if ( $ ( '#time_range_out_minut' ) . val ( ) != '' && $ ( '#time_range_out_minut' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_minut' ) . val ( $ ( '#time_range_out_minut' ) . val ( ) ) ;
} else {
$ ( '#time_range_out_minut' ) . val ( '00' ) ;
}
if ( $ ( '#time_range_out_hour1' ) . val ( ) != '' && $ ( '#time_range_out_hour1' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_hour1' ) . val ( $ ( '#time_range_out_hour1' ) . val ( ) ) ;
} else {
$ ( '#time_range_out_hour1' ) . val ( date2 _hours ) ;
}
if ( $ ( '#time_range_out_minut1' ) . val ( ) != '' && $ ( '#time_range_out_minut1' ) . val ( ) != 'None' ) {
$ ( '#time_range_out_minut1' ) . val ( $ ( '#time_range_out_minut1' ) . val ( ) ) ;
} else {
$ ( '#time_range_out_minut1' ) . val ( date2 _minute ) ;
}
2022-09-28 14:18:53 +00:00
2018-04-08 07:33:09 +00:00
$ ( '#0' ) . click ( function ( ) {
$ ( '.auto-refresh-div' ) . show ( "blind" , "fast" ) ;
2022-09-28 14:18:53 +00:00
$ ( '#0' ) . css ( "display" , "none" ) ;
2018-04-08 07:33:09 +00:00
$ ( '#1' ) . css ( "display" , "inline" ) ;
} ) ;
2022-09-28 14:18:53 +00:00
$ ( '#1' ) . click ( function ( ) {
2018-04-08 07:33:09 +00:00
$ ( '.auto-refresh-div' ) . hide ( "blind" , "fast" ) ;
2022-09-28 14:18:53 +00:00
$ ( '#1' ) . css ( "display" , "none" ) ;
$ ( '#0' ) . css ( "display" , "inline" ) ;
2018-04-08 07:33:09 +00:00
} ) ;
2019-09-26 15:48:56 +00:00
$ ( '#auth' ) . submit ( function ( ) {
2023-10-07 18:48:23 +00:00
var next _url = findGetParameter ( 'next' ) ;
2019-09-17 07:18:48 +00:00
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/login" ,
2019-09-17 07:18:48 +00:00
data : {
2019-09-26 15:48:56 +00:00
login : $ ( '#login' ) . val ( ) ,
2023-10-07 18:48:23 +00:00
pass : $ ( '#pass' ) . val ( ) ,
next : next _url
2019-09-17 07:18:48 +00:00
} ,
2019-12-04 13:38:07 +00:00
type : "POST" ,
2019-09-17 07:18:48 +00:00
success : function ( data ) {
2023-09-17 09:42:39 +00:00
if ( data . indexOf ( 'disabled' ) != '-1' ) {
2020-01-18 23:50:43 +00:00
$ ( '.alert' ) . show ( ) ;
$ ( '.alert' ) . html ( data ) ;
2019-09-26 15:48:56 +00:00
} else if ( data . indexOf ( 'ban' ) != '-1' ) {
2022-09-28 14:18:53 +00:00
ban ( ) ;
2023-02-13 14:45:45 +00:00
} else if ( data . indexOf ( 'error' ) != '-1' ) {
toastr . error ( data ) ;
2023-09-17 09:42:39 +00:00
} else {
2023-10-16 15:35:26 +00:00
sessionStorage . removeItem ( 'check-service' ) ;
2023-09-17 09:42:39 +00:00
window . location . replace ( data ) ;
2022-09-28 14:18:53 +00:00
}
2018-07-18 13:14:03 +00:00
}
2019-09-26 15:48:56 +00:00
} ) ;
return false ;
2018-07-18 05:46:37 +00:00
} ) ;
2020-07-05 06:59:51 +00:00
$ ( '#show_log_form' ) . submit ( function ( ) {
2023-09-17 09:42:39 +00:00
showLog ( ) ;
2020-07-05 06:59:51 +00:00
return false ;
} ) ;
2023-09-17 09:42:39 +00:00
$ ( '#show_internal_log_form' ) . submit ( function ( ) {
viewLogs ( ) ;
return false ;
} ) ;
2023-02-13 14:45:45 +00:00
var user _settings _tabel _title = $ ( "#show-user-settings-table" ) . attr ( 'title' ) ;
var cancel _word = $ ( '#translate' ) . attr ( 'data-cancel' ) ;
var save _word = $ ( '#translate' ) . attr ( 'data-save' ) ;
var change _word = $ ( '#translate' ) . attr ( 'data-change' ) ;
var password _word = $ ( '#translate' ) . attr ( 'data-password' ) ;
var change _pass _word = change _word + ' ' + password _word
2021-02-03 19:25:37 +00:00
var showUserSettings = $ ( "#show-user-settings" ) . dialog ( {
2023-09-17 09:42:39 +00:00
autoOpen : false ,
width : 600 ,
modal : true ,
title : user _settings _tabel _title ,
buttons : [ {
text : save _word ,
click : function ( ) {
saveUserSettings ( ) ;
$ ( this ) . dialog ( "close" ) ;
}
} , {
text : change _pass _word ,
click : function ( ) {
changePassword ( ) ;
$ ( this ) . dialog ( "close" ) ;
}
} , {
text : cancel _word ,
click : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
} ]
} ) ;
2021-02-03 19:25:37 +00:00
$ ( '#show-user-settings-button' ) . click ( function ( ) {
2022-03-20 20:36:46 +00:00
if ( localStorage . getItem ( 'disabled_alert' ) == '1' ) {
2023-04-02 16:58:55 +00:00
$ ( '#disable_alerting' ) . prop ( 'checked' , false ) . checkboxradio ( 'refresh' ) ;
2021-08-21 18:21:22 +00:00
} else {
2023-04-02 16:58:55 +00:00
$ ( '#disable_alerting' ) . prop ( 'checked' , true ) . checkboxradio ( 'refresh' ) ;
2021-02-03 19:25:37 +00:00
}
2023-09-17 09:42:39 +00:00
$ . ajax ( {
url : "/app/user/group/current" ,
// data: {
// token: $('#token').val()
// },
// type: "POST",
success : function ( data ) {
2021-08-21 18:21:22 +00:00
if ( data . indexOf ( 'danger' ) != '-1' ) {
$ ( "#ajax" ) . html ( data ) ;
} else {
2022-02-16 07:46:30 +00:00
$ ( '#show-user-settings-group' ) . html ( data ) ;
2023-09-17 09:42:39 +00:00
$ ( "select" ) . selectmenu ( ) ;
2021-08-21 18:21:22 +00:00
}
}
2023-09-17 09:42:39 +00:00
} ) ;
2021-02-03 19:25:37 +00:00
showUserSettings . dialog ( 'open' ) ;
2018-07-18 05:46:37 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
var cur _url = window . location . href . split ( '/app/' ) . pop ( ) ;
cur _url = cur _url . split ( '/' ) ;
if ( cur _url [ 0 ] . indexOf ( 'install' ) != '-1' ) {
$ ( ".installproxy" ) . on ( "click" , function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
$ ( this ) . children ( ".installproxy" ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( ".installproxy" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . children ( ".installproxy" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
} ) ;
$ ( "#tabs" ) . tabs ( "option" , "active" , 0 ) ;
} ) ;
$ ( ".installmon" ) . on ( "click" , function ( ) {
2019-09-20 06:42:19 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
$ ( this ) . children ( ".installmon" ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( ".installmon" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . children ( ".installmon" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
} ) ;
$ ( "#tabs" ) . tabs ( "option" , "active" , 1 ) ;
} ) ;
$ ( ".installgeo" ) . on ( "click" , function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
$ ( this ) . children ( ".installgeo" ) . css ( 'padding-left' , '30px' ) ;
$ ( this ) . children ( ".installgeo" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . children ( ".installgeo" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
} ) ;
$ ( "#tabs" ) . tabs ( "option" , "active" , 2 ) ;
} ) ;
}
if ( cur _url [ 0 ] . indexOf ( 'admin' ) != '-1' || cur _url [ 0 ] . indexOf ( 'servers' ) != '-1' ) {
$ ( ".users" ) . on ( "click" , function ( ) {
$ ( '.menu li ul li' ) . each ( function ( ) {
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' )
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-09-20 06:42:19 +00:00
$ ( this ) . children ( ".users" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".users" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".users" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2018-09-29 05:23:01 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 0 ) ;
} ) ;
if ( cur _url [ 0 ] . indexOf ( 'admin' ) != '-1' ) {
$ ( ".group" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-10-21 06:00:16 +00:00
$ ( this ) . children ( ".group" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".group" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".group" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 1 ) ;
} ) ;
$ ( ".runtime" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-10-21 06:00:16 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 2 ) ;
} ) ;
$ ( ".admin" ) . on ( "click" , function ( ) {
2019-09-20 06:42:19 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-09-20 06:42:19 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-09-20 06:42:19 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 3 ) ;
} ) ;
$ ( ".settings" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-10-21 06:00:16 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 5 ) ;
} ) ;
$ ( ".services" ) . on ( "click" , function ( ) {
2020-05-12 18:57:05 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2020-05-12 18:57:05 +00:00
$ ( this ) . children ( ".services" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".services" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".services" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2020-05-12 18:57:05 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 6 ) ;
2021-02-26 14:41:18 +00:00
loadServices ( ) ;
2023-09-17 09:42:39 +00:00
} ) ;
$ ( ".updatehapwi" ) . on ( "click" , function ( ) {
2019-09-20 06:42:19 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-10-21 06:00:16 +00:00
$ ( this ) . children ( ".updatehapwi" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".updatehapwi" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".updatehapwi" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 7 ) ;
2021-02-26 14:41:18 +00:00
loadupdatehapwi ( ) ;
2023-09-17 09:42:39 +00:00
} ) ;
2019-10-21 06:00:16 +00:00
} else {
2023-09-17 09:42:39 +00:00
$ ( ".runtime" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-09-20 06:42:19 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".runtime" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-09-20 06:42:19 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 1 ) ;
} ) ;
$ ( ".admin" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2019-10-21 06:00:16 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".admin" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 2 ) ;
} ) ;
$ ( ".settings" ) . on ( "click" , function ( ) {
2020-08-10 18:32:44 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2020-08-10 18:32:44 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".settings" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2020-08-10 18:32:44 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 4 ) ;
} ) ;
$ ( ".installproxy" ) . on ( "click" , function ( ) {
2019-10-21 06:00:16 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2022-05-16 09:13:17 +00:00
$ ( this ) . children ( ".installproxy" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".installproxy" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".installproxy" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2019-10-21 06:00:16 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 5 ) ;
} ) ;
$ ( ".installmon" ) . on ( "click" , function ( ) {
2020-06-01 16:13:28 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2022-05-16 09:13:17 +00:00
$ ( this ) . children ( ".installmon" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".installmon" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".installmon" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2020-06-01 16:13:28 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 6 ) ;
} ) ;
$ ( ".backup" ) . on ( "click" , function ( ) {
2020-01-11 21:16:27 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'padding-left' , '20px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . find ( 'a' ) . css ( 'border-left' , '0px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . find ( 'a' ) . css ( 'background-color' , '#48505A' ) ;
2020-01-11 21:16:27 +00:00
$ ( this ) . children ( ".backup" ) . css ( 'padding-left' , '30px' ) ;
2022-06-15 07:34:20 +00:00
$ ( this ) . children ( ".backup" ) . css ( 'border-left' , '4px solid var(--right-menu-blue-rolor)' ) ;
2023-09-17 09:42:39 +00:00
$ ( this ) . children ( ".backup" ) . css ( 'background-color' , 'var(--right-menu-blue-rolor)' ) ;
2020-01-11 21:16:27 +00:00
} ) ;
2023-09-17 09:42:39 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 7 ) ;
} ) ;
2018-09-28 16:10:01 +00:00
}
}
2021-07-05 14:51:05 +00:00
$ ( '.copyToClipboard' ) . hover ( function ( ) {
$ . getScript ( "/inc/fontawesome.min.js" ) ;
} ) ;
$ ( '.copyToClipboard' ) . click ( function ( ) {
let str = $ ( this ) . attr ( 'data-copy' ) ;
const el = document . createElement ( 'textarea' ) ;
el . value = str ;
el . setAttribute ( 'readonly' , '' ) ;
el . style . position = 'absolute' ;
el . style . left = '-9999px' ;
document . body . appendChild ( el ) ;
el . select ( ) ;
document . execCommand ( 'copy' ) ;
document . body . removeChild ( el ) ;
} )
2018-05-12 15:49:24 +00:00
} ) ;
2021-02-03 19:25:37 +00:00
function saveUserSettings ( ) {
2023-04-02 16:58:55 +00:00
if ( $ ( '#disable_alerting' ) . is ( ':checked' ) ) {
2021-02-03 19:25:37 +00:00
localStorage . removeItem ( 'disabled_alert' ) ;
2023-04-02 16:58:55 +00:00
} else {
localStorage . setItem ( 'disabled_alert' , '1' ) ;
2021-02-03 19:25:37 +00:00
}
2021-08-21 18:21:22 +00:00
changeCurrentGroupF ( ) ;
2023-09-17 09:42:39 +00:00
Cookies . set ( 'lang' , $ ( '#lang_select' ) . val ( ) , { expires : 365 , path : '/' , samesite : 'strict' , secure : 'true' } ) ;
2021-02-03 19:25:37 +00:00
}
2019-09-11 06:05:57 +00:00
function sleep ( ms ) {
2019-10-25 07:18:57 +00:00
return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
2019-09-11 06:05:57 +00:00
}
async function ban ( ) {
$ ( '#login' ) . attr ( 'disabled' , 'disabled' ) ;
$ ( '#pass' ) . attr ( 'disabled' , 'disabled' ) ;
$ ( "input[type=submit], button" ) . button ( 'disable' ) ;
2023-09-17 09:42:39 +00:00
$ ( '#wrong-login' ) . show ( ) ;
2019-09-11 06:05:57 +00:00
$ ( '#ban_10' ) . show ( ) ;
$ ( '#ban_timer' ) . text ( 10 ) ;
2022-09-28 14:18:53 +00:00
2019-09-11 06:05:57 +00:00
let i = 10 ;
while ( i > 0 ) {
i -- ;
await sleep ( 1000 ) ;
$ ( '#ban_timer' ) . text ( i ) ;
}
2022-09-28 14:18:53 +00:00
2019-09-11 06:05:57 +00:00
$ ( '#login' ) . removeAttr ( 'disabled' ) ;
$ ( '#pass' ) . removeAttr ( 'disabled' ) ;
$ ( "input[type=submit], button" ) . button ( 'enable' ) ;
$ ( '#ban_10' ) . hide ( ) ;
2022-09-28 14:18:53 +00:00
}
2018-05-12 15:49:24 +00:00
function replace _text ( id _textarea , text _var ) {
var str = $ ( id _textarea ) . val ( ) ;
var len = str . length ;
var len _var = text _var . length ;
var beg = str . indexOf ( text _var ) ;
var end = beg + len _var
var text _val = str . substring ( 0 , beg ) + str . substring ( end , len ) ;
$ ( id _textarea ) . text ( text _val ) ;
2018-06-29 06:07:24 +00:00
}
2019-12-01 17:15:09 +00:00
function createHistroy ( ) {
2021-01-09 15:42:08 +00:00
if ( localStorage . getItem ( 'history' ) === null ) {
2023-09-17 09:42:39 +00:00
var get _history _array = [ 'login' , 'login' , 'login' ] ;
2021-01-09 15:42:08 +00:00
localStorage . setItem ( 'history' , JSON . stringify ( get _history _array ) ) ;
2019-12-01 17:15:09 +00:00
}
}
2022-09-28 14:18:53 +00:00
function listHistroy ( ) {
2021-01-09 15:42:08 +00:00
var browse _history = JSON . parse ( localStorage . getItem ( 'history' ) ) ;
2019-12-01 17:15:09 +00:00
var history _link = '' ;
var title = [ ]
var link _text = [ ]
2023-10-03 19:56:34 +00:00
var cur _path = window . location . pathname ;
2019-12-01 17:15:09 +00:00
for ( let i = 0 ; i < browse _history . length ; i ++ ) {
if ( i == 0 ) {
browse _history [ 0 ] = browse _history [ 1 ] ;
}
2020-07-15 04:16:31 +00:00
if ( i == 1 ) {
2019-12-01 17:15:09 +00:00
browse _history [ 1 ] = browse _history [ 2 ]
}
if ( i == 2 ) {
2023-10-03 19:56:34 +00:00
browse _history [ 2 ] = cur _path
2019-12-01 17:15:09 +00:00
}
2020-07-02 14:44:13 +00:00
$ ( function ( ) {
2019-12-01 17:15:09 +00:00
$ ( '.menu li ul li' ) . each ( function ( ) {
var link1 = $ ( this ) . find ( 'a' ) . attr ( 'href' ) ;
2023-10-03 19:56:34 +00:00
if ( browse _history [ i ] . replace ( /\/$/ , "" ) == link1 ) {
2020-07-30 05:36:29 +00:00
title [ i ] = $ ( this ) . find ( 'a' ) . attr ( 'title' ) ;
link _text [ i ] = $ ( this ) . find ( 'a' ) . text ( ) ;
history _link = '<li><a href="' + browse _history [ i ] + '" title="' + title [ i ] + '">' + link _text [ i ] + '</a></li>'
2023-10-03 19:56:34 +00:00
$ ( '#browse_history' ) . append ( history _link ) ;
2019-12-01 17:15:09 +00:00
}
} ) ;
} ) ;
}
2021-01-09 15:42:08 +00:00
localStorage . setItem ( 'history' , JSON . stringify ( browse _history ) ) ;
2019-12-01 17:15:09 +00:00
}
2023-10-03 19:56:34 +00:00
createHistroy ( ) ;
listHistroy ( ) ;
2020-05-10 06:17:07 +00:00
2023-09-17 09:42:39 +00:00
function changeCurrentGroupF ( ) {
2020-05-10 06:17:07 +00:00
Cookies . remove ( 'group' ) ;
2023-09-17 09:42:39 +00:00
Cookies . set ( 'group' , $ ( '#newCurrentGroup' ) . val ( ) , { expires : 365 , path : '/' , samesite : 'strict' , secure : 'true' } ) ;
$ . ajax ( {
url : "/app/user/group/change" ,
2021-01-02 16:36:43 +00:00
data : {
changeUserCurrentGroupId : $ ( '#newCurrentGroup' ) . val ( ) ,
changeUserGroupsUser : Cookies . get ( 'uuid' ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2023-09-17 09:42:39 +00:00
success : function ( data ) {
2021-01-02 16:36:43 +00:00
if ( data . indexOf ( 'error: ' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
location . reload ( ) ;
}
}
2023-09-17 09:42:39 +00:00
} ) ;
2020-07-02 14:44:13 +00:00
}
2020-08-02 18:24:09 +00:00
function updateTips ( t ) {
var tips = $ ( ".validateTips" ) ;
tips . text ( t ) . addClass ( "alert-warning" ) ;
2021-08-11 05:37:36 +00:00
tips . text ( t ) . addClass ( "alert-one-row" ) ;
2020-08-02 18:24:09 +00:00
}
function clearTips ( ) {
var tips = $ ( ".validateTips" ) ;
2021-08-11 05:37:36 +00:00
tips . html ( 'Fields marked "<span class="need-field">*</span>" are required' ) . removeClass ( "alert-warning" ) ;
2020-08-02 18:24:09 +00:00
allFields = $ ( [ ] ) . add ( $ ( '#new-server-add' ) ) . add ( $ ( '#new-ip' ) ) . add ( $ ( '#new-port' ) ) . add ( $ ( '#new-username' ) ) . add ( $ ( '#new-password' ) )
allFields . removeClass ( "ui-state-error" ) ;
}
function checkLength ( o , n , min ) {
if ( o . val ( ) . length < min ) {
o . addClass ( "ui-state-error" ) ;
2022-05-12 06:42:16 +00:00
updateTips ( "Field " + n + " is required" ) ;
2020-08-02 18:24:09 +00:00
return false ;
} else {
return true ;
}
2020-08-25 12:38:49 +00:00
}
2020-10-02 12:39:00 +00:00
$ ( function ( ) {
ion . sound ( {
sounds : [
{
name : "bell_ring" ,
} ,
{
name : "glass" ,
volume : 1 ,
} ,
{
name : "alert_sound" ,
volume : 0.3 ,
preload : false
}
] ,
volume : 0.5 ,
path : "/inc/sounds/" ,
preload : true
} ) ;
} ) ;
2022-03-15 09:51:03 +00:00
let socket = new ReconnectingWebSocket ( "wss://" + window . location . host , null , { maxReconnectAttempts : 20 , reconnectInterval : 3000 } ) ;
socket . onopen = function ( e ) {
console . log ( "[open] Connection is established with " + window . location . host ) ;
getAlerts ( ) ;
} ;
function getAlerts ( ) {
socket . send ( "alert_group " + Cookies . get ( 'group' ) + ' ' + Cookies . get ( 'uuid' ) ) ;
}
socket . onmessage = function ( event ) {
2024-01-09 06:55:19 +00:00
var cur _url = window . location . href . split ( '/app/' ) . pop ( ) ;
cur _url = cur _url . split ( '/' ) ;
if ( cur _url != 'login' && localStorage . getItem ( 'disabled_alert' ) === null ) {
2022-03-15 09:51:03 +00:00
data = event . data . split ( ";" ) ;
for ( i = 0 ; i < data . length ; i ++ ) {
if ( data [ i ] . indexOf ( 'error:' ) != '-1' || data [ i ] . indexOf ( 'alert' ) != '-1' || data [ i ] . indexOf ( 'FAILED' ) != '-1' ) {
if ( data [ i ] . indexOf ( 'error: database is locked' ) == '-1' ) {
toastr . error ( data [ i ] ) ;
ion . sound . play ( "bell_ring" ) ;
2020-10-02 12:39:00 +00:00
}
2022-03-15 09:51:03 +00:00
} else if ( data [ i ] . indexOf ( 'info: ' ) != '-1' ) {
toastr . info ( data [ i ] ) ;
ion . sound . play ( "glass" ) ;
} else if ( data [ i ] . indexOf ( 'success: ' ) != '-1' ) {
toastr . success ( data [ i ] ) ;
ion . sound . play ( "glass" ) ;
} else if ( data [ i ] . indexOf ( 'warning: ' ) != '-1' ) {
toastr . warning ( data [ i ] ) ;
ion . sound . play ( "bell_ring" ) ;
2023-01-17 18:23:53 +00:00
} else if ( data [ i ] . indexOf ( 'critical: ' ) != '-1' ) {
toastr . error ( data [ i ] ) ;
ion . sound . play ( "bell_ring" ) ;
2020-10-02 12:39:00 +00:00
}
2022-03-15 09:51:03 +00:00
}
2020-10-02 12:39:00 +00:00
}
2022-03-15 09:51:03 +00:00
} ;
socket . onclose = function ( event ) {
if ( event . wasClean ) {
console . log ( ` [close] Соединение закрыто чисто, код= ${ event . code } причина= ${ event . reason } ` ) ;
} else {
console . log ( '[close] Соединение прервано' ) ;
}
} ;
socket . onerror = function ( error ) {
console . log ( ` [error] ${ error . message } ` ) ;
} ;
2022-02-16 07:46:30 +00:00
function changePassword ( ) {
2022-11-09 16:47:59 +00:00
$ ( "#user-change-password-table" ) . dialog ( {
autoOpen : true ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
title : "Change password" ,
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : {
"Change" : function ( ) {
changeUserPasswordItOwn ( $ ( this ) ) ;
2022-02-16 07:46:30 +00:00
} ,
2022-11-09 16:47:59 +00:00
Cancel : function ( ) {
$ ( this ) . dialog ( "close" ) ;
$ ( '#missmatchpass' ) . hide ( ) ;
2022-02-16 07:46:30 +00:00
}
2022-11-09 16:47:59 +00:00
}
} ) ;
2022-02-16 07:46:30 +00:00
}
function changeUserPasswordItOwn ( d ) {
var pass = $ ( '#change-password' ) . val ( ) ;
var pass2 = $ ( '#change2-password' ) . val ( ) ;
2023-09-17 09:42:39 +00:00
if ( pass != pass2 ) {
2022-02-16 07:46:30 +00:00
$ ( '#missmatchpass' ) . show ( ) ;
} else {
$ ( '#missmatchpass' ) . hide ( ) ;
toastr . clear ( ) ;
2023-09-17 09:42:39 +00:00
$ . ajax ( {
url : "/app/user/password" ,
2022-02-16 07:46:30 +00:00
data : {
updatepassowrd : pass ,
uuid : Cookies . get ( 'uuid' ) ,
token : $ ( '#token' ) . val ( )
} ,
type : "POST" ,
2023-09-17 09:42:39 +00:00
success : function ( data ) {
data = data . replace ( /\s+/g , ' ' ) ;
2022-02-16 07:46:30 +00:00
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
2023-09-17 09:42:39 +00:00
d . dialog ( "close" ) ;
2022-02-16 07:46:30 +00:00
}
}
2023-09-17 09:42:39 +00:00
} ) ;
2022-02-16 07:46:30 +00:00
}
}
2022-04-27 18:10:26 +00:00
function findInConfig ( words ) {
2022-03-02 20:09:39 +00:00
clearAllAjaxFields ( ) ;
2023-09-17 09:42:39 +00:00
$ . ajax ( {
url : "/app/config/" + $ ( "#service" ) . val ( ) + "/find-in-config" ,
data : {
serv : $ ( "#serv" ) . val ( ) ,
words : words
} ,
type : "POST" ,
success : function ( data ) {
if ( data . indexOf ( 'error:' ) != '-1' ) {
toastr . error ( data ) ;
} else {
toastr . clear ( ) ;
$ ( "#ajax" ) . html ( data ) ;
2022-03-02 20:09:39 +00:00
}
2023-09-17 09:42:39 +00:00
}
} ) ;
2022-03-02 20:09:39 +00:00
}
2022-04-27 18:10:26 +00:00
function waitForElm ( selector ) {
2023-09-17 09:42:39 +00:00
return new Promise ( resolve => {
if ( document . querySelector ( selector ) ) {
return resolve ( document . querySelector ( selector ) ) ;
}
2022-04-27 18:10:26 +00:00
2023-09-17 09:42:39 +00:00
const observer = new MutationObserver ( mutations => {
if ( document . querySelector ( selector ) ) {
resolve ( document . querySelector ( selector ) ) ;
observer . disconnect ( ) ;
}
} ) ;
2022-04-27 18:10:26 +00:00
2023-09-17 09:42:39 +00:00
observer . observe ( document . body , {
childList : true ,
subtree : true
} ) ;
} ) ;
2022-04-27 18:10:26 +00:00
}
2022-06-02 09:08:37 +00:00
function randomIntFromInterval ( min , max ) {
return Math . floor ( Math . random ( ) * ( max - min + 1 ) + min )
}
2022-06-15 07:34:20 +00:00
const removeEmptyLines = str => str . split ( /\r?\n/ ) . filter ( line => line . trim ( ) !== '' ) . join ( '\n' ) ;
function returnNiceCheckingConfig ( data ) {
if ( data . indexOf ( 'sudo: firewall-cmd: command not found' ) != '-1' ) {
data = data . replaceAll ( 'sudo: firewall-cmd: command not found\n' , '' ) ;
data = data . replaceAll ( 'sudo: firewall-cmd: command not found' , '' ) ;
toastr . warning ( 'The Firewalld service is not enabled. You should disable this setting for this server or enable the firewalld service on the server.' )
}
data = data . replaceAll ( 'Configuration file is valid' , '' ) ;
data = data . replaceAll ( 'Warnings were found.' , '' ) ;
data = data . replaceAll ( 'nginx: the configuration file /etc/nginx/nginx.conf syntax is ok' , '' ) ;
data = data . replaceAll ( 'nginx: configuration file /etc/nginx/nginx.conf test is successful' , '' ) ;
data = data . replaceAll ( 'Syntax OK' , '' ) ;
output = data . split ( '<br>' )
2022-07-15 18:55:54 +00:00
var alerts = [ ] ;
var alert _warning = '' ;
2022-07-16 07:09:34 +00:00
var alert _warning2 = '' ;
2022-07-15 18:55:54 +00:00
var alert _error = '' ;
2022-07-16 07:09:34 +00:00
var second _alert = false ;
2022-06-15 07:34:20 +00:00
alerts . push ( output [ 0 ] + '\n' + output [ 1 ] ) ;
2022-07-16 07:09:34 +00:00
var server _name = output [ 0 ] ;
var server _name2 = '' ;
2022-06-15 07:34:20 +00:00
try {
for ( var i = 0 ; i < output . length ; i ++ ) {
if ( i > 1 ) {
if ( output [ i ] !== undefined ) {
alerts . push ( output [ i ] )
}
}
}
} catch ( err ) {
console . log ( err ) ;
}
alerts . forEach ( ( element ) => {
2023-09-17 09:42:39 +00:00
if ( element . indexOf ( 'error: ' ) != '-1' || element . indexOf ( 'Fatal' ) != '-1' || element . indexOf ( 'Error' ) != '-1' || element . indexOf ( 'failed ' ) != '-1' || element . indexOf ( 'emerg] ' ) != '-1' || element . indexOf ( 'Syntax error ' ) != '-1' || element . indexOf ( 'Parsing' ) != '-1' ) {
2022-10-30 17:22:05 +00:00
alert _error = alert _error + element ;
2022-06-15 07:34:20 +00:00
return
}
if ( element . indexOf ( '[WARNING]' ) != '-1' || element . indexOf ( '[ALER]' ) != '-1' || element . indexOf ( '[warn]' ) != '-1' ) {
element = removeEmptyLines ( element ) ;
2022-07-16 07:09:34 +00:00
if ( second _alert == false ) {
alert _warning = alert _warning + element ;
} else {
alert _warning2 = alert _warning2 + element ;
2022-10-30 17:22:05 +00:00
server _name = 'Master server:' ;
server _name2 = 'Slave server:' ;
2022-07-16 07:09:34 +00:00
}
}
if ( second _alert && output . length > 4 && output [ 1 ] . indexOf ( '[NOTICE]' ) == '-1' ) {
2022-10-30 17:22:05 +00:00
server _name = 'Master server:' ;
server _name2 = 'Slave server:' ;
2022-07-16 07:09:34 +00:00
}
if ( element . length === 0 ) {
second _alert = true ;
2022-06-15 07:34:20 +00:00
}
2022-07-16 07:09:34 +00:00
2022-06-15 07:34:20 +00:00
} )
2022-07-16 07:09:34 +00:00
if ( alert _error ) {
toastr . error ( server _name + '<pre style="padding: 0; margin: 0;">' + alert _error + '</pre>' ) ;
2022-07-15 18:55:54 +00:00
toastr . info ( 'Config not applied' ) ;
2022-07-16 07:09:34 +00:00
} else if ( alert _warning ) {
toastr . warning ( server _name + '<pre style="padding: 0; margin: 0;">' + alert _warning + '</pre>' ) ;
toastr . success ( '<b>' + server _name + ' Configuration file is valid</b>' ) ;
} else {
toastr . success ( '<b>' + server _name + ' Configuration file is valid</b>' ) ;
}
if ( alert _warning2 ) {
toastr . warning ( server _name2 + '<pre style="padding: 0; margin: 0;">' + alert _warning2 + '</pre>' ) ;
toastr . success ( '<b>' + server _name2 + ' Configuration file is valid</b>' ) ;
} else if ( server _name2 ) {
toastr . success ( '<b>' + server _name2 + ' Configuration file is valid</b>' ) ;
2022-07-15 18:55:54 +00:00
}
2022-06-15 07:34:20 +00:00
}
2022-09-02 14:12:28 +00:00
function show _version ( ) {
NProgress . configure ( { showSpinner : false } ) ;
$ . ajax ( {
2023-09-17 09:42:39 +00:00
url : "/app/internal/show_version" ,
2022-09-02 14:12:28 +00:00
success : function ( data ) {
$ ( '#version' ) . html ( data ) ;
var showUpdates = $ ( "#show-updates" ) . dialog ( {
autoOpen : false ,
width : 600 ,
modal : true ,
title : 'There is a new Roxy-WI version' ,
buttons : {
Close : function ( ) {
$ ( this ) . dialog ( "close" ) ;
clearTips ( ) ;
}
}
} ) ;
$ ( '#show-updates-button' ) . click ( function ( ) {
showUpdates . dialog ( 'open' ) ;
} ) ;
}
} ) ;
NProgress . configure ( { showSpinner : true } ) ;
}
2022-11-09 19:05:47 +00:00
function statAgriment ( ) {
2024-01-09 06:55:19 +00:00
var cur _url = window . location . href . split ( '/app/' ) . pop ( ) ;
cur _url = cur _url . split ( '/' ) ;
if ( localStorage . getItem ( 'statistic' ) == null && cur _url != 'login' ) {
2022-11-09 19:05:47 +00:00
var titles = new Map ( )
var body = new Map ( )
var yes _ans = new Map ( )
var no _ans = new Map ( )
2022-11-09 19:54:35 +00:00
var ver _question = randomIntFromInterval ( 1 , 2 ) ;
2022-11-09 19:05:47 +00:00
titles . set ( 1 , 'Help us improve Roxy-WI' ) ;
titles . set ( 2 , 'Data collection agreement' ) ;
body . set ( 1 , 'We want to improve the user experience by collecting anonymous statistics. No marketing.' ) ;
body . set ( 2 , 'We’ d like to improve your experience in Roxy-WI, so we ask for statistics collection. No personal data is collected.' ) ;
yes _ans . set ( 1 , 'Yes' ) ;
yes _ans . set ( 2 , 'Agree and help the Roxy-WI team' ) ;
no _ans . set ( 1 , 'No' ) ;
no _ans . set ( 2 , 'Disagree' ) ;
$ ( "#statistic" ) . dialog ( {
autoOpen : true ,
resizable : false ,
height : "auto" ,
width : 600 ,
modal : true ,
2022-11-09 19:22:08 +00:00
title : titles . get ( ver _question ) ,
2022-11-09 19:05:47 +00:00
show : {
effect : "fade" ,
duration : 200
} ,
hide : {
effect : "fade" ,
duration : 200
} ,
buttons : [ {
"id" : "statYesBut" ,
text : "Yes" ,
click : function ( ) {
localStorage . setItem ( 'statistic' , '1' ) ;
$ ( this ) . dialog ( "close" ) ;
sendGet ( 'page/ans/1/' + ver _question ) ;
statAgriment ( ) ;
} ,
} , {
"id" : "statNoBut" ,
text : "No" ,
click : function ( ) {
localStorage . setItem ( 'statistic' , '0' ) ;
$ ( this ) . dialog ( "close" ) ;
sendGet ( 'page/ans/0/' + ver _question ) ;
}
} ]
} ) ;
$ ( "#statYesBut" ) . html ( '<span class="ui-button-text">' + yes _ans . get ( ver _question ) + '</span>' ) ;
$ ( "#statNoBut" ) . html ( '<span class="ui-button-text">' + no _ans . get ( ver _question ) + '</span>' ) ;
$ ( "#statistic-body" ) . html ( body . get ( ver _question ) ) ;
2022-11-09 16:47:59 +00:00
}
if ( localStorage . getItem ( 'statistic' ) == 1 ) {
2022-11-09 19:54:35 +00:00
cur _url = btoa ( cur _url ) ;
2022-11-09 19:05:47 +00:00
sendGet ( '/page/send/' + cur _url ) ;
2022-11-09 16:47:59 +00:00
}
}
2022-11-28 07:47:18 +00:00
function startIntro ( intro ) {
intro = intro . setOptions ( { 'exitOnOverlayClick' : false } ) ;
var intro _url = cur _url [ 0 ] . split ( '#' ) [ 0 ] ;
var intro _history = { } ;
intro . onbeforechange ( function ( targetElement ) {
2022-11-28 07:52:23 +00:00
if ( intro _url == 'users.py' && this . _currentStep == 3 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 1 ) ;
} else if ( intro _url == 'users.py' && this . _currentStep == 4 ) {
2022-11-28 07:47:18 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 2 ) ;
2022-11-28 07:52:23 +00:00
} else if ( intro _url == 'users.py' && this . _currentStep == 6 ) {
2022-11-28 07:47:18 +00:00
$ ( "#tabs" ) . tabs ( "option" , "active" , 3 ) ;
2022-11-28 07:52:23 +00:00
} else if ( intro _url == 'users.py' && this . _currentStep == 7 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 4 ) ;
} else if ( intro _url == 'users.py' && this . _currentStep == 9 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 6 ) ;
} else if ( intro _url == 'users.py' && this . _currentStep == 10 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 7 ) ;
} else if ( intro _url == 'users.py' && this . _currentStep == 12 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 8 ) ;
2022-11-28 07:47:18 +00:00
}
if ( intro _url == 'servers.py' && this . _currentStep == 5 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 1 ) ;
} else if ( intro _url == 'servers.py' && this . _currentStep == 13 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 2 ) ;
} else if ( intro _url == 'servers.py' && this . _currentStep == 16 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 6 ) ;
} else if ( intro _url == 'servers.py' && this . _currentStep == 18 ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 7 ) ;
}
} ) ;
intro . onbeforeexit ( function ( ) {
if ( localStorage . getItem ( 'intro' ) === null ) {
intro _history [ intro _url ] = '1' ;
localStorage . setItem ( 'intro' , JSON . stringify ( intro _history ) ) ;
} else {
intro _history = localStorage . getItem ( 'intro' ) ;
intro _history = JSON . parse ( intro _history ) ;
intro _history [ intro _url ] = '1' ;
localStorage . setItem ( 'intro' , JSON . stringify ( intro _history ) ) ;
}
} ) ;
intro . onexit ( function ( ) {
sendGet ( 'intro/' + intro _url + '/' + this . _currentStep ) ;
} ) ;
if ( localStorage . getItem ( 'intro' ) === null ) {
if ( intro _url . split ( '#' ) [ 0 ] == 'users.py' || intro _url . split ( '#' ) [ 0 ] == 'servers.py' ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 0 ) ;
}
intro . start ( ) ;
} else {
intro _history = localStorage . getItem ( 'intro' ) ;
intro _history = JSON . parse ( intro _history ) ;
if ( intro _history [ intro _url ] != '1' ) {
if ( intro _url . split ( '#' ) [ 0 ] == 'users.py' || intro _url . split ( '#' ) [ 0 ] == 'servers.py' ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , 0 ) ;
}
intro . start ( ) ;
}
}
}
document . addEventListener ( "DOMContentLoaded" , function ( event ) {
2024-01-09 06:55:19 +00:00
statAgriment ( ) ;
2022-11-28 07:47:18 +00:00
} ) ;
2022-11-09 19:05:47 +00:00
function sendGet ( page ) {
var xmlHttp = new XMLHttpRequest ( ) ;
var theUrl = 'https://roxy-wi.org/' + page ;
xmlHttp . open ( "GET" , theUrl , true ) ; // true for asynchronous
xmlHttp . send ( null ) ;
}
2022-11-20 07:48:15 +00:00
function show _pretty _ansible _error ( data ) {
try {
data = data . split ( 'error: ' ) ;
var p _err = JSON . parse ( data [ 1 ] ) ;
return p _err [ 'msg' ] ;
} catch ( e ) {
return data ;
}
}
2022-12-24 11:13:10 +00:00
function openTab ( tabId ) {
$ ( "#tabs" ) . tabs ( "option" , "active" , tabId ) ;
}
2023-04-02 16:58:55 +00:00
function showPassword ( input ) {
var x = document . getElementById ( input ) ;
if ( x . type === "password" ) {
x . type = "text" ;
} else {
x . type = "password" ;
}
}