haproxy-wi/app/templates/ajax/config_show.html

408 lines
12 KiB
HTML
Raw Normal View History

<div style="text-align: center;">
<h4>Config {% if config_file_name != 'undefined' %}{{config_file_name.replace('92', '/')}}{%endif%} from {{serv}}</h4>
<p class="accordion-expand-holder">
{% if role <= 3 %}
{% if not is_serv_protected or role <= 2 %}
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" id="edit_link" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
{% if service == 'haproxy' %}
<a class="ui-button ui-widget ui-corner-all" title="Add proxy" href="add.py#proxy">Add</a>
{% elif service == 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Add VRRP" href="ha.py">Add</a>
{% endif %}
{% endif %}
{% endif %}
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" id="expand_link" href="#">Expand all</a>
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
</p>
</div>
<div style="margin-left: 16%" class="configShow">
{% set i = 0 -%}
2019-11-18 18:53:09 +00:00
{% set section_name = {} %}
{% for line in conf -%}
{% set i = i + loop.index0 %}
{% if not role %}
{% if line.startswith('#HideBlockStart') %}
<!--{{line}}
{% continue %}
{% endif %}
{% if line.startswith('#HideBlockEnd') %}
{{line}}-->
{% continue %}
{% endif %}
{% endif %}
{% if service == 'nginx' %}
{% if i == 0 and "server {" not in line %}
<span class="param">
</span><div>
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{%- if "server {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
2019-11-18 18:53:09 +00:00
{% continue %}
{% endif %}
{%- if "stream {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "http {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "events {" in line -%}
</div>
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{% if "listen " in line or "location" in line or "server_name" in line or "}" in line %}
{% if "#" not in line %}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if "#" in line %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% endif %}
{% elif service == 'apache' %}
{% if i == 0 and "<VirtualHost" not in line %}
<span class="param">
</span><div>
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{%- if "<VirtualHost" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{% if "<" in line or "</" in line %}
{% if "#" not in line %}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if "#" in line %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% endif %}
{% elif service == 'keepalived' %}
{%- if "global_defs {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "vrrp_instance " in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "virtual_server " in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{%- if "vrrp_script " in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{% if "state " in line or "interface" in line or "priority" in line or "}" in line %}
{% if "#" not in line %}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if "#" in line %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
&emsp;&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% endif %}
{% else %}
{% if line.startswith('global') %}
<span class="param">{{ line }}
{% if role %}
{% if service != 'keepalived' %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('defaults') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{%- if line.startswith('listen') -%}
</div><span class="param">{{- line -}}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}" target="_blank">Edit/Delete</a>
</span>
{% endif %}
{%- set backend = line.split(' ') -%}
<span class="accordion-link">
<a href="/app/statsview.py?service=haproxy&serv={{-serv-}}#{{- backend[1]-}}" target="_blank">Stats</a>
</span>
{%- set backend = backend|join('_') -%}
{%- do section_name.update({i: backend}) -%}
<span id="{{-section_name[i]|replace('\n', '')-}}" class="accordion-link" target="_blank"></span>
</span><div>
{% continue %}
{%- endif -%}
{%- if line.startswith('frontend') -%}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
2019-10-18 17:23:35 +00:00
<span class="accordion-link">
<a href="/app/statsview.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span>
{% set backend = backend|join('_') %}
{% do section_name.update({i: backend}) %}
<span id="{{section_name[i]|replace('\n', '')}}" class="accordion-link"></span>
</span><div>
{% continue %}
{%- endif -%}
{% if line.startswith('backend') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
<span class="accordion-link">
<a href="/app/statsview.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
2019-10-18 17:23:35 +00:00
</span>
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('cache') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('peers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('resolvers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('userlist') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('http-errors') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit/Delete</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if "acl" in line or "option" in line or "server" in line %}
{% if "timeout" not in line and "default-server" not in line and "#use_backend" not in line and "#" not in line%}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if line.startswith("#") %}
2018-08-14 09:54:39 +00:00
<span class="numRow">
{{ i }}
</span>
<span class="comment">
{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
{{ line }}
</span><br />
{% endif %}
{%- if "bind" in line and "@" not in line and "-" not in line -%}
{%- set bind = line.split(':')[1] -%}
{%- set bind = bind.split(' ') -%}
<script>
{% set k = i - 1 %}
$('#{{-section_name[k]|replace("\n", "")-}}').html('<a href="http://{{-serv-}}:{{-bind[0]|replace("\n", "")-}}" title="Open {{serv-}}:{{-bind[0]|replace("\n", "")-}}" target="_blank">Open</a>')
</script>
{%- endif -%}
2019-11-18 18:53:09 +00:00
{%- endif -%}
{%- endfor -%}
</div>
</div>
{% if configver %}
<br>
<center>
{% if role <= 3 %}
{% if not is_serv_protected or role <= 2 %}
<form action="versions.py?service={{service}}" method="post">
<input type="hidden" value="{{serv}}" name="serv">
<input type="hidden" value="{{configver}}" name="configver">
<input type="hidden" value="1" name="config">
<button type='submit' value='save' name='save' class='btn btn-default' title="Save config without reloading the service">Save</button>
{% if is_restart|int == 0 %}
<button type='submit' value='' name='' class='btn btn-default'>Upload and restart</button>
{% endif %}
{% if service != 'keepalived' %}
<button type='submit' value='reload' name='save' class='btn btn-default'>Upload and reload</button>
{% endif %}
</form>
{% endif %}
{% endif %}
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will be reconfigured automatically</div>
</center>
{% endif %}
<script>
{% if role <= 3 %}
{% if not is_serv_protected or role <= 2 %}
$(document).bind('keydown', 'e', function (){
window.location = document.getElementById('edit_link').href;
});
{% endif %}
{% endif %}
$(document).on('keydown', null, 'r', raw_button);
function raw_button(event) {
$("#raw").trigger("click");
}
$(document).on('keydown', null, 'a', according_button);
function according_button(event) {
$("#according").click();
}
$(document).on('keydown', null, 'x', expand_button);
function expand_button(event) {
$("#expand_link").click();
}
</script>