mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
some tweaks
This commit is contained in:
parent
64520a75c5
commit
edccade28f
@ -981,8 +981,7 @@ header .actions {
|
|||||||
padding: 2em;
|
padding: 2em;
|
||||||
max-width: 25em;
|
max-width: 25em;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
max-height: 95vh;
|
max-height: 95%;
|
||||||
overflow: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.prompt h3,
|
.prompt h3,
|
||||||
@ -1030,6 +1029,8 @@ header .actions {
|
|||||||
|
|
||||||
.prompt .file-list {
|
.prompt .file-list {
|
||||||
flex-direction: initial;
|
flex-direction: initial;
|
||||||
|
max-height: 50vh;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prompt .file-list ul {
|
.prompt .file-list ul {
|
||||||
|
@ -138,6 +138,7 @@ webdav.convertURL = function (url) {
|
|||||||
webdav.move = function (oldLink, newLink) {
|
webdav.move = function (oldLink, newLink) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let request = new XMLHttpRequest();
|
let request = new XMLHttpRequest();
|
||||||
|
|
||||||
request.open('MOVE', webdav.convertURL(oldLink), true);
|
request.open('MOVE', webdav.convertURL(oldLink), true);
|
||||||
request.setRequestHeader('Destination', webdav.convertURL(newLink));
|
request.setRequestHeader('Destination', webdav.convertURL(newLink));
|
||||||
request.onload = () => {
|
request.onload = () => {
|
||||||
|
@ -358,8 +358,7 @@ window.addEventListener("resize", () => {
|
|||||||
listing.updateColumns();
|
listing.updateColumns();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listing.selectMoveFolder = function (event) {
|
||||||
function selectMoveFolder(event) {
|
|
||||||
if(event.target.getAttribute("aria-selected") === "true") {
|
if(event.target.getAttribute("aria-selected") === "true") {
|
||||||
event.target.setAttribute("aria-selected", false);
|
event.target.setAttribute("aria-selected", false);
|
||||||
return;
|
return;
|
||||||
@ -372,63 +371,73 @@ function selectMoveFolder(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadNextFolder(event) {
|
listing.getJSON = function (link) {
|
||||||
let request = new XMLHttpRequest(),
|
return new Promise((resolve, reject) => {
|
||||||
prompt = document.querySelector("form.prompt.active");
|
let request = new XMLHttpRequest();
|
||||||
|
request.open("GET", link);
|
||||||
|
request.setRequestHeader("Accept", "application/json");
|
||||||
|
request.onload = () => {
|
||||||
|
if(request.status == 200) {
|
||||||
|
resolve(request.responseText);
|
||||||
|
} else {
|
||||||
|
reject(request.statusText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.onerror = () => reject(request.statusText);
|
||||||
|
request.send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
prompt.addEventListener("submit", moveSelected);
|
listing.moveMakeItem = function (url, name) {
|
||||||
console.log(event);
|
let node = document.createElement("li");
|
||||||
request.open("GET", event.target.dataset.url);
|
|
||||||
request.setRequestHeader("Accept", "application/json");
|
node.dataset.url = url;
|
||||||
request.send();
|
node.innerHTML = name;
|
||||||
request.onreadystatechange = function () {
|
node.setAttribute("aria-selected", false);
|
||||||
if(request.readyState == 4 && request.status == 200) {
|
|
||||||
|
node.addEventListener("dblclick", listing.moveDialogNext);
|
||||||
|
node.addEventListener("click", listing.selectMoveFolder);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
listing.moveDialogNext = function (event) {
|
||||||
|
let request = new XMLHttpRequest(),
|
||||||
|
prompt = document.querySelector("form.prompt.active"),
|
||||||
|
list = prompt.querySelector("div.file-list ul");
|
||||||
|
|
||||||
|
prompt.addEventListener("submit", listing.moveSelected);
|
||||||
|
|
||||||
|
listing.getJSON(event.target.dataset.url)
|
||||||
|
.then((data) => {
|
||||||
let dirs = 0;
|
let dirs = 0;
|
||||||
|
|
||||||
prompt.querySelector("ul").innerHTML = "";
|
prompt.querySelector("ul").innerHTML = "";
|
||||||
prompt.querySelector('code').innerHTML = event.target.dataset.url;
|
prompt.querySelector('code').innerHTML = event.target.dataset.url;
|
||||||
|
|
||||||
if(prompt.querySelector('code').innerHTML != baseURL + "/") {
|
if(event.target.dataset.url != baseURL + "/") {
|
||||||
let newNode = document.createElement("li");
|
let node = listing.moveMakeItem(removeLastDirectoryPartOf(event.target.dataset.url) + "/", "..")
|
||||||
newNode.dataset.url = removeLastDirectoryPartOf(event.target.dataset.url) + "/";
|
list.appendChild(node);
|
||||||
newNode.innerHTML = "..";
|
|
||||||
newNode.setAttribute("aria-selected", false);
|
|
||||||
newNode.addEventListener("dblclick", loadNextFolder);
|
|
||||||
newNode.addEventListener("click", selectMoveFolder);
|
|
||||||
|
|
||||||
prompt.querySelector("div.file-list ul").appendChild(newNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(JSON.parse(request.response) == null) {
|
if(JSON.parse(data) == null) {
|
||||||
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(let f of JSON.parse(data)) {
|
||||||
for(let f of JSON.parse(request.response)) {
|
|
||||||
if(f.IsDir === true) {
|
if(f.IsDir === true) {
|
||||||
dirs++;
|
dirs++;
|
||||||
|
list.appendChild(listing.moveMakeItem(f.URL, f.Name));
|
||||||
let newNode = document.createElement("li");
|
|
||||||
newNode.dataset.url = f.URL;
|
|
||||||
newNode.innerHTML = f.Name;
|
|
||||||
newNode.setAttribute("aria-selected", false);
|
|
||||||
|
|
||||||
newNode.addEventListener("dblclick", loadNextFolder);
|
|
||||||
newNode.addEventListener("click", selectMoveFolder);
|
|
||||||
|
|
||||||
prompt.querySelector("div.file-list ul").appendChild(newNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dirs === 0) {
|
if(dirs === 0)
|
||||||
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
||||||
}
|
})
|
||||||
}
|
.catch(e => console.log(e));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveSelected(event) {
|
listing.moveSelected = function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
let promises = [];
|
let promises = [];
|
||||||
@ -436,9 +445,15 @@ function moveSelected(event) {
|
|||||||
|
|
||||||
for(let file of selectedItems) {
|
for(let file of selectedItems) {
|
||||||
let fileElement = document.getElementById(file),
|
let fileElement = document.getElementById(file),
|
||||||
destFolder = event.target.querySelector("p code").innerHTML;
|
destFolder = event.target.querySelector("p code").innerHTML;
|
||||||
if(event.srcElement.querySelector("li[aria-selected=true]") != null) destFolder = event.srcElement.querySelector("li[aria-selected=true]").innerHTML;
|
|
||||||
promises.push(webdav.move(fileElement.dataset.url, "/" + destFolder + "/" + fileElement.querySelector(".name").innerHTML));
|
if(event.srcElement.querySelector("li[aria-selected=true]") != null)
|
||||||
|
destFolder = event.srcElement.querySelector("li[aria-selected=true]").innerHTML;
|
||||||
|
|
||||||
|
let destPath = "/" + destFolder + "/" + fileElement.querySelector(".name").innerHTML;
|
||||||
|
destPath = destPath.replace('//', '/');
|
||||||
|
|
||||||
|
promises.push(webdav.move(fileElement.dataset.url, destPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
@ -452,62 +467,40 @@ function moveSelected(event) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveEvent(event) {
|
listing.moveEvent = function (event) {
|
||||||
if(event.currentTarget.classList.contains("disabled"))
|
if(event.currentTarget.classList.contains("disabled"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let request = new XMLHttpRequest();
|
listing.getJSON(window.location.pathname)
|
||||||
request.open("GET", window.location.pathname, true);
|
.then((data) => {
|
||||||
request.setRequestHeader("Accept", "application/json");
|
let prompt = document.importNode(templates.move.content, true),
|
||||||
request.send();
|
list = prompt.querySelector("div.file-list ul"),
|
||||||
request.onreadystatechange = function () {
|
dirs = 0;
|
||||||
if(request.readyState == 4) {
|
|
||||||
if(request.status == 200) {
|
|
||||||
let prompt = document.importNode(templates.move.content, true),
|
|
||||||
dirs = 0;
|
|
||||||
|
|
||||||
prompt.querySelector("form").addEventListener("submit", moveSelected);
|
prompt.querySelector("form").addEventListener("submit", listing.moveSelected);
|
||||||
prompt.querySelector('code').innerHTML = window.location.pathname;
|
prompt.querySelector('code').innerHTML = window.location.pathname;
|
||||||
|
|
||||||
if(window.location.pathname !== baseURL + "/") {
|
if(window.location.pathname !== baseURL + "/") {
|
||||||
let newNode = document.createElement("li");
|
list.appendChild(listing.moveMakeItem(removeLastDirectoryPartOf(window.location.pathname) + "/", ".."));
|
||||||
newNode.dataset.url = removeLastDirectoryPartOf(window.location.pathname) + "/";
|
|
||||||
newNode.innerHTML = "..";
|
|
||||||
newNode.setAttribute("aria-selected", false);
|
|
||||||
newNode.addEventListener("dblclick", loadNextFolder);
|
|
||||||
newNode.addEventListener("click", selectMoveFolder);
|
|
||||||
|
|
||||||
prompt.querySelector("div.file-list ul").appendChild(newNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(let f of JSON.parse(request.response)) {
|
|
||||||
if(f.IsDir === true) {
|
|
||||||
dirs++;
|
|
||||||
|
|
||||||
let newNode = document.createElement("li");
|
|
||||||
newNode.dataset.url = f.URL;
|
|
||||||
newNode.innerHTML = f.Name;
|
|
||||||
newNode.setAttribute("aria-selected", false);
|
|
||||||
|
|
||||||
newNode.addEventListener("dblclick", loadNextFolder);
|
|
||||||
newNode.addEventListener("click", selectMoveFolder);
|
|
||||||
|
|
||||||
prompt.querySelector("div.file-list ul").appendChild(newNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dirs === 0) {
|
|
||||||
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.appendChild(prompt);
|
|
||||||
document.querySelector(".overlay").classList.add("active");
|
|
||||||
document.querySelector(".prompt").classList.add("active");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for(let f of JSON.parse(data)) {
|
||||||
|
if(f.IsDir === true) {
|
||||||
|
dirs++;
|
||||||
|
list.appendChild(listing.moveMakeItem(f.URL, f.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dirs === 0) {
|
||||||
|
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(prompt);
|
||||||
|
document.querySelector(".overlay").classList.add("active");
|
||||||
|
document.querySelector(".prompt").classList.add("active");
|
||||||
|
})
|
||||||
|
.catch(e => console.log(e));
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', event => {
|
document.addEventListener('DOMContentLoaded', event => {
|
||||||
listing.updateColumns();
|
listing.updateColumns();
|
||||||
@ -519,7 +512,7 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||||||
buttons.download = document.getElementById('download');
|
buttons.download = document.getElementById('download');
|
||||||
buttons.move = document.getElementById("move");
|
buttons.move = document.getElementById("move");
|
||||||
|
|
||||||
buttons.move.addEventListener("click", moveEvent);
|
buttons.move.addEventListener("click", listing.moveEvent);
|
||||||
|
|
||||||
document.getElementById('multiple-selection-activate').addEventListener('click', event => {
|
document.getElementById('multiple-selection-activate').addEventListener('click', event => {
|
||||||
listing.selectMultiple = true;
|
listing.selectMultiple = true;
|
||||||
@ -569,4 +562,4 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||||||
document.addEventListener("drop", listing.documentDrop, false);
|
document.addEventListener("drop", listing.documentDrop, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user