Pavel Loginov 2022-01-16 16:50:53 +03:00
parent 89e0589e2b
commit e602e1c234
14 changed files with 247 additions and 96 deletions

View File

@ -12,6 +12,10 @@ funct.check_login()
form = funct.form
serv = form.getvalue('serv')
service = form.getvalue('service')
try:
config_file_name = form.getvalue('config_file_name').replace('92', '/')
except:
config_file_name = ''
config_read = ""
cfg = ""
stderr = ""
@ -57,7 +61,7 @@ if serv is not None and form.getvalue('open') is not None:
except Exception:
pass
elif service == 'nginx':
error = funct.get_config(serv, cfg, nginx=1)
error = funct.get_config(serv, cfg, nginx=1, config_file_name=config_file_name)
try:
funct.logging(serv, " Nginx config has been opened ")
except Exception:
@ -74,7 +78,7 @@ if serv is not None and form.getvalue('open') is not None:
config_read = conf.read()
conf.close()
except IOError:
error += '<br />Cannot read import config file'
error += '<br />Cannot read imported config file'
os.system("/bin/mv %s %s.old" % (cfg, cfg))
@ -90,12 +94,12 @@ if serv is not None and form.getvalue('config') is not None:
with open(cfg, "a") as conf:
conf.write(config)
except IOError:
print("error: Cannot read import config file")
print("error: Cannot read imported config file")
if service == 'keepalived':
stderr = funct.upload_and_restart(serv, cfg, just_save=save, keepalived=1, oldcfg=oldcfg)
elif service == 'nginx':
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save, nginx=1, oldcfg=oldcfg)
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save, nginx=1, oldcfg=oldcfg, config_file_name=config_file_name)
else:
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save, oldcfg=oldcfg)
@ -126,5 +130,6 @@ template = template.render(h2=1, title=title,
error=error,
service=service,
user_services=user_services,
config_file_name=config_file_name,
token=token)
print(template)

View File

@ -29,7 +29,7 @@ def default_values():
{'param': 'lists_path', 'value': 'lists', 'section': 'main',
'desc': 'Path to the black and the wild list. The value of this paramer should be specified as a relative path beginning with $HOME_ROXY-WI',
'group': '1'},
{'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs',
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/access.log', 'section': 'haproxy',
'desc': 'The default local path for saving logs', 'group': '1'},
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
'desc': 'Enable getting logs from a syslog server; (0 - no, 1 - yes)', 'group': '1'},
@ -67,10 +67,10 @@ def default_values():
'group': '1'},
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
'group': '1'},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', 'desc': 'Path to the Nginx directory',
'group': '1'},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx',
'desc': 'Path to the Nginx configuration file', 'group': '1'},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx',
'desc': 'Path to the Nginx directory with config files', 'group': '1'},
{'param': 'nginx_config_path', 'value': '/etc/nginx/nginx.conf', 'section': 'nginx',
'desc': 'Path to the main Nginx configuration file', 'group': '1'},
{'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'Enable LDAP (1 - yes, 0 - no)',
'group': '1'},
{'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address of the LDAP server', 'group': '1'},

View File

