Changelog: https://roxy-wi.org/changelog#6_3_7
pull/355/head
Aidaho 2 years ago
parent d190583abd
commit 4879b215b7

@ -167,6 +167,18 @@ def default_values():
except Exception as e:
print(str(e))
data_source = [
{'user_id': '1', 'user_group_id': '2', 'user_role_id': '1'},
{'user_id': '2', 'user_group_id': '2', 'user_role_id': '2'},
{'user_id': '3', 'user_group_id': '2', 'user_role_id': '4'}
]
try:
if create_users:
UserGroups.insert_many(data_source).on_conflict_ignore().execute()
except Exception as e:
print(str(e))
data_source = [
{'name': 'superAdmin', 'description': 'Has the highest level of administrative permissions and controls the actions of all other users'},
{'name': 'admin', 'description': 'Has access everywhere except the Admin area'},

@ -461,6 +461,7 @@ def show_compare_config(server_ip: str) -> None:
left = form.getvalue('left')
right = form.getvalue('right')
service = form.getvalue('service')
lang = roxywi_common.get_user_lang()
if service == 'nginx':
return_files = roxywi_common.get_files(get_config_var.get_config_var('configs', 'nginx_save_configs_dir'), 'conf')
@ -471,7 +472,7 @@ def show_compare_config(server_ip: str) -> None:
else:
return_files = roxywi_common.get_files()
template = template.render(serv=server_ip, right=right, left=left, return_files=return_files)
template = template.render(serv=server_ip, right=right, left=left, return_files=return_files, lang=lang)
print(template)
@ -480,6 +481,7 @@ def compare_config() -> None:
left = common.checkAjaxInput(form.getvalue('left'))
right = common.checkAjaxInput(form.getvalue('right'))
lang = roxywi_common.get_user_lang()
if form.getvalue('service') == 'nginx':
configs_dir = get_config_var.get_config_var('configs', 'nginx_save_configs_dir')
@ -496,7 +498,7 @@ def compare_config() -> None:
template = env.get_template('ajax/compare.html')
output, stderr = server_mod.subprocess_execute(cmd)
template = template.render(stdout=output)
template = template.render(stdout=output, lang=lang)
print(template)
print(stderr)

@ -20,9 +20,9 @@ def create_user(new_user: str, email: str, password: str, role: str, activeuser:
sql.update_user_role(user_id, group, role)
roxywi_common.logging(f'a new user {new_user}', ' has been created ', roxywi=1, login=1)
try:
sql.update_user_role(user_id, group_id, role_id)
sql.update_user_role(user_id, group, role)
except Exception as e:
print(str(e))
print(f'error: cannot update user role {e}')
try:
if password == 'aduser':
password = 'your domain password'
@ -121,18 +121,6 @@ def change_user_services() -> None:
print(e)
def move_user_service(action) -> None:
service_id = common.checkAjaxInput(form.getvalue('service_id'))
service_name = common.checkAjaxInput(form.getvalue('service_name'))
length_tr = common.checkAjaxInput(form.getvalue('length_tr'))
lang = roxywi_common.get_user_lang()
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ajax/move_user_service.html')
template = template.render(lang=lang, service_id=service_id, service_name=service_name, length_tr=length_tr, action=action)
print(template)
def change_user_active_group() -> None:
group_id = common.checkAjaxInput(form.getvalue('changeUserCurrentGroupId'))
user_uuid = common.checkAjaxInput(form.getvalue('changeUserGroupsUser'))
@ -180,17 +168,6 @@ def add_user_group_and_role() -> None:
print(template)
def remove_user_group_and_role() -> None:
group_id = common.checkAjaxInput(form.getvalue('group_id'))
group_name = common.checkAjaxInput(form.getvalue('group_name'))
length_tr = common.checkAjaxInput(form.getvalue('length_tr'))
lang = roxywi_common.get_user_lang()
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ajax/remove_user_group_and_role.html')
template = template.render(lang=lang, group_id=group_id, group_name=group_name, length_tr=length_tr)
print(template)
def save_user_group_and_role() -> None:
import json

@ -1095,11 +1095,6 @@ if act == 'add_user_group_and_role':
roxy_user.add_user_group_and_role()
if act == 'remove_user_group_and_role':
import modules.roxywi.user as roxy_user
roxy_user.remove_user_group_and_role()
if act == 'save_user_group_and_role':
import modules.roxywi.user as roxy_user
@ -1110,16 +1105,6 @@ if form.getvalue('changeUserServicesId') is not None:
roxy_user.change_user_services()
if act == 'add_user_service':
import modules.roxywi.user as roxy_user
roxy_user.move_user_service('add')
if act == 'remove_user_service':
import modules.roxywi.user as roxy_user
roxy_user.move_user_service('remove')
if form.getvalue('changeUserCurrentGroupId') is not None:
import modules.roxywi.user as roxy_user

@ -1,3 +1,4 @@
{% import 'languages/'+lang|default('en')+'.html' as lang %}
<div class="out">
<div class="diff">
{% set plus = [] %}
@ -23,7 +24,7 @@
{% set total_change = minus + plus %}
<div class="diffHead">
Total change: {{ total_change|length }}, additions: {{ plus|length }} & deletions: {{ minus|length }}
{{lang.words.total|title()}} {{lang.words.changes}}: {{ total_change|length }}, {{lang.words.additions}}: {{ plus|length }} & {{lang.words.deletions}}: {{ minus|length }}
</div>
</div>
</div>

@ -1,19 +0,0 @@
{% import 'languages/'+lang|default('en')+'.html' as lang %}
{% if length_tr|int() % 2 == 1 %}
{% set class = 'even' %}
{% endif %}
{% if action == 'add' %}
{% set tr_id = 'remove_service-' + service_id %}
{% else %}
{% set tr_id = 'add_service-' + service_id %}
{% endif %}
<tr class="{{class}}" id="{{tr_id}}" data-service_name="{{service_name}}">
<td class="padding20" style="width: 100%;">{{service_name}}</td>
<td>
{% if action == 'add' %}
<span class="remove_user_group" onclick="removeServiceFromUser({{service_id}})" title="{{lang.words.delete|title()}} {{lang.words.service}}">-</span>
{% else %}
<span class="add_user_group" onclick="addServiceToUser({{service_id}})" title="{{lang.words.add|title()}} {{lang.words.service}}">+</span>
{% endif %}
</td>
</tr>

@ -1,8 +0,0 @@
{% import 'languages/'+lang|default('en')+'.html' as lang %}
{% if length_tr|int() % 2 == 1 %}
{% set class = 'even' %}
{% endif %}
<tr class="{{class}}" id="add_group-{{group_id}}" data-group_name="{{group_name}}">
<td class="padding20" style="width: 100%">{{group_name}}</td>
<td><span class="add_user_group" title="{{lang.words.add|title()}} {{lang.words.group2}}" onclick="addGroupToUser({{group_id}})">+</span></td>
</tr>

@ -1,10 +1,11 @@
{% from 'include/input_macros.html' import input %}
{% import 'languages/'+lang|default('en')+'.html' as lang %}
<form action="" method="post">
<div style="text-align: center;margin-top: 20px;">
<h4>Comparing config files</h4>
<h4>{{ lang.phrases.comparing_config }}</h4>
<p>
<select autofocus required name="left" id="left">
<option disabled selected>Select an older config</option>
<option disabled selected>{{ lang.phrases.select_older_config }}</option>
{% for file in return_files %}
{% if file == left %}
<option value="{{ file }}" selected>{{ file.split('-', maxsplit=1)[1] }}</option>
@ -15,14 +16,14 @@
</select>
<select autofocus required name="right" id="right">
<option disabled selected>Select a newer config</option>
<option disabled selected>{{ lang.phrases.select_newer_config }}</option>
{% for file in return_files %}
<option value="{{ file }}">{{ file.split('-', maxsplit=1)[1] }}</option>
{% 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="showCompare()">Compare</a>
<a class="ui-button ui-widget ui-corner-all" id="show" title="{{ lang.words.compare|title() }}" onclick="showCompare()">{{ lang.words.compare|title() }}</a>
</p>
</div>
</form>

@ -9,9 +9,9 @@
<meta id="translate" style="display: none;" data-delete="{{lang.words.delete|title()}}" data-cancel="{{lang.words.cancel|title()}}" data-add="{{lang.words.add|title()}}"
data-superAdmin_pass="{{lang.phrases.superAdmin_pass}}" data-superAdmin_services="{{lang.phrases.superAdmin_services}}" data-change="{{lang.words.change|title()}}"
data-change2="{{lang.words.change2|title()}}" data-password="{{lang.words.password}}" data-groups="{{lang.words.groups}}" data-save="{{lang.words.save|title()}}"
data-manage="{{lang.words.manage|title()}}" data-services3="{{lang.words.services3}}" data-logout="{{lang.words.logout|title()}}"
data-manage="{{lang.words.manage|title()}}" data-services3="{{lang.words.services3}}" data-service="{{lang.words.service}}" data-logout="{{lang.words.logout|title()}}"
data-something_wrong="{{lang.words.something_wrong}}" data-check_logs="{{lang.words.check_logs}}" data-wait_mess="{{lang.phrases.wait_mess}}"
data-just_save="{{lang.words.just|title()}} {{lang.words.save}}" data-upload_and_restart="{{lang.phrases.upload_and_restart|title()}}"
data-just_save="{{lang.words.just|title()}} {{lang.words.save}}" data-group2="{{lang.words.group2}}" data-upload_and_restart="{{lang.phrases.upload_and_restart|title()}}"
data-are_you_sure="{{lang.phrases.are_you_sure}}" data-upload_and_reload="{{lang.phrases.upload_and_reload|title()}}" data-select_server="{{lang.errors.select_server}}"
data-empty_name="{{lang.errors.empty_name}}" data-edit="{{lang.words.edit|title()}}" data-close="{{lang.words.close|title()}}" data-server_info="{{lang.phrases.server_info}}"
data-generated_config="{{lang.words.generated|title()}} {{lang.words.config}}" data-restart="{{lang.words.restart|title()}}" data-start="{{lang.words.start|title()}}"

@ -293,6 +293,9 @@
"possible_service_name": "Possible service name",
"server_info": "Server info",
"user_groups": "User groups",
"comparing_config": "Comparing config files",
"select_older_config": "Select an older config",
"select_newer_config": "Select a newer config",
}
%}
{% set roles = {
@ -591,6 +594,7 @@
"save": "save",
"change": "change",
"change2": "change",
"changes": "changes",
"enter": "enter",
"enter2": "enter",
"lists": "lists",
@ -815,5 +819,7 @@
"rule": "rule",
"rules": "rules",
"send": "send",
"additions": "additions",
"deletions": "deletions",
}
%}

@ -293,6 +293,9 @@
"possible_service_name": "Nom de service possible",
"server_info": "Info Serveur",
"user_groups": "Groupes utilisateur",
"comparing_config": "Comparer les fichiers de configuration",
"select_older_config": "Sélectionnez une ancienne configuration",
"select_newer_config": "Sélectionnez une configuration plus récente",
}
%}
{% set roles = {
@ -591,6 +594,7 @@
"save": "sauvegarder",
"change": "changer",
"change2": "changer",
"changes": "changements",
"enter": "entrer",
"enter2": "entrer",
"lists": "listes",
@ -815,5 +819,7 @@
"rule": "règle",
"rules": "règles",
"send": "envoyer",
"additions": "ajouts",
"deletions": "suppressions",
}
%}

