Merge branch 'tweak/password-suggestion' into 'dev'

QOL Fixes

See merge request crafty-controller/crafty-commander!235
This commit is contained in:
Andrew 2022-04-03 01:51:10 +00:00
commit 261a57e034
10 changed files with 829 additions and 692 deletions

View File

@ -72,6 +72,7 @@ class Users_Controller:
up_data[key] = user_data[key] up_data[key] = user_data[key]
up_data["last_update"] = helper.get_time_as_string() up_data["last_update"] = helper.get_time_as_string()
up_data["lang"] = user_data["lang"] up_data["lang"] = user_data["lang"]
up_data["hints"] = user_data["hints"]
logger.debug(f"user: {user_data} +role:{added_roles} -role:{removed_roles}") logger.debug(f"user: {user_data} +role:{added_roles} -role:{removed_roles}")
for role in added_roles: for role in added_roles:
users_helper.get_or_create(user_id=user_id, role_id=role) users_helper.get_or_create(user_id=user_id, role_id=role)

View File

@ -49,6 +49,7 @@ class Users(Model):
valid_tokens_from = DateTimeField(default=datetime.datetime.now) valid_tokens_from = DateTimeField(default=datetime.datetime.now)
server_order = CharField(default="") server_order = CharField(default="")
preparing = BooleanField(default=False) preparing = BooleanField(default=False)
hints = BooleanField(default=True)
class Meta: class Meta:
table_name = "users" table_name = "users"

View File

@ -769,6 +769,7 @@ class PanelHandler(BaseHandler):
page_data["user"]["last_ip"] = "N/A" page_data["user"]["last_ip"] = "N/A"
page_data["user"]["last_update"] = "N/A" page_data["user"]["last_update"] = "N/A"
page_data["user"]["roles"] = set() page_data["user"]["roles"] = set()
page_data["user"]["hints"] = True
if Enum_Permissions_Crafty.User_Config not in exec_user_crafty_permissions: if Enum_Permissions_Crafty.User_Config not in exec_user_crafty_permissions:
self.redirect( self.redirect(
@ -1734,6 +1735,11 @@ class PanelHandler(BaseHandler):
password1 = bleach.clean(self.get_argument("password1", None)) password1 = bleach.clean(self.get_argument("password1", None))
email = bleach.clean(self.get_argument("email", "default@example.com")) email = bleach.clean(self.get_argument("email", "default@example.com"))
enabled = int(float(self.get_argument("enabled", "0"))) enabled = int(float(self.get_argument("enabled", "0")))
try:
hints = int(bleach.clean(self.get_argument("hints")))
hints = True
except:
hints = False
lang = bleach.clean( lang = bleach.clean(
self.get_argument("language"), helper.get_setting("language") self.get_argument("language"), helper.get_setting("language")
) )
@ -1765,6 +1771,7 @@ class PanelHandler(BaseHandler):
"password": password0, "password": password0,
"email": email, "email": email,
"lang": lang, "lang": lang,
"hints": hints,
} }
self.controller.users.update_user(user_id, user_data=user_data) self.controller.users.update_user(user_id, user_data=user_data)
@ -1806,6 +1813,7 @@ class PanelHandler(BaseHandler):
"roles": roles, "roles": roles,
"lang": lang, "lang": lang,
"superuser": superuser, "superuser": superuser,
"hints": hints,
} }
user_crafty_data = { user_crafty_data = {
"permissions_mask": permissions_mask, "permissions_mask": permissions_mask,
@ -1901,6 +1909,7 @@ class PanelHandler(BaseHandler):
password1 = bleach.clean(self.get_argument("password1", None)) password1 = bleach.clean(self.get_argument("password1", None))
email = bleach.clean(self.get_argument("email", "default@example.com")) email = bleach.clean(self.get_argument("email", "default@example.com"))
enabled = int(float(self.get_argument("enabled", "0"))) enabled = int(float(self.get_argument("enabled", "0")))
hints = True
lang = bleach.clean( lang = bleach.clean(
self.get_argument("lang", helper.get_setting("language")) self.get_argument("lang", helper.get_setting("language"))
) )
@ -1942,10 +1951,7 @@ class PanelHandler(BaseHandler):
enabled=enabled, enabled=enabled,
superuser=new_superuser, superuser=new_superuser,
) )
user_data = { user_data = {"roles": roles, "lang": lang, "hints": True}
"roles": roles,
"lang": lang,
}
user_crafty_data = { user_crafty_data = {
"permissions_mask": permissions_mask, "permissions_mask": permissions_mask,
"server_quantity": server_quantity, "server_quantity": server_quantity,

View File

@ -24,7 +24,11 @@
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-history"></i> &nbsp;Audit Logs</h4> <h4 class="card-title"><i class="fas fa-history"></i> &nbsp;Audit Logs</h4>
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}", data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}", data-placement="top"></span> {% if data['user_data']['hints'] %}
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" ,
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
data-placement="top"></span>
{% end %}
</div> </div>
<div class="card-body"> <div class="card-body">
@ -60,8 +64,9 @@
</div> </div>
</div> </div>
<style> <style>
.popover-body{ .popover-body {
color: white !important;; color: white !important;
;
} }
</style> </style>
@ -76,37 +81,37 @@
{% block js %} {% block js %}
<script> <script>
$( document ).ready(function() { $(document).ready(function () {
console.log('ready for JS!') console.log('ready for JS!')
$('#audit_table').DataTable({ $('#audit_table').DataTable({
'order': [1, 'desc'] 'order': [1, 'desc']
} }
); );
}); });
</script> </script>
<script> <script>
$(document).ready(function(){ $(document).ready(function () {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
} }
}); });
$(window).ready(function(){ $(window).ready(function () {
$('body').click(function(){ $('body').click(function () {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
}); });
}); });
$(window).resize(function() { $(window).resize(function () {
// This will execute whenever the window is resized // This will execute whenever the window is resized
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
} }
else{ else {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
} // New width } // New width
}); });
</script> </script>
{% end %} {% end %}

View File

