mirror of https://github.com/Aidaho12/haproxy-wi
v7.3.1.0: Remove OpenVPN code and update error handling in alert system
This commit removes unneeded OpenVPN related code and improves error handling in the alert system. All OpenVPN related functions and html files have been removed. Also, changes are made in the alerting module to raise exceptions instead of returning error messages, which provides a more pythonic way of error handling.pull/390/head
parent
64d0475df6
commit
6b24e8d39e
|
@ -1,7 +1,10 @@
|
|||
import json
|
||||
|
||||
import pika
|
||||
import pdpyras
|
||||
import requests
|
||||
import telebot
|
||||
from telebot import apihelper
|
||||
from flask import render_template, request, abort
|
||||
|
||||
import app.modules.db.sql as sql
|
||||
|
@ -163,8 +166,6 @@ def send_email(email_to: str, subject: str, message: str) -> None:
|
|||
|
||||
|
||||
def telegram_send_mess(mess, level, **kwargs):
|
||||
import telebot
|
||||
from telebot import apihelper
|
||||
token_bot = ''
|
||||
channel_name = ''
|
||||
|
||||
|
@ -191,10 +192,9 @@ def telegram_send_mess(mess, level, **kwargs):
|
|||
try:
|
||||
bot = telebot.TeleBot(token=token_bot)
|
||||
bot.send_message(chat_id=channel_name, text=f'{level}: {mess}')
|
||||
return 'ok'
|
||||
except Exception as e:
|
||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||
raise Exception(f'error: {e}')
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def slack_send_mess(mess, level, **kwargs):
|
||||
|
@ -225,15 +225,12 @@ def slack_send_mess(mess, level, **kwargs):
|
|||
|
||||
try:
|
||||
client.chat_postMessage(channel=f'#{channel_name}', text=f'{level}: {mess}')
|
||||
return 'ok'
|
||||
except SlackApiError as e:
|
||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||
raise Exception(f'error: {e}')
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None, **kwargs):
|
||||
import pdpyras
|
||||
|
||||
token = ''
|
||||
|
||||
if kwargs.get('channel_id') == 0:
|
||||
|
@ -259,7 +256,7 @@ def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None,
|
|||
dedup_key = f'{server_ip} {service_id} {alert_type}'
|
||||
except Exception as e:
|
||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||
raise Exception(f'error: {e}')
|
||||
raise Exception(e)
|
||||
|
||||
if proxy is not None and proxy != '' and proxy != 'None':
|
||||
proxies = dict(https=proxy, http=proxy)
|
||||
|
@ -270,10 +267,9 @@ def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None,
|
|||
session.resolve(dedup_key)
|
||||
else:
|
||||
session.trigger(mess, 'Roxy-WI', dedup_key=dedup_key, severity=level, custom_details={'server': server_ip, 'alert': mess})
|
||||
return 'ok'
|
||||
except Exception as e:
|
||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||
raise Exception(f'error: {e}')
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def mm_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None, **kwargs):
|
||||
|
@ -326,25 +322,22 @@ def mm_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None,
|
|||
proxy_dict = common.return_proxy_dict()
|
||||
try:
|
||||
requests.post(token, headers=headers, data=str(values), proxies=proxy_dict)
|
||||
return 'ok'
|
||||
except Exception as e:
|
||||
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
|
||||
raise Exception(f'error: {e}')
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def check_rabbit_alert() -> str:
|
||||
def check_rabbit_alert() -> None:
|
||||
try:
|
||||
user_group_id = request.cookies.get('group')
|
||||
except Exception as e:
|
||||
return f'error: Cannot send a message {e}'
|
||||
raise Exception(f'Cannot get user group {e}')
|
||||
|
||||
try:
|
||||
json_for_sending = {"user_group": user_group_id, "message": 'info: Test message'}
|
||||
send_message_to_rabbit(json.dumps(json_for_sending))
|
||||
except Exception as e:
|
||||
return f'error: Cannot send a message {e}'
|
||||
else:
|
||||
return 'ok'
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def check_email_alert() -> str:
|
||||
|
@ -369,7 +362,7 @@ def check_email_alert() -> str:
|
|||
return 'ok'
|
||||
|
||||
|
||||
def add_telegram_channel(token: str, channel: str, group: str, page: str) -> str:
|
||||
def add_telegram_channel(token: str, channel: str, group: str) -> str:
|
||||
if token is None or channel is None or group is None:
|
||||
return error_mess
|
||||
else:
|
||||
|
@ -379,10 +372,10 @@ def add_telegram_channel(token: str, channel: str, group: str, page: str) -> str
|
|||
groups = group_sql.select_groups()
|
||||
roxywi_common.logging('Roxy-WI server', f'A new Telegram channel {channel} has been created ', roxywi=1, login=1)
|
||||
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='telegram')
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, receiver='telegram')
|
||||
|
||||
|
||||
def add_slack_channel(token: str, channel: str, group: str, page: str) -> str:
|
||||
def add_slack_channel(token: str, channel: str, group: str) -> str:
|
||||
if token is None or channel is None or group is None:
|
||||
return error_mess
|
||||
else:
|
||||
|
@ -391,10 +384,10 @@ def add_slack_channel(token: str, channel: str, group: str, page: str) -> str:
|
|||
channels = channel_sql.select_slack(token=token)
|
||||
groups = group_sql.select_groups()
|
||||
roxywi_common.logging('Roxy-WI server', f'A new Slack channel {channel} has been created ', roxywi=1, login=1)
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='slack')
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, receiver='slack')
|
||||
|
||||
|
||||
def add_pd_channel(token: str, channel: str, group: str, page: str) -> str:
|
||||
def add_pd_channel(token: str, channel: str, group: str) -> str:
|
||||
if token is None or channel is None or group is None:
|
||||
return error_mess
|
||||
else:
|
||||
|
@ -403,10 +396,10 @@ def add_pd_channel(token: str, channel: str, group: str, page: str) -> str:
|
|||
channels = channel_sql.select_pd(token=token)
|
||||
groups = group_sql.select_groups()
|
||||
roxywi_common.logging('Roxy-WI server', f'A new PagerDuty channel {channel} has been created ', roxywi=1, login=1)
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='pd')
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, receiver='pd')
|
||||
|
||||
|
||||
def add_mm_channel(token: str, channel: str, group: str, page: str) -> str:
|
||||
def add_mm_channel(token: str, channel: str, group: str) -> str:
|
||||
if token is None or channel is None or group is None:
|
||||
return error_mess
|
||||
else:
|
||||
|
@ -415,7 +408,7 @@ def add_mm_channel(token: str, channel: str, group: str, page: str) -> str:
|
|||
channels = channel_sql.select_mm(token=token)
|
||||
groups = group_sql.select_groups()
|
||||
roxywi_common.logging('Roxy-WI server', f'A new Mattermost channel {channel} has been created ', roxywi=1, login=1)
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='mm')
|
||||
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, receiver='mm')
|
||||
|
||||
|
||||
def delete_telegram_channel(channel_id) -> str:
|
||||
|
@ -428,58 +421,51 @@ def delete_telegram_channel(channel_id) -> str:
|
|||
return 'ok'
|
||||
|
||||
|
||||
def delete_slack_channel(channel_id) -> str:
|
||||
def delete_slack_channel(channel_id) -> None:
|
||||
slack = channel_sql.select_slack(id=channel_id)
|
||||
channel_name = ''
|
||||
for t in slack:
|
||||
channel_name = t.chanel_name
|
||||
if channel_sql.delete_slack(channel_id):
|
||||
roxywi_common.logging('Roxy-WI server', f'The Slack channel {channel_name} has been deleted ', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def delete_pd_channel(channel_id) -> str:
|
||||
def delete_pd_channel(channel_id) -> None:
|
||||
pd = channel_sql.select_pd(id=channel_id)
|
||||
channel_name = ''
|
||||
for t in pd:
|
||||
channel_name = t.chanel_name
|
||||
if channel_sql.delete_pd(channel_id):
|
||||
roxywi_common.logging('Roxy-WI server', f'The PageDuty channel {channel_name} has been deleted ', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def delete_mm_channel(channel_id) -> str:
|
||||
def delete_mm_channel(channel_id) -> None:
|
||||
pd = channel_sql.select_mm(id=channel_id)
|
||||
channel_name = ''
|
||||
for t in pd:
|
||||
channel_name = t.chanel_name
|
||||
if channel_sql.delete_mm(channel_id):
|
||||
roxywi_common.logging('Roxy-WI server', f'The Mattermost channel {channel_name} has been deleted ', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def update_telegram(token: str, channel: str, group: str, user_id: int) -> str:
|
||||
def update_telegram(token: str, channel: str, group: int, user_id: int) -> None:
|
||||
channel_sql.update_telegram(token, channel, group, user_id)
|
||||
roxywi_common.logging('group ' + group, f'The Telegram token has been updated for channel: {channel}', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
roxywi_common.logging(f'group {group}', f'The Telegram token has been updated for channel: {channel}', roxywi=1, login=1)
|
||||
|
||||
|
||||
def update_slack(token: str, channel: str, group: str, user_id: int) -> str:
|
||||
def update_slack(token: str, channel: str, group: int, user_id: int) -> None:
|
||||
channel_sql.update_slack(token, channel, group, user_id)
|
||||
roxywi_common.logging(f'group {group}', f'The Slack token has been updated for channel: {channel}', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def update_pd(token: str, channel: str, group: str, user_id: int) -> str:
|
||||
def update_pd(token: str, channel: str, group: int, user_id: int) -> None:
|
||||
channel_sql.update_pd(token, channel, group, user_id)
|
||||
roxywi_common.logging(f'group {group}', f'The PagerDuty token has been updated for channel: {channel}', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def update_mm(token: str, channel: str, group: str, user_id: int) -> str:
|
||||
def update_mm(token: str, channel: str, group: int, user_id: int) -> None:
|
||||
channel_sql.update_mm(token, channel, group, user_id)
|
||||
roxywi_common.logging(f'group {group}', f'The Mattermost token has been updated for channel: {channel}', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def delete_receiver_channel(channel_id: int, receiver_name: str) -> None:
|
||||
|
@ -492,7 +478,7 @@ def delete_receiver_channel(channel_id: int, receiver_name: str) -> None:
|
|||
return delete_functions[receiver_name](channel_id)
|
||||
|
||||
|
||||
def add_receiver_channel(receiver_name: str, token: str, channel: str, group: id, page: str) -> str:
|
||||
def add_receiver_channel(receiver_name: str, token: str, channel: str, group: id) -> str:
|
||||
add_functions = {
|
||||
"telegram": add_telegram_channel,
|
||||
"slack": add_slack_channel,
|
||||
|
@ -501,9 +487,9 @@ def add_receiver_channel(receiver_name: str, token: str, channel: str, group: id
|
|||
}
|
||||
|
||||
try:
|
||||
return add_functions[receiver_name](token, channel, group, page)
|
||||
return add_functions[receiver_name](token, channel, group)
|
||||
except Exception as e:
|
||||
return f'error: Cannot add new receiver: {e}'
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def update_receiver_channel(receiver_name: str, token: str, channel: str, group: id, user_id: int) -> None:
|
||||
|
@ -516,7 +502,7 @@ def update_receiver_channel(receiver_name: str, token: str, channel: str, group:
|
|||
return update_functions[receiver_name](token, channel, group, user_id)
|
||||
|
||||
|
||||
def check_receiver(channel_id: int, receiver_name: str) -> str:
|
||||
def check_receiver(channel_id: int, receiver_name: str) -> None:
|
||||
functions = {
|
||||
"telegram": telegram_send_mess,
|
||||
"slack": slack_send_mess,
|
||||
|
@ -531,9 +517,9 @@ def check_receiver(channel_id: int, receiver_name: str) -> str:
|
|||
level = 'info'
|
||||
|
||||
try:
|
||||
return functions[receiver_name](mess, level, channel_id=channel_id)
|
||||
functions[receiver_name](mess, level, channel_id=channel_id)
|
||||
except Exception as e:
|
||||
return f'error: Cannot send message: {e}'
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
def load_channels():
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import os
|
||||
|
||||
import pytz
|
||||
import distro
|
||||
from flask import render_template, request, g
|
||||
from flask_login import login_required
|
||||
|
||||
|
@ -14,11 +11,9 @@ import app.modules.db.group as group_sql
|
|||
import app.modules.db.server as server_sql
|
||||
import app.modules.db.service as service_sql
|
||||
from app.middleware import get_user_params
|
||||
import app.modules.common.common as common
|
||||
import app.modules.roxywi.roxy as roxy
|
||||
import app.modules.roxywi.auth as roxywi_auth
|
||||
import app.modules.roxywi.common as roxywi_common
|
||||
import app.modules.server.server as server_mod
|
||||
import app.modules.tools.smon as smon_mod
|
||||
import app.modules.tools.common as tools_common
|
||||
|
||||
|
@ -46,8 +41,6 @@ def admin():
|
|||
masters = server_sql.select_servers(get_master_servers=1, uuid=g.user_params['user_uuid'])
|
||||
sshs = cred_sql.select_ssh(group=user_group)
|
||||
|
||||
|
||||
|
||||
kwargs = {
|
||||
'lang': g.user_params['lang'],
|
||||
'users': users,
|
||||
|
@ -118,105 +111,6 @@ def check_update():
|
|||
return 'ok'
|
||||
|
||||
|
||||
@bp.route('/openvpn')
|
||||
def load_openvpn():
|
||||
roxywi_auth.page_for_admin()
|
||||
openvpn_configs = ''
|
||||
openvpn_sess = ''
|
||||
openvpn = ''
|
||||
|
||||
if distro.id() == 'ubuntu':
|
||||
stdout, stderr = server_mod.subprocess_execute("apt show openvpn3 2>&1|grep E:")
|
||||
elif distro.id() == 'centos' or distro.id() == 'rhel':
|
||||
stdout, stderr = server_mod.subprocess_execute("rpm --query openvpn3-client")
|
||||
|
||||
if (
|
||||
(stdout[0] != 'package openvpn3-client is not installed' and stderr != '/bin/sh: rpm: command not found')
|
||||
and stdout[0] != 'E: No packages found'
|
||||
):
|
||||
cmd = "sudo openvpn3 configs-list |grep -E 'ovpn|(^|[^0-9])[0-9]{4}($|[^0-9])' |grep -v net|awk -F\" \" '{print $1}'|awk 'ORS=NR%2?\" \":\"\\n\"'"
|
||||
openvpn_configs, stderr = server_mod.subprocess_execute(cmd)
|
||||
cmd = "sudo openvpn3 sessions-list|grep -E 'Config|Status'|awk -F\":\" '{print $2}'|awk 'ORS=NR%2?\" \":\"\\n\"'| sed 's/^ //g'"
|
||||
openvpn_sess, stderr = server_mod.subprocess_execute(cmd)
|
||||
openvpn = stdout[0]
|
||||
|
||||
return render_template('ajax/load_openvpn.html', openvpn=openvpn, openvpn_sess=openvpn_sess, openvpn_configs=openvpn_configs)
|
||||
|
||||
|
||||
@bp.post('/openvpn/upload')
|
||||
def upload_openvpn():
|
||||
roxywi_auth.page_for_admin()
|
||||
name = common.checkAjaxInput(request.form.get('ovpnname'))
|
||||
ovpn_file = f"{os.path.dirname('/tmp/')}/{name}.ovpn"
|
||||
|
||||
try:
|
||||
with open(ovpn_file, "w") as conf:
|
||||
conf.write(request.form.get('uploadovpn'))
|
||||
except IOError as e:
|
||||
error = f'error: Cannot save ovpn file {e}'
|
||||
roxywi_common.logging('Roxy-WI server', error, roxywi=1)
|
||||
return error
|
||||
|
||||
try:
|
||||
cmd = 'sudo openvpn3 config-import --config %s --persistent' % ovpn_file
|
||||
server_mod.subprocess_execute(cmd)
|
||||
except IOError as e:
|
||||
error = f'error: Cannot import OpenVPN file: {e}'
|
||||
roxywi_common.logging('Roxy-WI server', error, roxywi=1)
|
||||
return error
|
||||
|
||||
try:
|
||||
cmd = 'sudo cp %s /etc/openvpn3/%s.conf' % (ovpn_file, name)
|
||||
server_mod.subprocess_execute(cmd)
|
||||
except IOError as e:
|
||||
error = f'error: Cannot save OpenVPN file: {e}'
|
||||
roxywi_common.logging('Roxy-WI server', error, roxywi=1)
|
||||
return error
|
||||
|
||||
roxywi_common.logging("Roxy-WI server", f" has been uploaded a new ovpn file {ovpn_file}", roxywi=1, login=1)
|
||||
|
||||
return 'success: ovpn file has been saved </div>'
|
||||
|
||||
|
||||
@bp.post('/openvpn/delete')
|
||||
def delete_openvpn():
|
||||
roxywi_auth.page_for_admin()
|
||||
openvpndel = common.checkAjaxInput(request.form.get('openvpndel'))
|
||||
|
||||
cmd = f'sudo openvpn3 config-remove --config /tmp/{openvpndel}.ovpn --force'
|
||||
try:
|
||||
server_mod.subprocess_execute(cmd)
|
||||
roxywi_common.logging(openvpndel, ' has deleted the ovpn file ', roxywi=1, login=1)
|
||||
except IOError as e:
|
||||
error = f'error: Cannot delete OpenVPN file: {e}'
|
||||
roxywi_common.logging('Roxy-WI server', error, roxywi=1)
|
||||
return error
|
||||
else:
|
||||
return 'ok'
|
||||
|
||||
|
||||
@bp.route('/openvpn/action/<action>/<openvpn>')
|
||||
def action_openvpn(action, openvpn):
|
||||
roxywi_auth.page_for_admin()
|
||||
openvpn = common.checkAjaxInput(openvpn)
|
||||
|
||||
if action == 'start':
|
||||
cmd = f'sudo openvpn3 session-start --config /tmp/{openvpn}.ovpn'
|
||||
elif action == 'restart':
|
||||
cmd = f'sudo openvpn3 session-manage --config /tmp/{openvpn}.ovpn --restart'
|
||||
elif action == 'disconnect':
|
||||
cmd = f'sudo openvpn3 session-manage --config /tmp/{openvpn}.ovpn --disconnect'
|
||||
else:
|
||||
return 'error: wrong action'
|
||||
try:
|
||||
server_mod.subprocess_execute(cmd)
|
||||
roxywi_common.logging(openvpn, f' The ovpn session has been {action}ed ', roxywi=1, login=1)
|
||||
return f"success: The {openvpn} has been {action}ed"
|
||||
except IOError as e:
|
||||
roxywi_common.logging('Roxy-WI server', e.args[0], roxywi=1)
|
||||
return f'error: Cannot {action} OpenVPN: {e}'
|
||||
|
||||
|
||||
@bp.get('/settings')
|
||||
@get_user_params()
|
||||
def get_settings():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from flask import request, render_template
|
||||
from flask import request, render_template, jsonify
|
||||
from flask_login import login_required
|
||||
|
||||
from app.routes.channel import bp
|
||||
|
@ -32,17 +32,24 @@ def load_channels():
|
|||
return f'{e}'
|
||||
|
||||
|
||||
@bp.route('/check/<channel_id>/<receiver_name>')
|
||||
@bp.route('/check/<int:channel_id>/<receiver_name>')
|
||||
def check_receiver(channel_id, receiver_name):
|
||||
channel_id = common.checkAjaxInput(channel_id)
|
||||
receiver_name = common.checkAjaxInput(receiver_name)
|
||||
|
||||
return alerting.check_receiver(channel_id, receiver_name)
|
||||
try:
|
||||
alerting.check_receiver(channel_id, receiver_name)
|
||||
return jsonify({'status': 'success'})
|
||||
except Exception as e:
|
||||
roxywi_common.handle_json_exceptions(e, 'Roxy-WI', f'Cannot send message via {receiver_name}')
|
||||
|
||||
|
||||
@bp.route('/check/rabbit')
|
||||
def check_rabbit():
|
||||
return alerting.check_rabbit_alert()
|
||||
try:
|
||||
alerting.check_rabbit_alert()
|
||||
return jsonify({'status': 'success'})
|
||||
except Exception as e:
|
||||
roxywi_common.handle_json_exceptions(e, 'Roxy-WI', 'Cannot send message via Web panel')
|
||||
|
||||
|
||||
@bp.route('/check/email')
|
||||
|
@ -51,23 +58,34 @@ def check_email():
|
|||
|
||||
|
||||
@bp.route('/receiver/<receiver_name>', methods=['PUT', 'POST', 'DELETE'])
|
||||
@get_user_params()
|
||||
def receiver(receiver_name):
|
||||
json_data = request.get_json()
|
||||
if request.method == 'POST':
|
||||
token = common.checkAjaxInput(request.form.get('receiver'))
|
||||
channel = common.checkAjaxInput(request.form.get('channel'))
|
||||
group = common.checkAjaxInput(request.form.get('group'))
|
||||
page = common.checkAjaxInput(request.form.get('page'))
|
||||
page = page.split("#")[0]
|
||||
token = common.checkAjaxInput(json_data['receiver'])
|
||||
channel = common.checkAjaxInput(json_data['channel'])
|
||||
group = int(json_data['group'])
|
||||
|
||||
return alerting.add_receiver_channel(receiver_name, token, channel, group, page)
|
||||
try:
|
||||
data = alerting.add_receiver_channel(receiver_name, token, channel, group)
|
||||
return jsonify({'status': 'updated', 'data': data})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, 'Roxy-WI', f'Cannot create {receiver_name} channel')
|
||||
elif request.method == 'PUT':
|
||||
token = common.checkAjaxInput(request.form.get('receiver_token'))
|
||||
channel = common.checkAjaxInput(request.form.get('channel'))
|
||||
group = common.checkAjaxInput(request.form.get('group'))
|
||||
user_id = common.checkAjaxInput(request.form.get('id'))
|
||||
token = common.checkAjaxInput(json_data['receiver_token'])
|
||||
channel = common.checkAjaxInput(json_data['channel'])
|
||||
group = int(json_data['group'])
|
||||
user_id = int(json_data['id'])
|
||||
|
||||
return alerting.update_receiver_channel(receiver_name, token, channel, group, user_id)
|
||||
try:
|
||||
alerting.update_receiver_channel(receiver_name, token, channel, group, user_id)
|
||||
return jsonify({'status': 'updated'})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, 'Roxy-WI', f'Cannot update {receiver_name} channel')
|
||||
elif request.method == 'DELETE':
|
||||
channel_id = common.checkAjaxInput(request.form.get('channel_id'))
|
||||
|
||||
return alerting.delete_receiver_channel(channel_id, receiver_name)
|
||||
channel_id = int(json_data['channel_id'])
|
||||
try:
|
||||
alerting.delete_receiver_channel(channel_id, receiver_name)
|
||||
return jsonify({'status': 'deleted'})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, 'Roxy-WI', f'Cannot delete {receiver_name} channel')
|
||||
|
|
|
@ -38,7 +38,7 @@ def create_user():
|
|||
current_user_role_id = g.user_params['role']
|
||||
if not roxywi_common.check_user_group_for_flask():
|
||||
return roxywi_common.handle_json_exceptions('Wrong group', 'Roxy-WI server', '')
|
||||
if current_user_role_id < role:
|
||||
if current_user_role_id > role:
|
||||
return roxywi_common.handle_json_exceptions('Wrong role', 'Roxy-WI server', '')
|
||||
try:
|
||||
user_id = roxywi_user.create_user(new_user, email, password, role, enabled, group_id)
|
||||
|
|
|
@ -16,8 +16,6 @@ $( function() {
|
|||
loadSettings();
|
||||
} else if (activeTab == '#updatehapwi') {
|
||||
loadupdatehapwi();
|
||||
} else if (activeTab == '#openvpn') {
|
||||
loadopenvpn();
|
||||
} else if (activeTab == '#backup') {
|
||||
loadBackup();
|
||||
}
|
||||
|
@ -35,8 +33,6 @@ window.onload = function() {
|
|||
loadBackup();
|
||||
} else if (activeTabIdx == 7) {
|
||||
loadupdatehapwi();
|
||||
} else if (activeTabIdx == 8) {
|
||||
loadopenvpn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,86 +88,6 @@ function updateService(service, action='update') {
|
|||
}
|
||||
});
|
||||
}
|
||||
function confirmDeleteOpenVpnProfile(id) {
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 400,
|
||||
modal: true,
|
||||
title: "Are you sure you want to delete profile " +id+ "?",
|
||||
buttons: {
|
||||
"Delete": function() {
|
||||
$( this ).dialog( "close" );
|
||||
removeOpenVpnProfile(id);
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function removeOpenVpnProfile(id) {
|
||||
$("#" + id).css("background-color", "#f2dede");
|
||||
$.ajax({
|
||||
url: "/app/admin/openvpn/delete",
|
||||
data: {
|
||||
openvpndel: id
|
||||
},
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data == "ok") {
|
||||
$("#" + id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function uploadOvpn() {
|
||||
toastr.clear();
|
||||
if ($("#ovpn_upload_name").val() == '' || $('#ovpn_upload_file').val() == '') {
|
||||
toastr.error('All fields must be completed');
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/app/admin/openvpn/upload",
|
||||
data: {
|
||||
uploadovpn: $('#ovpn_upload_file').val(),
|
||||
ovpnname: $('#ovpn_upload_name').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.success(data);
|
||||
location.reload();
|
||||
} else {
|
||||
toastr.error('Something wrong, check and try again');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function OpenVpnSess(id, action) {
|
||||
$.ajax({
|
||||
url: "/app/admin/openvpn/" + action + "/" + id,
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.success(data)
|
||||
location.reload()
|
||||
} else {
|
||||
toastr.error('Something wrong, check and try again');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function loadSettings() {
|
||||
$.ajax({
|
||||
url: "/app/admin/settings",
|
||||
|
@ -223,20 +139,6 @@ function checkUpdateRoxy() {
|
|||
}
|
||||
} );
|
||||
}
|
||||
function loadopenvpn() {
|
||||
$.ajax({
|
||||
url: "/app/admin/openvpn",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('group_error') == '-1' && data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
$('#openvpn').html(data);
|
||||
$.getScript(awesome);
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function confirmAjaxServiceAction(action, service) {
|
||||
let action_word = translate_div.attr('data-'+action);
|
||||
$( "#dialog-confirm-services" ).dialog({
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
let cur_url = window.location.href.split('/app/').pop();
|
||||
cur_url = cur_url.split('/');
|
||||
$( function() {
|
||||
$('#add-telegram-button').click(function() {
|
||||
$('#add-telegram-button').click(function () {
|
||||
addTelegramDialog.dialog('open');
|
||||
});
|
||||
$('#add-slack-button').click(function() {
|
||||
$('#add-slack-button').click(function () {
|
||||
addSlackDialog.dialog('open');
|
||||
});
|
||||
$('#add-pd-button').click(function() {
|
||||
$('#add-pd-button').click(function () {
|
||||
addPDDialog.dialog('open');
|
||||
});
|
||||
$('#add-mm-button').click(function() {
|
||||
$('#add-mm-button').click(function () {
|
||||
addMMDialog.dialog('open');
|
||||
});
|
||||
let telegram_tabel_title = $( "#telegram-add-table-overview" ).attr('title');
|
||||
let addTelegramDialog = $( "#telegram-add-table" ).dialog({
|
||||
let telegram_tabel_title = $("#telegram-add-table-overview").attr('title');
|
||||
let addTelegramDialog = $("#telegram-add-table").dialog({
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
|
@ -42,8 +40,8 @@ $( function() {
|
|||
}
|
||||
}]
|
||||
});
|
||||
let slack_tabel_title = $( "#slack-add-table-overview" ).attr('title');
|
||||
let addSlackDialog = $( "#slack-add-table" ).dialog({
|
||||
let slack_tabel_title = $("#slack-add-table-overview").attr('title');
|
||||
let addSlackDialog = $("#slack-add-table").dialog({
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
|
@ -71,8 +69,8 @@ $( function() {
|
|||
}
|
||||
}]
|
||||
});
|
||||
let pd_tabel_title = $( "#pd-add-table-overview" ).attr('title');
|
||||
let addPDDialog = $( "#pd-add-table" ).dialog({
|
||||
let pd_tabel_title = $("#pd-add-table-overview").attr('title');
|
||||
let addPDDialog = $("#pd-add-table").dialog({
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
|
@ -100,8 +98,8 @@ $( function() {
|
|||
}
|
||||
}]
|
||||
});
|
||||
let mm_tabel_title = $( "#mm-add-table-overview" ).attr('title');
|
||||
let addMMDialog = $( "#mm-add-table" ).dialog({
|
||||
let mm_tabel_title = $("#mm-add-table-overview").attr('title');
|
||||
let addMMDialog = $("#mm-add-table").dialog({
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
|
@ -129,27 +127,27 @@ $( function() {
|
|||
}
|
||||
}]
|
||||
});
|
||||
$( "#checker_telegram_table input" ).change(function() {
|
||||
$("#checker_telegram_table input").change(function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[2], 'telegram')
|
||||
});
|
||||
$( "#checker_telegram_table select" ).on('selectmenuchange',function() {
|
||||
$("#checker_telegram_table select").on('selectmenuchange', function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[1], 'telegram')
|
||||
});
|
||||
$( "#checker_slack_table input" ).change(function() {
|
||||
$("#checker_slack_table input").change(function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[2], 'slack')
|
||||
});
|
||||
$( "#checker_slack_table select" ).on('selectmenuchange',function() {
|
||||
$("#checker_slack_table select").on('selectmenuchange', function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[1], 'slack')
|
||||
});
|
||||
$( "#checker_pd_table input" ).change(function() {
|
||||
$("#checker_pd_table input").change(function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[2], 'pd')
|
||||
});
|
||||
$( "#checker_pd_table select" ).on('selectmenuchange',function() {
|
||||
$("#checker_pd_table select").on('selectmenuchange', function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateReceiver(id[1], 'pd')
|
||||
});
|
||||
|
@ -164,36 +162,35 @@ function loadChannel() {
|
|||
toastr.error(data);
|
||||
} else {
|
||||
$('#checker').html(data);
|
||||
$( "select" ).selectmenu();
|
||||
$("select").selectmenu();
|
||||
$("button").button();
|
||||
$( "input[type=checkbox]" ).checkboxradio();
|
||||
$("input[type=checkbox]").checkboxradio();
|
||||
$.getScript('/app/static/js/channel.js');
|
||||
$.getScript(awesome);
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
function updateReceiver(id, receiver_name) {
|
||||
if (cur_url[0].indexOf('servers') != '-1') {
|
||||
let group = $('#new-group').val();
|
||||
} else {
|
||||
let group = $('#' + receiver_name + 'group-' + id).val();
|
||||
let group = $('#' + receiver_name + 'group-' + id).val();
|
||||
if (group === undefined || group === null) {
|
||||
group = $('#channel-group').val();
|
||||
}
|
||||
toastr.clear();
|
||||
let json_data = {
|
||||
"receiver_token": $('#' + receiver_name + '-token-' + id).val(),
|
||||
"channel": $('#' + receiver_name + '-chanel-' + id).val(),
|
||||
"group": group,
|
||||
"id": id
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/channel/receiver/" + receiver_name,
|
||||
data: {
|
||||
receiver_token: $('#' + receiver_name + '-token-' + id).val(),
|
||||
channel: $('#' + receiver_name + '-chanel-' + id).val(),
|
||||
group: group,
|
||||
id: id,
|
||||
token: $('#token').val()
|
||||
},
|
||||
data: JSON.stringify(json_data),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
type: "PUT",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
toastr.clear();
|
||||
$("#" + receiver_name + "-table-" + id).addClass("update", 1000);
|
||||
|
@ -207,14 +204,10 @@ function updateReceiver(id, receiver_name) {
|
|||
function checkReceiver(channel_id, receiver_name) {
|
||||
$.ajax({
|
||||
url: "/app/channel/check/" + channel_id + "/" + receiver_name,
|
||||
// data: {
|
||||
// token: $('#token').val()
|
||||
// },
|
||||
// type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') {
|
||||
toastr.error(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
toastr.success('Test message has been sent');
|
||||
}
|
||||
|
@ -222,35 +215,35 @@ function checkReceiver(channel_id, receiver_name) {
|
|||
});
|
||||
}
|
||||
function addRecevier(dialog_id, receiver_name) {
|
||||
let valid = true;
|
||||
toastr.clear();
|
||||
let allFields = $([]).add($('#' + receiver_name + '-token-add')).add($('#' + receiver_name + '-chanel-add'));
|
||||
let valid = true;
|
||||
let receiver_name_div = $('#' + receiver_name + '-token-add');
|
||||
let channel_div = $('#' + receiver_name + '-chanel-add');
|
||||
let group = $('#new-' + receiver_name + '-group-add').val();
|
||||
let allFields = $([]).add(receiver_name_div).add(channel_div);
|
||||
allFields.removeClass("ui-state-error");
|
||||
valid = valid && checkLength($('#' + receiver_name + '-token-add'), "token", 1);
|
||||
valid = valid && checkLength($('#' + receiver_name + '-chanel-add'), "channel name", 1);
|
||||
valid = valid && checkLength(receiver_name_div, "token", 1);
|
||||
valid = valid && checkLength(channel_div, "channel name", 1);
|
||||
if (group === undefined || group === null) {
|
||||
group = $('#channel-group').val();
|
||||
}
|
||||
if (valid) {
|
||||
let jsonData = {
|
||||
"receiver": receiver_name_div.val(),
|
||||
"channel": channel_div.val(),
|
||||
"group": group,
|
||||
}
|
||||
toastr.clear();
|
||||
$.ajax({
|
||||
url: "/app/channel/receiver/" + receiver_name,
|
||||
data: {
|
||||
receiver: $('#' + receiver_name + '-token-add').val(),
|
||||
channel: $('#' + receiver_name + '-chanel-add').val(),
|
||||
group: $('#new-' + receiver_name + '-group-add').val(),
|
||||
page: cur_url[0].split('#')[0],
|
||||
token: $('#token').val()
|
||||
},
|
||||
data: JSON.stringify(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
let getId = new RegExp(receiver_name + '-table-[0-9]+');
|
||||
let id = data.match(getId) + '';
|
||||
id = id.split('-').pop();
|
||||
$('select:regex(id, ' + receiver_name + '_channel)').append('<option value=' + id + '>' + $('#' + receiver_name + '-chanel-add').val() + '</option>').selectmenu("refresh");
|
||||
common_ajax_action_after_success(dialog_id, 'newgroup', 'checker_' + receiver_name + '_table', data);
|
||||
$("input[type=submit], button").button();
|
||||
$("input[type=checkbox]").checkboxradio();
|
||||
common_ajax_action_after_success(dialog_id, 'newgroup', 'checker_' + receiver_name + '_table', data.data);
|
||||
$("select").selectmenu();
|
||||
}
|
||||
}
|
||||
|
@ -258,25 +251,25 @@ function addRecevier(dialog_id, receiver_name) {
|
|||
}
|
||||
}
|
||||
function confirmDeleteReceiver(id, receiver_name) {
|
||||
$( "#dialog-confirm-services" ).dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 400,
|
||||
modal: true,
|
||||
title: delete_word + " " + $('#' + receiver_name + '-chanel-' + id).val() + "?",
|
||||
buttons: [{
|
||||
text: delete_word,
|
||||
click: function () {
|
||||
$(this).dialog("close");
|
||||
removeReceiver(receiver_name, id);
|
||||
}
|
||||
}, {
|
||||
text: cancel_word,
|
||||
click: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
$("#dialog-confirm-services").dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 400,
|
||||
modal: true,
|
||||
title: delete_word + " " + $('#' + receiver_name + '-chanel-' + id).val() + "?",
|
||||
buttons: [{
|
||||
text: delete_word,
|
||||
click: function () {
|
||||
$(this).dialog("close");
|
||||
removeReceiver(receiver_name, id);
|
||||
}
|
||||
}, {
|
||||
text: cancel_word,
|
||||
click: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
function cloneReceiver(id, receiver_name) {
|
||||
$('#add-'+receiver_name+'-button').trigger( "click" );
|
||||
|
@ -287,17 +280,14 @@ function removeReceiver(receiver_name, receiver_id) {
|
|||
$("#" + receiver_name + "-table-" + receiver_id).css("background-color", "#f2dede");
|
||||
$.ajax({
|
||||
url: "/app/channel/receiver/" + receiver_name,
|
||||
data: {
|
||||
channel_id: receiver_id,
|
||||
token: $('#token').val()
|
||||
},
|
||||
data: JSON.stringify({"channel_id": receiver_id}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
type: "DELETE",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data == "ok") {
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
$("#" + receiver_name + "-table-" + receiver_id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -305,14 +295,10 @@ function removeReceiver(receiver_name, receiver_id) {
|
|||
function checkWebPanel() {
|
||||
$.ajax({
|
||||
url: "/app/channel/check/rabbit",
|
||||
// data: {
|
||||
// token: $('#token').val()
|
||||
// },
|
||||
// type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') {
|
||||
toastr.error(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
toastr.success('Test message has been sent');
|
||||
}
|
||||
|
@ -322,10 +308,6 @@ function checkWebPanel() {
|
|||
function checkEmail() {
|
||||
$.ajax({
|
||||
url: "/app/channel/check/email",
|
||||
// data: {
|
||||
// token: $('#token').val()
|
||||
// },
|
||||
// type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<li><a href="#groups" title="{{lang.words.admin_area|title()}}: {{lang.words.manage|title()}} {{lang.words.groups}} - Roxy-WI">{{lang.words.groups|title()}}</a></li>
|
||||
<li><a href="#tools" title="{{lang.words.admin_area|title()}}: {{lang.words.manage|title()}} Roxy-WI {{lang.words.tools}} - Roxy-WI">{{lang.words.tools|title()}}</a></li>
|
||||
<li><a href="#updatehapwi" title="{{lang.words.admin_area|title()}}: {{lang.words.w_update|title()}} Roxy-WI - Roxy-WI">{{lang.words.w_update|title()}}</a></li>
|
||||
<li><a href="#openvpn" title="{{lang.words.admin_area|title()}}: {{lang.words.manage|title()}} OpenVPN - Roxy-WI" id="admin-tabs-vpn">OpenVPN</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div id="users">
|
||||
|
@ -137,7 +136,6 @@
|
|||
<div id="ajax-update"></div>
|
||||
</div>
|
||||
|
||||
<div id="openvpn"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'include/admins_dialogs.html' %}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
{% from 'include/input_macros.html' import input, select %}
|
||||
{% if openvpn != '' %}
|
||||
<table id="openvpn_table" class="overview">
|
||||
<caption><h3>OpenVPN profiles</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
Profile name
|
||||
</td>
|
||||
<td style="width: 35%;">
|
||||
Created
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% for c in openvpn_configs %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{c.split('/')[-1].split('.')[0]}}">
|
||||
<td class="padding10 first-collumn">
|
||||
{{c.split('/')[-1]}}
|
||||
</td>
|
||||
<td style="width: 100%">
|
||||
{{c.split('/')[0]}}
|
||||
</td>
|
||||
<td>
|
||||
<a class="service-start" onclick="OpenVpnSess('{{c.split('/')[-1].split('.')[0]}}', 'start')" title="Start OpenVPN with profile {{c.split('/')[-1]}}"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteOpenVpnProfile('{{c.split('/')[-1].split('.')[0]}}')" title="Delete OpenVPN profile {{c.split('/')[-1]}}" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br />
|
||||
<table id="openvpn_table" class="overview">
|
||||
<caption><h3>OpenVPN sessions</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
Session name
|
||||
</td>
|
||||
<td class="padding10 first-collumn" style="width: 35%;">
|
||||
Status
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% for c in openvpn_sess %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}">
|
||||
<td class="padding10 first-collumn">
|
||||
{{c.split(' ')[0]}}
|
||||
</td>
|
||||
<td style="width: 100%">
|
||||
{{c.split(' ')[4]}}
|
||||
</td>
|
||||
<td>
|
||||
<a class="service-reload" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'restart')" title="Restart OpenVPN with profile {{c.split('/')[0]}}"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'disconnect')" title="Disconnect OpenVPN profile {{c.split('/')[2]}}" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br />
|
||||
<table id="openvpn_upload_table" class="overview">
|
||||
<caption><h3>Uploading ovpn files</h3></caption>
|
||||
<tr class="overviewHead" style="width: 50%;">
|
||||
<td class="padding10 first-collumn" style="width: 25%;">Ovpn file name</td>
|
||||
<td>
|
||||
<span title="Ovpn file must be with an auto-login profile" class="help_cursor">Upload a file</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 50%;">
|
||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||
{{ input('ovpn_upload_name', size='30') }}
|
||||
</td>
|
||||
<td style="padding-top: 15px;">
|
||||
<textarea id="ovpn_upload_file" cols="50" rows="5"></textarea><br /><br />
|
||||
<a class="ui-button ui-widget ui-corner-all" id="ovpn_upload" title="Upload ovpn file" onclick="uploadOvpn()">Upload</a>
|
||||
<br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% else %}
|
||||
<div style="text-align: center;">
|
||||
<br />
|
||||
<h3>You have not installed OpenVPN client.</h3>
|
||||
<img src="{{ url_for('static', filename='images/no_servers.png')}}" alt="There is no server">
|
||||
<h4>Read <a href="https://roxy-wi.org/tools/openvpn" title="OpenVPN" style="color: #5d9ceb;" target="_blank">here</a>
|
||||
how to install OpenVPN client.</h4>
|
||||
</div>
|
||||
{% endif %}
|
|
@ -8,7 +8,7 @@
|
|||
<td>
|
||||
<input type="text" id="{{receiver}}-chanel-{{c.id}}" class="form-control" value="{{c.chanel_name}}" size="30">
|
||||
</td>
|
||||
{% if page != "servers.py" %}
|
||||
{% if g.user_params['role'] > 1 %}
|
||||
<td>
|
||||
<select id="{{receiver}}group-{{c.id}}" name="{{receiver}}group-{{c.id}}">
|
||||
{% for group in groups %}
|
||||
|
|
|
@ -9,4 +9,7 @@
|
|||
<script>
|
||||
loadChannel();
|
||||
</script>
|
||||
{% if g.user_params['role'] > 1 %}
|
||||
{{ input('channel-group', type='hidden', value=g.user_params['group_id']) }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
#oops_div {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
{% if page == 'servers.py' or page == 'users.py' %}
|
||||
margin-top: 50px;
|
||||
{% else %}
|
||||
bottom: 50px;
|
||||
{% endif %}
|
||||
}
|
||||
</style>
|
||||
<center>
|
||||
|
@ -22,5 +18,5 @@
|
|||
</h4>
|
||||
</center>
|
||||
<div id="oops_div">
|
||||
<img src="/app/static/images/images/oops.png" alt="Oops">
|
||||
<img src="/app/static/images/oops.png" alt="Oops">
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue