Fixed favorites...

This commit is contained in:
Maxim Stewart 2020-10-11 17:48:06 -05:00
parent fc21329546
commit 9318b7768a
4 changed files with 9 additions and 13 deletions

View File

@ -69,9 +69,8 @@ def getAllFavoritesRoute():
@app.route('/load-favorite', methods=['GET', 'POST'], subdomain='webfm')
def loadFavorite():
if request.method == 'POST':
ID = str(request.values['id']).strip()
try:
ID = int(ID)
ID = int(str(request.values['id']).strip())
fave = db.session.query(Favorites).filter_by(id=ID).first()
file_manager.setNewPathFromFavorites(fave.link)
file_manager.loadPreviousPath()
@ -90,19 +89,18 @@ def loadFavorite():
def manageFavoritesRoute():
if request.method == 'POST':
ACTION = str(request.values['action']).strip()
PATH = str(request.values['path']).strip()
path = file_manager.getPath()
if ACTION == "add":
fave = Favorites(link=PATH)
fave = Favorites(link=path)
db.session.add(fave)
msg = "Added to Favorites successfully..."
msg = "Added to Favorites successfully..."
else:
fave = db.session.query(Favorites).filter_by(link=PATH).first()
fave = db.session.query(Favorites).filter_by(link=path).first()
db.session.delete(fave)
msg = "Deleted from Favorites successfully..."
msg = "Deleted from Favorites successfully..."
db.session.commit()
return msgHandler.createMessageJSON("success", msg)
else:
msg = "Can't manage the request type..."

View File

@ -13,8 +13,8 @@ const loadFavoriteLink = async (id) => {
doAjax("load-favorite", data, "load-favorite");
}
const manageFavoritesAjax = async (action, path) => {
const data = "action=" + action + "&path=" + path;
const manageFavoritesAjax = async (action) => {
const data = "action=" + action;
doAjax("manage-favorites", data, "manage-favorites");
}

View File

@ -9,8 +9,7 @@ const manageFavorites = (elm) => {
action = "add";
}
let path = document.getElementById("path").innerHTML;
manageFavoritesAjax(action, path);
manageFavoritesAjax(action);
}

View File

@ -11,7 +11,6 @@ const postAjaxController = (data, action) => {
generateFavesList(data.faves_list);
if (data.hasOwnProperty("refresh")) {
if (data.refresh == "true") {
console.log("here");
reloadDirectory();
}
}