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

@ -9,7 +9,7 @@
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Page Title Header Starts--> <!-- Page Title Header Starts-->
<div class="row page-title-header"> <div class="row page-title-header">
<div class="col-12"> <div class="col-12">
<div class="page-header"> <div class="page-header">
@ -24,35 +24,39 @@
<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">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover" id="audit_table" style="overflow: scroll;" width="100%"> <table class="table table-hover" id="audit_table" style="overflow: scroll;" width="100%">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
<td>Username</td> <td>Username</td>
<td>Time</td> <td>Time</td>
<td>Action</td> <td>Action</td>
<td>Server ID</td> <td>Server ID</td>
<td>IP</td> <td>IP</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in data['audit_logs'] %} {% for row in data['audit_logs'] %}
<tr> <tr>
<td>{{ row['user_name'] }}</td> <td>{{ row['user_name'] }}</td>
<td> <td>
{{ row['created'].strftime('%Y-%m-%d %H:%M:%S') }} {{ row['created'].strftime('%Y-%m-%d %H:%M:%S') }}
</td> </td>
<td>{{ row['log_msg'] }}</td> <td>{{ row['log_msg'] }}</td>
<td>{{ row['server_id'] }}</td> <td>{{ row['server_id'] }}</td>
<td>{{ row['source_ip'] }}</td> <td>{{ row['source_ip'] }}</td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
@ -60,9 +64,10 @@
</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,8 +15,9 @@
<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>
{% end %} </h4>
{% 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;
@ -160,20 +164,21 @@
<a data-id="{{server['server_data']['server_id']}}" class="" title="{{ <a data-id="{{server['server_data']['server_id']}}" class="" title="{{
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>
data['lang']) }}</a> {{ translate('serverTerm', 'downloading',
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' %}
@ -239,17 +246,19 @@
</td> </td>
<td draggable="false" id="server_running_status_{{server['server_data']['server_id']}}"> <td draggable="false" id="server_running_status_{{server['server_data']['server_id']}}">
{% if server['stats']['running'] %} {% if server['stats']['running'] %}
<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',
data['lang']) }}</span> 'crashed',
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'));
@ -459,17 +472,17 @@
function update_servers_status(data) { function update_servers_status(data) {
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,60 +641,60 @@
} }
}); });
$(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);
}, },
}); });
} }
// Inits the sortable // Inits the sortable
$("table#servers_table tbody") $("table#servers_table tbody")
.sortable({ .sortable({
items: '> tr', items: '> tr',
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();
try { try {
sendOrder(ids); sendOrder(ids);
} catch { } catch {
console.log("Search is actively supressing order change") console.log("Search is actively supressing order change")
} }
}, },
}); });
// Give the table an actual width so the draggable does't collapse when dragged // Give the table an actual width so the draggable does't collapse when dragged
$("table#servers_table") $("table#servers_table")
.children() .children()
.find("td") .find("td")
.each(function () { .each(function () {
$(this).css("width", "").css("width", $(this).outerWidth()); $(this).css("width", "").css("width", $(this).outerWidth());
}); });
// 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

