Event updates, list updates, bacend changes

This commit is contained in:
maximstewart 2021-02-08 18:36:55 -06:00
parent 7fedf2f367
commit 0ebdc31f19
30 changed files with 114 additions and 68 deletions

View File

@ -86,7 +86,6 @@ def fileManagerAction(_type, _hash = None):
view.set_to_home() view.set_to_home()
return redirect("/") return redirect("/")
folder = view.get_current_directory() folder = view.get_current_directory()
file = view.get_path_part_from_hash(_hash) file = view.get_path_part_from_hash(_hash)
fpath = os.path.join(folder, file) fpath = os.path.join(folder, file)
@ -100,6 +99,7 @@ def fileManagerAction(_type, _hash = None):
# I.E....this is stupid but for now works better than nothing # I.E....this is stupid but for now works better than nothing
return view.remuxVideo(_hash, fpath) return view.remuxVideo(_hash, fpath)
if _type == "run-locally": if _type == "run-locally":
msg = "Opened media..."
view.openFilelocally(fpath) view.openFilelocally(fpath)
return msgHandler.createMessageJSON("success", msg) return msgHandler.createMessageJSON("success", msg)
@ -140,7 +140,7 @@ def manageFavorites(_action):
if request.method == 'POST': if request.method == 'POST':
ACTION = _action.strip() ACTION = _action.strip()
view = get_window_controller().get_window(1).get_view(0) view = get_window_controller().get_window(1).get_view(0)
path = view.getPath() path = view.get_current_directory()
if ACTION == "add": if ACTION == "add":
fave = Favorites(link=path) fave = Favorites(link=path)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,28 @@
@font-face {
font-family: Dosis;
src: url("/static/css/fonts/dosis/Dosis-Regular.ttf"),
url("/static/css/fonts/dosis/Dosis-Medium.ttf"),
url("/static/css/fonts/dosis/Dosis-Light.ttf"),
url("/static/css/fonts/dosis/Dosis-ExtraLight.ttf"),
url("/static/css/fonts/dosis/Dosis-Bold.ttf"),
url("/static/css/fonts/dosis/Dosis-ExtraBold.ttf"),
url("/static/css/fonts/dosis/Dosis-SemiBold.ttf"),
url("/static/css/fonts/Dosis-VariableFont_wght.ttf"),
url("/static/css/fonts/fa-brands-400.ttf"),
url("/static/css/fonts/fa-regular-400.ttf"),
url("/static/css/fonts/fa-solid-900.ttf");
font-style: normal;
font-display: auto;
}
body {
font-family: Dosis;
}
ul, li {
list-style: none;
}
ul, li { ul, li {
list-style: none; list-style: none;
} }

View File

@ -0,0 +1,8 @@
const getCookie = (cookieKey) => {
return Cookies.get(cookieKey);
}
const setCookie = (key, value, args = { expires: new Date('December 31, 2034 03:24:00'),
path: '/' }) => {
Cookies.set(key, value, args);
}

View File

