refactor: sequential scan, screens for details, new sidebar layout
All checks were successful
Build and Release .deb / build-deb (push) Successful in 21s
All checks were successful
Build and Release .deb / build-deb (push) Successful in 21s
- Scan sequential with asyncio.to_thread for proper Textual integration
- Use push_screen/pop_screen for package/CVE lists (no more mount/remove)
- Sidebar now shows 'APT X CVE X' with right-aligned indicators
- Loader uses black circles (⚫) for pending tasks
- Removed unused package_table.py and cve_table.py
This commit is contained in:
parent
2237d83ddd
commit
76eb75d4a6
7 changed files with 150 additions and 319 deletions
80
full_updater/ui/detail_screens.py
Normal file
80
full_updater/ui/detail_screens.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
from textual.screen import Screen
|
||||
from textual.widgets import DataTable, Button, Static
|
||||
from textual.containers import Vertical, Horizontal
|
||||
|
||||
try:
|
||||
import pyperclip
|
||||
PYPERCLIP_OK = True
|
||||
except Exception:
|
||||
PYPERCLIP_OK = False
|
||||
|
||||
|
||||
class PackageListScreen(Screen):
|
||||
BINDINGS = [("b", "back", "Retour")]
|
||||
|
||||
def __init__(self, packages: list[dict]):
|
||||
super().__init__()
|
||||
self.packages = packages
|
||||
|
||||
def compose(self):
|
||||
with Vertical():
|
||||
with Horizontal(id="pkg-toolbar"):
|
||||
yield Button("⬅ Retour", id="pkg-back", variant="default")
|
||||
table = DataTable(id="pkg-table")
|
||||
table.add_columns("Nom", "Version actuelle", "Nouvelle version", "Taille")
|
||||
for pkg in self.packages:
|
||||
table.add_row(pkg.get("name", "?"), pkg.get("current", "?"), pkg.get("new", "?"), pkg.get("size", "-"))
|
||||
yield table
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed):
|
||||
if event.button.id == "pkg-back":
|
||||
self.app.pop_screen()
|
||||
|
||||
def action_back(self):
|
||||
self.app.pop_screen()
|
||||
|
||||
|
||||
class CVEListScreen(Screen):
|
||||
BINDINGS = [("b", "back", "Retour")]
|
||||
|
||||
def __init__(self, cves: list[dict]):
|
||||
super().__init__()
|
||||
self.cves = cves
|
||||
self.urls = {}
|
||||
|
||||
def compose(self):
|
||||
with Vertical():
|
||||
with Horizontal(id="cve-toolbar"):
|
||||
yield Button("⬅ Retour", id="cve-back", variant="default")
|
||||
table = DataTable(id="cve-table")
|
||||
table.add_columns("CVE-ID", "Paquet", "Lien")
|
||||
table.cursor_type = "row"
|
||||
for i, cve in enumerate(self.cves):
|
||||
cve_id = cve.get("id", "?")
|
||||
pkg = cve.get("package", "?")
|
||||
url = cve.get("url", "")
|
||||
self.urls[i] = url
|
||||
table.add_row(cve_id, pkg, url)
|
||||
yield table
|
||||
|
||||
def on_data_table_row_selected(self, event: DataTable.RowSelected):
|
||||
row_key = event.row_key
|
||||
row_index = list(self.query_one("#cve-table").rows.keys()).index(row_key)
|
||||
url = self.urls.get(row_index, "")
|
||||
if not url:
|
||||
return
|
||||
if PYPERCLIP_OK:
|
||||
try:
|
||||
pyperclip.copy(url)
|
||||
self.notify(f"Lien copié : {url}", severity="information")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
self.notify(f"Lien (copie manuelle) : {url}", severity="warning")
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed):
|
||||
if event.button.id == "cve-back":
|
||||
self.app.pop_screen()
|
||||
|
||||
def action_back(self):
|
||||
self.app.pop_screen()
|
||||
Loading…
Add table
Add a link
Reference in a new issue