From 7c285fd8923eb8f52837b37a4cbc5e020e710c81 Mon Sep 17 00:00:00 2001 From: Aidaho12 Date: Thu, 26 Apr 2018 22:24:36 +0600 Subject: [PATCH] v2.0 cosmetic changes --- cgi-bin/add.py | 18 ++++++++++-------- cgi-bin/funct.py | 4 ++-- cgi-bin/haproxy-webintarface.config | 11 ++++++----- cgi-bin/options.py | 19 +++++++++++++------ cgi-bin/users.py | 6 +++--- inc/script.js | 9 +++++---- inc/style.css | 10 ++++++---- inc/users.js | 22 ++++++++++++---------- 8 files changed, 57 insertions(+), 42 deletions(-) diff --git a/cgi-bin/add.py b/cgi-bin/add.py index 50fdac9a..9cfa11b8 100644 --- a/cgi-bin/add.py +++ b/cgi-bin/add.py @@ -130,7 +130,7 @@ print('
' '
  • Listen
  • ' '
  • Frontend
  • ' '
  • Backend
  • ' - '
  • Upload certs
  • ' + '
  • SSL certificates
  • ' '' '
    ' '
    ' @@ -448,12 +448,12 @@ print('' '
    ' '' '' - '' + '' '' '' '' '' @@ -464,14 +464,16 @@ print('' for i in listhap: print('' % (i[2], i[1])) -print('' - '' + '' '' + 'Upload' + '' + '' '
    Upload ssl pem certsUpload SSL certificates' - 'Name pem file' + 'Certificate name' '' - 'Key(?)' + 'Paste certificate content here(?)' '
    ' +print('' + '' '' '' '

    ' - 'Upload' - '
    ' '
    ' '
    ') diff --git a/cgi-bin/funct.py b/cgi-bin/funct.py index 657ba517..b2424f36 100644 --- a/cgi-bin/funct.py +++ b/cgi-bin/funct.py @@ -199,7 +199,7 @@ def links(): '') print('' '' - '' + '' '
    ') def show_login_links(): @@ -213,7 +213,7 @@ def show_login_links(): def footer(): print('
    ' - '
    ' + '
    ' '

    ' 'UP' '


    ' diff --git a/cgi-bin/haproxy-webintarface.config b/cgi-bin/haproxy-webintarface.config index b87ec5c0..e21f6b51 100644 --- a/cgi-bin/haproxy-webintarface.config +++ b/cgi-bin/haproxy-webintarface.config @@ -1,15 +1,16 @@ [main] #Path to files destination -fullpath = /var/www/haproxy-wi/ -cgi_path = %(fullpath)s/cgi-bin/ -log_path = %(fullpath)s/log/ +fullpath = /var/www/haproxy-wi +cgi_path = ${fullpath}/cgi-bin/ +log_path = ${fullpath}/log/ +cert_local_dir = ${cgi_path}/certs/ time_zone = UTC [configs] #Server for save configs from HAproxy servers haproxy_configs_server = localhost #Dir where configs will be save -haproxy_save_configs_dir = /var/www/haproxy-wi/cgi-bin/hap_config/ +haproxy_save_configs_dir = ${main:fullpath}/cgi-bin/hap_config/ [mysql] #Enable MySQL DB. If default will be used Sqlite DB. Default disable @@ -40,7 +41,7 @@ syslog_server = #Default bot send message disable enable = 0 token = -channel_name = +channel_name = proxy = [haproxy] diff --git a/cgi-bin/options.py b/cgi-bin/options.py index 42d9e0fc..07519685 100644 --- a/cgi-bin/options.py +++ b/cgi-bin/options.py @@ -35,28 +35,35 @@ if form.getvalue('ssh_cert'): print('
    Can\'t save ssh keys file. Check ssh keys path in config
    ') else: print('
    Ssh key was save into: %s
    ' % ssh_keys) + + funct.logging("local", "users.py#ssh upload new ssl cert %s" % ssh_keys) if serv and form.getvalue('ssl_cert'): + cert_local_dir = config.get('main', 'cert_local_dir') + cert_path = config.get('haproxy', 'cert_path') + if form.getvalue('ssl_name') is None: - print('
    Please enter name pem file
    ') + print('
    Please enter desired name
    ') else: name = form.getvalue('ssl_name') + '.pem' - cert_path = config.get('haproxy', 'cert_path') + try: with open(name, "w") as ssl_cert: ssl_cert.write(form.getvalue('ssl_cert')) except IOError: - print('
    Can\'t save ssh keys file. Check ssh keys path in config
    ') + print('
    Can\'t save ssl keys file. Check ssh keys path in config
    ') else: - print("Save ok") + print('
    SSL file was upload to %s into: %s
    ' % (serv, cert_path)) MASTERS = sql.is_master(serv) for master in MASTERS: if master[0] != None: funct.upload(master[0], cert_path, name) funct.upload(serv, cert_path, name) - os.system("rm -f %s" % name) - + + os.system("mv %s %s" % (name, cert_local_dir)) + funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name) + if backend is not None: cmd='echo "show backend" |nc %s 1999' % serv diff --git a/cgi-bin/users.py b/cgi-bin/users.py index 0d5b0b28..51480075 100644 --- a/cgi-bin/users.py +++ b/cgi-bin/users.py @@ -25,7 +25,7 @@ print('' '
  • Groups
  • ' '
  • Servers
  • ' '
  • Roles
  • ' - '
  • Ssh certs
  • ' + '
  • Ssh key
  • ' '' '
    ' '' @@ -200,7 +200,7 @@ print('
    ' '
    ' '' '' - '' + '' '' @@ -208,7 +208,7 @@ print('
    Upload ssh pem certsUpload SSH Key' 'Key(?)' '
    ' '' '' '' - 'Note: Somthing about ssh keys' + 'Note: Paste pem file content here' '' '' '

    ' diff --git a/inc/script.js b/inc/script.js index 0faa9ee8..0ebd505a 100644 --- a/inc/script.js +++ b/inc/script.js @@ -667,16 +667,17 @@ $( function() { type: "GET", success: function( data ) { data = data.replace(/\s+/g,' '); - if (data.indexOf('alert') != '-1') { - $("#ajax-ssl").append(data); - } else if (data == "Save ok ") { + if (data.indexOf('danger') != '-1') { + $("#ajax-ssl").html(data); + } else if (data.indexOf('success') != '-1') { $('.alert-danger').remove(); $("#ssl").addClass( "update", 1000 ); setTimeout(function() { $( "#ssl").removeClass( "update" ); }, 2500 ); + $("#ajax-ssl").html(data); } else { - $("#ajax-ssl").append('
    Something wrong, check and try again
    '); + $("#ajax-ssl").html('
    Something wrong, check and try again
    '); } } } ); diff --git a/inc/style.css b/inc/style.css index 26acaec0..51a043bc 100644 --- a/inc/style.css +++ b/inc/style.css @@ -534,16 +534,18 @@ a:focus { color: #a94442; background-color: #f2dede; border-color: #ebccd1; - width: 330px; + width: 400px; display: block; margin-top: 15px; margin-bottom: -50px; margin-left: 20px; } .alert-success { - color: #3c763d; - background-color: #dff0d8; - border-color: #d6e9c6; + color: #3c763d; + background-color: #dff0d8; + border-color: #d6e9c6; + width: 400px; + margin-left: 15px; } label { display: inline-block; diff --git a/inc/users.js b/inc/users.js index 31653430..b10bcef6 100644 --- a/inc/users.js +++ b/inc/users.js @@ -312,16 +312,18 @@ function uploadSsh() { type: "GET", success: function( data ) { data = data.replace(/\s+/g,' '); - if (data.indexOf('alert-danger') != '-1') { - $("#ajax-ssh").append(data); - } else { - $('.alert-danger').remove(); - $("#ssh").addClass( "update", 1000 ); - setTimeout(function() { - $( "#ssh").removeClass( "update" ); - }, 2500 ); - $("#ajax-ssh").append(data); - } + if (data.indexOf('danger') != '-1') { + $("#ajax-ssh").html(data); + } else if (data.indexOf('success') != '-1') { + $('.alert-danger').remove(); + $("#ssh").addClass( "update", 1000 ); + setTimeout(function() { + $( "#ssh").removeClass( "update" ); + }, 2500 ); + $("#ajax-ssh").html(data); + } else { + $("#ajax-ssh").html('
    Something wrong, check and try again
    '); + } } } ); } \ No newline at end of file