From 92c94f8ae6454e4f2e99e4632a19b40035850cec Mon Sep 17 00:00:00 2001 From: maximstewart Date: Tue, 9 Feb 2021 22:15:32 -0600 Subject: [PATCH] fixing faves icon' --- src/core/routes/Routes.py | 19 +++++++------- src/core/static/css/main.css | 2 +- src/core/static/js/post-ajax.js | 1 + src/core/static/js/react-ui-logic.js | 2 +- src/core/static/js/ui-logic.js | 14 +++++------ src/core/templates/pages/index.html | 2 +- src/core/templates/pages/protected.html | 33 ------------------------- src/core/utils/shellfm/windows/Path.py | 5 ++++ src/core/utils/shellfm/windows/View.py | 5 ++++ 9 files changed, 29 insertions(+), 54 deletions(-) delete mode 100644 src/core/templates/pages/protected.html diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index 03ff493..7eb6589 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -68,10 +68,10 @@ def listFiles(_hash = None): path = view.get_path_part_from_hash(_hash) view.push_to_path(path) - path = view.get_current_directory() - files = view.get_files_formatted() - fave = db.session.query(Favorites).filter_by(link = path).first() - in_fave = "true" if fave else "false" + sub_path = view.get_current_sub_path() + files = view.get_files_formatted() + fave = db.session.query(Favorites).filter_by(link = sub_path).first() + in_fave = "true" if fave else "false" files.update({'in_fave': in_fave}) return files else: @@ -129,7 +129,6 @@ def loadFavorite(_id): ID = int(_id) fave = db.session.query(Favorites).filter_by(id = ID).first() view = get_window_controller().get_window(1).get_view(0) - print(fave.link) view.set_path_with_sub_path(fave.link) return '{"refresh": "true"}' except Exception as e: @@ -144,16 +143,16 @@ def loadFavorite(_id): @app.route('/api/manage-favorites/<_action>', methods=['GET', 'POST']) def manageFavorites(_action): if request.method == 'POST': - ACTION = _action.strip() - view = get_window_controller().get_window(1).get_view(0) - path = view.get_current_directory() + ACTION = _action.strip() + view = get_window_controller().get_window(1).get_view(0) + sub_path = view.get_current_sub_path() if ACTION == "add": - fave = Favorites(link=path) + fave = Favorites(link = sub_path) db.session.add(fave) msg = "Added to Favorites successfully..." else: - fave = db.session.query(Favorites).filter_by(link = path).first() + fave = db.session.query(Favorites).filter_by(link = sub_path).first() db.session.delete(fave) msg = "Deleted from Favorites successfully..." diff --git a/src/core/static/css/main.css b/src/core/static/css/main.css index 9ab0ce6..edb9d36 100644 --- a/src/core/static/css/main.css +++ b/src/core/static/css/main.css @@ -51,7 +51,7 @@ } .viewer { - max-width: 45em; + max-width: 60em; } diff --git a/src/core/static/js/post-ajax.js b/src/core/static/js/post-ajax.js index 7f16887..a3c1cef 100644 --- a/src/core/static/js/post-ajax.js +++ b/src/core/static/js/post-ajax.js @@ -21,6 +21,7 @@ const postAjaxController = (data, action) => { const updateHTMLDirList = async (data) => { let images = data.list.images[0]; let isInFaves = data.in_fave; + console.log(isInFaves); let background_image = (images[0]) ? images[0][0] : ""; diff --git a/src/core/static/js/react-ui-logic.js b/src/core/static/js/react-ui-logic.js index 905cf43..c91c5ef 100644 --- a/src/core/static/js/react-ui-logic.js +++ b/src/core/static/js/react-ui-logic.js @@ -74,7 +74,7 @@ class FilesList extends React.Component { } final.push( -
  • +
  • {card_header} diff --git a/src/core/static/js/ui-logic.js b/src/core/static/js/ui-logic.js index 0b2a73c..83159cf 100644 --- a/src/core/static/js/ui-logic.js +++ b/src/core/static/js/ui-logic.js @@ -120,22 +120,20 @@ const openWithLocalProgram = async (hash, extension = "") => { const searchPage = () => { let query = document.getElementById('search-files-field').value.toLowerCase(); - let list = document.getElementById("file-grid").querySelectorAll("[title]"); + let list = document.getElementById("files").querySelectorAll("li[title]"); let size = list.length; for (var i = 0; i < size; i++) { - if (!list[i].tagName.includes("SPAN")) { - if (!list[i].title.toLowerCase().includes(query)) { - list[i].style.display = "none"; - } else { - list[i].style.display = ""; - } + if (!list[i].title.toLowerCase().includes(query)) { + list[i].style.display = "none"; + } else { + list[i].style.display = ""; } } } const clearSearch = () => { - let list = document.getElementById("file-grid").querySelectorAll("[title]"); + let list = document.getElementById("files").querySelectorAll("li[title]"); let size = list.length; document.getElementById('search-files-field').value = ""; diff --git a/src/core/templates/pages/index.html b/src/core/templates/pages/index.html index 5185cce..7b7dd74 100644 --- a/src/core/templates/pages/index.html +++ b/src/core/templates/pages/index.html @@ -19,7 +19,6 @@ {% block favorites_modal %} {% endblock %} - {% endblock body_content_additional %} {% block body_footer_additional %} @@ -31,5 +30,6 @@ + {% endblock body_scripts_additional %} diff --git a/src/core/templates/pages/protected.html b/src/core/templates/pages/protected.html deleted file mode 100644 index ad7155c..0000000 --- a/src/core/templates/pages/protected.html +++ /dev/null @@ -1,33 +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 %} -
    -
    -

    {{secret}}

    -
    -
    -{% endblock body_content_additional %} - -{% block body_footer_additional %} -{% endblock body_footer_additional %} - - -{% block body_scripts_additional %} - - - - -{% endblock body_scripts_additional %} diff --git a/src/core/utils/shellfm/windows/Path.py b/src/core/utils/shellfm/windows/Path.py index 8b38456..5d46fbd 100644 --- a/src/core/utils/shellfm/windows/Path.py +++ b/src/core/utils/shellfm/windows/Path.py @@ -31,6 +31,11 @@ class Path: self.path = list( filter(None, path.replace("\\", "/").split('/')) ) self.load_directory() + def set_path_with_sub_path(self, sub_path): + path = os.path.join(self.get_home(), sub_path) + self.path = list( filter(None, path.replace("\\", "/").split('/')) ) + self.load_directory() + def set_to_home(self): home = os.path.expanduser("~") + self.subpath path = list( filter(None, home.replace("\\", "/").split('/')) ) diff --git a/src/core/utils/shellfm/windows/View.py b/src/core/utils/shellfm/windows/View.py index 8ec48ba..9ed9b7d 100644 --- a/src/core/utils/shellfm/windows/View.py +++ b/src/core/utils/shellfm/windows/View.py @@ -123,6 +123,11 @@ class View(Settings, Launcher, Path): def get_current_directory(self): return self.get_path() + def get_current_sub_path(self): + path = self.get_path() + home = self.get_home() + "/" + return path.replace(home, "") + def get_dot_dots(self): return self.hashSet(['.', '..'])