Fixed favorites...
This commit is contained in:
parent
fc21329546
commit
9318b7768a
@ -69,9 +69,8 @@ def getAllFavoritesRoute():
|
|||||||
@app.route('/load-favorite', methods=['GET', 'POST'], subdomain='webfm')
|
@app.route('/load-favorite', methods=['GET', 'POST'], subdomain='webfm')
|
||||||
def loadFavorite():
|
def loadFavorite():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
ID = str(request.values['id']).strip()
|
|
||||||
try:
|
try:
|
||||||
ID = int(ID)
|
ID = int(str(request.values['id']).strip())
|
||||||
fave = db.session.query(Favorites).filter_by(id=ID).first()
|
fave = db.session.query(Favorites).filter_by(id=ID).first()
|
||||||
file_manager.setNewPathFromFavorites(fave.link)
|
file_manager.setNewPathFromFavorites(fave.link)
|
||||||
file_manager.loadPreviousPath()
|
file_manager.loadPreviousPath()
|
||||||
@ -90,19 +89,18 @@ def loadFavorite():
|
|||||||
def manageFavoritesRoute():
|
def manageFavoritesRoute():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
ACTION = str(request.values['action']).strip()
|
ACTION = str(request.values['action']).strip()
|
||||||
PATH = str(request.values['path']).strip()
|
path = file_manager.getPath()
|
||||||
|
|
||||||
if ACTION == "add":
|
if ACTION == "add":
|
||||||
fave = Favorites(link=PATH)
|
fave = Favorites(link=path)
|
||||||
db.session.add(fave)
|
db.session.add(fave)
|
||||||
msg = "Added to Favorites successfully..."
|
msg = "Added to Favorites successfully..."
|
||||||
else:
|
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)
|
db.session.delete(fave)
|
||||||
msg = "Deleted from Favorites successfully..."
|
msg = "Deleted from Favorites successfully..."
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return msgHandler.createMessageJSON("success", msg)
|
return msgHandler.createMessageJSON("success", msg)
|
||||||
else:
|
else:
|
||||||
msg = "Can't manage the request type..."
|
msg = "Can't manage the request type..."
|
||||||
|
@ -13,8 +13,8 @@ const loadFavoriteLink = async (id) => {
|
|||||||
doAjax("load-favorite", data, "load-favorite");
|
doAjax("load-favorite", data, "load-favorite");
|
||||||
}
|
}
|
||||||
|
|
||||||
const manageFavoritesAjax = async (action, path) => {
|
const manageFavoritesAjax = async (action) => {
|
||||||
const data = "action=" + action + "&path=" + path;
|
const data = "action=" + action;
|
||||||
doAjax("manage-favorites", data, "manage-favorites");
|
doAjax("manage-favorites", data, "manage-favorites");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ const manageFavorites = (elm) => {
|
|||||||
action = "add";
|
action = "add";
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = document.getElementById("path").innerHTML;
|
manageFavoritesAjax(action);
|
||||||
manageFavoritesAjax(action, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ const postAjaxController = (data, action) => {
|
|||||||
generateFavesList(data.faves_list);
|
generateFavesList(data.faves_list);
|
||||||
if (data.hasOwnProperty("refresh")) {
|
if (data.hasOwnProperty("refresh")) {
|
||||||
if (data.refresh == "true") {
|
if (data.refresh == "true") {
|
||||||
console.log("here");
|
|
||||||
reloadDirectory();
|
reloadDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user