Adding refresh on dash and term when update finishes to get the status to change. Could not do it dynamically. Buttons would no longer be clickable. Would like to figure that out at some point in the future.

This commit is contained in:
Andrew McManus 2021-07-26 21:05:52 -04:00
parent fa9184c1ad
commit 0643a68c74
3 changed files with 12 additions and 7 deletions

View File

@ -439,14 +439,15 @@ class Server:
time.sleep(5)
db_helper.set_update(self.server_id, False)
dashOffHtmlString = '<a data-id="'+str(self.server_id)+'" class="play_button"><i class="fas fa-play"></i></a> &nbsp;<a data-id="'+str(self.server_id)+'" class="clone_button"> <i class="fas fa-clone"></i></a>&nbsp;'
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
'wasRunning': wasStarted,
'dashOffGetString': dashOffHtmlString
})
time.sleep(3)
websocket_helper.broadcast('notification', "Executable update finished for "+self.name)

View File

@ -128,7 +128,7 @@
<a class="stop_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-stop"></i></a> &nbsp;
<a class="restart_button" data-id="{{server['server_data']['server_id']}}"> <i class="fas fa-sync"></i></a> &nbsp;
{% elif server['stats']['updating']%}
<a data-id="{{server['server_data']['server_id']}}" class="clone_button"> UPDATING...</i></a>
<a data-id="{{server['server_data']['server_id']}}" class=""> UPDATING...</i></a>
{% else %}
<a data-id="{{server['server_data']['server_id']}}" class="play_button"><i class="fas fa-play"></i></a> &nbsp;
<a data-id="{{server['server_data']['server_id']}}" class="clone_button"> <i class="fas fa-clone"></i></a>&nbsp;
@ -285,18 +285,22 @@ $( document ).ready(function() {
if (webSocket) {
webSocket.on('update_button_status', function (updateButton) {
var id = 'controls';
var dataId = updateButton.server_id;
console.log(dataId)
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>';
document.getElementById(id).innerHTML = '<a data-id="dataId" class=""> UPDATING...</i></a>';
}
else{
window.location.reload()
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> &nbsp;<a class="restart_button" data-id="{{server["server_data"]["server_id"]}}"> <i class="fas fa-sync"></i></a> &nbsp;';
document.getElementById(id).innerHTML = '<a class="stop_button" data-id="dataId"> <i class="fas fa-stop"></i></a> &nbsp;<a class="restart_button" data-id="{{server["server_data"]["server_id"]}}"> <i class="fas fa-sync"></i></a> &nbsp;';
}else{
document.getElementById(id).innerHTML = '<a data-id="{{server["server_data"]["server_id"]}}" class="play_button"><i class="fas fa-play"></i></a> &nbsp;<a data-id="{{server["server_data"]["server_id"]}}" class="clone_button"> <i class="fas fa-clone"></i></a>&nbsp;';
document.getElementById(id).innerHTML = updateButton.dashOffGetString;
console.log(updateButton.dashOffGetString);
}
}

View File

@ -139,7 +139,7 @@
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{
window.location.reload()
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>';
}
});