Fix in app
This commit is contained in:
parent
3a38dd8952
commit
12ea2a085a
2 changed files with 69 additions and 2 deletions
|
|
@ -115,6 +115,7 @@ for app_load in config_admin:
|
|||
|
||||
@admin_app.route('/admin/')
|
||||
def admin():
|
||||
|
||||
return t.load_template('home.phtml', title=I18n.lang('admin', 'admin', 'Admin'))
|
||||
|
||||
"""
|
||||
|
|
@ -394,6 +395,17 @@ def auth_check():
|
|||
|
||||
return {'error': error, 'you_cannot_login': you_cannot_login}
|
||||
|
||||
@admin_app.route('/admin/change_theme/')
|
||||
def change_theme():
|
||||
|
||||
theme_selected=str(request.args.get('theme', '0'))
|
||||
print('Theme '+theme_selected)
|
||||
session['theme']=theme_selected
|
||||
|
||||
error=0
|
||||
|
||||
return {'error': error}
|
||||
|
||||
"""
|
||||
@admin_app.route('/admin/recovery_password/')
|
||||
def recovery_password():
|
||||
|
|
|
|||
|
|
@ -1,3 +1,16 @@
|
|||
<%
|
||||
|
||||
from flask import session
|
||||
|
||||
dark_checked=''
|
||||
dark_css=''
|
||||
|
||||
if session.get('theme', '0')=='1':
|
||||
dark_checked='checked'
|
||||
dark_css='dark'
|
||||
|
||||
|
||||
%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
|
@ -20,7 +33,7 @@ ${load_js()|n}
|
|||
<%block name="extra_header">
|
||||
</%block>
|
||||
</head>
|
||||
<body>
|
||||
<body class="${dark_css}">
|
||||
<div id="layer_loading" style="display:none;"><div id="container_loading"><div class="lds-dual-ring"></div></div></div>
|
||||
<div id="languages_general">
|
||||
</div>
|
||||
|
|
@ -98,7 +111,7 @@ ${load_js()|n}
|
|||
</div>
|
||||
<div class="switch-slider">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="theme" />
|
||||
<input type="checkbox" name="theme" value="1" id="theme" ${dark_checked}/>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -133,12 +146,54 @@ ${load_js()|n}
|
|||
const slider = document.querySelector('input[name="theme"]');
|
||||
|
||||
slider.addEventListener("change", function () {
|
||||
|
||||
//Block button while send to ajax.
|
||||
|
||||
$(this).prop("disabled",true);
|
||||
|
||||
var dark='';
|
||||
|
||||
if (this.checked) {
|
||||
document.body.classList.add("dark");
|
||||
|
||||
dark='1';
|
||||
|
||||
} else {
|
||||
document.body.classList.remove("dark");
|
||||
|
||||
dark='0';
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "${url_for('admin_app.change_theme')}?theme="+dark,
|
||||
type: 'GET',
|
||||
data: {},
|
||||
success: function (data) {
|
||||
|
||||
if(!data.error) {
|
||||
|
||||
console.log('Changed to dark in all pages');
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
console.log('Cannot set dark theme in all pages!');
|
||||
|
||||
}
|
||||
|
||||
$(slider).prop("disabled",false);
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
alert('Error: '+data.status+' '+data.statusText);
|
||||
|
||||
$(slider).prop("disabled", false);
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue