From 4258623548db6b23a702d0cea838d7e01d5b007e Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Mon, 6 Apr 2020 18:38:58 +0200 Subject: [PATCH] v4.2.1.0 https://haproxy-wi.org/changelog.py#4_2_1 --- app/templates/admin.html | 30 ++++-- app/templates/include/input_macros.html | 5 +- app/templates/ovw.html | 2 +- app/templates/servers.html | 22 ++-- app/tools/keep_alive.py | 6 +- inc/users.js | 127 +++++++++++++++++++++--- 6 files changed, 153 insertions(+), 39 deletions(-) diff --git a/app/templates/admin.html b/app/templates/admin.html index 74abcdd1..87af3ffa 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -94,13 +94,15 @@ {% else %} - + {% set id = 'name-' + group.0|string() %} + {{ input(id, value=group.1) }} + {% set id = 'descript-' + group.0|string() %} {% if group.2 != "None" %} - + {{ input(id, value=group.2, size='60') }} {% else %} - + {{ input(id, value='', size='60') }} {% endif %} @@ -158,13 +160,15 @@ {% for server in servers %} - + {% set id = 'hostname-' + server.0|string() %} + {{ input(id, value=server.1, size='10') }} {{server.2}} - + {% set id = 'port-' + server.0|string() %} + {{ input(id, value=server.10, size='2') }} + {% set id = 'ssh_name-' + ssh.0|string() %} + {{ input(id, value=ssh.1, size='10') }} {% if ssh.2 == 1 %} @@ -232,12 +237,13 @@

- + {% set id = 'ssh_user-' + ssh.0|string() %} + {{ input(id, value=ssh.3, size='10') }}

{% if ssh.2 == 1 %} - + {% else %} - + {% endif %}
@@ -328,10 +334,12 @@ {% for telegram in telegrams %} - + {% set id = 'telegram-token-' + telegram.0|string() %} + {{ input(id, value=telegram.1, style="margin-bottom: 23px;") }} - + {% set id = 'telegram-token-' + telegram.0|string() %} + {{ input(id, value=telegram.2) }} + {% if readonly == '' %} + {% set readonly = 'readonly onfocus=this.removeAttribute(\'readonly\');' %} + {% endif %} + {%- endmacro %} {%- macro checkbox(id, name='', checked='', title='', value='', desc='') -%} diff --git a/app/templates/ovw.html b/app/templates/ovw.html index ebff6f5a..506382d0 100644 --- a/app/templates/ovw.html +++ b/app/templates/ovw.html @@ -72,7 +72,7 @@ - +
{% include 'include/admin_servers.html' %} @@ -127,7 +129,8 @@ {% if ssh.5|string() == group %} @@ -228,10 +232,12 @@ {% if telegram.3|string() == group %}
Tools status diff --git a/app/templates/servers.html b/app/templates/servers.html index 944f2af4..42c67cb6 100644 --- a/app/templates/servers.html +++ b/app/templates/servers.html @@ -87,14 +87,16 @@ {% do ssh_group.append(server.3) %}
- + {% set id = 'hostname-' + server.0|string() %} + {{ input(id, value=server.1, size='10') }} {{server.2}} - + {% set id = 'port-' + server.0|string() %} + {{ input(id, value=server.10, size='2') }}
- + {% set id = 'ssh_name-' + ssh.0|string() %} + {{ input(id, value=ssh.1, size='10') }} {% if ssh.2 == 1 %} @@ -138,12 +141,13 @@

- + {% set id = 'ssh_user-' + ssh.0|string() %} + {{ input(id, value=ssh.3, size='10') }}

