From 9f9794d64d8384b95f4f39b2d52851089bf3b2fb Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Mon, 18 Nov 2019 21:53:09 +0300 Subject: [PATCH] v3.7.3.2 The config show was impoved --- app/create_db.py | 2 +- app/options.py | 4 +-- app/templates/add.html | 5 ++-- app/templates/ajax/config_show.html | 42 +++++++++++++++++++---------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/app/create_db.py b/app/create_db.py index ae8d6a1a..721d7b26 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -438,7 +438,7 @@ def update_db_v_3_5_3(**kwargs): def update_ver(**kwargs): con, cur = get_cur() - sql = """update version set version = '3.7.3.1'; """ + sql = """update version set version = '3.7.3.2'; """ try: cur.execute(sql) con.commit() diff --git a/app/options.py b/app/options.py index 7abb1425..e68eca02 100644 --- a/app/options.py +++ b/app/options.py @@ -560,7 +560,7 @@ if serv is not None and form.getvalue('right') is not None: right = form.getvalue('right') hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir') cmd='diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right) - env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=['jinja2.ext.loopcontrols', "jinja2.ext.do"]) + env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"]) template = env.get_template('ajax/compare.html') output, stderr = funct.subprocess_execute(cmd) @@ -585,7 +585,7 @@ if serv is not None and act == "configShow": print('
Can\'t read import config file
') from jinja2 import Environment, FileSystemLoader - env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, extensions=['jinja2.ext.loopcontrols']) + env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"]) template = env.get_template('config_show.html') template = template.render(conf=conf, view=form.getvalue('view'), serv=serv, configver=form.getvalue('configver'), role=funct.is_admin(level=2)) diff --git a/app/templates/add.html b/app/templates/add.html index 9b9b20e5..454b01f2 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -156,7 +156,6 @@ h3 {
Start typing options: {{ input('options') }} - or press down. Read more about options @@ -214,7 +213,7 @@ h3 {
-
+ @@ -345,7 +344,7 @@ h3 { diff --git a/app/templates/ajax/config_show.html b/app/templates/ajax/config_show.html index 7813a070..102bad09 100644 --- a/app/templates/ajax/config_show.html +++ b/app/templates/ajax/config_show.html @@ -11,7 +11,8 @@
{% set i = 0 -%} - {% for line in conf %} + {% set section_name = {} %} + {% for line in conf -%} {% set i = i + loop.index0 %} {% if not role %} {% if line.startswith('#HideBlockStart') %} @@ -43,21 +44,24 @@
{% continue %} {% endif %} - {% if line.startswith('listen') %} -
{{ line }} + {%- if line.startswith('listen') -%} +
{{- line -}} {% if role %} Edit {% endif %} - {% set backend = line.split(' ') %} + {%- set backend = line.split(' ') -%} - Stats + Stats -
- {% continue %} - {% endif %} - {% if line.startswith('frontend') %} + {%- set backend = backend|join('_') -%} + {%- do section_name.update({i: backend}) -%} + +
+ {% continue %} + {%- endif -%} + {%- if line.startswith('frontend') -%}
{{ line }} {% if role %} @@ -67,10 +71,13 @@ {% set backend = line.split(' ') %} Stats - -
- {% continue %} - {% endif %} + + {% set backend = backend|join('_') %} + {% do section_name.update({i: backend}) %} + +
+ {% continue %} + {%- endif -%} {% if line.startswith('backend') %}
{{ line }} {% if role %} @@ -141,7 +148,14 @@ {{ line }}
{% endif %} - {% endfor %} + {%- if "bind" in line -%} + {%- set bind = line.split(':') -%} + + {%- endif -%} + {%- endfor -%}
{% if configver %}

Add frontend

- +