diff --git a/app/classes/web/upload_handler.py b/app/classes/web/upload_handler.py index 0d9e00e5..90d59892 100644 --- a/app/classes/web/upload_handler.py +++ b/app/classes/web/upload_handler.py @@ -62,16 +62,18 @@ class UploadHandler(tornado.web.RequestHandler): def post(self): logger.info("Upload completed") - + files_left = int(self.request.headers.get('X-Files-Left', None)) if self.do_upload: time.sleep(5) - websocket_helper.broadcast('close_upload_box', 'success') + if files_left == 0: + websocket_helper.broadcast('close_upload_box', 'success') self.finish('success') # Nope, I'm sending "success" self.f.close() else: time.sleep(5) - websocket_helper.broadcast('close_upload_box', 'error') + if files_left == 0: + websocket_helper.broadcast('close_upload_box', 'error') self.finish('error') def data_received(self, data): diff --git a/app/frontend/templates/panel/server_files.html b/app/frontend/templates/panel/server_files.html index 24476d5c..aedd93f2 100644 --- a/app/frontend/templates/panel/server_files.html +++ b/app/frontend/templates/panel/server_files.html @@ -525,7 +525,7 @@ window.location.href = "/panel/server_detail?id={{ data['server_stats']['server_id']['server_id'] }}&subpage=files" } - function sendFile(file, path, server_id, onProgress){ + function sendFile(file, path, server_id, left, onProgress){ var xmlHttpRequest = new XMLHttpRequest(); var token = getCookie("_xsrf") var fileName = file.name @@ -537,6 +537,7 @@ xmlHttpRequest.setRequestHeader('X-XSRFToken', token); xmlHttpRequest.setRequestHeader('X-Content-Disposition', 'attachment; filename="' + fileName + '"'); xmlHttpRequest.setRequestHeader('X-Path', path); + xmlHttpRequest.setRequestHeader('X-Files-Left', left); xmlHttpRequest.setRequestHeader('X-FileName', fileName); xmlHttpRequest.setRequestHeader('X-ServerId', "{{ data['server_stats']['server_id']['server_id'] }}"); xmlHttpRequest.upload.addEventListener('progress', (event) => @@ -583,17 +584,18 @@ label: "Upload", className: "btn-default", callback: async function () { + var height = files.files.length*50; + + var waitMessage = '

'+ + ''+ + 'Please wait while we upload your files... This may take a while.
'+ + 'DO NOT CLOSE THIS PAGE.'+ + '

'+ + '
'+ + '
' files = document.getElementById("files"); uploadWaitDialog = bootbox.dialog({ - message: ` -

- - Please wait while we upload your files... This may take a while.
- DO NOT CLOSE THIS PAGE. -

-
-
- `, + message: waitMessage, closeButton: false }); let nFiles = files.files.length; @@ -603,23 +605,24 @@ hideUploadBox(); break; } - console.log(files.files[i]); + console.log(files.files[i].name); const progressHtml = ` -
- ${path + '/' + files.files[i]}: -
+ ${files.files[i].name}: +
-
+

`; $('#upload-progress-bar-parent').append(progressHtml); - sendFile(files.files[i], path, server_id, (progress) => { + console.log(files.files.length) + sendFile(files.files[i], path, server_id, files.files.length - i - 1, (progress) => { $(`#upload-progress-bar-${i + 1}`).attr('aria-valuenow', progress) $(`#upload-progress-bar-${i + 1}`).css('width', progress + '%') }); @@ -756,7 +759,6 @@ hideUploadBox(); }); } - function hideUploadBox(){ if (!uploadWaitDialog) return; uploadWaitDialog.modal('hide'); diff --git a/app/frontend/templates/panel/server_term.html b/app/frontend/templates/panel/server_term.html index 0b660a29..80db63d0 100644 --- a/app/frontend/templates/panel/server_term.html +++ b/app/frontend/templates/panel/server_term.html @@ -67,7 +67,7 @@ - + T