mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Another commit because it seems like the first one didn't work. Added seamless hchanging on update status
This commit is contained in:
parent
b205c00c06
commit
a2f32ed324
@ -396,7 +396,8 @@ class Server:
|
|||||||
|
|
||||||
def a_jar_update(self):
|
def a_jar_update(self):
|
||||||
wasStarted = "-1"
|
wasStarted = "-1"
|
||||||
self.backup_server()
|
#self.backup_server()
|
||||||
|
time.sleep(5)
|
||||||
#checks if server is running. Calls shutdown if it is running.
|
#checks if server is running. Calls shutdown if it is running.
|
||||||
if self.check_running():
|
if self.check_running():
|
||||||
wasStarted = True
|
wasStarted = True
|
||||||
@ -436,8 +437,20 @@ class Server:
|
|||||||
pass
|
pass
|
||||||
logger.info("Executable updated successfully. Starting Server")
|
logger.info("Executable updated successfully. Starting Server")
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
db_helper.set_update(self.server_id, False)
|
db_helper.set_update(self.server_id, False)
|
||||||
|
|
||||||
|
if len(websocket_helper.clients) > 0:
|
||||||
|
# There are clients
|
||||||
|
self.check_update()
|
||||||
|
websocket_helper.broadcast('update_button_status', {
|
||||||
|
'isUpdating': self.check_update(),
|
||||||
|
'server_id': self.server_id,
|
||||||
|
'wasRunning': wasStarted
|
||||||
|
})
|
||||||
|
time.sleep(3)
|
||||||
websocket_helper.broadcast('notification', "Executable update finished for "+self.name)
|
websocket_helper.broadcast('notification', "Executable update finished for "+self.name)
|
||||||
|
|
||||||
db_helper.add_to_audit_log_raw('Alert', '-1', self.server_id, "Executable update finished for "+self.name, self.settings['server_ip'])
|
db_helper.add_to_audit_log_raw('Alert', '-1', self.server_id, "Executable update finished for "+self.name, self.settings['server_ip'])
|
||||||
if wasStarted:
|
if wasStarted:
|
||||||
self.start_server()
|
self.start_server()
|
||||||
|
@ -123,7 +123,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="actions_serverlist">
|
<td id="controls{{server['server_data']['server_id']}}" class="actions_serverlist">
|
||||||
{% if server['stats']['running'] %}
|
{% if server['stats']['running'] %}
|
||||||
<a class="stop_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-stop"></i></a>
|
<a class="stop_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-stop"></i></a>
|
||||||
<a class="restart_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-sync"></i></a>
|
<a class="restart_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-sync"></i></a>
|
||||||
@ -282,6 +282,28 @@ $( document ).ready(function() {
|
|||||||
mem_percent.textContent = hostStats.mem_percent + '%';
|
mem_percent.textContent = hostStats.mem_percent + '%';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (webSocket) {
|
||||||
|
webSocket.on('update_button_status', function (updateButton) {
|
||||||
|
var id = 'controls';
|
||||||
|
var id = id.concat(updateButton.server_id);
|
||||||
|
console.log("ID " + id);
|
||||||
|
if (updateButton.isUpdating){
|
||||||
|
console.log(updateButton.isUpdating)
|
||||||
|
document.getElementById(id).innerHTML = '<a data-id="{{server["server_data"]["server_id"]}}" class="clone_button"> UPDATING...</i></a>';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (updateButton.wasStarted){
|
||||||
|
document.getElementById(id).innerHTML = '<a class="stop_button" data-id="{{server["server_data"]["server_id"]}}"> <i class="fas fa-stop"></i></a> <a class="restart_button" data-id="{{server["server_data"]["server_id"]}}"> <i class="fas fa-sync"></i></a> ';
|
||||||
|
|
||||||
|
}else{
|
||||||
|
document.getElementById(id).innerHTML = '<a data-id="{{server["server_data"]["server_id"]}}" class="play_button"><i class="fas fa-play"></i></a> <a data-id="{{server["server_data"]["server_id"]}}" class="clone_button"> <i class="fas fa-clone"></i></a> ';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById(id).innerHTML = '<button onclick="send_command(server_id, "start_server");" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "start") }}</button><button onclick="send_command(server_id, "restart_server");" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart") %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop") }}</button>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$( ".clone_button" ).click(function() {
|
$( ".clone_button" ).click(function() {
|
||||||
server_id = $(this).attr("data-id");
|
server_id = $(this).attr("data-id");
|
||||||
|
@ -84,13 +84,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{% if data['server_stats']['updating']%}
|
{% if data['server_stats']['updating']%}
|
||||||
<div class="mt-4 flex-wrap d-flex justify-content-between justify-content-md-center align-items-center px-5 px-md-0">
|
<div id="update_control_buttons" class="mt-4 flex-wrap d-flex justify-content-between justify-content-md-center align-items-center px-5 px-md-0" style="visibility: visible">
|
||||||
<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverTerm', 'updating') }}</button>
|
<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverTerm', 'updating') }}</button>
|
||||||
<button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1 disabled">{% raw translate('serverTerm', 'restart') %}</button>
|
<button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1 disabled">{% raw translate('serverTerm', 'restart') %}</button>
|
||||||
<button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate('serverTerm', 'stop') }}</button>
|
<button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate('serverTerm', 'stop') }}</button>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="mt-4 flex-wrap d-flex justify-content-between justify-content-md-center align-items-center px-5 px-md-0">
|
<div id="control_buttons" class="mt-4 flex-wrap d-flex justify-content-between justify-content-md-center align-items-center px-5 px-md-0" style="visibility: visible">
|
||||||
<button onclick="send_command(server_id, 'start_server');" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate('serverTerm', 'start') }}</button>
|
<button onclick="send_command(server_id, 'start_server');" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate('serverTerm', 'start') }}</button>
|
||||||
<button onclick="send_command(server_id, 'restart_server');" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate('serverTerm', 'restart') %}</button>
|
<button onclick="send_command(server_id, 'restart_server');" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate('serverTerm', 'restart') %}</button>
|
||||||
<button onclick="send_command(server_id, 'stop_server');" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1">{{ translate('serverTerm', 'stop') }}</button>
|
<button onclick="send_command(server_id, 'stop_server');" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1">{{ translate('serverTerm', 'stop') }}</button>
|
||||||
@ -132,6 +132,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (webSocket) {
|
||||||
|
webSocket.on('update_button_status', function (updateButton) {
|
||||||
|
if (updateButton.isUpdating){
|
||||||
|
console.log(updateButton.isUpdating)
|
||||||
|
document.getElementById('update_control_buttons').innerHTML = '<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "updating") }}</button><button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart") %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop") }}</button>';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
document.getElementById('update_control_buttons').innerHTML = '<button onclick="send_command(server_id, "start_server");" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "start") }}</button><button onclick="send_command(server_id, "restart_server");" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart") %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop") }}</button>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Convert running to lower case (example: 'True' converts to 'true') and
|
// Convert running to lower case (example: 'True' converts to 'true') and
|
||||||
// then to boolean via JSON.parse()
|
// then to boolean via JSON.parse()
|
||||||
|
Loading…
Reference in New Issue
Block a user