diff --git a/Server/FileExplorer/images/file.png b/Server/FileExplorer/images/file.png new file mode 100644 index 0000000..361dcd6 Binary files /dev/null and b/Server/FileExplorer/images/file.png differ diff --git a/Server/FileExplorer/images/folder.png b/Server/FileExplorer/images/folder.png new file mode 100644 index 0000000..b1a23e1 Binary files /dev/null and b/Server/FileExplorer/images/folder.png differ diff --git a/Server/FileExplorer/index.html b/Server/FileExplorer/index.html index cb09b75..44497ab 100644 --- a/Server/FileExplorer/index.html +++ b/Server/FileExplorer/index.html @@ -55,16 +55,27 @@ } }, "columns": [ - { "data": "url" }, + { + "data": null, + "render": function(data, type, row) { + if (data.url == "..") { + //data.url = "a"; + } + return data.url; + } + }, { "data": "modified" }, { "data": "size" } - ] + ], + "createdRow": function(row, data, dataIndex) { + $(row).addClass('d-flex align-items-center'); + } }); // add click event listener to table rows $('#explorer tbody').on('click', 'tr', function() { // fetch data from the server and update the table // Get the clicked element's text - var clickedText = $('#explorer').DataTable().cell(this, 0).data(); + var clickedText = $('#explorer').DataTable().cell(this, 0).data().url; // Send an AJAX request to the Flask app to retrieve the updated data $.ajax({ diff --git a/Server/FileExplorer/style.css b/Server/FileExplorer/style.css index 60eca88..006b9c1 100644 --- a/Server/FileExplorer/style.css +++ b/Server/FileExplorer/style.css @@ -93,3 +93,13 @@ td:nth-child(2) { /* targets the second column */ td:nth-child(3) { /* targets the third column */ text-align: right; } + +#folder { + width: 2%; + height: auto; +} + +.centered { + position: relative; + top: -7px; +} diff --git a/Server/Server.py b/Server/Server.py index 6607b7f..4ea5a66 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -75,6 +75,7 @@ def get_data() : got_path = request.get_data().decode("latin-1") got_path = urllib.parse.unquote_plus(got_path) if got_path and got_path != "{}" : + if "img" in got_path : got_path = got_path.split("centered\">")[1] got_path = got_path.replace("","").replace("","").replace("folder_path=","") if got_path == ".." : @@ -120,6 +121,7 @@ def get_data() : client_num = int(path_parts.pop(0).replace("Client n°","")) if client_num != i : continue path_parts[0] = path_parts[0] + ":" + path_file_ex_2 = '/'.join(path_parts) client.send(CAESAR(path_file_ex_2 + "\0").encode()) @@ -135,7 +137,18 @@ def get_data() : infos = recv_message_ret(client).decode("latin-1") taille, modified = infos.split("/") - data.append({"url": f"{f}", "modified": f"{modified}", "size":f"{convert_size(int(taille))}"}) + is_dir = False + if taille != "N" : + taille = convert_size(int(taille)) + if taille == "0 O" : + is_dir = True + + if is_dir : + data.append({"url": f"\"Folder{f}", + "modified": f"{modified}", "size": f"{taille}"}) + else : + data.append({"url": f"\"File{f}", + "modified": f"{modified}", "size": f"{taille}"}) json_data = jsonify({"data":data}) return json_data