@ -429,11 +429,11 @@ def ssh_connect(server_ip):
def get_config(server_ip, cfg, **kwargs):
import sql
if kwargs.get("keepalived"):
if kwargs.get("keepalived") or kwargs.get("service") == 'keepalived':
config_path = "/etc/keepalived/keepalived.conf"
elif kwargs.get("nginx"):
config_path = sql.get_setting('nginx_config_path')
elif kwargs.get("waf"):
elif kwargs.get("nginx") or kwargs.get("service") == 'nginx':
config_path = kwargs.get('config_file_name')
elif kwargs.get("waf") or kwargs.get("service") == 'waf':
config_path = sql.get_setting('haproxy_dir') + '/waf/rules/' + kwargs.get("waf_rule_file")
else:
config_path = sql.get_setting('haproxy_config_path')
@ -928,8 +928,12 @@ def upload_and_restart(server_ip, cfg, **kwargs):
login = 1
if service == "nginx":
config_path = sql.get_setting('nginx_config_path')
# config_path = sql.get_setting('nginx_config_path')
config_path = kwargs.get('config_file_name')
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".conf"
elif service == "keepalived":
config_path = "/etc/keepalived/keepalived.conf"
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
else:
config_path = sql.get_setting('haproxy_config_path')
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
@ -940,13 +944,14 @@ def upload_and_restart(server_ip, cfg, **kwargs):
return 'Please install dos2unix'
if service == "keepalived":
move_config = "sudo mv -f " + tmp_file + " " + config_path
if action == "save":
commands = ["sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf"]
commands = [move_config]
elif action == "reload":
commands = [
"sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf && sudo systemctl reload keepalived"]
move_config + " && sudo systemctl reload keepalived"]
else:
commands = ["sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf && sudo systemctl restart keepalived"]
commands = [move_config + " && sudo systemctl restart keepalived"]
elif service == "nginx":
is_docker = sql.select_service_setting(server_id, 'nginx', 'dockerized')
if is_docker == '1':
@ -1015,10 +1020,11 @@ def upload_and_restart(server_ip, cfg, **kwargs):
if not kwargs.get('slave'):
diff = ''
old_cfg = kwargs.get('oldcfg')
if kwargs.get('oldcfg') is None:
if not old_cfg:
old_cfg = tmp_file + '.old'
print(old_cfg)
try:
get_config(server_ip, old_cfg)
get_config(server_ip, old_cfg, service=service, config_file_name=config_path)
except Exception:
logging('localhost', ' Cannot download config', haproxywi=1)
try:
@ -1055,14 +1061,24 @@ def master_slave_upload_and_restart(server_ip, cfg, just_save, **kwargs):
masters = sql.is_master(server_ip)
for master in masters:
if master[0] is not None:
error = upload_and_restart(master[0], cfg, just_save=just_save, nginx=kwargs.get('nginx'), slave=1)
error = upload_and_restart(master[0],
cfg,
just_save=just_save,
nginx=kwargs.get('nginx'),
config_file_name=kwargs.get('config_file_name'),
slave=1)
if kwargs.get('login'):
login = kwargs.get('login')
else:
login = ''
error = upload_and_restart(server_ip, cfg, just_save=just_save,
nginx=kwargs.get('nginx'), oldcfg=kwargs.get('oldcfg'), login=login)
error = upload_and_restart(server_ip,
cfg,
just_save=just_save,
nginx=kwargs.get('nginx'),
config_file_name=kwargs.get('config_file_name'),
oldcfg=kwargs.get('oldcfg'),
login=login)
return error
@ -1195,7 +1211,7 @@ def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', h
local_path_logs = sql.get_setting('nginx_path_error_logs')
commands = ["sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act)]
else:
local_path_logs = sql.get_setting('local_path_logs')
local_path_logs = sql.get_setting('haproxy_path_logs')
commands = ["sudo cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act)]
syslog_server = serv
else:
@ -1401,6 +1417,14 @@ def get_files(dir=get_config_var('configs', 'haproxy_save_configs_dir'), format=
return file
def get_remote_files(server_ip: str, config_dir: str, file_format: str):
if config_dir[-1] != '/':
config_dir += '/'
commands = ['ls ' + config_dir + '*.' + file_format]
config_files = ssh_command(server_ip, commands)
return config_files
def get_key(item):
return item[0]

View File

@ -688,7 +688,6 @@ if act == "overviewwaf":
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value))
print(template)
if act == "overviewServers":
import asyncio
@ -1135,6 +1134,10 @@ if serv is not None and act == "configShow":
user_uuid = cookie.get('uuid')
role_id = sql.get_user_role_by_uuid(user_uuid.value)
service = form.getvalue('service')
try:
config_file_name = form.getvalue('config_file_name').replace('/', '92')
except:
config_file_name = ''
if service == 'keepalived':
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
@ -1149,7 +1152,7 @@ if serv is not None and act == "configShow":
if form.getvalue('configver') is None:
cfg = configs_dir + serv + "-" + funct.get_data('config') + cfg
if service == 'nginx':
funct.get_config(serv, cfg, nginx=1)
funct.get_config(serv, cfg, nginx=1, config_file_name=form.getvalue('config_file_name'))
elif service == 'keepalived':
funct.get_config(serv, cfg, keepalived=1)
else:
@ -1174,12 +1177,29 @@ if serv is not None and act == "configShow":
configver=form.getvalue('configver'),
role=role_id,
service=service,
config_file_name=config_file_name,
is_serv_protected=is_serv_protected)
print(template)
if form.getvalue('configver') is None:
os.system("/bin/rm -f " + cfg)
if act == 'configShowFiles':
config_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
nginx_config_dir = sql.get_setting('nginx_dir')
try:
config_file_name = form.getvalue('config_file_name').replace('92', '/')
except:
config_file_name = ''
return_files = funct.get_remote_files(serv, nginx_config_dir, 'conf')
return_files += ' ' + sql.get_setting('nginx_config_path')
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ajax/show_configs_files.html')
template = template.render(serv=serv, return_files=return_files, config_file_name=config_file_name)
print(template)
if form.getvalue('master'):
master = form.getvalue('master')
slave = form.getvalue('slave')

