04/24 fix bugs

This commit is contained in:
2026-04-24 08:08:35 -04:00
parent 6ec439bafe
commit 07bae2a724
5 changed files with 1124 additions and 58 deletions
+56 -18
View File
@@ -68,6 +68,13 @@ class App(tk.Tk):
"""Initialise database schema, then proceed to login."""
try:
initialize_database()
# Signal the DB log handler that the pool is ready so queued
# startup log records are flushed to app_log immediately.
try:
from config import db_log_handler
db_log_handler.install()
except Exception:
pass
except Exception as e:
messagebox.showerror(
"Database Error",
@@ -148,28 +155,37 @@ class App(tk.Tk):
self._nav_buttons = {}
self._active_section = None
# nav_groups is a list of (group_label, items) tuples.
# group_label=None means no section header — used for the user role.
# A separator is rendered between every group automatically.
if self.current_user["role"] == "admin":
nav_items = [
("🏠 Dashboard", "dashboard", self._show_dashboard),
("👤 Users", "users", self._show_users),
("🌐 Websites", "websites", self._show_websites),
("🗓 Shifts", "shift_mgmt", self._show_shift_mgmt),
("📋 Activity Log", "log", self._show_log),
("📊 My Shifts", "shifts", self._show_shifts),
("📑 Reports", "reports", self._show_reports),
("📧 Email Reports","email", self._show_email_settings),
("🤖 AI Summary", "ai_summary", self._show_ai_summary),
("📌 Bid Tracker", "bid_tracker", self._show_bid_tracker),
("⚙ Settings", "settings", self._show_settings),
nav_groups = [
("MANAGEMENT", [
("🏠 Dashboard", "dashboard", self._show_dashboard),
("👤 Users", "users", self._show_users),
("🌐 Websites", "websites", self._show_websites),
("🗓 Shifts", "shift_mgmt", self._show_shift_mgmt),
("📑 Reports", "reports", self._show_reports),
("📋 Activity Log", "log", self._show_log),
("📧 Email Reports", "email", self._show_email_settings),
(" Settings", "settings", self._show_settings),
]),
("MY WORKSPACE", [
("📊 My Shifts", "shifts", self._show_shifts),
("🤖 AI Summary", "ai_summary", self._show_ai_summary),
("📌 Bid Tracker", "bid_tracker", self._show_bid_tracker),
]),
]
else:
nav_items = [
("📊 My Shifts", "shifts", self._show_shifts),
("🤖 AI Summary", "ai_summary", self._show_ai_summary),
("📌 Bid Tracker", "bid_tracker", self._show_bid_tracker),
nav_groups = [
(None, [
("📊 My Shifts", "shifts", self._show_shifts),
("🤖 AI Summary", "ai_summary", self._show_ai_summary),
("📌 Bid Tracker", "bid_tracker", self._show_bid_tracker),
]),
]
for label, key, cmd in nav_items:
def _make_nav_btn(label, key, cmd):
btn = tk.Button(
sidebar,
text=label,
@@ -182,12 +198,34 @@ class App(tk.Tk):
anchor="w",
font=FONT_BOLD,
padx=20,
pady=12,
pady=10,
cursor="hand2",
)
btn.pack(fill="x")
self._nav_buttons[key] = btn
for i, (group_label, items) in enumerate(nav_groups):
# Separator between groups (not before the first one)
if i > 0:
ttk.Separator(sidebar, orient="horizontal").pack(
fill="x", pady=4)
# Section header label (skip for user role where label is None)
if group_label:
tk.Label(
sidebar,
text=group_label,
bg=COLOURS["surface"],
fg=COLOURS["text_dim"],
font=(FONT_SMALL[0], 8, "bold"),
anchor="w",
padx=20,
pady=4,
).pack(fill="x")
for label, key, cmd in items:
_make_nav_btn(label, key, cmd)
# Spacer + user info at bottom
ttk.Separator(sidebar, orient="horizontal").pack(fill="x", side="bottom", pady=8)
user_frame = tk.Frame(sidebar, bg=COLOURS["surface"], pady=10)