04/22 user dashboard view, no credentials popup automatically
This commit is contained in:
@@ -362,7 +362,24 @@ class UserDashboardView(ttk.Frame):
|
||||
activeforeground=COLOURS["accent"],
|
||||
relief="flat", font=FONT_SMALL, cursor="hand2",
|
||||
padx=10, pady=4,
|
||||
).pack()
|
||||
).pack(pady=(0, 6))
|
||||
|
||||
# 🔑 Credentials button — only shown if this site has saved credentials
|
||||
try:
|
||||
from models import get_website_credentials
|
||||
creds = get_website_credentials(wid)
|
||||
except Exception:
|
||||
creds = []
|
||||
if creds:
|
||||
tk.Button(
|
||||
btn_frame, text="🔑 Credentials",
|
||||
command=lambda s=site, c=creds: CredentialsPopup(self, s["name"], c),
|
||||
bg=COLOURS["surface2"], fg=COLOURS["text"],
|
||||
activebackground=COLOURS["accent"],
|
||||
activeforeground=COLOURS["white"],
|
||||
relief="flat", font=FONT_SMALL, cursor="hand2",
|
||||
padx=10, pady=4,
|
||||
).pack()
|
||||
|
||||
# ─── Bulk Actions ─────────────────────────────────────────────────────────
|
||||
|
||||
@@ -507,11 +524,6 @@ class UserDashboardView(ttk.Frame):
|
||||
except Exception as e:
|
||||
show_error(f"Could not open URL:\n{e}")
|
||||
|
||||
from models import get_website_credentials
|
||||
creds = get_website_credentials(site["id"])
|
||||
if creds:
|
||||
CredentialsPopup(self, site["name"], creds)
|
||||
|
||||
def _mark_checked(self, site: dict):
|
||||
try:
|
||||
from models import mark_website_checked
|
||||
@@ -647,22 +659,39 @@ class CredentialsPopup(tk.Toplevel):
|
||||
label = cred.get("label") or "Default"
|
||||
tk.Label(frame, text=label, font=FONT_BOLD,
|
||||
bg=COLOURS["surface"], fg=COLOURS["accent"]).grid(
|
||||
row=0, column=0, columnspan=4, sticky="w", padx=10, pady=(4, 2))
|
||||
row=0, column=0, columnspan=6, sticky="w", padx=10, pady=(4, 2))
|
||||
|
||||
# ── Username row ──────────────────────────────────────────────────
|
||||
tk.Label(frame, text="Username:", bg=COLOURS["surface"],
|
||||
fg=COLOURS["text_dim"]).grid(
|
||||
row=1, column=0, sticky="w", padx=(10, 4))
|
||||
tk.Label(frame, text=cred["username"], bg=COLOURS["surface"],
|
||||
fg=COLOURS["text"], font=FONT_BOLD).grid(
|
||||
row=1, column=1, sticky="w", padx=(0, 20))
|
||||
row=1, column=1, sticky="w", padx=(0, 8))
|
||||
|
||||
user_copy_btn = tk.Button(
|
||||
frame, text="📋", width=3,
|
||||
bg=COLOURS["surface2"], fg=COLOURS["text_dim"],
|
||||
activebackground=COLOURS["accent"], activeforeground=COLOURS["white"],
|
||||
relief="flat", cursor="hand2", font=FONT_SMALL,
|
||||
)
|
||||
user_copy_btn.grid(row=1, column=2, padx=(0, 16))
|
||||
|
||||
def _copy_user(c=cred, b=user_copy_btn):
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append(c["username"])
|
||||
b.config(text="✔", fg=COLOURS["success"])
|
||||
self.after(2000, lambda: b.config(text="📋", fg=COLOURS["text_dim"]))
|
||||
user_copy_btn.config(command=_copy_user)
|
||||
|
||||
# ── Password row ──────────────────────────────────────────────────
|
||||
tk.Label(frame, text="Password:", bg=COLOURS["surface"],
|
||||
fg=COLOURS["text_dim"]).grid(
|
||||
row=1, column=2, sticky="w", padx=(0, 4))
|
||||
row=1, column=3, sticky="w", padx=(0, 4))
|
||||
pw_var = tk.StringVar(value="••••••••")
|
||||
tk.Label(frame, textvariable=pw_var, bg=COLOURS["surface"],
|
||||
fg=COLOURS["text"], font=FONT_BOLD).grid(
|
||||
row=1, column=3, sticky="w")
|
||||
row=1, column=4, sticky="w", padx=(0, 4))
|
||||
|
||||
revealed = [False]
|
||||
def toggle(c=cred, v=pw_var, r=revealed):
|
||||
@@ -671,7 +700,24 @@ class CredentialsPopup(tk.Toplevel):
|
||||
tk.Button(frame, text="👁", command=toggle,
|
||||
bg=COLOURS["surface"], fg=COLOURS["text_dim"],
|
||||
relief="flat", cursor="hand2").grid(
|
||||
row=1, column=4, padx=(8, 10))
|
||||
row=1, column=5, padx=(0, 4))
|
||||
|
||||
pw_copy_btn = tk.Button(
|
||||
frame, text="📋", width=3,
|
||||
bg=COLOURS["surface2"], fg=COLOURS["text_dim"],
|
||||
activebackground=COLOURS["accent"], activeforeground=COLOURS["white"],
|
||||
relief="flat", cursor="hand2", font=FONT_SMALL,
|
||||
)
|
||||
pw_copy_btn.grid(row=1, column=6, padx=(0, 10))
|
||||
|
||||
def _copy_pw(c=cred, b=pw_copy_btn):
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append(c["password"])
|
||||
b.config(text="✔", fg=COLOURS["success"])
|
||||
# Auto-clear clipboard after 15 s for security
|
||||
self.after(15_000, self.clipboard_clear)
|
||||
self.after(2000, lambda: b.config(text="📋", fg=COLOURS["text_dim"]))
|
||||
pw_copy_btn.config(command=_copy_pw)
|
||||
|
||||
ttk.Button(self, text="Close", command=self.destroy).pack(pady=16)
|
||||
self._centre()
|
||||
|
||||
Reference in New Issue
Block a user