diff --git a/README.md b/README.md
index 5caf3ceb..5b104b7a 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ For install just clone:
$ cd /var/www/
$ git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wi
$ chown -R apache:apache haproxy-wi/
-$ pip install -r haproxy-wi/requirements.txt
+$ pip3 install -r haproxy-wi/requirements.txt
$ chmod +x haproxy-wi/app/*.py
```
diff --git a/app/configshow.py b/app/configshow.py
index 50bf2f5b..aa34122c 100644
--- a/app/configshow.py
+++ b/app/configshow.py
@@ -1,13 +1,15 @@
#!/usr/bin/env python3
import os
import sql
-import http
+import http.cookies, cgi
import funct
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('config.html')
print('Content-type: text/html\n')
funct.check_login()
+form = cgi.FieldStorage()
+serv = form.getvalue('serv')
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
@@ -22,6 +24,7 @@ output_from_parsed_template = template.render(h2 = 1, title = "Show Runnig confi
user = user,
onclick = "showConfig()",
select_id = "serv",
+ serv = serv,
selects = servers,
note = 0)
print(output_from_parsed_template)
\ No newline at end of file
diff --git a/app/options.py b/app/options.py
index 1edf6a7e..9637bf9f 100644
--- a/app/options.py
+++ b/app/options.py
@@ -114,6 +114,9 @@ if form.getvalue('action') is not None and serv is not None:
if act == "overview":
ovw.get_overview()
+if act == "overviewServers":
+ ovw.get_overviewServers()
+
if serv is not None and act == "stats":
import requests
from requests_toolbelt.utils import dump
diff --git a/app/overview.py b/app/overview.py
index 341d498c..658283f5 100644
--- a/app/overview.py
+++ b/app/overview.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import funct, sql
import create_db
-import os, http
+import os, http.cookies
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('ovw.html')
@@ -14,7 +14,8 @@ try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user = sql.get_user_name_by_uuid(user_id.value)
-
+ users = sql.select_users()
+ groups = sql.select_groups()
except:
pass
@@ -22,5 +23,7 @@ output_from_parsed_template = template.render(h2 = 1,
autorefresh = 1,
title = "Overview",
role = sql.get_user_role_by_uuid(user_id.value),
- user = user)
+ user = user,
+ users = users,
+ groups = groups)
print(output_from_parsed_template)
\ No newline at end of file
diff --git a/app/ovw.py b/app/ovw.py
index 847bb703..398d8606 100644
--- a/app/ovw.py
+++ b/app/ovw.py
@@ -18,53 +18,7 @@ hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
form = cgi.FieldStorage()
def get_overview():
- USERS = sql.select_users()
listhap = sql.get_dick_permit()
-
- if funct.is_admin():
- print('
'
- ''
- 'Login | '
- 'Email | '
- 'Group | '
- 'Role | '
- ''
- ''
- ''
- 'Show all'
- ''
- ''
- ' | '
- '
')
-
- i = 0
- style = ""
- for users in USERS:
- i = i + 1
- if i is 4:
- style = 'style="display: none;" class="show-users"'
- print('' + users[1] +' | ')
- print(users[2]+' | ')
- print(sql.select_user_name_group(users[5]))
- print(' | ')
- print(users[4])
- print(' | |
')
- print('
')
-
- print(''
- ''
- 'Server | '
- ''
- 'HAproxy status'
- ' | '
- ''
- 'Action'
- ' | '
- ''
- 'Last edit'
- ' | '
- ' | '
- '
')
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
commands1 = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
@@ -86,17 +40,8 @@ def get_overview():
funct.ssh_command(server[2], commands1)
print(' | ')
- print('
'
- ''
- 'Server | '
- ''
- 'HAproxy info'
- ' | '
- ''
- 'Server status'
- ' | '
- '
')
-
+def get_overviewServers():
+ listhap = sql.get_dick_permit()
commands = [ "cat " + haproxy_config_path + " |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l",
"uname -smor",
"haproxy -v |head -1",
@@ -109,8 +54,6 @@ def get_overview():
print('')
funct.ssh_command(server[2], commands1)
print(' | ')
-
- print('|
')
def get_map(serv):
from datetime import datetime
diff --git a/app/templates/base.html b/app/templates/base.html
index 19ed6432..1e60a3c8 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -98,7 +98,7 @@
{% endif %}
-
+
diff --git a/app/templates/overview.html b/app/templates/overview.html
index 5c0f967b..1ecd2c1d 100644
--- a/app/templates/overview.html
+++ b/app/templates/overview.html
@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% block content %}
+ {% if role <= 1 %}
Login |
@@ -14,16 +15,29 @@
+ {% set counter = 0 -%}
{% for user in users %}
-
- {{ user.1 }} |
- {{ user.2 }} |
- {{ user.5 }} |
- {{ user.4 }} |
- |
-
+ {% set counter = counter + 1 %}
+ {% if counter < 4 %}
+
+ {{ user.1 }} |
+ {{ user.2 }} |
+ {{ user.5 }} |
+ {{ user.4 }} |
+ |
+
+ {% else %}
+
+ {{ user.1 }} |
+ {{ user.2 }} |
+ {{ user.5 }} |
+ {{ user.4 }} |
+ |
+
+ {% endif %}
{% endfor %}
+ {% endif %}
Server |
diff --git a/app/templates/ovw.html b/app/templates/ovw.html
index 22cbf46d..9acb47fb 100644
--- a/app/templates/ovw.html
+++ b/app/templates/ovw.html
@@ -1,10 +1,91 @@
{% extends "base.html" %}
{% block content %}
+{% if role <= 1 %}
+
+
+ Login |
+ Email |
+ Group |
+ Role |
+
+
+
+ Show all
+
+
+ |
+
+ {% set counter = 0 -%}
+ {% for USER in users %}
+ {% set counter = counter + loop.index0 %}
+ {% if counter <= 2 %}
+
+ {{ USER.1 }} |
+ {{ USER.2 }} |
+ {% for group in groups %}
+ {% if USER.5 == group.0|string() %}
+ {{ group.1 }} |
+ {% endif %}
+ {% endfor %}
+ {{ USER.4 }} |
+ |
+
+ {% else %}
+
+ {{ USER.1 }} |
+ {{ USER.2 }} |
+ {% for group in groups %}
+ {% if group.0|string() == USER.5 %}
+ {{ group.1 }} |
+ {% endif %}
+ {% endfor %}
+ {{ USER.4 }} |
+ |
+
+ {% endif %}
+ {% endfor %}
+
+{% endif %}
+
+
+
+ Server
+ |
+
+ HAproxy status
+ |
+
+ Action
+ |
+
+ Last edit
+ |
+ |
+
+
+
+
+
+
+
+ Server
+ |
+
+ HAproxy info
+ |
+
+ Server status
+ |
+
+
+
+
-
+
{% endblock %}
\ No newline at end of file
diff --git a/inc/script.js b/inc/script.js
index 51b4f54f..79d43726 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -97,7 +97,8 @@ $( document ).ajaxSend(function( event, request, settings ) {
$( document ).ajaxComplete(function( event, request, settings ) {
NProgress.done();
});
-function showOverview() {
+function showOverview() {
+ showOverviewServers();
$.ajax( {
url: "options.py",
data: {
@@ -105,7 +106,21 @@ function showOverview() {
},
type: "GET",
success: function( data ) {
- $("#ajax").html(data);
+ $("#ajaxstatus").empty();
+ $("#ajaxstatus").html(data);
+ }
+ } );
+}
+
+function showOverviewServers() {
+ $.ajax( {
+ url: "options.py",
+ data: {
+ act: "overviewServers",
+ },
+ type: "GET",
+ success: function( data ) {
+ $("#ajaxservers").html(data);
$.getScript('/inc/overview.js');
}
} );
@@ -501,7 +516,7 @@ $( function() {
}
var availableTags = [
- "acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "tcpka", "tcplog", "forwardfor", "option"
+ "acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "set cookie", "dynamic-cookie-key", "mysql-check", "tcpka", "tcplog", "forwardfor", "option"
];
$( "#ip" ).autocomplete({