Pavel Loginov 2020-08-11 14:56:53 +02:00
parent 639fafd97d
commit 759ea01589
4 changed files with 27 additions and 16 deletions

View File

@ -163,6 +163,7 @@ def create_table(**kwargs):
def update_db_v_31(**kwargs): def update_db_v_31(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = list() sql = list()
sql.append("CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64), value varchar(64), section varchar(64), `desc` varchar(100), `group` INTEGER NOT NULL DEFAULT 1, UNIQUE(param, `group`));")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('time_zone', 'UTC', 'main', 'Time Zone');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('time_zone', 'UTC', 'main', 'Time Zone');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');")

View File

@ -1669,11 +1669,7 @@ def select_table_metrics(uuid):
def get_setting(param, **kwargs): def get_setting(param, **kwargs):
import os user_group = funct.get_user_group(id=1)
import http.cookies
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
group = cookie.get('group')
user_group = group.value
if user_group == '' or param == 'lists_path': if user_group == '' or param == 'lists_path':
user_group = '1' user_group = '1'
@ -1697,11 +1693,7 @@ def get_setting(param, **kwargs):
def update_setting(param, val): def update_setting(param, val):
import http.cookies user_group = funct.get_user_group(id=1)
import os
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
group = cookie.get('group')
user_group = group.value
if funct.check_user_group(): if funct.check_user_group():
con, cur = get_cur() con, cur = get_cur()
@ -1910,6 +1902,8 @@ def insert_smon(server, port, enable, proto, uri, body, group, desc, telegram, u
def select_smon(user_group, **kwargs): def select_smon(user_group, **kwargs):
con, cur = get_cur() con, cur = get_cur()
funct.check_user_group()
if user_group == 1: if user_group == 1:
user_group = '' user_group = ''
else: else:
@ -1943,6 +1937,9 @@ def select_smon(user_group, **kwargs):
def delete_smon(id, user_group): def delete_smon(id, user_group):
con, cur = get_cur() con, cur = get_cur()
funct.check_user_group()
sql = """delete from smon sql = """delete from smon
where id = '%s' and user_group = '%s' """ % (id, user_group) where id = '%s' and user_group = '%s' """ % (id, user_group)
try: try:
@ -1959,6 +1956,7 @@ def delete_smon(id, user_group):
def update_smon(id, ip, port, body, telegram, group, desc, en): def update_smon(id, ip, port, body, telegram, group, desc, en):
funct.check_user_group()
con, cur = get_cur() con, cur = get_cur()
sql = """ update smon set sql = """ update smon set
ip = '%s', ip = '%s',

View File

@ -336,8 +336,12 @@
<table class="overview-wi"> <table class="overview-wi">
<tr class="overviewHead"> <tr class="overviewHead">
<td class="padding10 first-collumn-wi"> <td class="padding10 first-collumn-wi">
{% if role == 2 %}
<a href="/app/viewlogs.py?type=2&viewlogs={{haproxy_wi_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View HAProxy-WI logs" class="logs_link">
{% else %}
<a href="/app/viewlogs.py?viewlogs={{haproxy_wi_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View HAProxy-WI logs" class="logs_link"> <a href="/app/viewlogs.py?viewlogs={{haproxy_wi_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View HAProxy-WI logs" class="logs_link">
Recent HAProxy-WI`s log {% endif %}
Recent HAProxy-WI log
</a> </a>
</td> </td>
<td> <td>

View File

@ -100,6 +100,15 @@ $( function() {
$(this).parent().find('a').css('padding-left', '20px'); $(this).parent().find('a').css('padding-left', '20px');
$(this).find('a').css('padding-left', '30px'); $(this).find('a').css('padding-left', '30px');
$(this).find('a').css('border-left', '4px solid #5D9CEB'); $(this).find('a').css('border-left', '4px solid #5D9CEB');
} else if(cur_url[0] == 'viewlogs.py' && cur_url[1].split('&')[0] == 'type=2' && link2 == 'viewlogs.py?type=2'){
$(this).parent().css('display', 'contents');
$(this).parent().css('font-size', '13px');
$(this).parent().css('top', '0');
$(this).parent().css('left', '0');
$(this).parent().children().css('margin-left', '-20px');
$(this).parent().find('a').css('padding-left', '20px');
$(this).find('a').css('padding-left', '30px');
$(this).find('a').css('border-left', '4px solid #5D9CEB');
} }
}); });
}); });
@ -545,7 +554,6 @@ function viewLogs() {
var minut1 = $('#time_range_out_minut1').val() var minut1 = $('#time_range_out_minut1').val()
var viewlogs = $('#viewlogs').val() var viewlogs = $('#viewlogs').val()
var type = findGetParameter('type') var type = findGetParameter('type')
console.log(type)
if (viewlogs == null){ if (viewlogs == null){
viewlogs = findGetParameter('viewlogs') viewlogs = findGetParameter('viewlogs')
} }
@ -565,15 +573,15 @@ function viewLogs() {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
window.history.pushState("View logs", "View logs", cur_url[0] + "?viewlogs=" + viewlogs + window.history.pushState("View logs", "View logs", cur_url[0] + "?type="+ type +
"&viewlogs=" + viewlogs +
'&rows=' + rows + '&rows=' + rows +
'&grep=' + grep + '&grep=' + grep +
'&exgrep=' + exgrep + '&exgrep=' + exgrep +
'&hour=' + hour + '&hour=' + hour +
'&minut=' + minut + '&minut=' + minut +
'&hour1=' + hour1 + '&hour1=' + hour1 +
'&minut1=' + minut1 + '&minut1=' + minut1);
'&type=' + type);
} }
} ); } );
} }