@ -11,10 +11,10 @@ document.body.onload = (eve) => {
elm.parentElement.removeChild(elm); elm.parentElement.removeChild(elm);
// Stylesheet for iframe views // Stylesheet for iframe views
var link = document.createElement("link"); let link = document.createElement("link");
link.href = formatURL("static/css/iframe.css"); link.href = formatURL("static/css/iframe.css");
link.type = "text/css"; link.type = "text/css";
link.rel = "stylesheet"; link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link); document.getElementsByTagName("head")[0].appendChild(link);
}, 500); }, 500);
} }
@ -22,47 +22,30 @@ document.body.onload = (eve) => {
const openFile = (eve) => { const openFile = (eve) => {
let target = eve.target; const target = eve.target;
let hash = target.getAttribute("app"); const ftype = target.getAttribute("ftype");
listFilesAjax(hash); const title = target.getAttribute("title");
const hash = target.getAttribute("hash");
const parts = title.split('.');
const extension = "." + parts[parts.length - 1].toLowerCase();
if (ftype === "dir") {
listFilesAjax(hash);
} else if (ftype === "video") {
showMedia(hash, extension, "video");
} else {
showMedia(hash, extension, "file");
}
} }
const openFileLocally = (eve) => { const openFileLocally = (eve) => {
let target = eve.target; const target = eve.target;
let hash = target.getAttribute("app"); const hash = target.getAttribute("hash");
openWithLocalProgram(hash); openWithLocalProgram(hash);
} }
// Actions for content
// document.getElementById('file-grid').ondblclick = (event) => {
// let target = event.target;
// let className = target.className;
//
// // Left click detect
// if (event.which == 1) {
// // If clicking on container
// if (className === "dir-style" || className === "video-style" ||
// className === "file-style" || className === "image-style") {
// const title = target.getAttribute("title");
// const hash = target.getAttribute("hash");
// const parts = title.split('.');
// const extension = "." + parts[parts.length - 1].toLowerCase();
//
// if (className === "dir-style") {
// listFilesAjax(hash);
// } else if (className === "video-style") {
// showMedia(hash, extension, "video");
// } else {
// showMedia(hash, extension, "file");
// }
// }
// }
// }

View File

@ -68,7 +68,5 @@ const updateHTMLDirList = async (data) => {
else else
tggl_faves_btn.classList.remove("btn-info"); tggl_faves_btn.classList.remove("btn-info");
console.log(data.list);
renderFilesList(data.list); renderFilesList(data.list);
} }

View File

