Converted to python flask #1

Merged
itdominator merged 49 commits from develop into master 2021-10-03 19:49:44 +00:00
8 changed files with 64 additions and 154 deletions
Showing only changes of commit 16ae96b9cf - Show all commits

View File

@ -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)

View File

@ -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();

View File

@ -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();
});

View File

@ -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)
// }

View File

@ -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 {
<div class="card-body">
<img class="image-style" src={"api/file-manager-action/" + file[1]} alt={file[0]} />
</div>
<div class="card-footer">
<input app={file[1]} class="btn btn-secondary btn-sm" type="button" value="Open"/>
<input app={file[1]} class="btn btn-secondary btn-sm" type="button" value="Open Locally"/>
<div class="card-footer justify-content-right">
<input app={file[1]} onClick={this.openThis} class="btn btn-secondary btn-sm" type="button" value="Open"/>
<input app={file[1]} onClick={this.openThisLocally} class="btn btn-secondary btn-sm" type="button" value="Open Locally"/>
</div>
</div>
</div>

View File

@ -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) => {

View File

@ -28,8 +28,7 @@
<button class="btn btn-sm btn-secondary" data-toggle="modal"
data-target="#favorites-modal">Faves List &#8597;</button>
<button id="tggl-faves-btn" class="btn btn-sm btn-secondary" title="Add/Delete from favorites..." >&#9734;</button>
<button id="lock-folders-btn" class="btn btn-sm btn-secondary" title="Lock unlocked folders..." >&#x1F512;</button>
<button id="scroll-files-to-top-btn" class="btn btn-sm btn-secondary" title="Lock unlocked folders..." >Scroll Files To Top</button>
<button id="scroll-files-to-top-btn" class="btn btn-sm btn-secondary" title="Scroll to top..." >Scroll Files To Top</button>
</div>
</li>
{% else %}

View File

@ -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 %}
<div id="react-container">
</div>
{% endblock body_content_additional %}
{% block body_footer_additional %}
{% endblock body_footer_additional %}
{% block body_scripts_additional %}
<script src="{{ url_for('static', filename='js/post-ajax.js')}}"></script>
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
<script src="{{ url_for('static', filename='js/events.js')}}"></script>
<script src="{{ url_for('static', filename='js/react-ui-logic.js')}}"></script>
{% endblock body_scripts_additional %}