diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index f68bdd4b..e6478c88 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -396,7 +396,8 @@ class Server: def a_jar_update(self): wasStarted = "-1" - self.backup_server() + #self.backup_server() + time.sleep(5) #checks if server is running. Calls shutdown if it is running. if self.check_running(): wasStarted = True @@ -436,8 +437,20 @@ class Server: pass logger.info("Executable updated successfully. Starting Server") time.sleep(5) + 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) + db_helper.add_to_audit_log_raw('Alert', '-1', self.server_id, "Executable update finished for "+self.name, self.settings['server_ip']) if wasStarted: self.start_server() diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 84b56a7d..15e04e1b 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -123,7 +123,7 @@ - + {% if server['stats']['running'] %}     @@ -282,6 +282,28 @@ $( document ).ready(function() { 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 = ' UPDATING...'; + } + else{ + if (updateButton.wasStarted){ + document.getElementById(id).innerHTML = '    '; + + }else{ + document.getElementById(id).innerHTML = '    '; + + } + + document.getElementById(id).innerHTML = ''; + } + }); + } $( ".clone_button" ).click(function() { server_id = $(this).attr("data-id"); diff --git a/app/frontend/templates/panel/server_term.html b/app/frontend/templates/panel/server_term.html index 7441708b..e71c4852 100644 --- a/app/frontend/templates/panel/server_term.html +++ b/app/frontend/templates/panel/server_term.html @@ -84,13 +84,13 @@ {% if data['server_stats']['updating']%} -
+
{% else %} -
+
@@ -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 = ''; + } + else{ + + document.getElementById('update_control_buttons').innerHTML = ''; + } + }); + } // Convert running to lower case (example: 'True' converts to 'true') and // then to boolean via JSON.parse()