Fix id mismatch zip upload import

This commit is contained in:
Andrew 2022-12-15 18:48:15 -05:00
parent 551020f738
commit c74aeb5dde
2 changed files with 52 additions and 25 deletions

View File

@ -424,8 +424,8 @@
<input type="text" class="form-control" id="zip_root_path" name="zip_root_path"> <input type="text" class="form-control" id="zip_root_path" name="zip_root_path">
</div> </div>
</div> </div>
<div class="modal fade" id="dir_select" tabindex="-1" role="dialog" aria-labelledby="dir_select" <div class="modal fade" id="dir_upload_select" tabindex="-1" role="dialog"
aria-hidden="true"> aria-labelledby="dir_select" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -436,7 +436,7 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="tree-ctx-item" id="main-tree-div" data-path="" <div class="tree-ctx-item" id="main-tree-div-upload" data-path=""
style="overflow: scroll; max-height:75%;"> style="overflow: scroll; max-height:75%;">
<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked> <input type="radio" id="main-tree-input-upload" name="root_path" value="" checked>
<span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""> <span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path="">
@ -558,7 +558,7 @@
{% block js%} {% block js%}
<script> <script>
var upload;
var file; var file;
function sendFile() { function sendFile() {
file = $("#file")[0].files[0] file = $("#file")[0].files[0]
@ -597,8 +597,9 @@
document.getElementById("root_upload_button").addEventListener("click", function () { document.getElementById("root_upload_button").addEventListener("click", function () {
if (file) { if (file) {
upload = true;
if (document.getElementById('root_upload_button').classList.contains('clicked')) { if (document.getElementById('root_upload_button').classList.contains('clicked')) {
document.getElementById('main-tree-div').innerHTML = '<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked><span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>' document.getElementById('main-tree-div-upload').innerHTML = '<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked><span id="main-tree-upload" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>'
} else { } else {
document.getElementById('root_upload_button').classList.add('clicked') document.getElementById('root_upload_button').classList.add('clicked')
} }
@ -692,7 +693,11 @@
} }
function show_file_tree() { function show_file_tree() {
$("#dir_select").modal(); if (upload) {
$("#dir_upload_select").modal();
} else {
$("#dir_select").modal();
}
} }
function getTreeView(path) { function getTreeView(path) {
@ -716,12 +721,20 @@
dataArr = data.split('\n'); dataArr = data.split('\n');
serverDir = dataArr.shift(); // Remove & return first element (server directory) serverDir = dataArr.shift(); // Remove & return first element (server directory)
text = dataArr.join('\n'); text = dataArr.join('\n');
if (styles.visibility === "hidden") {
try { try {
document.getElementById('main-tree-div').innerHTML += text; document.getElementById('main-tree-div').innerHTML += text;
document.getElementById('main-tree').parentElement.classList.add("clicked"); document.getElementById('main-tree').parentElement.classList.add("clicked");
} catch { } catch {
document.getElementById('files-tree').innerHTML = text; document.getElementById('files-tree').innerHTML = text;
}
} else {
try {
document.getElementById('main-tree-div-upload').innerHTML += text;
document.getElementById('main-tree-upload').parentElement.classList.add("clicked");
} catch {
document.getElementById('files-tree').innerHTML = text;
}
} }

View File

@ -552,8 +552,8 @@
<input type="text" class="form-control" id="zip_root_path" name="zip_root_path"> <input type="text" class="form-control" id="zip_root_path" name="zip_root_path">
</div> </div>
</div> </div>
<div class="modal fade" id="dir_select" tabindex="-1" role="dialog" aria-labelledby="dir_select" <div class="modal fade" id="dir_upload_select" tabindex="-1" role="dialog"
aria-hidden="true"> aria-labelledby="dir_select" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -564,10 +564,11 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="tree-ctx-item" id="main-tree-div" data-path="" <div class="tree-ctx-item" id="main-tree-div-upload" data-path=""
style="overflow: scroll; max-height:75%;"> style="overflow: scroll; max-height:75%;">
<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked> <input type="radio" id="main-tree-input-upload" name="root_path" value="" checked>
<span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""> <span id="main-tree-upload" class="files-tree-title tree-caret-down root-dir"
data-path="">
<i class="far fa-folder"></i> <i class="far fa-folder"></i>
<i class="far fa-folder-open"></i> <i class="far fa-folder-open"></i>
{{ translate('serverFiles', 'files', data['lang']) }} {{ translate('serverFiles', 'files', data['lang']) }}
@ -799,6 +800,7 @@
{% block js %} {% block js %}
<script> <script>
var upload = false;
var file; var file;
function sendFile() { function sendFile() {
file = $("#file")[0].files[0] file = $("#file")[0].files[0]
@ -862,8 +864,9 @@
document.getElementById("root_upload_button").addEventListener("click", function () { document.getElementById("root_upload_button").addEventListener("click", function () {
if (file) { if (file) {
upload = true;
if (document.getElementById('root_upload_button').classList.contains('clicked')) { if (document.getElementById('root_upload_button').classList.contains('clicked')) {
document.getElementById('main-tree-div').innerHTML = '<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked><span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>' document.getElementById('main-tree-div-upload').innerHTML = '<input type="radio" id="main-tree-input-upload" name="root_path" value="" checked><span id="main-tree-upload" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>'
} else { } else {
document.getElementById('root_upload_button').classList.add('clicked') document.getElementById('root_upload_button').classList.add('clicked')
} }
@ -926,7 +929,11 @@
} }
function show_file_tree() { function show_file_tree() {
$("#dir_select").modal(); if (upload) {
$("#dir_upload_select").modal();
} else {
$("#dir_select").modal();
}
} }
function check_sizes(a, b, changed) { function check_sizes(a, b, changed) {
@ -961,15 +968,22 @@
dataArr = data.split('\n'); dataArr = data.split('\n');
serverDir = dataArr.shift(); // Remove & return first element (server directory) serverDir = dataArr.shift(); // Remove & return first element (server directory)
text = dataArr.join('\n'); text = dataArr.join('\n');
if (styles.visibility === "hidden") {
try { try {
document.getElementById('main-tree-div').innerHTML += text; document.getElementById('main-tree-div').innerHTML += text;
document.getElementById('main-tree').parentElement.classList.add("clicked"); document.getElementById('main-tree').parentElement.classList.add("clicked");
} catch { } catch {
document.getElementById('files-tree').innerHTML = text; document.getElementById('files-tree').innerHTML = text;
}
} else {
try {
document.getElementById('main-tree-div-upload').innerHTML += text;
document.getElementById('main-tree-upload').parentElement.classList.add("clicked");
} catch {
document.getElementById('files-tree').innerHTML = text;
}
} }
document.getElementsByClassName('files-tree-title')[0].setAttribute('data-path', serverDir); document.getElementsByClassName('files-tree-title')[0].setAttribute('data-path', serverDir);
document.getElementsByClassName('files-tree-title')[0].setAttribute('data-name', 'Files'); document.getElementsByClassName('files-tree-title')[0].setAttribute('data-name', 'Files');