mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Moved delete server to ajax call instead of a task.
This commit is contained in:
parent
c1ce2b985a
commit
00422f24cd
@ -113,16 +113,6 @@ class TasksManager:
|
||||
|
||||
elif command == "update_executable":
|
||||
svr.jar_update()
|
||||
elif command == "delete_server":
|
||||
logger.info(
|
||||
"Removing server from panel for server: {}".format(c['server_id']['server_name']))
|
||||
self.controller.remove_server(c['server_id']['server_id'], False)
|
||||
|
||||
elif command == "delete_server_files":
|
||||
logger.info(
|
||||
"Removing server and all associated files for server: {}".format(c['server_id']['server_name']))
|
||||
self.controller.remove_server(c['server_id']['server_id'], True)
|
||||
|
||||
db_helper.mark_command_complete(c.get('command_id', None))
|
||||
|
||||
time.sleep(1)
|
||||
|
@ -229,6 +229,18 @@ class AjaxHandler(BaseHandler):
|
||||
# os.rmdir(dir_path) # Would only remove empty directories
|
||||
shutil.rmtree(dir_path) # Removes also when there are contents
|
||||
|
||||
elif page == "delete_server":
|
||||
server_id = self.get_argument('id', None)
|
||||
logger.info(
|
||||
"Removing server from panel for server: {}".format(db_helper.get_server_friendly_name(server_id)))
|
||||
self.controller.remove_server(server_id, False)
|
||||
|
||||
elif page == "delete_server_files":
|
||||
server_id = self.get_argument('id', None)
|
||||
logger.info(
|
||||
"Removing server and all associated files for server: {}".format(db_helper.get_server_friendly_name(server_id)))
|
||||
self.controller.remove_server(server_id, True)
|
||||
|
||||
@tornado.web.authenticated
|
||||
def put(self, page):
|
||||
if page == "save_file":
|
||||
|
@ -203,6 +203,35 @@
|
||||
|
||||
});
|
||||
|
||||
function deleteServerE(callback) {
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: {'X-XSRFToken': token},
|
||||
url: '/ajax/delete_server?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
data: {
|
||||
},
|
||||
success: function(data){
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
function deleteServerFilesE(path, callback) {
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: {'X-XSRFToken': token},
|
||||
url: '/ajax/delete_server_files?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
data: {
|
||||
},
|
||||
success: function(data){
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
|
||||
function send_command (server_id, command){
|
||||
@ -249,7 +278,7 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
},
|
||||
callback: function(result) {
|
||||
if (!result){
|
||||
send_command(server_id, 'delete_server');
|
||||
deleteServerE()
|
||||
setTimeout(function(){ window.location = '/panel/dashboard'; }, 5000);
|
||||
bootbox.dialog({
|
||||
backdrop: true,
|
||||
@ -260,7 +289,7 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
|
||||
return;}
|
||||
else{
|
||||
send_command(server_id, 'delete_server_files');
|
||||
deleteServerFilesE();
|
||||
setTimeout(function(){ window.location = '/panel/dashboard'; }, 5000);
|
||||
bootbox.dialog({
|
||||
backdrop: true,
|
||||
|
Loading…
Reference in New Issue
Block a user