mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix db not found issue
Add page feedback.
This commit is contained in:
parent
d273589f2e
commit
e43c63a8b7
@ -101,7 +101,9 @@ class ServersController(metaclass=Singleton):
|
||||
server_instance: ServerInstance = ServersController().get_server_instance_by_id(
|
||||
server_obj.server_id
|
||||
)
|
||||
print("before update", server_instance.server_path)
|
||||
server_instance.update_server_instance()
|
||||
print("after update", server_instance.server_path)
|
||||
return ret
|
||||
|
||||
def get_history_stats(self, server_id, days):
|
||||
|
@ -6,6 +6,7 @@ import platform
|
||||
import shutil
|
||||
import time
|
||||
import logging
|
||||
import threading
|
||||
from peewee import DoesNotExist
|
||||
|
||||
# TZLocal is set as a hidden import on win pipeline
|
||||
@ -1010,6 +1011,22 @@ class Controller:
|
||||
HelpersManagement.set_master_server_dir(server_dir)
|
||||
|
||||
def update_master_server_dir(self, server_dir, user_id):
|
||||
move_thread = threading.Thread(
|
||||
name="dir_move",
|
||||
target=self.t_update_master_server_dir,
|
||||
daemon=True,
|
||||
args=(
|
||||
server_dir,
|
||||
user_id,
|
||||
),
|
||||
)
|
||||
move_thread.start()
|
||||
return
|
||||
|
||||
def t_update_master_server_dir(self, server_dir, user_id):
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/panel_config", "move_status", "Checking dir"
|
||||
)
|
||||
if self.management.get_master_server_dir() == server_dir:
|
||||
logger.info(
|
||||
"Admin tried to change server dir to current server dir. Canceling..."
|
||||
@ -1021,7 +1038,9 @@ class Controller:
|
||||
" current server dir. This will result in a copy loop."
|
||||
)
|
||||
self.helper.servers_dir = server_dir
|
||||
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/panel_config", "move_status", "Checking permissions"
|
||||
)
|
||||
if not self.helper.ensure_dir_exists(os.path.join(server_dir, "servers")):
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user_id,
|
||||
@ -1042,6 +1061,11 @@ class Controller:
|
||||
server_dir, "servers", server.get("server_uuid")
|
||||
)
|
||||
if os.path.isdir(server_path):
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/panel_config",
|
||||
"move_status",
|
||||
f"Moving {server.get('server_name')}",
|
||||
)
|
||||
self.file_helper.move_dir(
|
||||
server_path,
|
||||
new_server_path,
|
||||
@ -1057,3 +1081,8 @@ class Controller:
|
||||
else:
|
||||
self.servers.update_unloaded_server(server_obj)
|
||||
self.servers.init_all_servers()
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/panel_config",
|
||||
"move_status",
|
||||
"done",
|
||||
)
|
||||
|
@ -156,6 +156,8 @@ class ServerInstance:
|
||||
self.jar_update_url = server_data.executable_update_url
|
||||
self.name = server_data.server_name
|
||||
self.server_object = server_data
|
||||
self.stats_helper.select_database()
|
||||
self.reload_server_settings()
|
||||
|
||||
def reload_server_settings(self):
|
||||
server_data = HelperServers.get_server_data_by_id(self.server_id)
|
||||
|
@ -252,6 +252,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-success" type="submit">Submit</button> <span id="submit-status"></span>
|
||||
<br>
|
||||
<span id="submit-list"></span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -274,6 +276,29 @@
|
||||
color: white !important;
|
||||
;
|
||||
}
|
||||
|
||||
.loading:after {
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
-webkit-animation: ellipsis steps(4, end) 900ms infinite;
|
||||
animation: ellipsis steps(4, end) 900ms infinite;
|
||||
content: "\2026";
|
||||
/* ascii code for the ellipsis character */
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
@keyframes ellipsis {
|
||||
to {
|
||||
width: 1.25em;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes ellipsis {
|
||||
to {
|
||||
width: 1.25em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
@ -281,6 +306,19 @@
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
if (webSocket) {
|
||||
webSocket.on('move_status', function (message) {
|
||||
if (message === "done") {
|
||||
$("#submit-list").removeClass("loading");
|
||||
$("#submit-list").html("");
|
||||
$("#submit-status").html('<i class="fa fa-check"></i>');
|
||||
} else {
|
||||
$("#submit-status").html('<i class="fa fa-spinner fa-spin"></i>');
|
||||
$("#submit-list").html(message);
|
||||
$("#submit-list").addClass("loading");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#server-path").submit(function (e) {
|
||||
var token = getCookie("_xsrf")
|
||||
@ -299,9 +337,6 @@
|
||||
data: {
|
||||
"server_dir": encoded,
|
||||
},
|
||||
success: function (data) {
|
||||
$("#submit-status").html('<i class="fa fa-check"></i>');
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user