From 1d888b290cb21efdb6c2ffe4a3953bb3936fee96 Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Fri, 17 Feb 2023 21:01:56 +0100 Subject: [PATCH] fix de tout l'ui du file explorer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reste à faire download/upload/delete + ajout des boutons --- Server/FileExplorer/index.html | 148 +++++++++++++++++++++------------ Server/FileExplorer/style.css | 14 ++-- Server/Server.py | 36 +++++--- 3 files changed, 130 insertions(+), 68 deletions(-) diff --git a/Server/FileExplorer/index.html b/Server/FileExplorer/index.html index 44497ab..6320fa5 100644 --- a/Server/FileExplorer/index.html +++ b/Server/FileExplorer/index.html @@ -28,6 +28,7 @@ data-show-pagination-switch="false"> + Nom Modifié le Taille @@ -38,62 +39,107 @@ diff --git a/Server/FileExplorer/style.css b/Server/FileExplorer/style.css index 006b9c1..56c0f87 100644 --- a/Server/FileExplorer/style.css +++ b/Server/FileExplorer/style.css @@ -77,20 +77,20 @@ th { text-align: center; } -td:nth-child(1) { /* targets the first column */ - cursor: pointer; +td:nth-child(2) { /* targets the first column */ margin-left: 20%; + cursor: default; } -td:nth-child(1):hover { +td:nth-child(2):hover { color: #5660f1; } -td:nth-child(2) { /* targets the second column */ +td:nth-child(3) { /* targets the second column */ text-align: center; } -td:nth-child(3) { /* targets the third column */ +td:nth-child(4) { /* targets the third column */ text-align: right; } @@ -103,3 +103,7 @@ td:nth-child(3) { /* targets the third column */ position: relative; top: -7px; } + +.checkbox_style { + transform: scale(1.5); +} diff --git a/Server/Server.py b/Server/Server.py index 4ea5a66..e4036a3 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -43,18 +43,21 @@ def CAESAR_DECRYPT(in_s: str) -> str : return r def convert_size(size_bytes): - if size_bytes == 0: - return "0 O" - size_name = ("O", "Ko", "Mo", "Go", "To", "Po", "Eo", "Zo", "Yo") - i = int(math.floor(math.log(size_bytes, 1024))) - p = math.pow(1024, i) - s = round(size_bytes / p, 2) - return "%s %s" % (s, size_name[i]) + if size_bytes == 0: + return "0 O" + size_name = ("O", "Ko", "Mo", "Go", "To", "Po", "Eo", "Zo", "Yo") + try : + i = int(math.floor(math.log(size_bytes, 1024))) + except : + return "N" + p = math.pow(1024, i) + s = round(size_bytes / p, 2) + return "%s %s" % (s, size_name[i]) app = Flask(__name__) # Disable Flask's default logging -#log = logging.getLogger('werkzeug') -#log.disabled = True +log = logging.getLogger('werkzeug') +log.disabled = True @app.route('/') def serve_file(filename): @@ -66,10 +69,12 @@ def index() : index_path = os.path.join(os.getcwd(), 'FileExplorer/index.html') return send_file(index_path) +FILES_=[] path_file_ex = "" @app.route('/get_data', methods=['POST']) def get_data() : global path_file_ex + global FILES_ data = [] got_path = request.get_data().decode("latin-1") @@ -93,8 +98,6 @@ def get_data() : path_file_ex = "" i = -1 - print(path_file_ex.split("/")) - if CONNECT_CLIENTS != [] : data.append({"url" : f"..", "modified":"", "size" : ""}) @@ -121,11 +124,18 @@ def get_data() : client_num = int(path_parts.pop(0).replace("Client n°","")) if client_num != i : continue path_parts[0] = path_parts[0] + ":" + + if path_parts[len(path_parts)-2] in FILES_ : + path_parts.pop(len(path_parts)-2) + path_file_ex_parts = path_file_ex.split("/") + path_file_ex_parts.pop(len(path_file_ex_parts)-2) + path_file_ex = '/'.join(path_file_ex_parts) path_file_ex_2 = '/'.join(path_parts) client.send(CAESAR(path_file_ex_2 + "\0").encode()) - + files = recv_message_ret(client).decode("latin-1") + FILES_ = [] for f in files.split("/") : f = CAESAR_DECRYPT(f) #print(path_file_ex + f) @@ -142,6 +152,8 @@ def get_data() : taille = convert_size(int(taille)) if taille == "0 O" : is_dir = True + else : + FILES_.append(f) if is_dir : data.append({"url": f"\"Folder{f}",