mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add loading screen while servers init
This commit is contained in:
parent
ec4bcda31e
commit
28b3a4f8f3
@ -22,6 +22,7 @@ from app.classes.models.server_permissions import (
|
||||
PermissionsServers,
|
||||
EnumPermissionsServer,
|
||||
)
|
||||
from app.classes.shared.websocket_manager import WebSocketManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -36,6 +37,7 @@ class ServersController(metaclass=Singleton):
|
||||
self.management_helper = management_helper
|
||||
self.servers_list = []
|
||||
self.stats = Stats(self.helper, self)
|
||||
self.ws = WebSocketManager()
|
||||
|
||||
# **********************************************************************************
|
||||
# Generic Servers Methods
|
||||
@ -171,6 +173,9 @@ class ServersController(metaclass=Singleton):
|
||||
self.failed_servers = []
|
||||
|
||||
for server in servers:
|
||||
self.ws.broadcast(
|
||||
"update", {"message": f"Initializing {server['server_name']}."}
|
||||
)
|
||||
server_id = server.get("server_id")
|
||||
|
||||
# if we have already initialized this server, let's skip it.
|
||||
|
@ -80,6 +80,7 @@ class Helpers:
|
||||
self.translation = Translation(self)
|
||||
self.update_available = False
|
||||
self.ignored_names = ["crafty_managed.txt", "db_stats"]
|
||||
self.crafty_starting = False
|
||||
|
||||
@staticmethod
|
||||
def auto_installer_fix(ex):
|
||||
|
@ -1609,7 +1609,8 @@ class PanelHandler(BaseHandler):
|
||||
logs_thread.start()
|
||||
self.redirect("/panel/dashboard")
|
||||
return
|
||||
|
||||
if self.helper.crafty_starting:
|
||||
template = "panel/loading.html"
|
||||
self.render(
|
||||
template,
|
||||
data=page_data,
|
||||
|
64
app/frontend/templates/panel/loading.html
Normal file
64
app/frontend/templates/panel/loading.html
Normal file
@ -0,0 +1,64 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller Starting{% end %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content-wrapper">
|
||||
<div class="card-header justify-content-between align-items-center">
|
||||
<div id="image-div" style="width: 100%;">
|
||||
<img class="img-center" id="logo-animate" src="../static/assets/images/crafty-logo-square-1024.png"
|
||||
width="20%" style="clear: both;">
|
||||
</div>
|
||||
<br>
|
||||
</br>
|
||||
<div id="text-div" style="width: 100%; text-align: center;">
|
||||
<h2 id="status" style="display: block;">Crafty Is Starting</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.img-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function rotateImage(degree) {
|
||||
$('#logo-animate').animate({ transform: degree }, {
|
||||
step: function (now, fx) {
|
||||
$(this).css({
|
||||
'-webkit-transform': 'rotate(' + now + 'deg)',
|
||||
'-moz-transform': 'rotate(' + now + 'deg)',
|
||||
'transform': 'rotate(' + now + 'deg)'
|
||||
});
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
rotateImage(360);
|
||||
}, 2000);
|
||||
}
|
||||
$(document).ready(function () {
|
||||
setTimeout(function () {
|
||||
rotateImage(360);
|
||||
}, 2000);
|
||||
if (webSocket) {
|
||||
webSocket.on('update', function (data) {
|
||||
console.log("got status")
|
||||
$("#status").html(data.message);
|
||||
});
|
||||
webSocket.on('send_start_reload', function () {
|
||||
setTimeout(function () {
|
||||
location.href = '/panel/dashboard'
|
||||
}, 5000);
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{% end %}
|
Loading…
Reference in New Issue
Block a user