From 506964c77372d65d3307d20a96e9a41cd74932c6 Mon Sep 17 00:00:00 2001 From: Kobe Date: Mon, 26 May 2025 10:39:39 +0200 Subject: [PATCH] stay on correct settings tab after reload --- __pycache__/models.cpython-313.pyc | Bin 12303 -> 12303 bytes routes/__pycache__/main.cpython-313.pyc | Bin 29236 -> 29370 bytes routes/main.py | 4 +- static/js/settings.js | 39 ++++++++++++++ templates/settings/settings.html | 66 ++++++++++++------------ 5 files changed, 74 insertions(+), 35 deletions(-) diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index ba276ec90d0fab9f020893a1dbf9ecd55171b981..9f733d16cf81d1072f78762626419a100202e8aa 100644 GIT binary patch delta 23 ccmeBA=uhDL%*)Hg00fm9CK>!P8~GRw084HKTmS$7 delta 23 ccmeBA=uhDL%*)Hg00db%#u-i08~GRw08ilt0ssI2 diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index 0b8cc23132900752cadb82233727f7fbba8777ab..ffb86a17017cb2563c566a1ca60a0d197a3b77a0 100644 GIT binary patch delta 653 zcmZ9IU1-x#6vuO#G_@(Ig)S0jhuzlViYRt=qJlmtDEMGgyGd6m>4zFWTAM`iVS?gI z(TUar`l@dQKVZa}V!A;k~@y<07G-oc1cXo*2hXana+YEz}erUU0AL<`T{!M<-K+QK{oGOoC71 zr#%vvWE2^zYy56VxVCX2Cb9y@;zOd%nrhbObEOj{-N1?XYGAPu4|;7u&6(PnLWYzh zB7Tc+*iJRroT?u&^fGaEmf|7BBZ7#-77fiTWQ>AoYDLoYm}CvAD2O|i80gqNvav5T zCr97Q(Wbn)A}&aQo9SwLP72RT;ai2;!KSpOBH%qm7Uu^Bf4W#-ti`bIm^G{XaPXa% z@MZFyXOcd;9N!*Z>-j4}uVZ6)FC4I>k>3t@hFz(%@EotCLjR5Quny9?klM|cfQYJ{g{AY@JiVqYYaXNnpu3EhXjqCkqFIr1exCtVD zy-xi_>y8!$etB^5SQ0K;TaTAn-&0zBK`~A73!fC%3rob6$T4nM--|1uOK`^8EW>wE g1X~;lTe9UpH3qPR*UCL0;QjJBx6Z?$-bcp%0F!LKiU0rr delta 613 zcmdn>lyS=wM!wIyyj%=Gz{g{fp%=W7uRDO34agM+;?Gxr#N>4`3X}IZa!fuKkk8K# z6aa%@mQaQufyoo4g_#+GgeGqk5N2n!WL9C&WShJ%&~#FeBqP&gsUQU=O|How!lWiA z1qrJ#12qUw=-WfJgV{J_A(>BG1=GWb0c8^p}Xeqk55w<7GAtQjuP z4Y#gn+vMPIPsX6lbHo2JG47f?C#r&NH^>=$AomFfg7l$kmStuFYD$TAWz5~YD*81m zW5?uaiMDb_fhu3JfOIn5V#_HmDatIk#adEYkdvy(SafRg$HZX9w#lwZD;SSXewUQU z*tIzzS(%aJI7kC?(TT~`DKc!Qft*{ulMe=oPEJUam^?d`ck=ZVVaEQ+uTxxP&Vy94 z7M%i8MR!01C=QA)fQYM;y;EZudpEC4&16wTax6$L21IZI2~FXmZ6Nl&&Bj@VjBHSi zS=phCjhhc-7cvWM2g&XM5&J>Jr^$}_+FU^%p0T+spPx~TgVl%eGcyC52#8Sl yzyjib5ZOGlpoUQ%q_#*AL@0p>Wgu~j!zMRBr8Fniu83{2Nl`6l0UM(cSQ-E{ak6v( diff --git a/routes/main.py b/routes/main.py index d7773bb..42d4fa2 100644 --- a/routes/main.py +++ b/routes/main.py @@ -331,9 +331,11 @@ def init_routes(main_bp): return redirect(url_for('main.dashboard')) site_settings = SiteSettings.get_settings() + active_tab = request.args.get('tab', 'colors') return render_template('settings/settings.html', primary_color=site_settings.primary_color, - secondary_color=site_settings.secondary_color) + secondary_color=site_settings.secondary_color, + active_tab=active_tab) @main_bp.route('/settings/colors', methods=['POST']) @login_required diff --git a/static/js/settings.js b/static/js/settings.js index c748ad5..81c3e83 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -2,6 +2,45 @@ document.addEventListener('DOMContentLoaded', function() { const primaryColorInput = document.getElementById('primaryColor'); const secondaryColorInput = document.getElementById('secondaryColor'); + // Tab persistence + const settingsTabs = document.querySelectorAll('#settingsTabs button[data-bs-toggle="tab"]'); + const tabContent = document.querySelectorAll('.tab-pane'); + + // Function to activate a specific tab + function activateTab(tabId) { + // Remove active class from all tabs and content + settingsTabs.forEach(tab => { + tab.classList.remove('active'); + tab.setAttribute('aria-selected', 'false'); + }); + tabContent.forEach(content => { + content.classList.remove('show', 'active'); + }); + + // Activate the selected tab + const selectedTab = document.querySelector(`#${tabId}-tab`); + const selectedContent = document.getElementById(tabId); + if (selectedTab && selectedContent) { + selectedTab.classList.add('active'); + selectedTab.setAttribute('aria-selected', 'true'); + selectedContent.classList.add('show', 'active'); + // Save to localStorage + localStorage.setItem('settingsActiveTab', tabId); + } + } + + // Add click event listeners to tabs + settingsTabs.forEach(tab => { + tab.addEventListener('click', (e) => { + const tabId = e.target.getAttribute('data-bs-target').substring(1); + activateTab(tabId); + }); + }); + + // Restore active tab from localStorage or URL hash + const savedTab = localStorage.getItem('settingsActiveTab') || window.location.hash.substring(1) || 'colors'; + activateTab(savedTab); + // Color manipulation functions function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); diff --git a/templates/settings/settings.html b/templates/settings/settings.html index 96b11df..a27b262 100644 --- a/templates/settings/settings.html +++ b/templates/settings/settings.html @@ -23,42 +23,40 @@
-
-
- -
-
-
- -
- {{ colors_tab(primary_color, secondary_color, csrf_token) }} -
+
+ +
+
+
+ +
+ {{ colors_tab(primary_color, secondary_color, csrf_token) }} +
- -
- {{ general_tab() }} -
+ +
+ {{ general_tab() }} +
- -
- {{ security_tab() }} -
+ +
+ {{ security_tab() }}