@ -295,6 +295,9 @@
"possible_service_name": "Возможное название службы",
"server_info": "Информация о сервере",
"user_groups": "Пользовательские группы",
"comparing_config": "Сравнение файлов конфигурации",
"select_older_config": "Выберите более старую конфигурацию",
"select_newer_config": "Выберите более новую конфигурацию",
}
%}
{% set roles = {
@ -595,6 +598,7 @@
"save": "сохранить",
"change": "изменение",
"change2": "изменить",
"changes": "изменений",
"enter": "ввод",
"enter2": "введите",
"lists": "листы",
@ -822,5 +826,7 @@
"rule": "правило",
"rules": "правила",
"send": "отправить",
"additions": "дополнения",
"deletions": "удаления",
}
%}

@ -1040,7 +1040,6 @@ function addUser(dialog_id) {
} else {
var getId = new RegExp('[0-9]+');
var id = data.match(getId);
addUserGroup(id[0]);
common_ajax_action_after_success(dialog_id, 'user-'+id, 'ajax-users', data);
}
}
@ -2319,7 +2318,7 @@ function changeUserServiceDialog(id) {
$( "#change-user-service-dialog" ).dialog({
resizable: false,
height: "auto",
width: 450,
width: 700,
modal: true,
title: manage_word+" "+$('#login-'+id).val()+" "+services_word,
buttons: [{
@ -2339,14 +2338,19 @@ function changeUserServiceDialog(id) {
}
} );
}
function changeUserServices(id) {
var services = $('#userservice-'+id).val().toString();
function changeUserServices(user_id) {
var jsonData = {};
jsonData[user_id] = {};
$('#checked_services tbody tr').each(function () {
var this_id = $(this).attr('id').split('-')[1];
jsonData[user_id][this_id] = {}
});
$.ajax( {
url: "options.py",
data: {
changeUserServicesId: id,
changeUserServices: services,
changeUserServicesUser: $('#login-'+id).val(),
changeUserServicesId: user_id,
jsonDatas: JSON.stringify(jsonData),
changeUserServicesUser: $('#login-'+user_id).val(),
token: $('#token').val()
},
type: "POST",
@ -2354,30 +2358,43 @@ function changeUserServices(id) {
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
} else {
$("#user-" + id).addClass("update", 1000);
$("#user-" + user_id).addClass("update", 1000);
setTimeout(function () {
$("#user-" + id).removeClass("update");
$("#user-" + user_id).removeClass("update");
}, 2500);
}
}
} );
}
function addUserGroup(id) {
$.ajax( {
url: "options.py",
data: {
changeUserGroupId: id,
changeUserGroups: $('#new-group').val(),
changeUserGroupsUser: 'new',
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
toastr.error(data);
}
}
} );
function addServiceToUser(service_id) {
var service_name = $('#add_service-'+service_id).attr('data-service_name');
var delete_word = $('#translate').attr('data-delete');
var service_word = $('#translate').attr('data-service');
var length_tr = $('#checked_services tbody tr').length;
var tr_class = 'odd';
if (length_tr % 2 != 0) {
tr_class = 'even';
}
var html_tag = '<tr class="'+tr_class+'" id="remove_service-'+service_id+'" data-service_name="'+service_name+'">' +
'<td class="padding20" style="width: 100%;">'+service_name+'</td>' +
'<td><span class="add_user_group" onclick="removeServiceFromUser('+service_id+')" title="'+delete_word+' '+service_word+'">+</span></td></tr>';
$('#add_service-'+service_id).remove();
$("#checked_services tbody").append(html_tag);
}
function removeServiceFromUser(service_id) {
var service_name = $('#remove_service-'+service_id).attr('data-service_name');
var add_word = $('#translate').attr('data-add');
var service_word = $('#translate').attr('data-service');
var length_tr = $('#all_services tbody tr').length;
var tr_class = 'odd';
if (length_tr % 2 != 0) {
tr_class = 'even';
}
var html_tag = '<tr class="'+tr_class+'" id="add_service-'+service_id+'" data-service_name="'+service_name+'">' +
'<td class="padding20" style="width: 100%;">'+service_name+'</td>' +
'<td><span class="add_user_group" onclick="addServiceToUser('+service_id+')" title="'+add_word+' '+service_word+'">+</span></td></tr>';
$('#remove_service-'+service_id).remove();
$("#all_services tbody").append(html_tag);
}
function confirmAjaxServiceAction(action, service) {
var cancel_word = $('#translate').attr('data-cancel');
@ -3090,6 +3107,7 @@ function confirmChangeGroupsAndRoles(user_id) {
var cancel_word = $('#translate').attr('data-cancel');
var action_word = $('#translate').attr('data-save');
var user_groups_word = $('#translate').attr('data-user_groups');
var username = $('#login-'+user_id).val();
$.ajax({
url: "options.py",
data: {
@ -3105,7 +3123,7 @@ function confirmChangeGroupsAndRoles(user_id) {
height: "auto",
width: 700,
modal: true,
title: user_groups_word,
title: user_groups_word + ' ' + username,
buttons: [{
text: action_word,
click: function () {
@ -3142,21 +3160,19 @@ function addGroupToUser(group_id) {
}
function removeGroupFromUser(group_id) {
var group_name = $('#remove_group-'+group_id).attr('data-group_name');
$.ajax({
url: "options.py",
data: {
act: 'remove_user_group_and_role',
group_id: group_id,
group_name: group_name,
length_tr: $('#all_groups tbody tr').length,
token: $('#token').val()
},
type: "POST",
success: function (data) {
var add_word = $('#translate').attr('data-add');
var group2_word = $('#translate').attr('data-group2');
var length_tr = $('#all_groups tbody tr').length;
var tr_class = 'odd';
if (length_tr % 2 != 0) {
tr_class = 'even';
}
var html_tag = '<tr class="'+tr_class+'" id="add_group-'+group_id+'" data-group_name='+group_name+'>\n' +
' <td class="padding20" style="width: 100%">'+group_name+'</td>\n' +
' <td><span class="add_user_group" title="'+add_word+' '+group2_word+'" onclick="addGroupToUser('+group_id+')">+</span></td>\n' +
'</tr>'
$('#remove_group-'+group_id).remove();
$("#all_groups tbody").append(data);
}
});
$("#all_groups tbody").append(html_tag);
}
function saveGroupsAndRoles(user_id) {
var length_tr = $('#checked_groups tbody tr').length;
@ -3167,11 +3183,11 @@ function saveGroupsAndRoles(user_id) {
var role_id = $('#add_role-'+this_id).val();
jsonData[user_id][this_id] = {'role_id': role_id};
});
console.log(jsonData);
$.ajax({
url: "options.py",
data: {
act: 'save_user_group_and_role',
changeUserGroupsUser: $('#login-'+user_id).val(),
jsonDatas: JSON.stringify(jsonData),
token: $('#token').val()
},

Loading…
Cancel
Save