From 9cffe4e427cac4ac9036c1b11b3e4e60e499d923 Mon Sep 17 00:00:00 2001 From: H4CK3R-01 Date: Tue, 6 Jul 2021 23:15:18 +0200 Subject: [PATCH] - design fixes - auto logout - upload file --- .idea/.gitignore | 5 ++++ .idea/Webengineering-Filemanager.iml | 12 ++++++++ .idea/discord.xml | 6 ++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ Frontend/index.html | 2 ++ Frontend/static/css/index.css | 1 - Frontend/static/css/modal.css | 10 +++---- Frontend/static/js/index.js | 42 ++++++++++----------------- Frontend/static/js/modal.js | 20 ++++++++----- Frontend/static/js/tools.js | 33 +++++++++++++++++++++ Frontend/static/js/views.js | 24 +++++++++++---- WebService/auth.db | Bin 0 -> 12288 bytes 13 files changed, 123 insertions(+), 46 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/Webengineering-Filemanager.iml create mode 100644 .idea/discord.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 WebService/auth.db diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Webengineering-Filemanager.iml b/.idea/Webengineering-Filemanager.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/Webengineering-Filemanager.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..cd711a0 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..27c39b5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Frontend/index.html b/Frontend/index.html index a25fb47..3e0c3e7 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -2,6 +2,8 @@ + + File Manager diff --git a/Frontend/static/css/index.css b/Frontend/static/css/index.css index f7642f5..873c9af 100644 --- a/Frontend/static/css/index.css +++ b/Frontend/static/css/index.css @@ -17,7 +17,6 @@ margin: 5px; height: 100%; width: 30%; - max-width: 400px; border-right: #404040 2px solid; } diff --git a/Frontend/static/css/modal.css b/Frontend/static/css/modal.css index 17bd541..ca6a48c 100644 --- a/Frontend/static/css/modal.css +++ b/Frontend/static/css/modal.css @@ -2,11 +2,9 @@ position: fixed; z-index: 100000; padding-top: 100px; - left: 0; - top: 0; + padding-bottom: 100px; width: 100%; - height: 100%; - overflow: auto; + height: calc(100% - 200px); background-color: rgba(0, 0, 0, 0.8); } @@ -16,6 +14,7 @@ padding: 20px; border: 1px solid #888; width: 90%; + height: 100%; border-radius: 5px; display: flex; flex-direction: column; @@ -51,9 +50,10 @@ #modal_content { display: flex; + flex-direction: column; justify-content: center; align-items: center; background-color: #fefefe; width: 100%; - height: calc(100% - 16px - 2em); + height: 90%; } \ No newline at end of file diff --git a/Frontend/static/js/index.js b/Frontend/static/js/index.js index 95485f2..afd3b42 100644 --- a/Frontend/static/js/index.js +++ b/Frontend/static/js/index.js @@ -1,5 +1,6 @@ -base_url = 'http://localhost:8080'; //'http://192.168.178.98:8080'; -file_path = []; +let base_url = 'http://localhost:8080'; //'http://192.168.178.98:8080'; +let file_path = []; +let timeout = null; window.addEventListener('load', function () { if (sessionStorage.getItem("authorization") !== null) { @@ -20,17 +21,6 @@ window.addEventListener('popstate', function () { function path_changed() { let curr_dir = get_curr_path(); - - // TODO show opened directory in tree-view - // let tree_elem = document.getElementById(curr_dir.replaceAll('/', '-')); - // console.log(curr_dir.replaceAll('/', '-')) - // if(tree_elem !== undefined && tree_elem !== null) { - // tree_elem.classList.toggle('folder-open'); - // - // if (tree_elem.parentElement.querySelector(".nested") !== null) { - // tree_elem.parentElement.querySelector(".nested").classList.toggle("active"); - // } - // } httpGetAsync(base_url + curr_dir, null, show_files); } @@ -46,12 +36,14 @@ function login() { create_logout_view(); create_tree_data(''); path_changed(); + + timeout = startTimeout(); } else if (code === 401) { create_error_view("Wrong username or password!"); } else { try_to_parse_error(response); } - }) + }); } function show_files(response, code) { @@ -111,7 +103,7 @@ function add_file() { } function upload_file() { - let content = ``; + let content = `
`; let footer = ` `; create_modal('Upload File', content, footer); @@ -130,17 +122,13 @@ function api_create_folder(name) { }); } -function api_upload_file() { // TODO - let files = document.getElementById('modal_content').children[0].children[0].files[0]; - console.log(files); - - // let formData = new FormData(); - // formData.append('local', files, files.name); - // - // httpPostAsync(base_url + get_curr_path() + '/' + files.name, 'newFile=' + formData, function (response, code) { - // console.log(code) - // console.log(response) - // }) +function api_upload_file() { + let formData = new FormData(document.getElementById('modal_content').children[0]); + let filename = document.getElementById('modal_content').children[0].children[0].files[0].name; + httpUploadAsync(base_url + get_curr_path() + '/' + filename, formData, function () { + remove_modal(); + path_changed(); + }); } function get_curr_path() { @@ -154,5 +142,7 @@ function get_curr_path() { curr_dir = '/' + curr_dir; } + if(curr_dir === '') curr_dir = '/'; + return curr_dir; } \ No newline at end of file diff --git a/Frontend/static/js/modal.js b/Frontend/static/js/modal.js index 24243ea..948dd8b 100644 --- a/Frontend/static/js/modal.js +++ b/Frontend/static/js/modal.js @@ -2,20 +2,24 @@ function create_modal(title, content, footer) { let div = document.createElement('div'); div.innerHTML = `