fixing faves icon'

This commit is contained in:
maximstewart 2021-02-09 22:15:32 -06:00
parent 5ad243f475
commit 92c94f8ae6
9 changed files with 29 additions and 54 deletions

View File

@ -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..."

View File

@ -51,7 +51,7 @@
}
.viewer {
max-width: 45em;
max-width: 60em;
}

View File

@ -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] : "";

View File

@ -74,7 +74,7 @@ class FilesList extends React.Component {
}
final.push(
<li class="col-sm-12 col-md-6 col-lg-4">
<li class="col-sm-12 col-md-6 col-lg-4" title={name}>
<div class="card">
<div class="card-header">
{card_header}

View File

@ -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 = "";

View File

@ -19,7 +19,6 @@
{% block favorites_modal %}
{% endblock %}
{% endblock body_content_additional %}
{% block body_footer_additional %}
@ -31,5 +30,6 @@
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
<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/video-events.js')}}"></script>
<script src="{{ url_for('static', filename='js/events.js')}}"></script>
{% endblock body_scripts_additional %}

View File

@ -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 %}
<div class="row">
<div class="col justify-content-center text-center">
<h1>{{secret}}</h1>
</div>
</div>
{% endblock body_content_additional %}
{% block body_footer_additional %}
{% endblock body_footer_additional %}
{% block body_scripts_additional %}
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
<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>
{% endblock body_scripts_additional %}

View File

@ -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('/')) )

View File

@ -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(['.', '..'])