Added modal logic, fixed favorites logic
This commit is contained in:
parent
e7d588691e
commit
781d2ece5a
@ -16,7 +16,8 @@ from core.utils import Logger
|
|||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
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)
|
oidc = OpenIDConnect(app)
|
||||||
login_manager = LoginManager(app)
|
login_manager = LoginManager(app)
|
||||||
|
@ -18,6 +18,7 @@ class Config(object):
|
|||||||
TITLE = APP_NAME
|
TITLE = APP_NAME
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TESTING = False
|
TESTING = False
|
||||||
|
THREADED =True
|
||||||
SECRET_KEY = secrets.token_hex(32)
|
SECRET_KEY = secrets.token_hex(32)
|
||||||
|
|
||||||
PERMANENT_SESSION_LIFETIME = timedelta(days = 7).total_seconds()
|
PERMANENT_SESSION_LIFETIME = timedelta(days = 7).total_seconds()
|
||||||
@ -55,6 +56,7 @@ class DevelopmentConfig(Config):
|
|||||||
DEBUG = True
|
DEBUG = True
|
||||||
OIDC_ID_TOKEN_COOKIE_SECURE = False
|
OIDC_ID_TOKEN_COOKIE_SECURE = False
|
||||||
OIDC_REQUIRE_VERIFIED_EMAIL = False
|
OIDC_REQUIRE_VERIFIED_EMAIL = False
|
||||||
|
USE_RELOADER = True
|
||||||
|
|
||||||
|
|
||||||
class TestingConfig(Config):
|
class TestingConfig(Config):
|
||||||
|
@ -124,7 +124,8 @@ def loadFavorite(_id):
|
|||||||
ID = int(_id)
|
ID = int(_id)
|
||||||
fave = db.session.query(Favorites).filter_by(id = ID).first()
|
fave = db.session.query(Favorites).filter_by(id = ID).first()
|
||||||
view = get_window_controller().get_window(1).get_view(0)
|
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"}'
|
return '{"refresh": "true"}'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(repr(e))
|
print(repr(e))
|
||||||
|
@ -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 openFile = (eve) => {
|
||||||
const target = eve.target;
|
const target = eve.target;
|
||||||
|
@ -8,8 +8,7 @@ const postAjaxController = (data, action) => {
|
|||||||
if (data.hasOwnProperty('path_head'))
|
if (data.hasOwnProperty('path_head'))
|
||||||
updateHTMLDirList(data);
|
updateHTMLDirList(data);
|
||||||
if (data.hasOwnProperty('faves_list'))
|
if (data.hasOwnProperty('faves_list'))
|
||||||
// generateFavesList(data.faves_list);
|
renderFavesList(data);
|
||||||
console.log("faves stub...");
|
|
||||||
if (data.hasOwnProperty("refresh")) {
|
if (data.hasOwnProperty("refresh")) {
|
||||||
if (data.refresh == "true") {
|
if (data.refresh == "true") {
|
||||||
reloadDirectory();
|
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) => {
|
const updateHTMLDirList = async (data) => {
|
||||||
let images = data.list.images[0];
|
let images = data.list.images[0];
|
||||||
|
54
src/core/static/js/react-ui-logic.js
vendored
54
src/core/static/js/react-ui-logic.js
vendored
@ -30,10 +30,7 @@ const setFileIconType = (fileName) => {
|
|||||||
return [icoPath, ftype]
|
return [icoPath, ftype]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a ES6 class component
|
|
||||||
class FilesList extends React.Component {
|
class FilesList extends React.Component {
|
||||||
// Use the render function to return JSX component
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.openThis = this.openThis.bind(this);
|
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(
|
||||||
|
<li onClick={this.loadFaveEvent} faveid={_faveId} class="btn btn-secondary btn-sm" name={name} title={name}>
|
||||||
|
{name}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
{final}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const renderFilesList = (data = null) => {
|
const renderFilesList = (data = null) => {
|
||||||
const filesListElm = document.getElementById('files');
|
const filesListElm = document.getElementById('files');
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
@ -109,3 +149,11 @@ const renderFilesList = (data = null) => {
|
|||||||
filesListElm
|
filesListElm
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderFavesList = (data = null) => {
|
||||||
|
const favesListElm = document.getElementById("faves-list");
|
||||||
|
ReactDOM.render(
|
||||||
|
React.createElement(FavoritesList, data),
|
||||||
|
favesListElm
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const reloadDirectory = () => {
|
const reloadDirectory = () => {
|
||||||
let target = document.getElementById('refresh-btn')
|
const target = document.getElementById('refresh-btn');
|
||||||
const hash = target.getAttribute("hash");
|
const hash = target.getAttribute("hash");
|
||||||
listFilesAjax(hash);
|
listFilesAjax(hash);
|
||||||
}
|
}
|
||||||
@ -172,8 +172,6 @@ const disableEdit = (elm) => {
|
|||||||
const updateBackground = (srcLink, isvideo = true) => {
|
const updateBackground = (srcLink, isvideo = true) => {
|
||||||
try {
|
try {
|
||||||
let elm = document.getElementById("bg");
|
let elm = document.getElementById("bg");
|
||||||
|
|
||||||
console.log(srcLink);
|
|
||||||
if (isvideo) {
|
if (isvideo) {
|
||||||
if (elm.getAttribute('src') === "") {
|
if (elm.getAttribute('src') === "") {
|
||||||
elm.src = srcLink;
|
elm.src = srcLink;
|
||||||
@ -201,7 +199,7 @@ const manageFavorites = (elm) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const loadFave = (id) => {
|
const loadFavorite = (id) => {
|
||||||
loadFavoriteLink(id);
|
loadFavoriteLink(id);
|
||||||
document.getElementById("favorites-modal")
|
document.getElementById("favorites-modal")
|
||||||
.getElementsByClassName("modal-footer")[0]
|
.getElementsByClassName("modal-footer")[0]
|
||||||
|
@ -91,6 +91,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% include "modals/options-modal.html" %}
|
||||||
|
{% include "modals/favorites-modal.html" %}
|
||||||
|
{% include "modals/file-modal.html" %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block body_scripts %}
|
{% block body_scripts %}
|
||||||
<!-- For Bootstrap in this exact order... -->
|
<!-- For Bootstrap in this exact order... -->
|
||||||
<script src="{{ url_for('static', filename='js/libs/bootstrap/jquery-3.3.1.slim.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/libs/bootstrap/jquery-3.3.1.slim.min.js')}}"></script>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
{% extends "pages/index.html" %}
|
|
||||||
|
|
||||||
{% block favorites_modal %}
|
{% block favorites_modal %}
|
||||||
<!-- Favorites modal -->
|
<!-- Favorites modal -->
|
||||||
<div class="modal fade" id="favorites-modal" tabindex="-1" role="dialog">
|
<div class="modal fade" id="favorites-modal" tabindex="-1" role="dialog">
|
@ -1,3 +1,4 @@
|
|||||||
|
{% block file_modal %}
|
||||||
<!-- File viewer modal -->
|
<!-- File viewer modal -->
|
||||||
<div class="modal fade" id="file-view-modal" tabindex="-1" role="dialog">
|
<div class="modal fade" id="file-view-modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog modal-xl" role="document">
|
<div class="modal-dialog modal-xl" role="document">
|
||||||
@ -75,3 +76,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock file_modal %}
|
@ -1,3 +1,4 @@
|
|||||||
|
{% block options_modal %}
|
||||||
<!-- Other Options modal -->
|
<!-- Other Options modal -->
|
||||||
<div class="modal fade" id="options-modal" tabindex="-1" role="dialog">
|
<div class="modal fade" id="options-modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog modal-xl" role="document">
|
<div class="modal-dialog modal-xl" role="document">
|
||||||
@ -40,3 +41,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock options_modal %}
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
{% block body_scripts_additional %}
|
{% block body_scripts_additional %}
|
||||||
<script type="text/babel" src="{{ url_for('static', filename='js/react-ui-logic.js')}}"></script>
|
<script type="text/jsx" src="{{ url_for('static', filename='js/react-ui-logic.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
|
<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/post-ajax.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
|
||||||
|
@ -11,4 +11,4 @@ eventlet.monkey_patch()
|
|||||||
from core import app
|
from core import app
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=False)
|
app.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user