{% if ssh.2 == 1 %} - + {% else %} - + {% endif %}
- + {% set id = 'telegram-token-' + telegram.0|string() %} + {{ input(id, value=telegram.1, style="margin-bottom: 23px;") }} - + {% set id = 'telegram-chanel-' + telegram.0|string() %} + {{ input(id, value=telegram.2) }} diff --git a/app/tools/keep_alive.py b/app/tools/keep_alive.py index abe20489..18139ad6 100644 --- a/app/tools/keep_alive.py +++ b/app/tools/keep_alive.py @@ -30,7 +30,7 @@ def main(): try: readstats = subprocess.check_output(["echo show stat | nc "+serv[0]+" "+port], shell=True) except CalledProcessError as e: - alert = "Try start HAProxy serivce at " + serv[0] + alert = "Try to start HAProxy serivce on " + serv[0] funct.logging("localhost", " "+alert, keep_alive=1) start_command = [] @@ -47,7 +47,7 @@ def main(): if __name__ == "__main__": - funct.logging("localhost", " Keep alive service started", keep_alive=1) + funct.logging("localhost", " Keep alive service is started", keep_alive=1) killer = GracefulKiller() while True: @@ -57,4 +57,4 @@ if __name__ == "__main__": if killer.kill_now: break - funct.logging("localhost", " Keep alive service shutdown", keep_alive=1) \ No newline at end of file + funct.logging("localhost", " Keep alive service is shutdown", keep_alive=1) \ No newline at end of file diff --git a/inc/users.js b/inc/users.js index 4c4ae17a..5ef99185 100644 --- a/inc/users.js +++ b/inc/users.js @@ -50,6 +50,7 @@ $( function() { autoFocus: true, minLength: -1 }); + var wait_mess = '
Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time
' var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; $('#create').click(function() { var hap = 0; @@ -73,7 +74,7 @@ $( function() { } else if ($("#master").val() == $("#slave").val() ){ $("#ajax").html('
Master and slave must be diff servers
') } else { - $("#ajax").html('
Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time
'); + $("#ajax").html(wait_mess); $.ajax( { url: "options.py", data: { @@ -119,7 +120,7 @@ $( function() { } else if(! $("#vrrp-ip-add").val().match(ipformat)) { $("#ajax").html('
Please enter IP in "VRRP IP" field
') } else { - $("#ajax").html('
Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time
'); + $("#ajax").html(wait_mess); $.ajax( { url: "options.py", data: { @@ -153,7 +154,7 @@ $( function() { if ($('#syn_flood').is(':checked')) { syn_flood = '1'; } - $("#ajax").html('
Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time
'); + $("#ajax").html(wait_mess); $.ajax( { url: "options.py", data: { @@ -164,6 +165,41 @@ $( function() { }, type: "POST", success: function( data ) { + data = data.replace(/\s+/g,' '); + if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') { + $("#ajax").html('
'+data+'
'); + } else if (data.indexOf('success') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } else if (data.indexOf('Info') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } else { + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } + } + } ); + }); + $('#nginx_install').click(function() { + $("#ajax").html('') + var syn_flood = 0; + if ($('#nginx_syn_flood').is(':checked')) { + syn_flood = '1'; + } + $("#ajax").html(wait_mess); + $.ajax( { + url: "options.py", + data: { + install_nginx: $('#nginxaddserv').val(), + syn_flood: syn_flood, + token: $('#token').val() + }, + type: "POST", + success: function( data ) { data = data.replace(/\s+/g,' '); if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') { $("#ajax").html('
'+data+'
'); @@ -183,18 +219,43 @@ $( function() { } } ); }); - $('#nginx_install').click(function() { + $('#grafna_install').click(function() { $("#ajax").html('') - var syn_flood = 0; - if ($('#nginx_syn_flood').is(':checked')) { - syn_flood = '1'; - } - $("#ajax").html('
Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time
'); + $("#ajax").html(wait_mess); $.ajax( { url: "options.py", data: { - install_nginx: $('#nginxaddserv').val(), - syn_flood: syn_flood, + install_grafana: '1', + token: $('#token').val() + }, + type: "POST", + success: function( data ) { + data = data.replace(/\s+/g,' '); + if (data.indexOf('FAILED') != '-1') { + $("#ajax").html('
'+data+'
'); + } else if (data.indexOf('success') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } else if (data.indexOf('Info') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } else { + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } + } + } ); + }); + $('#haproxy_exp_install').click(function() { + $("#ajax").html('') + $("#ajax").html(wait_mess); + $.ajax( { + url: "options.py", + data: { + haproxy_exp_install: $('#haproxy_exp_addserv').val(), token: $('#token').val() }, type: "POST", @@ -205,7 +266,41 @@ $( function() { } else if (data.indexOf('success') != '-1' ){ $('.alert-danger').remove(); $('.alert-warning').remove(); - $("#ajax").html('
'+data+'
'); + $("#ajax").html('
'+data+'
'); + $('#cur_haproxy_exp_ver').text('HAProxy expoter is installed'); + $('#haproxy_exp_install').text('Update'); + } else if (data.indexOf('Info') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } else { + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + } + } + } ); + }); + $('#nginx_exp_install').click(function() { + $("#ajax").html('') + $("#ajax").html(wait_mess); + $.ajax( { + url: "options.py", + data: { + nginx_exp_install: $('#nginx_exp_addserv').val(), + token: $('#token').val() + }, + type: "POST", + success: function( data ) { + data = data.replace(/\s+/g,' '); + if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') { + $("#ajax").html('
'+data+'
'); + } else if (data.indexOf('success') != '-1' ){ + $('.alert-danger').remove(); + $('.alert-warning').remove(); + $("#ajax").html('
'+data+'
'); + $('#cur_nginx_exp_ver').text('Nginx expoter is installed'); + $('#nginx_exp_install').text('Update'); } else if (data.indexOf('Info') != '-1' ){ $('.alert-danger').remove(); $('.alert-warning').remove(); @@ -1206,10 +1301,8 @@ function updateServer(id) { enable = '1'; } var servergroup = $('#servergroup-'+id+' option:selected' ).val(); - console.log(cur_url[0]) if (cur_url[0].split('#')[0] == "servers.py") { servergroup = $('#new-server-group-add').val(); - console.log('1') } console.log(servergroup) $.ajax( { @@ -1280,12 +1373,16 @@ function updateSSH(id) { if ($('#ssh_enable-'+id).is(':checked')) { ssh_enable = '1'; } + var group = $('#sshgroup-'+id).val(); + if (cur_url[0].split('#')[0] == "servers.py") { + group = $('#new-server-group-add').val(); + } $.ajax( { url: "options.py", data: { updatessh: 1, name: $('#ssh_name-'+id).val(), - group: $('#sshgroup-'+id).val(), + group: group, ssh_enable: ssh_enable, ssh_user: $('#ssh_user-'+id).val(), ssh_pass: $('#ssh_pass-'+id).val(),