diff --git a/src/core/__init__.py b/src/core/__init__.py index 6b8c7e1..8f92ea8 100644 --- a/src/core/__init__.py +++ b/src/core/__init__.py @@ -16,7 +16,8 @@ from core.utils import Logger app = Flask(__name__) -app.config.from_object("core.config.Config") +app.config.from_object("core.config.ProductionConfig") +# app.config.from_object("core.config.DevelopmentConfig") oidc = OpenIDConnect(app) login_manager = LoginManager(app) diff --git a/src/core/config.py b/src/core/config.py index 7dd22cf..98044eb 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -18,6 +18,7 @@ class Config(object): TITLE = APP_NAME DEBUG = False TESTING = False + THREADED =True SECRET_KEY = secrets.token_hex(32) PERMANENT_SESSION_LIFETIME = timedelta(days = 7).total_seconds() @@ -55,6 +56,7 @@ class DevelopmentConfig(Config): DEBUG = True OIDC_ID_TOKEN_COOKIE_SECURE = False OIDC_REQUIRE_VERIFIED_EMAIL = False + USE_RELOADER = True class TestingConfig(Config): diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index f5e675a..4284a9d 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -124,7 +124,8 @@ 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) - view.set_path(fave.link) + print(fave.link) + view.set_path_with_sub_path(fave.link) return '{"refresh": "true"}' except Exception as e: print(repr(e)) diff --git a/src/core/static/js/events.js b/src/core/static/js/events.js index b42b1ec..de003d1 100644 --- a/src/core/static/js/events.js +++ b/src/core/static/js/events.js @@ -21,7 +21,11 @@ document.body.onload = (eve) => { } - +const loadFavePath = (e) => { + const target = e.target; + const faveId = target.getAttribute("faveid"); + loadFavorite(faveId); +} const openFile = (eve) => { const target = eve.target; diff --git a/src/core/static/js/post-ajax.js b/src/core/static/js/post-ajax.js index b47255e..7f16887 100644 --- a/src/core/static/js/post-ajax.js +++ b/src/core/static/js/post-ajax.js @@ -8,8 +8,7 @@ const postAjaxController = (data, action) => { if (data.hasOwnProperty('path_head')) updateHTMLDirList(data); if (data.hasOwnProperty('faves_list')) - // generateFavesList(data.faves_list); - console.log("faves stub..."); + renderFavesList(data); if (data.hasOwnProperty("refresh")) { if (data.refresh == "true") { reloadDirectory(); @@ -18,31 +17,6 @@ const postAjaxController = (data, action) => { } -const generateFavesList = (data) => { - let listView = document.getElementById("faves-list"); - clearChildNodes(listView); - - data.forEach(faveArry => { - let fave = faveArry[0] - let faveId = faveArry[1] - let liTag = document.createElement("LI"); - let parts = (fave.includes("/")) ? fave.split("/") : fave.split("\\"); - - let part = parts[parts.length - 1] - if (part.toLowerCase().includes("season")) { - part = parts[parts.length - 2] + "/" + part - } - - let txtNode = document.createTextNode(part); - liTag.setAttribute("class", "btn btn-secondary btn-sm"); - liTag.setAttribute("name", fave); - liTag.setAttribute("title", fave); - liTag.setAttribute("onclick", "loadFave(" + faveId +")"); - liTag.appendChild(txtNode); - listView.appendChild(liTag); - }); -} - const updateHTMLDirList = async (data) => { let images = data.list.images[0]; diff --git a/src/core/static/js/react-ui-logic.js b/src/core/static/js/react-ui-logic.js index e18520b..1ffb972 100644 --- a/src/core/static/js/react-ui-logic.js +++ b/src/core/static/js/react-ui-logic.js @@ -30,10 +30,7 @@ const setFileIconType = (fileName) => { return [icoPath, ftype] } -// Create a ES6 class component class FilesList extends React.Component { - // Use the render function to return JSX component - constructor(props) { super(props); this.openThis = this.openThis.bind(this); @@ -102,6 +99,49 @@ class FilesList extends React.Component { } } + +class FavoritesList extends React.Component { + constructor(props) { + super(props); + this.loadFaveEvent = this.loadFaveEvent.bind(this); + } + + loadFaveEvent(e) { + e.preventDefault(); + loadFavePath(e); + } + + render() { + let final = []; + let faves = this.props.faves_list; + + for (let fave of faves) { + let title = fave[0] + let _faveId = fave[1] + let liTag = document.createElement("LI"); + let parts = (title.includes("/")) ? title.split("/") : title.split("\\"); + + let name = parts[parts.length - 1] + if (name.toLowerCase().includes("season")) { + name = name[name.length - 2] + "/" + name + } + + final.push( +