@ -15,7 +15,8 @@
<div class="page-header"> <div class="page-header">
<h4 class="page-title">{{ translate('dashboard', 'dashboard', data['lang']) }} <h4 class="page-title">{{ translate('dashboard', 'dashboard', data['lang']) }}
{% if data['server_stats']['running'] != 0 %} {% if data['server_stats']['running'] != 0 %}
<span id="sync" style="margin-left: 5px;"><i class="fas fa-sync fa-spin"></i></span></h4> <span id="sync" style="margin-left: 5px;"><i class="fas fa-sync fa-spin"></i></span>
</h4>
{% end %} {% end %}
</div> </div>
</div> </div>
@ -74,7 +75,8 @@
<h3 class="mb-0 font-weight-semibold" id="total_players">{{ data['num_players'] }}</h3> <h3 class="mb-0 font-weight-semibold" id="total_players">{{ data['num_players'] }}</h3>
</div> </div>
<div class="wrapper my-auto ml-auto ml-lg-4"> <div class="wrapper my-auto ml-auto ml-lg-4">
<p class="mb-0 text-warning"><span id="max_players">0</span> {{ translate('dashboard', 'max', data['lang']) }}</p> <p class="mb-0 text-warning"><span id="max_players">0</span> {{ translate('dashboard', 'max',
data['lang']) }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -91,10 +93,12 @@
<h4 class="card-title"><i class="fas fa-server"></i> &nbsp;{{ translate('dashboard', 'allServers', <h4 class="card-title"><i class="fas fa-server"></i> &nbsp;{{ translate('dashboard', 'allServers',
data['lang']) }}</h4> data['lang']) }}</h4>
{% if len(data['servers']) > 0 %} {% if len(data['servers']) > 0 %}
{% if data['user_data']['hints'] %}
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" , <span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" ,
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" , data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
data-placement="top"></span> data-placement="top"></span>
{% end %} {% end %}
{% end %}
<div><a class="nav-link" href="/server/step1"><i class="fas fa-plus-circle"></i> &nbsp; {{ <div><a class="nav-link" href="/server/step1"><i class="fas fa-plus-circle"></i> &nbsp; {{
translate('dashboard', 'newServer', data['lang']) }}</a></div> translate('dashboard', 'newServer', data['lang']) }}</a></div>
</div> </div>
@ -136,18 +140,18 @@
<td draggable="false" id="controls{{server['server_data']['server_id']}}" class="actions_serverlist"> <td draggable="false" id="controls{{server['server_data']['server_id']}}" class="actions_serverlist">
{% if server['user_command_permission'] %} {% if server['user_command_permission'] %}
{% if server['stats']['running'] %} {% if server['stats']['running'] %}
<a data-id="{{server['server_data']['server_id']}}" class="stop_button" <a data-id="{{server['server_data']['server_id']}}" class="stop_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'stop' , data['lang']) }}"> title="{{ translate('dashboard', 'stop' , data['lang']) }}">
<i class="fas fa-stop"></i> <i class="fas fa-stop"></i>
</a> &nbsp; </a> &nbsp;
<a data-id="{{server['server_data']['server_id']}}" class="restart_button" <a data-id="{{server['server_data']['server_id']}}" class="restart_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'restart' , data['lang']) }}"> title="{{ translate('dashboard', 'restart' , data['lang']) }}">
<i class="fas fa-sync"></i> <i class="fas fa-sync"></i>
</a> &nbsp; </a> &nbsp;
<a data-id="{{server['server_data']['server_id']}}" class="kill_button" <a data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}"> title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i> <i class="fas fa-skull"></i>
</a> &nbsp; </a> &nbsp;
@ -161,19 +165,20 @@
translate('dashboard', 'delay-explained' , data['lang'])}}">{{ translate('dashboard', 'starting', translate('dashboard', 'delay-explained' , data['lang'])}}">{{ translate('dashboard', 'starting',
data['lang']) }}</i></a> data['lang']) }}</i></a>
{% elif server['stats']['downloading']%} {% elif server['stats']['downloading']%}
<a data-id="{{server['server_data']['server_id']}}" class=""><i class="fa fa-spinner fa-spin"></i> {{ translate('serverTerm', 'downloading', <a data-id="{{server['server_data']['server_id']}}" class=""><i class="fa fa-spinner fa-spin"></i>
{{ translate('serverTerm', 'downloading',
data['lang']) }}</a> data['lang']) }}</a>
{% else %} {% else %}
<a data-id="{{server['server_data']['server_id']}}" class="play_button" <a data-id="{{server['server_data']['server_id']}}" class="play_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'start' , data['lang']) }}"> title="{{ translate('dashboard', 'start' , data['lang']) }}">
<i class="fas fa-play"></i> <i class="fas fa-play"></i>
</a> &nbsp; </a> &nbsp;
<a data-id="{{server['server_data']['server_id']}}" class="clone_button" <a data-id="{{server['server_data']['server_id']}}" class="clone_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'clone' , data['lang']) }}"> title="{{ translate('dashboard', 'clone' , data['lang']) }}">
<i class="fas fa-clone"></i> <i class="fas fa-clone"></i>
</a> &nbsp; </a> &nbsp;
<a data-id="{{server['server_data']['server_id']}}" class="kill_button" <a data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip"
data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}"> title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i> <i class="fas fa-skull"></i>
</a> &nbsp; </a> &nbsp;
{% end %} {% end %}
@ -228,7 +233,9 @@
data['lang']) }} <br /> data['lang']) }} <br />
{% if server['stats']['desc'] != 'False' %} {% if server['stats']['desc'] != 'False' %}
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ server['stats']['desc'] }}</div> <br /> <div id="desc_id"
style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{
server['stats']['desc'] }}</div> <br />
{% end %} {% end %}
{% if server['stats']['version'] != 'False' %} {% if server['stats']['version'] != 'False' %}
@ -242,14 +249,16 @@
<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online', <span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online',
data['lang']) }}</span> data['lang']) }}</span>
{% elif server['stats']['crashed'] %} {% elif server['stats']['crashed'] %}
<span class="text-danger"><i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', <span class="text-danger"><i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard',
'crashed',
data['lang']) }}</span> data['lang']) }}</span>
{% else %} {% else %}
<span class="text-warning"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', <span class="text-warning"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline',
data['lang']) }}</span> data['lang']) }}</span>
{% end %} {% end %}
</td> </td>
<span class="server-player-totals" id="server_players_{{server['server_data']['server_id']}}" data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}"></span> <span class="server-player-totals" id="server_players_{{server['server_data']['server_id']}}"
data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}"></span>
</tr> </tr>
{% end %} {% end %}
@ -271,15 +280,19 @@
color: white !important; color: white !important;
; ;
} }
#desc_id {
-ms-overflow-style: none; /* for Internet Explorer, Edge */
scrollbar-width: none; /* for Firefox */
overflow-y: scroll;
}
#desc_id::-webkit-scrollbar { #desc_id {
display: none; /* for Chrome, Safari, and Opera */ -ms-overflow-style: none;
} /* for Internet Explorer, Edge */
scrollbar-width: none;
/* for Firefox */
overflow-y: scroll;
}
#desc_id::-webkit-scrollbar {
display: none;
/* for Chrome, Safari, and Opera */
}
</style> </style>
@ -296,20 +309,20 @@
}; };
} }
$(document).ready(function() { $(document).ready(function () {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
if ($(window).width() < 1000) { if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
} }
}); });
$(window).ready(function() { $(window).ready(function () {
$('body').click(function() { $('body').click(function () {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
}); });
}); });
$(window).resize(function() { $(window).resize(function () {
// This will execute whenever the window is resized // This will execute whenever the window is resized
if ($(window).width() < 1000) { if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
@ -379,7 +392,7 @@
cpu_status = "bg-warning"; cpu_status = "bg-warning";
} }
server_cpu.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="`+ server.cpu +`"><div class="progress-bar `+ cpu_status + `" role="progressbar" style="width: `+ server.cpu + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>`+ server.cpu +`%`; server_cpu.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server.cpu + `"><div class="progress-bar ` + cpu_status + `" role="progressbar" style="width: ` + server.cpu + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.cpu + `%`;
/* Update Memory */ /* Update Memory */
@ -396,7 +409,7 @@
total_mem = server.mem; total_mem = server.mem;
} }
server_mem.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="`+ server_mem +`"><div class="progress-bar `+ mem_status + `" role="progressbar" style="width: `+ server.mem_percent + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>`+ server.mem_percent +`% - ` + total_mem; server_mem.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server_mem + `"><div class="progress-bar ` + mem_status + `" role="progressbar" style="width: ` + server.mem_percent + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.mem_percent + `% - ` + total_mem;
/* Update World Infos */ /* Update World Infos */
server_world.innerHTML = server.world_size server_world.innerHTML = server.world_size
@ -412,7 +425,7 @@
let servers = document.getElementsByClassName("server-player-totals"); let servers = document.getElementsByClassName("server-player-totals");
let all_total_players = 0; let all_total_players = 0;
let all_total_max_players = 0; let all_total_max_players = 0;
for(let i = 0; i < servers.length; i++) { for (let i = 0; i < servers.length; i++) {
try { try {
all_total_players += parseInt(servers[i].getAttribute('data-players')); all_total_players += parseInt(servers[i].getAttribute('data-players'));
all_total_max_players += parseInt(servers[i].getAttribute('data-max')); all_total_max_players += parseInt(servers[i].getAttribute('data-max'));
@ -461,15 +474,15 @@
try { try {
update_one_server_status(data[0]); update_one_server_status(data[0]);
} catch (e) { } catch (e) {
console.log ('Failed to update server stats', e) console.log('Failed to update server stats', e)
} }
display_motd(); display_motd();
} }
$(document).ready(function() { $(document).ready(function () {
console.log('ready for JS!') console.log('ready for JS!')
$(".play_button").click(function() { $(".play_button").click(function () {
server_id = $(this).attr("data-id"); server_id = $(this).attr("data-id");
send_command(server_id, 'start_server'); send_command(server_id, 'start_server');
bootbox.alert({ bootbox.alert({
@ -479,7 +492,7 @@
}); });
}); });
$(".stop_button").click(function() { $(".stop_button").click(function () {
console.log("stopping server"); console.log("stopping server");
server_id = $(this).attr("data-id"); server_id = $(this).attr("data-id");
send_command(server_id, 'stop_server'); send_command(server_id, 'stop_server');
@ -490,7 +503,7 @@
}); });
}); });
$(".restart_button").click(function() { $(".restart_button").click(function () {
server_id = $(this).attr("data-id"); server_id = $(this).attr("data-id");
send_command(server_id, 'restart_server'); send_command(server_id, 'restart_server');
bootbox.alert({ bootbox.alert({
@ -499,7 +512,7 @@
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientRestart", data["lang"]) %} </div>' message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientRestart", data["lang"]) %} </div>'
}); });
}); });
$(".kill_button").click(function() { $(".kill_button").click(function () {
server_id = $(this).attr("data-id"); server_id = $(this).attr("data-id");
bootbox.confirm({ bootbox.confirm({
message: "This will kill the server process and all it's subprocesses. Killing a process can potentially corrupt files. Only do this in extreme circumstances. Are you sure you would like to continue?", message: "This will kill the server process and all it's subprocesses. Killing a process can potentially corrupt files. Only do this in extreme circumstances. Are you sure you would like to continue?",
@ -513,7 +526,7 @@
className: 'btn-secondary' className: 'btn-secondary'
} }
}, },
callback: function(result) { callback: function (result) {
if (result) { if (result) {
send_kill(server_id); send_kill(server_id);
let dialog = bootbox.dialog({ let dialog = bootbox.dialog({
@ -521,8 +534,8 @@
message: '<p><i class="fa fa-spin fa-spinner"></i> Loading...</p>' message: '<p><i class="fa fa-spin fa-spinner"></i> Loading...</p>'
}); });
dialog.init(function() { dialog.init(function () {
setTimeout(function() { setTimeout(function () {
location.reload(); location.reload();
}, 15000); }, 15000);
}); });
@ -537,7 +550,7 @@
mem_percent = document.getElementById('mem_percent'); mem_percent = document.getElementById('mem_percent');
webSocket.on('update_host_stats', function(hostStats) { webSocket.on('update_host_stats', function (hostStats) {
let cpuDataTitle = `{% raw translate('dashboard', 'cpuCores', data['lang']) %}: ${hostStats.cpu_cores} <br /> {% raw translate("dashboard", "cpuCurFreq", data['lang']) %}: ${hostStats.cpu_cur_freq} <br /> {% raw translate("dashboard", "cpuMaxFreq", data['lang']) %}: ${hostStats.cpu_max_freq}`; let cpuDataTitle = `{% raw translate('dashboard', 'cpuCores', data['lang']) %}: ${hostStats.cpu_cores} <br /> {% raw translate("dashboard", "cpuCurFreq", data['lang']) %}: ${hostStats.cpu_cur_freq} <br /> {% raw translate("dashboard", "cpuMaxFreq", data['lang']) %}: ${hostStats.cpu_max_freq}`;
cpu_data.setAttribute('data-original-title', cpuDataTitle); cpu_data.setAttribute('data-original-title', cpuDataTitle);
cpu_usage.textContent = hostStats.cpu_usage; cpu_usage.textContent = hostStats.cpu_usage;
@ -547,13 +560,13 @@
} }
if (webSocket) { if (webSocket) {
webSocket.on('send_start_reload', function() { webSocket.on('send_start_reload', function () {
location.reload() location.reload()
}); });
} }
if (webSocket) { if (webSocket) {
webSocket.on('update_button_status', function(updateButton) { webSocket.on('update_button_status', function (updateButton) {
let serverId = updateButton.server_id; let serverId = updateButton.server_id;
let message = updateButton.string; let message = updateButton.string;
let updating = updateButton.isUpdating; let updating = updateButton.isUpdating;
@ -572,7 +585,7 @@
webSocket.on('update_server_status', update_servers_status); webSocket.on('update_server_status', update_servers_status);
} }
$(".clone_button").click(function() { $(".clone_button").click(function () {
server_id = $(this).attr("data-id"); server_id = $(this).attr("data-id");
send_command(server_id, 'clone_server'); send_command(server_id, 'clone_server');
bootbox.alert({ bootbox.alert({
@ -589,21 +602,25 @@
<link rel="stylesheet" href="/static/assets/css/jquery-ui.structure.css"> <link rel="stylesheet" href="/static/assets/css/jquery-ui.structure.css">
<style> <style>
@media only screen and (max-width: 760px) { @media only screen and (max-width: 760px) {
#mobile { display: none; } #mobile {
display: none;
} }
}
.ui-sortable-handle { .ui-sortable-handle {
cursor: default; cursor: default;
padding:2px; padding: 2px;
} }
.ui-sortable-handle:hover { .ui-sortable-handle:hover {
cursor: grab !important; cursor: grab !important;
padding:2px; padding: 2px;
} }
</style> </style>
<script> <script>
/* Search Bar */ /* Search Bar */
$(document).ready(function() { $(document).ready(function () {
let servers_table = $('#servers_table').DataTable({ let servers_table = $('#servers_table').DataTable({
"ordering": false, // false to disable sorting (or any other option) "ordering": false, // false to disable sorting (or any other option)
"paging": false "paging": false
@ -613,9 +630,9 @@
}); });
/* Search Bar End */ /* Search Bar End */
$(document).on("mousedown keyup click", function(event) { $(document).on("mousedown keyup click", function (event) {
const value = $('.dataTables_filter input').val(); const value = $('.dataTables_filter input').val();
const is_mobile = $('#mobile').css('display')=='none'; const is_mobile = $('#mobile').css('display') === 'none';
if ($("table#servers_table tbody").sortable("toArray").length > 1 && value === '' && !is_mobile) { if ($("table#servers_table tbody").sortable("toArray").length > 1 && value === '' && !is_mobile) {
$("table#servers_table tbody").sortable("enable"); $("table#servers_table tbody").sortable("enable");
@ -624,18 +641,18 @@
} }
}); });
$(document).ready(function() { $(document).ready(function () {
function sendOrder(id_string) { function sendOrder(id_string) {
const token = getCookie("_xsrf") const token = getCookie("_xsrf")
$.ajax({ $.ajax({
type: "POST", type: "POST",
headers: {'X-XSRFToken': token}, headers: { 'X-XSRFToken': token },
url: '/ajax/send_order?order='+id_string, url: '/ajax/send_order?order=' + id_string,
data: { data: {
order: id_string, order: id_string,
}, },
success: function(data) { success: function (data) {
console.log("got response:"); console.log("got response:");
console.log(data); console.log(data);
}, },
@ -649,10 +666,10 @@ $(document).ready(function() {
cursor: "grabbing", cursor: "grabbing",
axis: "y", axis: "y",
revert: true, revert: true,
handle:"i.fas.fa-server,a", handle: "i.fas.fa-server,a",
forcePlaceholderSize: true, forcePlaceholderSize: true,
placeholder:'table-placeholder', placeholder: 'table-placeholder',
deactivate: function(event, ui) { deactivate: function (event, ui) {
// Gets the list of ids in the server list as an array, // Gets the list of ids in the server list as an array,
// and joins the elements with an [,] and sends to the server. // and joins the elements with an [,] and sends to the server.
const ids = $("table#servers_table tbody").sortable("toArray").join(); const ids = $("table#servers_table tbody").sortable("toArray").join();
@ -674,10 +691,10 @@ $(document).ready(function() {
// Fixes the appearance of a scrollbar when a user tries to drag an item too low // Fixes the appearance of a scrollbar when a user tries to drag an item too low
// Disabled on mobile since sorting is disabled on mobile // Disabled on mobile since sorting is disabled on mobile
if($('#mobile').css('display') != 'none'){ if ($('#mobile').css('display') !== 'none') {
$("div#servers_table_wrapper").css({ overflow: "hidden" }); $("div#servers_table_wrapper").css({ overflow: "hidden" });
} }
}); });
</script> </script>

View File

@ -30,11 +30,16 @@
<div class="col-md-12 col-lg-12 grid-margin stretch-card"> <div class="col-md-12 col-lg-12 grid-margin stretch-card">
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-users"></i> {{ translate('panelConfig', 'users', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-users"></i> {{ translate('panelConfig', 'users', data['lang'])
<span class="too_small" title="{{ translate('dashboard', 'cannotSee', data['lang']) }}", data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}", data-placement="top"></span> }}</h4>
{% if data['user_data']['hints'] %}
<span class="too_small" title="{{ translate('dashboard', 'cannotSee', data['lang']) }}" ,
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
data-placement="top"></span>
{% end %}
<!-- TODO: Translate the following --> <!-- TODO: Translate the following -->
<div><a class="nav-link" href="/panel/add_user"><i class="fas fa-plus-circle"></i> &nbsp; {{ translate('panelConfig', 'newUser', data['lang']) }}</a></div> <div><a class="nav-link" href="/panel/add_user"><i class="fas fa-plus-circle"></i> &nbsp; {{
translate('panelConfig', 'newUser', data['lang']) }}</a></div>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
@ -93,9 +98,15 @@
<div class="col-md-12 col-lg-12 grid-margin stretch-card"> <div class="col-md-12 col-lg-12 grid-margin stretch-card">
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('panelConfig', 'roles', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('panelConfig', 'roles',
<span class="too_small2" title="{{ translate('dashboard', 'cannotSee', data['lang']) }}", data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}", data-placement="top"></span> data['lang']) }}</h4>
<div><a class="nav-link" href="/panel/add_role"><i class="fas fa-plus-circle"></i> &nbsp; {{ translate('panelConfig', 'newRole', data['lang']) }}</a></div> {% if data['user_data']['hints'] %}
<span class="too_small2" title="{{ translate('dashboard', 'cannotSee', data['lang']) }}" ,
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
data-placement="top"></span>
{% end %}
<div><a class="nav-link" href="/panel/add_role"><i class="fas fa-plus-circle"></i> &nbsp; {{
translate('panelConfig', 'newRole', data['lang']) }}</a></div>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
@ -120,7 +131,8 @@
{% end %} {% end %}
</ul> </ul>
</td> </td>
<td><ul> <td>
<ul>
{% for user in data['users'] %} {% for user in data['users'] %}
{% for ruser in data['user-roles'][user.user_id] %} {% for ruser in data['user-roles'][user.user_id] %}
{% if ruser == role.role_name %} {% if ruser == role.role_name %}
@ -146,10 +158,12 @@
<div class="col-md-12 col-lg-12 grid-margin stretch-card"> <div class="col-md-12 col-lg-12 grid-margin stretch-card">
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('panelConfig', 'adminControls', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('panelConfig', 'adminControls',
data['lang']) }}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<button type="button" class="btn btn-outline-danger clear-comm">{{ translate('panelConfig', 'clearComms', data['lang']) }}</button> <button type="button" class="btn btn-outline-danger clear-comm">{{ translate('panelConfig',
'clearComms', data['lang']) }}</button>
</div> </div>
</div> </div>
@ -165,9 +179,10 @@
</div> </div>
<style> <style>
.popover-body{ .popover-body {
color: white !important;; color: white !important;
} ;
}
</style> </style>
<!-- content-wrapper ends --> <!-- content-wrapper ends -->
@ -175,44 +190,44 @@
{% block js %} {% block js %}
<script> <script>
$(document).ready(function(){ $(document).ready(function () {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
$('.too_small2').popover("show"); $('.too_small2').popover("show");
} }
}); });
$(window).ready(function(){ $(window).ready(function () {
$('body').click(function(){ $('body').click(function () {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
$('.too_small2').popover("hide"); $('.too_small2').popover("hide");
}); });
}); });
$(window).resize(function() { $(window).resize(function () {
// This will execute whenever the window is resized // This will execute whenever the window is resized
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
} }
else{ else {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
} // New width } // New width
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small2').popover("show"); $('.too_small2').popover("show");
} }
else{ else {
$('.too_small2').popover("hide"); $('.too_small2').popover("hide");
} // New width } // New width
}); });
</script> </script>
<script> <script>
$( document ).ready(function() { $(document).ready(function () {
console.log('ready for JS!') console.log('ready for JS!')
}); });
$( ".show_button" ).click(function() { $(".show_button").click(function () {
console.log("showing key"); console.log("showing key");
api_key = $(this).attr("data-id"); api_key = $(this).attr("data-id");
bootbox.alert({ bootbox.alert({
@ -226,12 +241,12 @@ $( document ).ready(function() {
var token = getCookie("_xsrf") var token = getCookie("_xsrf")
$.ajax({ $.ajax({
type: "POST", type: "POST",
headers: {'X-XSRFToken': token}, headers: { 'X-XSRFToken': token },
url: '/ajax/clear_comm', url: '/ajax/clear_comm',
success: function (data) { success: function (data) {
}, },
}); });
}) })
</script> </script>
{% end %} {% end %}

View File

@ -21,7 +21,7 @@
</h4> </h4>
{% else %} {% else %}
<h4 class="page-title"> <h4 class="page-title">
{{ translate('userConfig', 'pageTitle', data['lang']) }} - {{ data['user']['user_id'] }} {{ translate('userConfig', 'pageTitle', data['lang']) }}
<br /> <br />
<small>UID: {{ data['user']['user_id'] }}</small> <small>UID: {{ data['user']['user_id'] }}</small>
</h4> </h4>
@ -39,13 +39,16 @@
<div class="card-body pt-0"> <div class="card-body pt-0">
<ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist"> <ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="/panel/{{ 'add_user' if data['new_user'] else 'edit_user' }}?id={{ data['user']['user_id'] }}&subpage=config" role="tab" aria-selected="true"> <a class="nav-link active"
<i class="fas fa-cogs"></i> {{ translate('userConfig', 'config', data['lang']) }} - {{ data['user']['user_id'] }}</a> href="/panel/{{ 'add_user' if data['new_user'] else 'edit_user' }}?id={{ data['user']['user_id'] }}&subpage=config"
role="tab" aria-selected="true">
<i class="fas fa-cogs"></i> {{ translate('userConfig', 'config', data['lang']) }}</a>
</li> </li>
{% if not data['new_user'] %} {% if not data['new_user'] %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" role="tab" aria-selected="false"> <a class="nav-link" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" role="tab"
<i class="fas fa-key"></i>{{ translate('userConfig', 'apiKey', data['lang']) }} - {{ data['user']['user_id'] }}</a> aria-selected="false">
<i class="fas fa-key"></i>{{ translate('userConfig', 'apiKey', data['lang']) }}</a>
</li> </li>
{% end %} {% end %}
</ul> </ul>
@ -64,28 +67,43 @@
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user"></i> {{ translate('userConfig', 'userSettings', data['lang']) }} - {{ data['user']['user_id'] }}</h4> <h4 class="card-title"><i class="fas fa-user"></i> {{ translate('userConfig', 'userSettings',
data['lang']) }}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="username">{{ translate('userConfig', 'userName', data['lang']) }} - {{ data['user']['user_id'] }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang']) }} - {{ data['user']['user_id'] }}</small> </label> <label class="form-label" for="username">{{ translate('userConfig', 'userName', data['lang'])
<input type="text" class="form-control" name="username" id="username" value="{{ data['user']['username'] }}" placeholder="User Name" > }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang'])
}}</small> </label>
<input type="text" class="form-control" name="username" id="username"
value="{{ data['user']['username'] }}" placeholder="User Name">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang']) }} - {{ data['user']['user_id'] }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }} - {{ data['user']['user_id'] }}</small> </label> <label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang'])
<input type="password" class="form-control" name="password0" id="password0" value="" placeholder="Password" > }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }}
</small> </label>
<input type="password" class="form-control" name="password0" id="password0" value=""
placeholder="Password">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }} - {{ data['user']['user_id'] }} <small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }} - {{ data['user']['user_id'] }}</small> </label> <label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }}
<input type="password" class="form-control" name="password1" id="password1" value="" placeholder="Repeat Password" > <small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang'])
}}</small> </label>
<input type="password" class="form-control" name="password1" id="password1" value=""
placeholder="Repeat Password">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang']) }} - {{ data['user']['user_id'] }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang']) }} - {{ data['user']['user_id'] }}</small> </label> <label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang'])
<input type="email" class="form-control" name="email" id="email" value="{{ data['user']['email'] }}" placeholder="Gravatar Email" > }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang'])
}}</small> </label>
<input type="email" class="form-control" name="email" id="email"
value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang']) }}</label> <label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang'])
<select class="form-select form-control form-control-lg select-css" id="language" name="language" form="user_form"> }}</label>
<select class="form-select form-control form-control-lg select-css" id="language"
name="language" form="user_form">
{% for lang in data['languages'] %} {% for lang in data['languages'] %}
{% if not 'incomplete' in lang %} {% if not 'incomplete' in lang %}
<option value="{{lang}}">{{lang}}</option> <option value="{{lang}}">{{lang}}</option>
@ -100,7 +118,9 @@
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('userConfig', 'userRoles', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('userConfig', 'userRolesDesc', data['lang']) }}</small></h4> <h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('userConfig', 'userRoles',
data['lang']) }} <small class="text-muted ml-1"> - {{ translate('userConfig', 'userRolesDesc',
data['lang']) }}</small></h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
@ -118,9 +138,13 @@
<td>{{ role.role_name }}</td> <td>{{ role.role_name }}</td>
<td> <td>
{% if role.role_id in data['user']['roles'] %} {% if role.role_id in data['user']['roles'] %}
<input type="checkbox" class="form-check-input" id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership" checked="" value="1"> <input type="checkbox" class="form-check-input"
id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership"
checked="" value="1">
{% else %} {% else %}
<input type="checkbox" class="form-check-input" id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership" value="1"> <input type="checkbox" class="form-check-input"
id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership"
value="1">
{% end %} {% end %}
</td> </td>
@ -137,7 +161,9 @@
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user-lock"></i> {{ translate('userConfig', 'craftyPerms', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('userConfig', 'craftyPermDesc', data['lang']) }}</small></h4> <h4 class="card-title"><i class="fas fa-user-lock"></i> {{ translate('userConfig', 'craftyPerms',
data['lang']) }} <small class="text-muted ml-1"> - {{ translate('userConfig', 'craftyPermDesc',
data['lang']) }}</small></h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
@ -156,12 +182,16 @@
<td>{{ permission.name }}</td> <td>{{ permission.name }}</td>
<td> <td>
{% if permission in data['permissions_list'] %} {% if permission in data['permissions_list'] %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" checked="" value="1"> <input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" checked="" value="1">
{% else %} {% else %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" value="1"> <input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1">
{% end %} {% end %}
</td> </td>
<td><input type="text" class="form-control" name="quantity_{{ permission.name }}" id="quantity_{{ permission.name }}" value="{{ data['quantity_server'][permission.name] }}"></td> <td><input type="text" class="form-control" name="quantity_{{ permission.name }}"
id="quantity_{{ permission.name }}"
value="{{ data['quantity_server'][permission.name] }}"></td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
@ -174,31 +204,50 @@
<div class="form-check-flat"> <div class="form-check-flat">
<label for="enabled" class="form-check-label ml-4 mb-4"> <label for="enabled" class="form-check-label ml-4 mb-4">
{% if data['user']['enabled'] %} {% if data['user']['enabled'] %}
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" checked="" value="1">{{ translate('userConfig', 'enabled', data['lang']) }} <input type="checkbox" class="form-check-input" id="enabled" name="enabled" checked=""
value="1">{{ translate('userConfig', 'enabled', data['lang']) }}
{% else %} {% else %}
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" value="1">{{ translate('userConfig', 'enabled', data['lang']) }} <input type="checkbox" class="form-check-input" id="enabled" name="enabled" value="1">{{
translate('userConfig', 'enabled', data['lang']) }}
{% end %} {% end %}
</label> </label>
<label for="superuser" class="form-check-label ml-4 mb-4"> <label for="superuser" class="form-check-label ml-4 mb-4">
{% if data['user']['superuser'] %} {% if data['user']['superuser'] %}
<input type="checkbox" onclick="superConfirm()" class="form-check-input" id="superuser" name="superuser" checked="" value="1" {{ data['super-disabled'] }} >{{ translate('userConfig', 'super', data['lang']) }} <input type="checkbox" onclick="superConfirm()" class="form-check-input" id="superuser"
name="superuser" checked="" value="1" {{ data['super-disabled'] }}>{{ translate('userConfig',
'super', data['lang']) }}
{% else %} {% else %}
<input type="checkbox" onclick="superConfirm()" class="form-check-input" id="superuser" name="superuser" {{ data['super-disabled'] }} value="1" >{{ translate('userConfig', 'super', data['lang']) }} <input type="checkbox" onclick="superConfirm()" class="form-check-input" id="superuser"
name="superuser" {{ data['super-disabled'] }} value="1">{{ translate('userConfig', 'super',
data['lang']) }}
{% end %}
</label>
<label for="hints" class="form-check-label ml-4 mb-4">
{% if data['user']['hints'] %}
<input type="checkbox" class="form-check-input" id="hints" name="hints" checked=""
value="1">Enable Hints?
{% else %}
<input type="checkbox" class="form-check-input" id="hints" name="hints" value="1"> Enable
Hints?
{% end %} {% end %}
</label> </label>
</div> </div>
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{ translate('panelConfig', 'save', data['lang']) }}</button> <button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{
<button type="reset" onclick="location.href='/panel/panel_config'" class="btn btn-light"><i class="fas fa-undo-alt"></i> {{ translate('panelConfig', 'cancel', data['lang']) }}</button> translate('panelConfig', 'save', data['lang']) }}</button>
<button type="reset" onclick="location.href='/panel/panel_config'" class="btn btn-light"><i
class="fas fa-undo-alt"></i> {{ translate('panelConfig', 'cancel', data['lang']) }}</button>
</form> </form>
</div> </div>
<div class="col-md-6 col-sm-12"> <div class="col-md-6 col-sm-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="card-title"><i class="fas fa-user-cog"></i> {{ translate('userConfig', 'configArea', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-user-cog"></i> {{ translate('userConfig', 'configArea',
data['lang']) }}</h4>
<p class="card-description"> {{ translate('userConfig', 'configAreaDesc', data['lang']) }}</p> <p class="card-description"> {{ translate('userConfig', 'configAreaDesc', data['lang']) }}</p>
<blockquote class="blockquote"> <blockquote class="blockquote">
<p class="mb-0"> <p class="mb-0">
@ -216,13 +265,16 @@
</div> </div>
<div class="text-center"> <div class="text-center">
{% if data['new_user'] %} {% if data['new_user'] %}
<a class="btn btn-sm btn-danger disabled"><i class="fas fa-trash"></i>{{ translate('userConfig', 'deleteUserB', data['lang']) }}</a><br /> <a class="btn btn-sm btn-danger disabled"><i class="fas fa-trash"></i>{{ translate('userConfig',
'deleteUserB', data['lang']) }}</a><br />
<small>{{ translate('userConfig', 'notExist', data['lang']) }}</small> <small>{{ translate('userConfig', 'notExist', data['lang']) }}</small>
{% elif data['user']['superuser'] %} {% elif data['user']['superuser'] %}
<a class="btn btn-sm btn-danger disabled"><i class="fas fa-trash"></i> {{ translate('userConfig', 'deleteUserB', data['lang']) }}</a><br /> <a class="btn btn-sm btn-danger disabled"><i class="fas fa-trash"></i> {{ translate('userConfig',
'deleteUserB', data['lang']) }}</a><br />
<small>{{ translate('userConfig', 'delSuper', data['lang']) }}</small> <small>{{ translate('userConfig', 'delSuper', data['lang']) }}</small>
{% else %} {% else %}
<button class="btn btn-sm btn-danger delete-user"><i class="fas fa-trash"></i> {{ translate('userConfig', 'deleteUserB', data['lang']) }}</a> <button class="btn btn-sm btn-danger delete-user"><i class="fas fa-trash"></i> {{
translate('userConfig', 'deleteUserB', data['lang']) }}</a>
{% end %} {% end %}
</div> </div>
@ -245,13 +297,13 @@
<script> <script>
const userId = new URLSearchParams(document.location.search).get('id') const userId = new URLSearchParams(document.location.search).get('id')
$( ".delete-user" ).click(function() { $(".delete-user").click(function () {
var file_to_del = $(this).data("file"); var file_to_del = $(this).data("file");
console.log("User to delete is "+userId); console.log("User to delete is " + userId);
bootbox.confirm({ bootbox.confirm({
title: "{% raw translate('userConfig', 'deleteUser', data['lang']) %} "+userId, title: "{% raw translate('userConfig', 'deleteUser', data['lang']) %} " + userId,
message: "{{ translate('userConfig', 'confirmDelete', data['lang']) }}", message: "{{ translate('userConfig', 'confirmDelete', data['lang']) }}",
buttons: { buttons: {
cancel: { cancel: {
@ -264,15 +316,15 @@
}, },
callback: function (result) { callback: function (result) {
console.log(result); console.log(result);
if (result == true) { if (result === true) {
location.href="/panel/remove_user?id="+userId; location.href = "/panel/remove_user?id=" + userId;
} }
} }
}); });
}); });
function superConfirm() { function superConfirm() {
if (document.getElementById('superuser').checked){ if (document.getElementById('superuser').checked) {
bootbox.confirm({ bootbox.confirm({
title: "{{ translate('panelConfig', 'superConfirmTitle', data['lang']) }}", title: "{{ translate('panelConfig', 'superConfirmTitle', data['lang']) }}",
message: "{{ translate('panelConfig', 'superConfirm', data['lang']) }}", message: "{{ translate('panelConfig', 'superConfirm', data['lang']) }}",
@ -286,16 +338,16 @@
} }
}, },
callback: function (result) { callback: function (result) {
if (result == true){ if (result === true) {
return; return;
}else{ } else {
document.getElementById('superuser').checked = false; document.getElementById('superuser').checked = false;
} }
} }
}); });
}else{ } else {
return return
} }
} }
@ -305,8 +357,8 @@
return r ? r[1] : undefined; return r ? r[1] : undefined;
} }
$( document ).ready(function() { $(document).ready(function () {
console.log( "ready!" ); console.log("ready!");
}); });

View File

@ -14,7 +14,8 @@
<div class="col-12"> <div class="col-12">
<div class="page-header"> <div class="page-header">
<h4 class="page-title"> <h4 class="page-title">
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{ data['server_stats']['server_id']['server_name'] }} {{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
data['server_stats']['server_id']['server_name'] }}
<br /> <br />
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small> <small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
</h4> </h4>
@ -38,11 +39,18 @@
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-calendar"></i> Scheduled Tasks</h4> <h4 class="card-title"><i class="fas fa-calendar"></i> Scheduled Tasks</h4>
<span class="too_small" title="{{ translate('serverSchedules', 'cannotSee', data['lang']) }}", data-content="{{ translate('serverSchedules', 'cannotSeeOnMobile', data['lang']) }}", data-placement="bottom"></span> {% if data['user_data']['hints'] %}
<div><button onclick="location.href=`/panel/add_schedule?id={{ data['server_stats']['server_id']['server_id'] }}`" class="btn btn-info">Create New Schedule <i class="fas fa-pencil-alt"></i></button></div> <span class="too_small" title="{{ translate('serverSchedules', 'cannotSee', data['lang']) }}" ,
data-content="{{ translate('serverSchedules', 'cannotSeeOnMobile', data['lang']) }}" ,
data-placement="bottom"></span>
{% end %}
<div><button
onclick="location.href=`/panel/add_schedule?id={{ data['server_stats']['server_id']['server_id'] }}`"
class="btn btn-info">Create New Schedule <i class="fas fa-pencil-alt"></i></button></div>
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table" width="100%" style="table-layout:fixed;"> <table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table" width="100%"
style="table-layout:fixed;">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
<th style="width: 2%; min-width: 10px;">ID</th> <th style="width: 2%; min-width: 10px;">ID</th>
@ -92,7 +100,9 @@
{% end %} {% end %}
</td> </td>
<td id="{{schedule.action}}" class="action"> <td id="{{schedule.action}}" class="action">
<button onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'" class="btn btn-info"> <button
onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'"
class="btn btn-info">
<i class="fas fa-pencil-alt"></i> <i class="fas fa-pencil-alt"></i>
</button> </button>
<br> <br>
@ -106,7 +116,8 @@
</tbody> </tbody>
</table> </table>
<hr /> <hr />
<table class="table table-hover d-block d-lg-none" id="mini_schedule_table" width="100%" style="table-layout:fixed;"> <table class="table table-hover d-block d-lg-none" id="mini_schedule_table" width="100%"
style="table-layout:fixed;">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
<th style="width: 25%; min-width: 50px;">Action</th> <th style="width: 25%; min-width: 50px;">Action</th>
@ -136,7 +147,8 @@
</td> </td>
</tr> </tr>
<!-- Modal --> <!-- Modal -->
<div class="modal fade" id="task_details_{{schedule.schedule_id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="task_details_{{schedule.schedule_id}}" tabindex="-1" role="dialog"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -148,27 +160,35 @@
<div class="modal-body"> <div class="modal-body">
<ul style="list-style: none;"> <ul style="list-style: none;">
<li id="{{schedule.schedule_id}}" class="id" style="border-top: .1em solid gray;"> <li id="{{schedule.schedule_id}}" class="id" style="border-top: .1em solid gray;">
<h4>ID</h4><p>{{schedule.schedule_id}}</p> <h4>ID</h4>
<p>{{schedule.schedule_id}}</p>
</li> </li>
<li id="{{schedule.action}}" class="action" style="border-top: .1em solid gray;"> <li id="{{schedule.action}}" class="action" style="border-top: .1em solid gray;">
<h4>Action</h4><p>{{schedule.action}}</p> <h4>Action</h4>
<p>{{schedule.action}}</p>
</li> </li>
<li id="{{schedule.command}}" class="action" style="border-top: .1em solid gray;"> <li id="{{schedule.command}}" class="action" style="border-top: .1em solid gray;">
<h4>Command</h4><p>{{schedule.command}}</p> <h4>Command</h4>
<p>{{schedule.command}}</p>
</li> </li>
<li id="{{schedule.interval}}" class="action" style="border-top: .1em solid gray;"> <li id="{{schedule.interval}}" class="action" style="border-top: .1em solid gray;">
{% if schedule.interval != '' %} {% if schedule.interval != '' %}
<h4>Interval</h4> <p>Every {{schedule.interval}} {{schedule.interval_type}}</p> <h4>Interval</h4>
<p>Every {{schedule.interval}} {{schedule.interval_type}}</p>
{% elif schedule.interval_type == 'reaction' %} {% elif schedule.interval_type == 'reaction' %}
<h4>Interval</h4> <p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p> <h4>Interval</h4>
<p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p>
{% else %} {% else %}
<h4>Interval</h4> <p>Cron String: {{schedule.cron_string}}</p> <h4>Interval</h4>
<p>Cron String: {{schedule.cron_string}}</p>
{% end %} {% end %}
</li> </li>
<li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;"> <li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;">
<h4>Start Time</h4> <p>{{schedule.start_time}}</p> <h4>Start Time</h4>
<p>{{schedule.start_time}}</p>
</li> </li>
<li id="{{schedule.enabled}}" class="action" style="border-top: .1em solid gray; border-bottom: .1em solid gray"> <li id="{{schedule.enabled}}" class="action"
style="border-top: .1em solid gray; border-bottom: .1em solid gray">
{% if schedule.enabled %} {% if schedule.enabled %}
<h4>Enabled</h4> <span class="text-success"> <h4>Enabled</h4> <span class="text-success">
<i class="fas fa-check-square"></i> Yes <i class="fas fa-check-square"></i> Yes
@ -182,7 +202,9 @@
</ul> </ul>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'" class="btn btn-info"> <button
onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'"
class="btn btn-info">
<i class="fas fa-pencil-alt"></i> Edit <i class="fas fa-pencil-alt"></i> Edit
</button> </button>
<button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button"> <button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
@ -206,8 +228,9 @@
</div> </div>
</div> </div>
<style> <style>
.popover-body{ .popover-body {
color: white !important;; color: white !important;
;
} }
</style> </style>
@ -215,17 +238,18 @@
</div> </div>
<style> <style>
/* Hide scrollbar for Chrome, Safari and Opera */ /* Hide scrollbar for Chrome, Safari and Opera */
td::-webkit-scrollbar { td::-webkit-scrollbar {
display: none; display: none;
} }
/* Hide scrollbar for IE, Edge and Firefox */ /* Hide scrollbar for IE, Edge and Firefox */
td { td {
-ms-overflow-style: none; /* IE and Edge */ -ms-overflow-style: none;
scrollbar-width: none; /* Firefox */ /* IE and Edge */
} scrollbar-width: none;
/* Firefox */
}
</style> </style>
<!-- content-wrapper ends --> <!-- content-wrapper ends -->
@ -236,50 +260,50 @@ td {
const serverId = new URLSearchParams(document.location.search).get('id') const serverId = new URLSearchParams(document.location.search).get('id')
$( document ).ready(function() { $(document).ready(function () {
console.log('ready for JS!') console.log('ready for JS!')
$('#schedule_table').DataTable({ $('#schedule_table').DataTable({
'order': [4, 'desc'] 'order': [4, 'desc']
} }
); );
}); });
$( document ).ready(function() { $(document).ready(function () {
console.log('ready for JS!') console.log('ready for JS!')
$('#mini_schedule_table').DataTable({ $('#mini_schedule_table').DataTable({
'order': [2, 'desc'] 'order': [2, 'desc']
} }
); );
document.getElementById('mini_schedule_table_wrapper').hidden = true; document.getElementById('mini_schedule_table_wrapper').hidden = true;
}); });
$(document).ready(function(){ $(document).ready(function () {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
document.getElementById('schedule_table_wrapper').hidden = true; document.getElementById('schedule_table_wrapper').hidden = true;
document.getElementById('mini_schedule_table_wrapper').hidden = false; document.getElementById('mini_schedule_table_wrapper').hidden = false;
} }
}); });
$(window).ready(function(){ $(window).ready(function () {
$('body').click(function(){ $('body').click(function () {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
}); });
}); });
$(window).resize(function() { $(window).resize(function () {
// This will execute whenever the window is resized // This will execute whenever the window is resized
if($(window).width() < 1000){ if ($(window).width() < 1000) {
$('.too_small').popover("show"); $('.too_small').popover("show");
document.getElementById('schedule_table_wrapper').hidden = true; document.getElementById('schedule_table_wrapper').hidden = true;
document.getElementById('mini_schedule_table_wrapper').hidden = false; document.getElementById('mini_schedule_table_wrapper').hidden = false;
} }
else{ else {
$('.too_small').popover("hide"); $('.too_small').popover("hide");
document.getElementById('schedule_table_wrapper').hidden = false; document.getElementById('schedule_table_wrapper').hidden = false;
document.getElementById('mini_schedule_table_wrapper').hidden = true; document.getElementById('mini_schedule_table_wrapper').hidden = true;
} // New width } // New width
}); });
</script> </script>
<script> <script>
@ -289,8 +313,8 @@ $( document ).ready(function() {
return r ? r[1] : undefined; return r ? r[1] : undefined;
} }
$( document ).ready(function() { $(document).ready(function () {
console.log( "ready!" ); console.log("ready!");
}); });
@ -315,8 +339,8 @@ $( document ).ready(function() {
document.getElementById("interval").required = true; document.getElementById("interval").required = true;
document.getElementById("time").required = true; document.getElementById("time").required = true;
} }
} }
function ifDays(that) { function ifDays(that) {
if (that.value == "days") { if (that.value == "days") {
document.getElementById("ifDays").style.display = "block"; document.getElementById("ifDays").style.display = "block";
document.getElementById("time").required = true; document.getElementById("time").required = true;
@ -324,9 +348,9 @@ function ifDays(that) {
document.getElementById("ifDays").style.display = "none"; document.getElementById("ifDays").style.display = "none";
document.getElementById("time").required = false; document.getElementById("time").required = false;
} }
} }
$( ".del_button" ).click(function() { $(".del_button").click(function () {
var sch_id = $(this).data('sch'); var sch_id = $(this).data('sch');
console.log(sch_id) console.log(sch_id)
@ -350,24 +374,24 @@ $( ".del_button" ).click(function() {
} }
} }
}); });
}); });
function del_task(sch_id, id){ function del_task(sch_id, id) {
var token = getCookie("_xsrf") var token = getCookie("_xsrf")
$.ajax({ $.ajax({
type: "DELETE", type: "DELETE",
headers: {'X-XSRFToken': token}, headers: { 'X-XSRFToken': token },
url: '/ajax/del_task?server_id='+id+'&schedule_id='+sch_id, url: '/ajax/del_task?server_id=' + id + '&schedule_id=' + sch_id,
data: { data: {
schedule_id: sch_id, schedule_id: sch_id,
id: id id: id
}, },
success: function(data) { success: function (data) {
location.reload(); location.reload();
}, },
}); });
} }
</script> </script>

View File

@ -0,0 +1,16 @@
# Generated by database migrator
import peewee
def migrate(migrator, database, **kwargs):
migrator.add_columns("users", hints=peewee.BooleanField(default=True))
"""
Write your migrations here.
"""
def rollback(migrator, database, **kwargs):
migrator.drop_columns("users", ["hints"])
"""
Write your rollback migrations here.
"""

View File

@ -517,7 +517,7 @@
"notExist": "You cannot delete something that doesn't exist!", "notExist": "You cannot delete something that doesn't exist!",
"pageTitle": "Edit User", "pageTitle": "Edit User",
"pageTitleNew": "Create User", "pageTitleNew": "Create User",
"password": "Password", "password": "New Password",
"permName": "Permission Name", "permName": "Permission Name",
"repeat": "Repeat Password", "repeat": "Repeat Password",
"roleName": "Role Name", "roleName": "Role Name",