@ -9,11 +9,11 @@
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Page Title Header Starts--> <!-- Page Title Header Starts-->
<div class="row page-title-header"> <div class="row page-title-header">
<div class="col-12"> <div class="col-12">
<div class="page-header"> <div class="page-header">
<!-- TODO: Translate the following --> <!-- TODO: Translate the following -->
<h4 class="page-title">{{ translate('panelConfig', 'pageTitle', data['lang']) }}</h4> <h4 class="page-title">{{ translate('panelConfig', 'pageTitle', data['lang']) }}</h4>
</div> </div>
</div> </div>
@ -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">
@ -50,38 +55,38 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for user in data['users'] %} {% for user in data['users'] %}
<tr> <tr>
<td><i class="fas fa-user"></i> {{ user.username }}</td> <td><i class="fas fa-user"></i> {{ user.username }}</td>
<td> <td>
{% if user.enabled %} {% if user.enabled %}
<span class="text-success"> <span class="text-success">
<i class="fas fa-check-square"></i> Yes <i class="fas fa-check-square"></i> Yes
</span> </span>
{% else %} {% else %}
<span class="text-danger"> <span class="text-danger">
<i class="far fa-times-square"></i> No <i class="far fa-times-square"></i> No
</span> </span>
{% end %} {% end %}
</td> </td>
<td id="server_list_{{user.user_id}}"> <td id="server_list_{{user.user_id}}">
<ul id="{{user.user_id}}"> <ul id="{{user.user_id}}">
{% for item in data['auth-servers'][user.user_id] %} {% for item in data['auth-servers'][user.user_id] %}
<li>{{item}}</li> <li>{{item}}</li>
{% end %} {% end %}
</ul> </ul>
</td> </td>
<td id="role_list_{{user.user_id}}"> <td id="role_list_{{user.user_id}}">
<ul> <ul>
{% for item in data['user-roles'][user.user_id] %} {% for item in data['user-roles'][user.user_id] %}
<li data-toggle="tooltip" title="{{ item }}">{{item}}</li> <li data-toggle="tooltip" title="{{ item }}">{{item}}</li>
{% end %} {% end %}
</ul> </ul>
</td> </td>
<td><a href="/panel/edit_user?id={{user.user_id}}"><i class="fas fa-pencil-alt"></i></a></td> <td><a href="/panel/edit_user?id={{user.user_id}}"><i class="fas fa-pencil-alt"></i></a></td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
</table> </table>
</div> </div>
@ -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">
@ -110,7 +121,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for role in data['roles'] %} {% for role in data['roles'] %}
<tr> <tr>
<td>{{ role.role_name }}</td> <td>{{ role.role_name }}</td>
<td id="role_list_{{role.role_id}}"> <td id="role_list_{{role.role_id}}">
@ -120,19 +131,20 @@
{% end %} {% end %}
</ul> </ul>
</td> </td>
<td><ul> <td>
{% for user in data['users'] %} <ul>
{% 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 %}
<li>{{ user.username }}</li> <li>{{ user.username }}</li>
{% end %} {% end %}
{% end %} {% end %}
{% end %} {% end %}
</ul> </ul>
</td> </td>
<td><a href="/panel/edit_role?id={{role.role_id}}"><i class="fas fa-pencil-alt"></i></a></td> <td><a href="/panel/edit_role?id={{role.role_id}}"><i class="fas fa-pencil-alt"></i></a></td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
</table> </table>
@ -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,46 +190,46 @@
{% 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({
backdrop: true, backdrop: true,
title: '', title: '',
@ -225,13 +240,13 @@ $( document ).ready(function() {
$('.clear-comm').click(function () { $('.clear-comm').click(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

@ -9,22 +9,22 @@
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Page Title Header Starts--> <!-- Page Title Header Starts-->
<div class="row page-title-header"> <div class="row page-title-header">
<div class="col-12"> <div class="col-12">
<div class="page-header"> <div class="page-header">
{% if data['new_user'] %} {% if data['new_user'] %}
<h4 class="page-title"> <h4 class="page-title">
{{ translate('userConfig', 'pageTitleNew', data['lang']) }} {{ translate('userConfig', 'pageTitleNew', data['lang']) }}
<br /> <br />
<small>UID: N/A</small> <small>UID: N/A</small>
</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>
{% end %} {% end %}
</div> </div>
</div> </div>
@ -37,198 +37,250 @@
<div class="col-sm-12 grid-margin"> <div class="col-sm-12 grid-margin">
<div class="card"> <div class="card">
<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"
</li> role="tab" aria-selected="true">
{% if not data['new_user'] %} <i class="fas fa-cogs"></i> {{ translate('userConfig', 'config', data['lang']) }}</a>
<li class="nav-item"> </li>
<a class="nav-link" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" role="tab" aria-selected="false"> {% if not data['new_user'] %}
<i class="fas fa-key"></i>{{ translate('userConfig', 'apiKey', data['lang']) }} - {{ data['user']['user_id'] }}</a> <li class="nav-item">
</li> <a class="nav-link" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" role="tab"
{% end %} aria-selected="false">
</ul> <i class="fas fa-key"></i>{{ translate('userConfig', 'apiKey', data['lang']) }}</a>
</li>
{% end %}
</ul>
<div class="row"> <div class="row">
<div class="col-md-6 col-sm-12"> <div class="col-md-6 col-sm-12">
{% if data['new_user'] %} {% if data['new_user'] %}
<form id="user_form" class="forms-sample" method="post" action="/panel/add_user"> <form id="user_form" class="forms-sample" method="post" action="/panel/add_user">
{% else %} {% else %}
<form id="user_form" class="forms-sample" method="post" action="/panel/edit_user"> <form id="user_form" class="forms-sample" method="post" action="/panel/edit_user">
{% end %} {% end %}
{% raw xsrf_form_html() %} {% raw xsrf_form_html() %}
<input type="hidden" name="id" value="{{ data['user']['user_id'] }}"> <input type="hidden" name="id" value="{{ data['user']['user_id'] }}">
<input type="hidden" name="subpage" value="config"> <input type="hidden" name="subpage" value="config">
<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',
</div> data['lang']) }}</h4>
<div class="card-body"> </div>
<div class="form-group"> <div class="card-body">
<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> <div class="form-group">
<input type="text" class="form-control" name="username" id="username" value="{{ data['user']['username'] }}" placeholder="User Name" > <label class="form-label" for="username">{{ translate('userConfig', 'userName', data['lang'])
</div> }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang'])
<div class="form-group"> }}</small> </label>
<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> <input type="text" class="form-control" name="username" id="username"
<input type="password" class="form-control" name="password0" id="password0" value="" placeholder="Password" > value="{{ data['user']['username'] }}" placeholder="User Name">
</div>
<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>
<input type="password" class="form-control" name="password1" id="password1" value="" placeholder="Repeat Password" >
</div>
<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>
<input type="email" class="form-control" name="email" id="email" value="{{ data['user']['email'] }}" placeholder="Gravatar Email" >
</div>
<div class="form-group">
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang']) }}</label>
<select class="form-select form-control form-control-lg select-css" id="language" name="language" form="user_form">
{% for lang in data['languages'] %}
{% if not 'incomplete' in lang %}
<option value="{{lang}}">{{lang}}</option>
{% else %}
<option value="{{lang}}" disabled>{{lang}}</option>
{% end %}
{% end %}
</select>
</div>
</div>
</div> </div>
<div class="form-group">
<div class="card"> <label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang'])
<div class="card-header header-sm d-flex justify-content-between align-items-center"> }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }}
<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> </small> </label>
</div> <input type="password" class="form-control" name="password0" id="password0" value=""
<div class="card-body"> placeholder="Password">
<div class="form-group">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="rounded">
<th>{{ translate('userConfig', 'roleName', data['lang']) }}</th>
<th>{{ translate('userConfig', 'member', data['lang']) }}</th>
</tr>
</thead>
<tbody>
{% for role in data['roles_all'] %}
<tr>
<td>{{ role.role_name }}</td>
<td>
{% 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">
{% else %}
<input type="checkbox" class="form-check-input" id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership" value="1">
{% end %}
</td>
</tr>
{% end %}
</tbody>
</table>
</div>
</div>
</div>
</div> </div>
<div class="form-group">
<!-- Put Permissions Crafty part here --> <label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }}
<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang'])
<div class="card"> }}</small> </label>
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <input type="password" class="form-control" name="password1" id="password1" value=""
<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> placeholder="Repeat Password">
</div>
<div class="card-body">
<div class="form-group">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="rounded">
<th>{{ translate('userConfig', 'permName', data['lang']) }}</th>
<th>{{ translate('userConfig', 'auth', data['lang']) }}</th>
<th>{{ translate('userConfig', 'uses', data['lang']) }}</th>
</tr>
</thead>
<tbody>
{% for permission in data['permissions_all'] %}
<tr>
<td>{{ permission.name }}</td>
<td>
{% if permission in data['permissions_list'] %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" checked="" value="1">
{% else %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" value="1">
{% end %}
</td>
<td><input type="text" class="form-control" name="quantity_{{ permission.name }}" id="quantity_{{ permission.name }}" value="{{ data['quantity_server'][permission.name] }}"></td>
</tr>
{% end %}
</tbody>
</table>
</div>
</div>
</div>
</div> </div>
<div class="form-group">
<div class="form-check-flat"> <label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang'])
<label for="enabled" class="form-check-label ml-4 mb-4"> }}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang'])
{% if data['user']['enabled'] %} }}</small> </label>
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" checked="" value="1">{{ translate('userConfig', 'enabled', data['lang']) }} <input type="email" class="form-control" name="email" id="email"
value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
</div>
<div class="form-group">
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang'])
}}</label>
<select class="form-select form-control form-control-lg select-css" id="language"
name="language" form="user_form">
{% for lang in data['languages'] %}
{% if not 'incomplete' in lang %}
<option value="{{lang}}">{{lang}}</option>
{% else %} {% else %}
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" value="1">{{ translate('userConfig', 'enabled', data['lang']) }} <option value="{{lang}}" disabled>{{lang}}</option>
{% end %} {% end %}
</label>
<label for="superuser" class="form-check-label ml-4 mb-4">
{% 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']) }}
{% else %}
<input type="checkbox" onclick="superConfirm()" class="form-check-input" id="superuser" name="superuser" {{ data['super-disabled'] }} value="1" >{{ translate('userConfig', 'super', data['lang']) }}
{% end %} {% end %}
</label> </select>
</div>
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{ 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>
</div>
<div class="col-md-6 col-sm-12">
<div class="card">
<div class="card-body">
<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>
<blockquote class="blockquote">
<p class="mb-0">
{{ translate('userConfig', 'created', data['lang']) }} {{ str(data['user']['created']) }}
<br />
{{ translate('userConfig', 'lastLogin', data['lang']) }} {{ str(data['user']['last_login']) }}
<br />
{{ translate('userConfig', 'lastUpdate', data['lang']) }} {{ str(data['user']['last_update']) }}
<br />
{{ translate('userConfig', 'lastIP', data['lang']) }} {{ data['user']['last_ip'] }}
<br />
</p>
</blockquote>
</div> </div>
</div> </div>
<div class="text-center"> </div>
{% 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 />
<small>{{ translate('userConfig', 'notExist', data['lang']) }}</small>
{% 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 />
<small>{{ translate('userConfig', 'delSuper', data['lang']) }}</small>
{% else %}
<button class="btn btn-sm btn-danger delete-user"><i class="fas fa-trash"></i> {{ translate('userConfig', 'deleteUserB', data['lang']) }}</a>
{% end %}
<div class="card">
<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>
</div> </div>
</div> <div class="card-body">
<div class="form-group">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="rounded">
<th>{{ translate('userConfig', 'roleName', data['lang']) }}</th>
<th>{{ translate('userConfig', 'member', data['lang']) }}</th>
</tr>
</thead>
<tbody>
{% for role in data['roles_all'] %}
<tr>
<td>{{ role.role_name }}</td>
<td>
{% 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">
{% else %}
<input type="checkbox" class="form-check-input"
id="role_{{ role.role_id }}_membership" name="role_{{ role.role_id }}_membership"
value="1">
{% end %}
</td>
</tr>
{% end %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Put Permissions Crafty part here -->
<div class="card">
<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>
</div>
<div class="card-body">
<div class="form-group">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="rounded">
<th>{{ translate('userConfig', 'permName', data['lang']) }}</th>
<th>{{ translate('userConfig', 'auth', data['lang']) }}</th>
<th>{{ translate('userConfig', 'uses', data['lang']) }}</th>
</tr>
</thead>
<tbody>
{% for permission in data['permissions_all'] %}
<tr>
<td>{{ permission.name }}</td>
<td>
{% if permission in data['permissions_list'] %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" checked="" value="1">
{% else %}
<input type="checkbox" class="form-check-input" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1">
{% end %}
</td>
<td><input type="text" class="form-control" name="quantity_{{ permission.name }}"
id="quantity_{{ permission.name }}"
value="{{ data['quantity_server'][permission.name] }}"></td>
</tr>
{% end %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="form-check-flat">
<label for="enabled" class="form-check-label ml-4 mb-4">
{% if data['user']['enabled'] %}
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" checked=""
value="1">{{ translate('userConfig', 'enabled', data['lang']) }}
{% else %}
<input type="checkbox" class="form-check-input" id="enabled" name="enabled" value="1">{{
translate('userConfig', 'enabled', data['lang']) }}
{% end %}
</label>
<label for="superuser" class="form-check-label ml-4 mb-4">
{% 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']) }}
{% else %}
<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 %}
</label>
</div>
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{
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>
</div> </div>
<div class="col-md-6 col-sm-12">
<div class="card">
<div class="card-body">
<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>
<blockquote class="blockquote">
<p class="mb-0">
{{ translate('userConfig', 'created', data['lang']) }} {{ str(data['user']['created']) }}
<br />
{{ translate('userConfig', 'lastLogin', data['lang']) }} {{ str(data['user']['last_login']) }}
<br />
{{ translate('userConfig', 'lastUpdate', data['lang']) }} {{ str(data['user']['last_update']) }}
<br />
{{ translate('userConfig', 'lastIP', data['lang']) }} {{ data['user']['last_ip'] }}
<br />
</p>
</blockquote>
</div>
</div>
<div class="text-center">
{% 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 />
<small>{{ translate('userConfig', 'notExist', data['lang']) }}</small>
{% 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 />
<small>{{ translate('userConfig', 'delSuper', data['lang']) }}</small>
{% else %}
<button class="btn btn-sm btn-danger delete-user"><i class="fas fa-trash"></i> {{
translate('userConfig', 'deleteUserB', data['lang']) }}</a>
{% end %}
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -245,70 +297,70 @@
<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: {
label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}' label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}'
}, },
confirm: { confirm: {
className: 'btn-outline-danger', className: 'btn-outline-danger',
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "confirm", data['lang']) }}' label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "confirm", data['lang']) }}'
}
},
callback: function (result) {
console.log(result);
if (result == true) {
location.href="/panel/remove_user?id="+userId;
} }
},
callback: function (result) {
console.log(result);
if (result === true) {
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']) }}",
buttons: { buttons: {
cancel: { cancel: {
label: '<i class="fa fa-times"></i> {{ translate('panelConfig', 'cancel', data['lang']) }}' label: '<i class="fa fa-times"></i> {{ translate('panelConfig', 'cancel', data['lang']) }}'
}, },
confirm: { confirm: {
className: 'btn-outline-warning', className: 'btn-outline-warning',
label: '<i class="fa fa-check"></i> {{ translate('serverBackups', 'confirm', data['lang']) }}' label: '<i class="fa fa-check"></i> {{ translate('serverBackups', 'confirm', data['lang']) }}'
} }
}, },
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
} }
} }
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security //used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
function getCookie(name) { function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined; return r ? r[1] : undefined;
} }
$( document ).ready(function() { $(document).ready(function () {
console.log( "ready!" ); console.log("ready!");
}); });
</script> </script>

View File

@ -9,14 +9,15 @@
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Page Title Header Starts--> <!-- Page Title Header Starts-->
<div class="row page-title-header"> <div class="row page-title-header">
<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']) }} - {{
<br /> data['server_stats']['server_id']['server_name'] }}
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small> <br />
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
</h4> </h4>
</div> </div>
</div> </div>
@ -24,208 +25,231 @@
</div> </div>
<!-- Page Title Header Ends--> <!-- Page Title Header Ends-->
{% include "parts/details_stats.html" %} {% include "parts/details_stats.html" %}
<div class="row"> <div class="row">
<div class="col-sm-12 grid-margin"> <div class="col-sm-12 grid-margin">
<div class="card"> <div class="card">
<div class="card-body pt-0"> <div class="card-body pt-0">
{% include "parts/server_controls_list.html" %} {% include "parts/server_controls_list.html" %}
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12" style="overflow-x:auto;"> <div class="col-md-12 col-sm-12" style="overflow-x:auto;">
<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']) }}" ,
</div> data-content="{{ translate('serverSchedules', 'cannotSeeOnMobile', data['lang']) }}" ,
<div class="card-body"> data-placement="bottom"></span>
<table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table" width="100%" style="table-layout:fixed;"> {% end %}
<thead> <div><button
<tr class="rounded"> onclick="location.href=`/panel/add_schedule?id={{ data['server_stats']['server_id']['server_id'] }}`"
<th style="width: 2%; min-width: 10px;">ID</th> class="btn btn-info">Create New Schedule <i class="fas fa-pencil-alt"></i></button></div>
<th style="width: 23%; min-width: 50px;">Action</th> </div>
<th style="width: 40%; min-width: 50px;">Command</th> <div class="card-body">
<th style="width: 10%; min-width: 50px;">Interval</th> <table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table" width="100%"
<th style="width: 10%; min-width: 50px;">Start Time</th> style="table-layout:fixed;">
<th style="width: 10%; min-width: 50px;">Enabled</th> <thead>
<th style="width: 10%; min-width: 50px;">Edit</th> <tr class="rounded">
</tr> <th style="width: 2%; min-width: 10px;">ID</th>
</thead> <th style="width: 23%; min-width: 50px;">Action</th>
<tbody> <th style="width: 40%; min-width: 50px;">Command</th>
{% for schedule in data['schedules'] %} <th style="width: 10%; min-width: 50px;">Interval</th>
<tr> <th style="width: 10%; min-width: 50px;">Start Time</th>
<td id="{{schedule.schedule_id}}" class="id"> <th style="width: 10%; min-width: 50px;">Enabled</th>
<p>{{schedule.schedule_id}}</p> <th style="width: 10%; min-width: 50px;">Edit</th>
</td> </tr>
<td id="{{schedule.action}}" class="action"> </thead>
<p>{{schedule.action}}</p> <tbody>
</td> {% for schedule in data['schedules'] %}
<td id="{{schedule.command}}" class="action" style="overflow: scroll; max-width: 30px;"> <tr>
<p>{{schedule.command}}</p> <td id="{{schedule.schedule_id}}" class="id">
</td> <p>{{schedule.schedule_id}}</p>
<td id="{{schedule.interval}}" class="action"> </td>
{% if schedule.interval != '' %} <td id="{{schedule.action}}" class="action">
<p>Every</p> <p>{{schedule.action}}</p>
<p>{{schedule.interval}} {{schedule.interval_type}}</p> </td>
{% elif schedule.interval_type == 'reaction' %} <td id="{{schedule.command}}" class="action" style="overflow: scroll; max-width: 30px;">
<p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p> <p>{{schedule.command}}</p>
{% else %} </td>
<p>Cron String:</p> <td id="{{schedule.interval}}" class="action">
<p>{{schedule.cron_string}}</p> {% if schedule.interval != '' %}
{% end %} <p>Every</p>
</td> <p>{{schedule.interval}} {{schedule.interval_type}}</p>
<td id="{{schedule.start_time}}" class="action"> {% elif schedule.interval_type == 'reaction' %}
<p>{{schedule.start_time}}</p> <p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p>
</td> {% else %}
<td id="{{schedule.enabled}}" class="action"> <p>Cron String:</p>
<p>{{schedule.cron_string}}</p>
{% end %}
</td>
<td id="{{schedule.start_time}}" class="action">
<p>{{schedule.start_time}}</p>
</td>
<td id="{{schedule.enabled}}" class="action">
{% if schedule.enabled %} {% if schedule.enabled %}
<span class="text-success"> <span class="text-success">
<i class="fas fa-check-square"></i> Yes <i class="fas fa-check-square"></i> Yes
</span> </span>
{% else %} {% else %}
<span class="text-danger"> <span class="text-danger">
<i class="far fa-times-square"></i> No <i class="far fa-times-square"></i> No
</span> </span>
{% 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
<i class="fas fa-pencil-alt"></i> onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'"
</button> class="btn btn-info">
<i class="fas fa-pencil-alt"></i>
</button>
<br> <br>
<br> <br>
<button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button"> <button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
<i class="fas fa-trash" aria-hidden="true"></i> <i class="fas fa-trash" aria-hidden="true"></i>
</button> </button>
</td> </td>
</tr> </tr>
{% end %}
</tbody>
</table>
<hr />
<table class="table table-hover d-block d-lg-none" id="mini_schedule_table" width="100%"
style="table-layout:fixed;">
<thead>
<tr class="rounded">
<th style="width: 25%; min-width: 50px;">Action</th>
<th style="max-width: 40%; min-width: 50px;">Command</th>
<th style="width: 10%; min-width: 50px;">Enabled</th>
</tr>
</thead>
<tbody>
{% for schedule in data['schedules'] %}
<tr data-toggle="modal" data-target="#task_details_{{schedule.schedule_id}}">
<td id="{{schedule.action}}" class="action">
<p>{{schedule.action}}</p>
</td>
<td id="{{schedule.command}}" class="action" style="overflow: scroll; max-width: 30px;">
<p>{{schedule.command}}</p>
</td>
<td id="{{schedule.enabled}}" class="action">
{% if schedule.enabled %}
<span class="text-success">
<i class="fas fa-check-square"></i> Yes
</span>
{% else %}
<span class="text-danger">
<i class="far fa-times-square"></i> No
</span>
{% end %} {% end %}
</tbody> </td>
</table> </tr>
<hr /> <!-- Modal -->
<table class="table table-hover d-block d-lg-none" id="mini_schedule_table" width="100%" style="table-layout:fixed;"> <div class="modal fade" id="task_details_{{schedule.schedule_id}}" tabindex="-1" role="dialog"
<thead> aria-labelledby="exampleModalLabel" aria-hidden="true">
<tr class="rounded"> <div class="modal-dialog" role="document">
<th style="width: 25%; min-width: 50px;">Action</th> <div class="modal-content">
<th style="max-width: 40%; min-width: 50px;">Command</th> <div class="modal-header">
<th style="width: 10%; min-width: 50px;">Enabled</th> <h5 class="modal-title" id="exampleModalLabel">Task Details</h5>
</tr> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
</thead> <span aria-hidden="true">&times;</span>
<tbody> </button>
{% for schedule in data['schedules'] %} </div>
<tr data-toggle="modal" data-target="#task_details_{{schedule.schedule_id}}"> <div class="modal-body">
<td id="{{schedule.action}}" class="action"> <ul style="list-style: none;">
<p>{{schedule.action}}</p> <li id="{{schedule.schedule_id}}" class="id" style="border-top: .1em solid gray;">
</td> <h4>ID</h4>
<td id="{{schedule.command}}" class="action" style="overflow: scroll; max-width: 30px;"> <p>{{schedule.schedule_id}}</p>
<p>{{schedule.command}}</p> </li>
</td> <li id="{{schedule.action}}" class="action" style="border-top: .1em solid gray;">
<td id="{{schedule.enabled}}" class="action"> <h4>Action</h4>
{% if schedule.enabled %} <p>{{schedule.action}}</p>
<span class="text-success"> </li>
<i class="fas fa-check-square"></i> Yes <li id="{{schedule.command}}" class="action" style="border-top: .1em solid gray;">
</span> <h4>Command</h4>
{% else %} <p>{{schedule.command}}</p>
<span class="text-danger"> </li>
<i class="far fa-times-square"></i> No <li id="{{schedule.interval}}" class="action" style="border-top: .1em solid gray;">
</span> {% if schedule.interval != '' %}
{% end %} <h4>Interval</h4>
</td> <p>Every {{schedule.interval}} {{schedule.interval_type}}</p>
</tr> {% elif schedule.interval_type == 'reaction' %}
<!-- Modal --> <h4>Interval</h4>
<div class="modal fade" id="task_details_{{schedule.schedule_id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p>
<div class="modal-dialog" role="document"> {% else %}
<div class="modal-content"> <h4>Interval</h4>
<div class="modal-header"> <p>Cron String: {{schedule.cron_string}}</p>
<h5 class="modal-title" id="exampleModalLabel">Task Details</h5> {% end %}
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> </li>
<span aria-hidden="true">&times;</span> <li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;">
</button> <h4>Start Time</h4>
</div> <p>{{schedule.start_time}}</p>
<div class="modal-body"> </li>
<ul style="list-style: none;"> <li id="{{schedule.enabled}}" class="action"
<li id="{{schedule.schedule_id}}" class="id" style="border-top: .1em solid gray;"> style="border-top: .1em solid gray; border-bottom: .1em solid gray">
<h4>ID</h4><p>{{schedule.schedule_id}}</p> {% if schedule.enabled %}
</li> <h4>Enabled</h4> <span class="text-success">
<li id="{{schedule.action}}" class="action" style="border-top: .1em solid gray;"> <i class="fas fa-check-square"></i> Yes
<h4>Action</h4><p>{{schedule.action}}</p> </span>
</li> {% else %}
<li id="{{schedule.command}}" class="action" style="border-top: .1em solid gray;"> <h4>Enabled</h4> <span class="text-danger">
<h4>Command</h4><p>{{schedule.command}}</p> <i class="far fa-times-square"></i> No
</li> </span>
<li id="{{schedule.interval}}" class="action" style="border-top: .1em solid gray;"> {% end %}
{% if schedule.interval != '' %} </li>
<h4>Interval</h4> <p>Every {{schedule.interval}} {{schedule.interval_type}}</p> </ul>
{% elif schedule.interval_type == 'reaction' %} </div>
<h4>Interval</h4> <p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p> <div class="modal-footer">
{% else %} <button
<h4>Interval</h4> <p>Cron String: {{schedule.cron_string}}</p> onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'"
{% end %} class="btn btn-info">
</li> <i class="fas fa-pencil-alt"></i> Edit
<li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;"> </button>
<h4>Start Time</h4> <p>{{schedule.start_time}}</p> <button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
</li> <i class="fas fa-trash" aria-hidden="true"></i> Delete
<li id="{{schedule.enabled}}" class="action" style="border-top: .1em solid gray; border-bottom: .1em solid gray"> </button>
{% if schedule.enabled %} <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<h4>Enabled</h4> <span class="text-success">
<i class="fas fa-check-square"></i> Yes
</span>
{% else %}
<h4>Enabled</h4> <span class="text-danger">
<i class="far fa-times-square"></i> No
</span>
{% end %}
</li>
</ul>
</div>
<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">
<i class="fas fa-pencil-alt"></i> Edit
</button>
<button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
<i class="fas fa-trash" aria-hidden="true"></i> Delete
</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div> </div>
</div> </div>
{% end %} </div>
</tbody>
</table>
</div> </div>
</div> {% end %}
</tbody>
</table>
</div> </div>
</div>
</div> </div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<style> <style>
.popover-body{ .popover-body {
color: white !important;; color: white !important;
} ;
}
</style> </style>
</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,138 +260,138 @@ 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>
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security //used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
function getCookie(name) { function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined; return r ? r[1] : undefined;
}
$(document).ready(function () {
console.log("ready!");
});
function yesnoCheck(that) {
if (that.value == "command") {
document.getElementById("ifYes").style.display = "block";
document.getElementById("command").required = true;
} else {
document.getElementById("ifYes").style.display = "none";
document.getElementById("command").required = false;
} }
$( document ).ready(function() {
console.log( "ready!" );
});
function yesnoCheck(that) {
if (that.value == "command") {
document.getElementById("ifYes").style.display = "block";
document.getElementById("command").required = true;
} else {
document.getElementById("ifYes").style.display = "none";
document.getElementById("command").required = false;
}
} }
function basicAdvanced(that) { function basicAdvanced(that) {
if (that.value == "advanced") { if (that.value == "advanced") {
document.getElementById("ifAdvanced").style.display = "block"; document.getElementById("ifAdvanced").style.display = "block";
document.getElementById("ifBasic").style.display = "none"; document.getElementById("ifBasic").style.display = "none";
document.getElementById("interval").required = false; document.getElementById("interval").required = false;
document.getElementById("time").required = false; document.getElementById("time").required = false;
} else { } else {
document.getElementById("ifAdvanced").style.display = "none"; document.getElementById("ifAdvanced").style.display = "none";
document.getElementById("ifBasic").style.display = "block"; document.getElementById("ifBasic").style.display = "block";
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;
} else { } else {
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)
bootbox.confirm({ bootbox.confirm({
title: "{{ translate('serverSchedules', 'areYouSure', data['lang']) }}", title: "{{ translate('serverSchedules', 'areYouSure', data['lang']) }}",
message: "{{ translate('serverSchedules', 'confirmDelete', data['lang']) }}", message: "{{ translate('serverSchedules', 'confirmDelete', data['lang']) }}",
buttons: { buttons: {
cancel: { cancel: {
label: '<i class="fas fa-times"></i> {{ translate("serverSchedules", "cancel", data['lang']) }}' label: '<i class="fas fa-times"></i> {{ translate("serverSchedules", "cancel", data['lang']) }}'
}, },
confirm: { confirm: {
className: 'btn-outline-danger', className: 'btn-outline-danger',
label: '<i class="fas fa-check"></i> {{ translate("serverSchedules", "confirm", data['lang']) }}' label: '<i class="fas fa-check"></i> {{ translate("serverSchedules", "confirm", data['lang']) }}'
} }
}, },
callback: function (result) { callback: function (result) {
console.log(result); console.log(result);
if (result == true) { if (result == true) {
del_task(sch_id, serverId); del_task(sch_id, serverId);
} }
} }
});
}); });
});
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",