diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index 7db690f..961c520 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -57,11 +57,11 @@ def listFiles(_hash = None): msg = "Log in with an Admin privlidged user to view the requested path!" is_locked = view.is_folder_locked(_hash) if is_locked and not oidc.user_loggedin: - return msgHandler.createMessageJSON("danger") + return msgHandler.createMessageJSON("danger", msg) elif is_locked and oidc.user_loggedin: isAdmin = oidc.user_getfield("isAdmin") if isAdmin != "yes" : - return msgHandler.createMessageJSON("danger") + return msgHandler.createMessageJSON("danger", msg) if dot_dots[0][1] != _hash and dot_dots[1][1] != _hash: path = view.get_path_part_from_hash(_hash) diff --git a/src/core/static/js/ajax.js b/src/core/static/js/ajax.js index 4c95d39..9b3ae14 100644 --- a/src/core/static/js/ajax.js +++ b/src/core/static/js/ajax.js @@ -18,11 +18,6 @@ const manageFavoritesAjax = async (action) => { doAjax("api/manage-favorites/" + action, data, "manage-favorites"); } -const lockFoldersAjax = async () => { - const data = "empty=NULL"; - doAjax("logout", data, "lock-folders"); -} - const doAjax = (actionPath, data, action) => { let xhttp = new XMLHttpRequest(); diff --git a/src/core/static/js/events.js b/src/core/static/js/events.js index 0535780..0d354f2 100644 --- a/src/core/static/js/events.js +++ b/src/core/static/js/events.js @@ -6,3 +6,38 @@ document.body.onload = (eve) => { getFavesAjax(); reloadDirectory(); } + +const openFile = (eve) => { + let target = eve.target; + let hash = target.getAttribute("app"); + listFilesAjax(hash); +} + +const openFileLocally = (eve) => { + let target = eve.target; + let hash = target.getAttribute("app"); +} + +$( "#search-files-field" ).bind( "keyup", async function(eve) { + searchPage(); +}); + +$( "#clear-search-btn" ).bind( "click", async function(eve) { + clearSearch(); +}); + +$( "#refresh-btn" ).bind( "click", async function(eve) { + reloadDirectory(); +}); + +$( "#back-btn" ).bind( "click", async function(eve) { + goUpADirectory(); +}); + +$( "#tggl-faves-btn" ).bind( "click", async function(eve) { + manageFavorites(eve.target); +}); + +$( "#scroll-files-to-top-btn" ).bind( "click", async function(eve) { + scrollFilesToTop(); +}); diff --git a/src/core/static/js/post-ajax.js b/src/core/static/js/post-ajax.js index 9b173e9..3597524 100644 --- a/src/core/static/js/post-ajax.js +++ b/src/core/static/js/post-ajax.js @@ -45,10 +45,7 @@ const generateFavesList = (data) => { const updateHTMLDirList = async (data) => { - // let dirs = data.list.dirs[0]; - // let videos = data.list.vids[0]; let images = data.list.images[0]; - // let files = data.list.files[0]; let isInFaves = data.in_fave; let background_image = (images[0]) ? images[0][0] : ""; @@ -73,112 +70,4 @@ const updateHTMLDirList = async (data) => { renderFilesList(data.list); - -// clearChildNodes(insertArea); -// // Insert dirs -// let dirClone = document.importNode(dirTemplate.content, true); -// let dir = null; -// size = dirs.length; -// for (; i < size; i++) { -// const clone = dirClone.cloneNode(true); -// title = dirs[i][0]; -// hash = dirs[i][1]; -// createElmBlock(insertArea, clone, thumbnail, title, hash); -// } -// -// // Insert videos -// let vidClone = document.importNode(vidTemplate.content, true); -// size = videos.length; -// for (i = 0; i < size; i++) { -// const clone = vidClone.cloneNode(true); -// title = videos[i][0]; -// thumbnail = formatURL(videos[i][1]); -// hash = videos[i][2]; -// createElmBlock(insertArea, clone, thumbnail, title, hash, true); -// } -// -// // Insert images -// let imgClone = document.importNode(imgTemplate.content, true); -// thumbnail = ""; -// size = images.length; -// for (i = 0; i < size; i++) { -// title = images[i][0]; -// thumbnail = formatURL("files/" + images[i][1]); -// hash = images[i][1]; -// -// if (thumbnail.match(/000\.(jpg|png|gif)\b/) == null && -// !thumbnail.includes("favicon.png") && !thumbnail.includes("000")) { -// const clone = imgClone.cloneNode(true); -// createElmBlock(insertArea, clone, thumbnail, title, hash); -// } -// } -// -// // Insert files -// let fileClone = document.importNode(filTemplate.content, true); -// size = files.length; -// for (i = 0; i < size; i++) { -// const clone = fileClone.cloneNode(true); -// title = files[i][0]; -// thumbnail = setFileIconType(files[i][0]); -// hash = files[i][1]; -// createElmBlock(insertArea, clone, thumbnail, title, hash); -// } -// } -// -// const createElmBlock = (ulElm, clone, thumbnail, title, hash, isVideo=false) => { -// let containerTag = clone.firstElementChild; -// containerTag.setAttribute("style", "background-image: url('" + thumbnail + "')"); -// containerTag.setAttribute("title", title); -// containerTag.setAttribute("hash", hash); -// -// // If image tag this sink to oblivion since there are no input tags in the template -// try { -// let inputTag = clone.querySelector("input"); -// inputTag.setAttribute("value", title); -// // NOTE: Keeping this just incase i do want to rename stuff... -// // -// // inputTag.addEventListener("dblclick", function (eve) { -// // enableEdit(eve.target); -// // }); -// // inputTag.addEventListener("focusout", function (eve) { -// // disableEdit(eve.target); -// // }); -// } catch (e) { } -// -// if (isVideo) { -// let popoutTag = clone.querySelector(".card-popout-btn"); -// popoutTag.setAttribute("hash", hash); -// popoutTag.addEventListener("click", function (eve) { -// let target = eve.target; -// const hash = target.getAttribute("hash"); -// openWithLocalProgram(hash); -// }); -// } -// -// -// ulElm.appendChild(clone); } - -// const setFileIconType = (fileName) => { -// icoPath = ""; -// -// if (fileName.match(/\.(doc|docx|xls|xlsx|rtf)\b/) != null) { -// icoPath = "static/imgs/icons/doc.png"; -// } else if (fileName.match(/\.(7z|7zip|zip|tar.gz|tar.xz|gz|rar|jar)\b/) != null) { -// icoPath = "resources/images/icons/arc.png"; -// } else if (fileName.match(/\.(pdf)\b/) != null) { -// icoPath = "static/imgs/icons/pdf.png"; -// } else if (fileName.match(/\.(html)\b/) != null) { -// icoPath = "static/imgs/icons/html.png"; -// } else if (fileName.match(/\.(txt|conf)\b/) != null) { -// icoPath = "static/imgs/icons/text.png"; -// } else if (fileName.match(/\.(iso|img)\b/) != null) { -// icoPath = "static/imgs/icons/img.png"; -// } else if (fileName.match(/\.(sh|batch|exe)\b/) != null) { -// icoPath = "static/imgs/icons/scrip.png"; -// } else { -// icoPath = "static/imgs/icons/bin.png"; -// } -// -// return formatURL(icoPath) -// } diff --git a/src/core/static/js/react-ui-logic.js b/src/core/static/js/react-ui-logic.js index 88ccc42..a7af278 100644 --- a/src/core/static/js/react-ui-logic.js +++ b/src/core/static/js/react-ui-logic.js @@ -25,10 +25,26 @@ const setFileIconType = (fileName) => { // Create a ES6 class component class FilesList extends React.Component { // Use the render function to return JSX component + + constructor(props) { + super(props); + this.openThis = this.openThis.bind(this); + this.openThisLocally = this.openThisLocally.bind(this); + } + + openThis(e) { + e.preventDefault(); + openFile(e); + } + + openThisLocally(e) { + e.preventDefault(); + openFileLocally(e); + } + render() { let final = []; let files = this.props.files[0]; - console.log(files); for (let file of files) { final.push( @@ -41,9 +57,9 @@ class FilesList extends React.Component {
{file[0]}
- diff --git a/src/core/static/js/ui-logic.js b/src/core/static/js/ui-logic.js index e27cb69..879b9df 100644 --- a/src/core/static/js/ui-logic.js +++ b/src/core/static/js/ui-logic.js @@ -15,6 +15,12 @@ const scrollFilesToTop = () => { target.scrollTop = 0; } +const openWithLocalProgram = async (hash, extension = "") => { + const url = "run-locally/" + hash; + let data = await fetchData(url); + let message = data.message; + displayMessage(message.text, message.type); +} const updateBackground = (srcLink, isvideo = true) => { diff --git a/src/core/templates/body-header.html b/src/core/templates/body-header.html index 5b13857..58714b2 100644 --- a/src/core/templates/body-header.html +++ b/src/core/templates/body-header.html @@ -28,8 +28,7 @@ - - + {% else %} diff --git a/src/core/templates/pages/react-page.html b/src/core/templates/pages/react-page.html deleted file mode 100644 index 8cdfeda..0000000 --- a/src/core/templates/pages/react-page.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends "layout.html" %} - -{% block header_meta_additional %} -{% endblock header_meta_additional %} - -{% block header_css_additional %} -{% endblock header_css_additional %} - -{% block header_scripts_additional %} -{% endblock header_scripts_additional %} - - -{% block body_header_additional %} -{% endblock body_header_additional %} - -{% block body_content_additional %} -
-
-{% endblock body_content_additional %} - -{% block body_footer_additional %} -{% endblock body_footer_additional %} - - -{% block body_scripts_additional %} - - - - -{% endblock body_scripts_additional %}