diff --git a/app/routes/service/routes.py b/app/routes/service/routes.py index 42718f3a..b761d8b6 100644 --- a/app/routes/service/routes.py +++ b/app/routes/service/routes.py @@ -2,7 +2,7 @@ from typing import Union import distro from flask import render_template, request, g -from flask_jwt_extended import jwt_required, get_jwt +from flask_jwt_extended import jwt_required from flask_pydantic import validate from pydantic import IPvAnyAddress @@ -10,7 +10,6 @@ from app import cache from app.routes.service import bp import app.modules.db.sql as sql import app.modules.db.waf as waf_sql -import app.modules.db.user as user_sql import app.modules.db.ha_cluster as ha_sql import app.modules.db.server as server_sql import app.modules.db.service as service_sql @@ -164,10 +163,8 @@ def cpu_ram_metrics(server_ip: Union[IPvAnyAddress, DomainName], server_id: int, return_out = '' servers = [[name, str(server_ip), return_out]] - claims = get_jwt() kwargs = { 'service_status': sorted(servers, key=common.get_key), - 'role': user_sql.get_user_role_in_group(claims['user_id'], claims['group']), 'id': server_id, 'service_page': service, 'lang': g.user_params['lang'] @@ -238,23 +235,23 @@ def save_service_settings(service): if service == 'haproxy': if service_sql.insert_or_update_service_setting(server_id, service, 'haproxy_enterprise', haproxy_enterprise): if haproxy_enterprise == '1': - roxywi_common.logging(server_ip, 'Service has been flagged as an Enterprise version', roxywi=1, login=1, + roxywi_common.logging(server_ip, 'Service has been flagged as an Enterprise version', keep_history=1, service=service) else: - roxywi_common.logging(server_ip, 'Service has been flagged as a community version', roxywi=1, login=1, + roxywi_common.logging(server_ip, 'Service has been flagged as a community version', keep_history=1, service=service) if service_sql.insert_or_update_service_setting(server_id, service, 'dockerized', service_dockerized): if service_dockerized == '1': - roxywi_common.logging(server_ip, service_docker, roxywi=1, login=1, keep_history=1, service=service) + roxywi_common.logging(server_ip, service_docker, keep_history=1, service=service) else: - roxywi_common.logging(server_ip, service_systemd, roxywi=1, login=1, keep_history=1, service=service) + roxywi_common.logging(server_ip, service_systemd, keep_history=1, service=service) if service_sql.insert_or_update_service_setting(server_id, service, 'restart', service_restart): if service_restart == '1': - roxywi_common.logging(server_ip, disable_restart, roxywi=1, login=1, keep_history=1, service=service) + roxywi_common.logging(server_ip, disable_restart, keep_history=1, service=service) else: - roxywi_common.logging(server_ip, enable_restart, roxywi=1, login=1, keep_history=1, service=service) + roxywi_common.logging(server_ip, enable_restart, keep_history=1, service=service) return 'ok' @@ -269,8 +266,7 @@ def update_tools_enable(service): metrics = request.form.get('metrics') service_sql.update_hapwi_server(server_id, alert, metrics, active, service) server_ip = server_sql.get_server(server_id).ip - roxywi_common.logging(server_ip, f'The server {name} has been updated ', roxywi=1, login=1, keep_history=1, - service=service) + roxywi_common.logging(server_ip, f'The server {name} has been updated ', keep_history=1, service=service) return 'ok' diff --git a/app/templates/ajax/service_settings.html b/app/templates/ajax/service_settings.html index b6232051..491d9199 100644 --- a/app/templates/ajax/service_settings.html +++ b/app/templates/ajax/service_settings.html @@ -1,4 +1,5 @@ {% from 'include/input_macros.html' import checkbox %} +{% set nice_service_name = {'haproxy': 'HAProxy', 'nginx': 'NGINX', 'apache': 'Apache'} %}
HAProxy dockerized | -- {% if s.value == '1' and s.setting == 'dockerized' %} - {{ checkbox('haproxy_dockerized', checked='checked', title='This service is running inside a Docker container') }} - {% elif s.setting == 'dockerized' %} - {{ checkbox('haproxy_dockerized', title='This server will be used as Docker container') }} - {% endif %} - | -
Disable restart | -- {% if s.value == '1' and s.setting == 'restart' %} - {{ checkbox('haproxy_restart', checked='checked', title='Restart option is disabled for this server') }} - {% elif s.setting == 'restart' %} - {{ checkbox('haproxy_restart', title='Only the reload button will be active') }} - {% endif %} - | -
HAProxy dockerized | -- {{ checkbox('haproxy_dockerized', title='This server will be used as Docker container') }} - | -
Disable restart | -- {{ checkbox('haproxy_restart', title='Only the reload button will be active') }} - | -
NGINX dockerized | -- {% if s.value == '1' and s.setting == 'dockerized' %} - {{ checkbox('nginx_dockerized', checked='checked', title='This service is running inside a Docker container') }} - {% else %} - {{ checkbox('nginx_dockerized', title='This server will be used as Docker container') }} - {% endif %} - | -
Disable restart | -- {% if s.value == '1' and s.setting == 'restart' %} - {{ checkbox('nginx_restart', checked='checked', title='Restart option is disabled for this server') }} - {% elif s.setting == 'restart' %} - {{ checkbox('nginx_restart', title='Only the reload button will be active') }} - {% endif %} - | -
NGINX dockerized | -- {{ checkbox('nginx_dockerized', title='This server will be used as Docker container') }} - | -
Disable restart | -- {{ checkbox('nginx_restart', title='Only the reload button will be active') }} - | -
Apache dockerized | -- {% if s.value == '1' and s.setting == 'dockerized' %} - {{ checkbox('apache_dockerized', checked='checked', title='This service is running inside a Docker container') }} - {% else %} - {{ checkbox('apache_dockerized', title='This server will be used as Docker container') }} - {% endif %} - | -
Disable restart | -- {% if s.value == '1' and s.setting == 'restart' %} - {{ checkbox('apache_restart', checked='checked', title='Restart option is disabled for this server') }} - {% elif s.setting == 'restart' %} - {{ checkbox('apache_restart', title='Only the reload button will be active') }} - {% endif %} - | -
Apache dockerized | -- {{ checkbox('apache_dockerized', title='This server will be used as Docker container') }} - | -
Disable restart | -- {{ checkbox('apache_restart', title='Only the reload button will be active') }} - | -
{{ nice_service_name[service] }} dockerized | ++ {% set id = service + '_dockerized' %} + {% if s.value == '1' and s.setting == 'dockerized' %} + {{ checkbox(id, checked='checked', title='This service is running inside a Docker container') }} + {% else %} + {{ checkbox(id, title='This server will be used as Docker container') }} + {% endif %} + | +
Disable restart | ++ {% set id = service + '_restart' %} + {% if s.value == '1' and s.setting == 'restart' %} + {{ checkbox(id, checked='checked', title='Restart option is disabled for this server') }} + {% elif s.setting == 'restart' %} + {{ checkbox(id, title='Only the reload button will be active') }} + {% endif %} + | +
{{ nice_service_name[service] }} dockerized | ++ {% set id = service + '_dockerized' %} + {{ checkbox(id, title='This server will be used as Docker container') }} + | +
Disable restart | ++ {% set id = service + '_restart' %} + {{ checkbox(id, title='Only the reload button will be active') }} + | +