@ -86,8 +86,8 @@ class FilesList extends React.Component {
{card_body} {card_body}
</div> </div>
<div class="card-footer"> <div class="card-footer">
<input app={hash} onClick={this.openThisLocally} ftype={filetype} class="btn btn-secondary btn-sm float-left" type="button" value="Open Locally"/> <input hash={hash} onClick={this.openThisLocally} ftype={filetype} class="btn btn-secondary btn-sm float-left" type="button" value="Open Locally"/>
<input app={hash} onClick={this.openThis} ftype={filetype} class="btn btn-secondary btn-sm float-right" title={name} type="button" value="Open"/> <input hash={hash} onClick={this.openThis} ftype={filetype} class="btn btn-secondary btn-sm float-right" title={name} type="button" value="Open"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -121,7 +121,7 @@ const setupFile = async (hash, extension) => {
const openWithLocalProgram = async (hash, extension = "") => { const openWithLocalProgram = async (hash, extension = "") => {
const url = "run-locally/" + hash; const url = "api/file-manager-action/run-locally/" + hash;
let data = await fetchData(url); let data = await fetchData(url);
let message = data.message; let message = data.message;
displayMessage(message.text, message.type); displayMessage(message.text, message.type);
@ -186,6 +186,30 @@ const updateBackground = (srcLink, isvideo = true) => {
} }
const manageFavorites = (elm) => {
const classType = "btn-info";
const hasClass = elm.classList.contains(classType);
if (hasClass) {
elm.classList.remove(classType);
action = "delete";
} else {
elm.classList.add(classType);
action = "add";
}
manageFavoritesAjax(action);
}
const loadFave = (id) => {
loadFavoriteLink(id);
document.getElementById("favorites-modal")
.getElementsByClassName("modal-footer")[0]
.children[0].click()
}
// Message handler // Message handler
const displayMessage = (message, type, timeout, msgWindow = "page-alert-zone") => { const displayMessage = (message, type, timeout, msgWindow = "page-alert-zone") => {
let alertField = document.getElementById(msgWindow); let alertField = document.getElementById(msgWindow);

View File

@ -8,11 +8,21 @@
<div id="navbarTogglerHeader" class="row collapse navbar-collapse"> <div id="navbarTogglerHeader" class="row collapse navbar-collapse">
<div class="col-sm"> <div class="col-sm">
{% if current_directory %} {% if current_directory %}
<ul class="navbar-nav">
<li class="nav-item">
<i id="back-btn" class="fa fa-arrow-left" aria-hidden="true" title="Back..." hash="{{dot_dots[1][1]}}">
Back...
</i>
</li>
<li class="nav-item">
<i id="refresh-btn" class="fa fa-refresh" aria-hidden="true" title="Refresh..." hash="{{dot_dots[0][1]}}">
Refresh...
</i>
</li>
<li class="nav-item"> <li class="nav-item">
<div class="input-group input-group-sm justify-content-center"> <div class="input-group input-group-sm justify-content-center">
<button title="Other Options..." class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#options-modal"></button> <button title="Other Options..." class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#options-modal"></button>
<button title="Refresh..." id="refresh-btn" class="btn btn-sm btn-secondary" hash="{{dot_dots[0][1]}}"></button>
<button title="Back..." id="back-btn" class="btn btn-sm btn-secondary" hash="{{dot_dots[1][1]}}"></button>
<input id="search-files-field" type="text" class="form-control" aria-label="Search..." placeholder="Search..." style="max-width: 260px"> <input id="search-files-field" type="text" class="form-control" aria-label="Search..." placeholder="Search..." style="max-width: 260px">
<div class="input-group-prepend"> <div class="input-group-prepend">
@ -27,23 +37,18 @@
<div class="input-group input-group-sm justify-content-center"> <div class="input-group input-group-sm justify-content-center">
<button class="btn btn-sm btn-secondary" data-toggle="modal" <button class="btn btn-sm btn-secondary" data-toggle="modal"
data-target="#favorites-modal">Faves List &#8597;</button> 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="scroll-files-to-top-btn" class="btn btn-sm btn-secondary" title="Scroll to top..." >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> </div>
</li> </li>
{% else %}
<!-- Branding -->
<div class="navbar-brand">
<div class="site-branding"> <li class="nav-item">
<h4 class="site-title"> <button id="tggl-faves-btn" class="btn btn-sm btn-secondary" title="Add/Delete from favorites..." >&#9734;</button>
<a href="{{ url_for('home') }}" title="{{TITLE}} Home" rel="home"> </li>
{{TITLE}}
</a> {% endif %}
</h4> </ul>
<h6 class="site-description">For the files!</h6>
</div>
</div>
{% endif %}
</div> </div>
<div class="col col-lg-auto"> <div class="col col-lg-auto">

View File

@ -5,13 +5,6 @@
{% block header_meta %} {% block header_meta %}
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{% if post %}
<meta name="author" content="{{post.meta_author}}">
<meta name="copyright" content="CC0">
<meta name="description" content="{{post.meta_description}}">
<meta name="keywords" content="{{post.meta_keywords}}">
{% endif %}
<meta name="robots" content="index,follow"> <meta name="robots" content="index,follow">
{% block header_meta_additional %} {% block header_meta_additional %}
{% endblock header_meta_additional %} {% endblock header_meta_additional %}

View File

@ -1,5 +1,6 @@
# Python imports # Python imports
import hashlib import hashlib
import os
from os import listdir from os import listdir
from os.path import isdir, isfile, join from os.path import isdir, isfile, join
@ -85,7 +86,7 @@ class View(Settings, Launcher, Path):
def get_files_formatted(self): def get_files_formatted(self):
files = self.hashSet(self.files), files = self.hashSet(self.files),
dirs = self.hashSet(self.dirs), dirs = self.hashSet(self.dirs),
videos = self.hashSet(self.vids), videos = self.get_videos(),
images = self.hashSet(self.images), images = self.hashSet(self.images),
desktops = self.hashSet(self.desktop), desktops = self.hashSet(self.desktop),
ungrouped = self.hashSet(self.ungrouped) ungrouped = self.hashSet(self.ungrouped)
@ -132,7 +133,16 @@ class View(Settings, Launcher, Path):
return self.hashSet(self.dirs) return self.hashSet(self.dirs)
def get_videos(self): def get_videos(self):
return self.hashSet(self.vids) videos_set = self.hashSet(self.vids)
current_directory = self.get_current_directory()
for video in videos_set:
hashImgPth = join(self.ABS_THUMBS_PTH, video[1]) + ".jpg"
if not os.path.exists(hashImgPth) :
fullPath = join(current_directory, video[0])
self.logger.debug(f"Hash Path: {hashImgPth}\nFile Path: {fullPath}")
self.generateVideoThumbnail(fullPath, hashImgPth)
return videos_set
def get_images(self): def get_images(self):
return self.hashSet(self.images) return self.hashSet(self.images)