Merge branch 'tweak/pretzel-files-design-change' into 'dev'

Files design change / Stats Collection on Offline servers

See merge request crafty-controller/crafty-4!257
This commit is contained in:
Andrew 2022-05-15 20:29:49 +00:00
commit 39e748c9c4
5 changed files with 37 additions and 42 deletions

View File

@ -826,8 +826,8 @@ class Helpers:
output += f"""<li class="tree-item" data-path="{dpath}">
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
{filename}
</span>
</div><li>
@ -835,7 +835,7 @@ class Helpers:
else:
if filename != "crafty_managed.txt":
output += f"""<li
class="tree-nested d-block tree-ctx-item tree-file tree-item"
class="d-block tree-ctx-item tree-file tree-item"
data-path="{dpath}"
data-name="{filename}"
onclick="clickOnFile(event)"><span style="margin-right: 6px;">
@ -864,15 +864,15 @@ class Helpers:
output += f"""<li class="tree-item" data-path="{dpath}">
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
{filename}
</span>
</div><li>"""
else:
if filename != "crafty_managed.txt":
output += f"""<li
class="tree-nested d-block tree-ctx-item tree-file tree-item"
class="d-block tree-ctx-item tree-file tree-item"
data-path="{dpath}"
data-name="{filename}"
onclick="clickOnFile(event)"><span style="margin-right: 6px;">
@ -894,8 +894,8 @@ class Helpers:
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<input type="radio" name="root_path" value="{dpath}">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
{filename}
</span>
</input></div><li>
@ -916,8 +916,8 @@ class Helpers:
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<input type="radio" name="root_path" value="{dpath}">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
{filename}
</span>
</input></div><li>"""

View File

@ -812,6 +812,7 @@ class Controller:
Console.info(f"Deleting Server: ID {server_id} | Name: {server_name} ")
srv_obj = server["server_obj"]
srv_obj.server_scheduler.shutdown()
running = srv_obj.check_running()
if running:

View File

@ -117,6 +117,12 @@ class Server:
self.backup_thread = threading.Thread(
target=self.a_backup_server, daemon=True, name=f"backup_{self.name}"
)
self.server_scheduler.add_job(
self.realtime_stats,
"interval",
seconds=5,
id="stats_" + str(self.server_id),
)
self.is_backingup = False
# Reset crash and update at initialization
HelperServerStats.server_crash_reset(self.server_id)
@ -184,21 +190,6 @@ class Server:
# Register an shedule for polling server stats when running
logger.info(f"Polling server statistics {self.name} every {5} seconds")
Console.info(f"Polling server statistics {self.name} every {5} seconds")
try:
self.server_scheduler.add_job(
self.realtime_stats,
"interval",
seconds=5,
id="stats_" + str(self.server_id),
)
except:
self.server_scheduler.remove_job("stats_" + str(self.server_id))
self.server_scheduler.add_job(
self.realtime_stats,
"interval",
seconds=5,
id="stats_" + str(self.server_id),
)
def setup_server_run_command(self):
# configure the server
@ -591,9 +582,6 @@ class Server:
self.cleanup_server_object()
server_users = PermissionsServers.get_server_user_list(self.server_id)
# remove the stats polling job since server is stopped
self.server_scheduler.remove_job("stats_" + str(self.server_id))
self.record_server_stats()
for user in server_users:
@ -641,8 +629,6 @@ class Server:
# clear the old scheduled watcher task
self.server_scheduler.remove_job(f"c_{self.server_id}")
# remove the stats polling job since server is stopped
self.server_scheduler.remove_job("stats_" + str(self.server_id))
# the server crashed, or isn't found - so let's reset things.
logger.warning(
@ -685,7 +671,6 @@ class Server:
proc.kill()
# kill the main process we are after
logger.info("Sending SIGKILL to parent")
self.server_scheduler.remove_job("stats_" + str(self.server_id))
self.process.kill()
def get_start_time(self):

View File

@ -134,15 +134,15 @@ class AjaxHandler(BaseHandler):
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<input type="checkbox" class="checkBoxClass" name="root_path" value="{dpath}" checked>
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
<strong>{filename}</strong>
</span>
</input></div><li>
\n"""
else:
output += f"""<li
class="tree-nested d-block tree-ctx-item tree-file"
class="d-block tree-ctx-item tree-file"
data-path="{dpath}"
data-name="{filename}"
onclick=""><input type='checkbox' class="checkBoxClass" name='root_path' value="{dpath}" checked><span style="margin-right: 6px;">
@ -154,15 +154,15 @@ class AjaxHandler(BaseHandler):
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<input type="checkbox" class="checkBoxClass" name="root_path" value="{dpath}">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i class="far fa-folder"></i>
<i class="far fa-folder-open"></i>
<i style="color: #8862e0;" class="far fa-folder"></i>
<i style="color: #8862e0;" class="far fa-folder-open"></i>
<strong>{filename}</strong>
</span>
</input></div><li>
\n"""
else:
output += f"""<li
class="tree-nested d-block tree-ctx-item tree-file"
class="d-block tree-ctx-item tree-file"
data-path="{dpath}"
data-name="{filename}"
onclick=""><input type='checkbox' class="checkBoxClass" name='root_path' value="{dpath}">

View File

@ -39,12 +39,15 @@
<noscript>
{{ translate('serverFiles', 'noscript', data['lang']) }}
</noscript>
<div id="files-tree-nav" class="overlay">
<div id="files-tree-nav" class="overlay" style="background-color: #9f9daf !important;">
<!-- Button to close the overlay navigation -->
<!-- Overlay content -->
<div id="files-tree-nav-content" class="overlay-content">
<div id="files-tree-nav-content" class="overlay-content" style="background-color: #9f9daf;">
<h4 id="context-title" style="color:#4b00ff; text-align: center; padding: 3px;">
</h4>
<p style="width: 90%; border-bottom: 2px solid black; margin:0 auto;"></p>
<a onclick="createFileE(event)" href="javascript:void(0)" id="createFile" href="#">{{
translate('serverFiles', 'createFile', data['lang']) }}</a>
<a onclick="createDirE(event)" href="javascript:void(0)" id="createDir" href="#">{{
@ -72,7 +75,7 @@
.overlay {
display: none;
flex-direction: column;
background-color: #fff;
background-color: #9f9daf;
border-radius: 10px;
box-shadow: 0 10px 20px rgb(64 64 64 / 5%);
padding: 10px 0;
@ -97,7 +100,7 @@
.overlay-content {
display: flex;
flex-direction: column;
background-color: #fff;
background-color: #9f9daf;
border-radius: 10px;
box-shadow: 0 10px 20px rgb(64 64 64 / 5%);
padding: 10px 0;
@ -125,7 +128,7 @@
/* When you mouse over the navigation links, change their color */
.overlay a:hover,
.overlay a:focus {
background: #f1f3f7;
background: grey;
color: #4b00ff;
}
@ -445,6 +448,9 @@
e.stopImmediatePropagation();
var ctxmenuPath = e.target.getAttribute('data-path');
var ctxmenuName = e.target.getAttribute('data-name');
document.getElementById('context-title').innerHTML = ctxmenuName;
console.log(ctxmenuName);
if (!ctxmenuPath) {
console.log({ 'event.target': e.target, ctxmenuPath });
return;
@ -926,6 +932,9 @@
$('#deleteDir').toggle(isDir);
$('#upload').toggle(isDir);
document.getElementById('context-title').innerHTML = ctxmenuName;
console.log(ctxmenuName);
var isFile = event.target.classList.contains('tree-file');
$('#deleteFile').toggle(isFile);
$('#downloadFile').toggle(isFile);