View File

@ -1,20 +1,11 @@
- name: Installing HAProxy conf for rsyslog
template:
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/haproxy_rsyslog.conf.j2
dest: /etc/rsyslog.d/haproxy.conf
force: no
ignore_errors: yes
- name: Installing rsyslog config
template:
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/rsyslog.conf
dest: /etc/rsyslog.conf
dest: /etc/rsyslog.d/49-haproxy.conf
force: no
ignore_errors: yes
notify: restart rsyslog
- name: Installing HAProxy conf for logrotate
template:
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/logrotate.conf.j2

View File

@ -1,2 +1,15 @@
if $programname startswith 'haproxy' then /var/log/haproxy.log
& stop
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
if $programname startswith 'haproxy' then {
if $syslogseverity == 6 then
action(type="omfile" file="/var/log/haproxy/access.log")
stop
if $syslogseverity <= 3 then
action(type="omfile" file="/var/log/haproxy/error.log")
stop
if $syslogseverity <= 5 then
action(type="omfile" file="/var/log/haproxy/status.log")
stop
}

View File

@ -135,7 +135,7 @@ def add_setting_for_new_group(group_id):
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. The path must be valid',
'group': group_id},
{'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs',
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/access.log', 'section': 'haproxy',
'desc': 'The default local path for saving logs', 'group': group_id},
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
'desc': 'Enable getting logs from a syslog server; (0 - no, 1 - yes)', 'group': group_id},
@ -169,10 +169,10 @@ def add_setting_for_new_group(group_id):
'group': group_id},
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
'group': group_id},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', 'desc': 'Path to the Nginx directory',
'group': group_id},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx',
'desc': 'Path to the Nginx configuration file', 'group': group_id},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx',
'desc': 'Path to the Nginx directory with config files', 'group': group_id},
{'param': 'nginx_config_path', 'value': '/etc/nginx/nginx.conf', 'section': 'nginx',
'desc': 'Path to the main Nginx configuration file', 'group': group_id},
{'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'Enable LDAP (1 - yes, 0 - no)',
'group': group_id},
{'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address of the LDAP server', 'group': group_id},
@ -2948,6 +2948,18 @@ def delete_config_version(service: str, local_path: str):
return True
def select_remote_path_from_version(server_ip: str, service: str, local_path: str):
server_id = select_server_id_by_ip(server_ip)
try:
query_res = ConfigVersion.get((ConfigVersion.server_id == server_id) &
(ConfigVersion.service == service) &
(ConfigVersion.local_path == local_path)).remote_path
except Exception as e:
out_error(e)
else:
return query_res
def insert_system_info(server_id: int, os_info: str, sys_info: str, cpu: str, ram: str, network: str, disks: str) -> bool:
try:
SystemInfo.insert(server_id=server_id, os_info=os_info, sys_info=sys_info, cpu=cpu, ram=ram,

View File

@ -1,9 +1,9 @@
<div style="text-align: center;">
<h4>Config from {{serv}}</h4>
<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" href="config.py?service={{service}}&serv={{serv}}&open=open">Edit</a>
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
{% endif %}
{% endif %}
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
@ -28,6 +28,15 @@
{% 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>
@ -44,6 +53,21 @@
</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">

View File

@ -0,0 +1,24 @@
{% from 'include/input_macros.html' import input %}
<form action="" method="post">
<div style="text-align: center;margin-top: 20px;">
{% if config_file_name == '' %}
<h4>Config files from {{serv}}</h4>
{% endif %}
<p>
<select autofocus required name="config_file_name" id="config_file_name">
<option disabled selected>Select a config file</option>
{% for file in return_files.split() %}
{% if file == config_file_name %}
<option value="{{ file }}" selected>{{ file.split('/', maxsplit=3)[3] }}</option>
{% else %}
<option value="{{ file }}">{{ file.split('/', maxsplit=3)[3] }}</option>
{% endif %}
{% endfor %}
</select>
{{ input('serv', type='hidden', value=serv) }}
{{ input('open', type='hidden', value='open') }}
<a class="ui-button ui-widget ui-corner-all" id="show" title="Compare" onclick="showConfig()">Open</a>
</p>
</div>
</form>

View File

@ -108,7 +108,6 @@
<input type="hidden" value="open" name="open">
<input type="hidden" value="del" name="del">
<input type="hidden" value="{{style}}" name="style">
<input type="hidden" value="{{service}}" name="service">
<p>
<button type="submit" value="" name="" class="btn btn-default">Delete</button>
</p>
@ -176,7 +175,6 @@
</select>
<input type="hidden" value="{{serv}}" name="serv">
<input type="hidden" value="open" name="open">
<input type="hidden" value="{{service}}" name="service" id="service">
<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="showUploadConfig()">Select</a>
</p>
<script>

View File

@ -12,17 +12,12 @@
<p>
<form action="{{ action }}" method="post">
<input type="hidden" id="service" value="{{service|default('haproxy', true)}}" />
<select autofocus required name="serv" id="{{ select_id }}">
<option disabled>------</option>
{% for select in selects %}
{% if select.2 == serv %}
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
{% else %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endif %}
{% endfor %}
</select>
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
{% include 'include/select.html' %}
{% if service == 'nginx'%}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfigFiles()">Open</a>
{% else %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
{% endif %}
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
{% endif %}
@ -35,6 +30,7 @@
{% endif %}
</form>
</p>
<div id="ajax-config_file_name"></div>
{% endif %}
{% if stderr or error %}
@ -43,18 +39,20 @@
{% if config %}
{% if role <= 3 %}
<h4>Config from {{ serv }}</h4>
<h4>Config {% if config_file_name != 'undefined' %}{{config_file_name.replace('92', '/')}}{%endif%} from {{ serv }}</h4>
</center>
<form action="config.py" name="saveconfig" id="saveconfig" method="post">
<input type="hidden" value="{{ serv }}" name="serv">
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
<input type="hidden" value="{{ token }}" name="token">
<input type="hidden" value="{{ service }}" name="service">
<input type="hidden" value="{{ config_file_name }}" name="config_file_name">
<div style="margin-left: 23%;width: 60%;">
<textarea name="config" id="config_text_area" class="config" rows="35" cols="100">{{ config }}</textarea>
</div>
<p>
<center>
<a href="config.py?service={{service}}&serv={{serv}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Return to configuration view">Back</a>
{% if service != 'keepalived' %}
<button type="submit" value="test" name="save" class="btn btn-default" title="Check config without saving the config">Check config</button>
{% endif %}
@ -79,7 +77,13 @@
}
if (cur_url[1].split('&')[2] == 'showConfig') {
showConfig();
}
}
if (cur_url[1].split('&')[2] == 'showConfigFiles') {
showConfigFiles();
}
if (cur_url[1].split('&')[3].split('=')[0] == 'config_file_name') {
showConfigFilesForEditing();
}
if (cur_url[1].split('&')[0] == 'service=haproxy' || cur_url[1].split('&')[0] == 'service=None') {
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"),
{mode: "haproxy", lineNumbers: true, autocapitalize: true, autocorrect: true, spellcheck: true});

View File

@ -11,7 +11,7 @@
<form action="{{ action }}" method="post">
<input type="hidden" value="{{service}}" name="service" id="service">
{% include 'include/select.html' %}
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="showListOfVersion(1)">Open</a>
<a class="ui-button ui-widget ui-corner-all" title="Open versions" onclick="showListOfVersion(1)">Open</a>
<a href="config.py?service={{service}}" class="ui-button ui-widget ui-corner-all" title="Configs page">Configs</a>
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>

View File

@ -240,7 +240,11 @@
{% endif %}
</div>
<div class="server-act-links">
{% if service == 'nginx' %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfigFiles" class="ui-button ui-widget ui-corner-all" title="Open running configs">Configs</a>
{% else %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Config</a>
{% endif %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showCompare" class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
{% if service != 'nginx' and service != 'keepalived' %}
<a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>

View File

@ -343,7 +343,7 @@ function showLog() {
}
} );
}
function showMap() {
function clearAllAjaxFields() {
$("#ajax").empty();
$('.alert').remove();
try {
@ -355,6 +355,10 @@ function showMap() {
$("h4").remove();
$("#ajax-compare").empty();
$("#config").empty();
}
function showMap() {
clearAllAjaxFields();
$('#ajax-config_file_name').empty();
var unique = $.now();
$.ajax( {
url: "options.py",
@ -397,15 +401,8 @@ function showCompare() {
} );
}
function showCompareConfigs() {
$("#ajax").empty();
$('.alert').remove();
try {
myCodeMirror.toTextArea();
} catch (e) {
console.log(e)
}
$("#saveconfig").remove();
$("h4").remove();
clearAllAjaxFields();
$('#ajax-config_file_name').empty();
$.ajax( {
url: "options.py",
data: {
@ -431,23 +428,15 @@ function showCompareConfigs() {
}
function showConfig() {
var service = $('#service').val();
$("#ajax").empty();
$('.alert').remove();
try {
myCodeMirror.toTextArea();
} catch (e) {
console.log(e)
}
$("#saveconfig").remove();
$("h4").remove();
$("#ajax-compare").empty();
$("#config").empty();
var config_file_name = encodeURI($('#config_file_name').val());
clearAllAjaxFields();
$.ajax( {
url: "options.py",
data: {
serv: $("#serv").val(),
act: "configShow",
service: service,
config_file_name: config_file_name,
token: $('#token').val()
},
type: "POST",
@ -463,6 +452,57 @@ function showConfig() {
}
} );
}
function showConfigFiles() {
var service = $('#service').val();
clearAllAjaxFields();
$.ajax( {
url: "options.py",
data: {
serv: $("#serv").val(),
act: "configShowFiles",
service: service,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax-config_file_name").html(data);
$( "select" ).selectmenu();
window.history.pushState("Show config", "Show config", cur_url[0] + "?service=" + service + "&serv=" + $("#serv").val() + "&showConfigFiles");
}
}
} );
}
function showConfigFilesForEditing() {
var service = $('#service').val();
var config_file_name = findGetParameter('config_file_name')
var service = findGetParameter('service')
if (service == 'nginx') {
$.ajax({
url: "options.py",
data: {
serv: $("#serv").val(),
act: "configShowFiles",
service: service,
config_file_name: config_file_name,
token: $('#token').val()
},
type: "POST",
success: function (data) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#ajax-config_file_name").html(data);
$("select").selectmenu();
}
}
});
}
}
function showUploadConfig() {
var service = $('#service').val();
var configver = $('#configver').val();
@ -493,19 +533,11 @@ function showListOfVersion(for_delver) {
var service = $('#service').val();
var serv = $("#serv").val();
var configver = findGetParameter('configver');
var style = 'old'
if (localStorage.getItem('version_style') == 'new') {
style = 'new'
var style = 'new'
if (localStorage.getItem('version_style') == 'old') {
style = 'old'
}
$("#ajax").empty();
$('.alert').remove();
try {
myCodeMirror.toTextArea();
} catch (e) {
console.log(e)
}
$("#saveconfig").remove();
$("h4").remove();
clearAllAjaxFields();
$.ajax( {
url: "options.py",
data: {
@ -530,11 +562,11 @@ function showListOfVersion(for_delver) {
} );
}
function changeVersion(){
if (localStorage.getItem('version_style') == 'new') {
localStorage.setItem('version_style', 'old');
if (localStorage.getItem('version_style') == 'old') {
localStorage.setItem('version_style', 'new');
showListOfVersion(1);
} else {
localStorage.setItem('version_style', 'new');
localStorage.setItem('version_style', 'old');
showListOfVersion(1);
}
}