mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-07-01 19:26:53 +02:00
Add JSON integrity hash checks
This commit is contained in:
@@ -510,3 +510,46 @@ class AssetClaimDialog(tk.Toplevel):
|
||||
return
|
||||
self.destroy()
|
||||
self.on_created(str(result["claim"]["claim_id"]))
|
||||
|
||||
|
||||
class IntegrityWarningDialog(tk.Toplevel):
|
||||
def __init__(
|
||||
self,
|
||||
master: tk.Misc,
|
||||
*,
|
||||
title: str,
|
||||
warnings: list[str],
|
||||
on_confirm: Callable[[], None],
|
||||
):
|
||||
super().__init__(master)
|
||||
self.on_confirm = on_confirm
|
||||
self.title(title)
|
||||
self.transient(master.winfo_toplevel())
|
||||
self.resizable(False, False)
|
||||
self.warnings = warnings
|
||||
self._build_ui()
|
||||
self.bind("<Escape>", lambda _event: self.destroy())
|
||||
self.after_idle(self._activate_modal)
|
||||
|
||||
def _build_ui(self) -> None:
|
||||
frame = ttk.Frame(self, padding=18)
|
||||
frame.pack(fill="both", expand=True)
|
||||
message = (
|
||||
"ACHTUNG: Die zugehörigen JSON-Dateien wurden vermutlich extern geändert.\n\n"
|
||||
"Haben Sie alle Daten geprüft und soll der Hash jetzt aktualisiert werden?"
|
||||
)
|
||||
ttk.Label(frame, text=message, justify="left").grid(row=0, column=0, sticky="w")
|
||||
ttk.Label(frame, text="\n".join(f"• {item}" for item in self.warnings), style="Warning.TLabel", justify="left").grid(
|
||||
row=1, column=0, sticky="w", pady=(12, 0)
|
||||
)
|
||||
buttons = ttk.Frame(frame)
|
||||
buttons.grid(row=2, column=0, sticky="e", pady=(18, 0))
|
||||
ttk.Button(buttons, text="Nein", command=self.destroy).pack(side="left", padx=(0, 8))
|
||||
ttk.Button(buttons, text="Ja, bestätigen", style="Accent.TButton", command=self._confirm).pack(side="left")
|
||||
|
||||
def _activate_modal(self) -> None:
|
||||
_activate_modal_window(self)
|
||||
|
||||
def _confirm(self) -> None:
|
||||
self.destroy()
|
||||
self.on_confirm()
|
||||
|
||||
Reference in New Issue
Block a user