function show_file_tree() { $("#dir_select").modal(); } function getDirView(event = false) { if (event) { try { let path = event.target.parentElement.getAttribute('data-path'); if (event.target.parentElement.classList.contains('clicked')) { if ($(`#${path}span`).hasClass('files-tree-title')) { $(`#${path}ul`).toggleClass("d-block"); $(`#${path}span`).toggleClass("tree-caret-down"); } return; } else { getTreeView(path); } } catch { console.log("Well that failed"); } } else if ($("#root_files_button").hasClass("clicked")) { getTreeView($("#zip_server_path").val(), true); } else { getTreeView($("#file-uploaded").val(), true, true); } } async function getTreeView(path, unzip = false, upload = false) { const token = getCookie("_xsrf"); console.log("IN TREE VIEW") console.log({ "page": "import", "folder": path, "upload": upload, "unzip": unzip }); let res = await fetch(`/api/v2/import/file/unzip/`, { method: 'POST', headers: { 'X-XSRFToken': token }, body: JSON.stringify({ "page": "import", "folder": path, "upload": upload, "unzip": unzip }), }); let responseData = await res.json(); if (responseData.status === "ok") { console.log(responseData); process_tree_response(responseData); let x = document.querySelector('.bootbox'); if (x) { x.remove() } x = document.querySelector('.modal-backdrop'); if (x) { x.remove() } show_file_tree(); } else { bootbox.alert({ title: responseData.status, message: responseData.error }); } } function process_tree_response(response) { const styles = window.getComputedStyle(document.getElementById("lower_half")); //If this value is still hidden we know the user is executing a zip import and not an upload if (styles.visibility === "hidden") { document.getElementById('zip_submit').disabled = false; } else { document.getElementById('upload_submit').disabled = false; } let path = response.data.root_path.path; $(".root-input").val(response.data.root_path.path); let text = `