diff --git a/src/lib/db/__init__.py b/src/lib/db/__init__.py
index bad5971..8e2ccf7 100644
--- a/src/lib/db/__init__.py
+++ b/src/lib/db/__init__.py
@@ -63,3 +63,4 @@ Users.register(username="USER", password="user")
if True:
# crud_db must be imported after db and models_reference are available
from .crud_db import Crud_DB
+
diff --git a/src/main.py b/src/main.py
index 5ae3806..9a17125 100644
--- a/src/main.py
+++ b/src/main.py
@@ -12,6 +12,7 @@ from datetime import datetime
from pathlib import Path
from ui.diagnostics import Diagnostics
from lib.helpers.single_process import SingleProcess
+from ui.logs_management.info import Logs_Management
if platform.system().lower() == "windows":
sys.path.append(f"{os.getcwd()}\src\components")
@@ -71,7 +72,7 @@ try:
from lib.helpers import ConfigReader
from PyQt5.QtCore import QObject, QThread, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QApplication, QMessageBox
- from ui import About, Archive, Login, Main_Window, Test, Users_Management, Recipe_Selection, \
+ from ui import About, Archive, Login, Main_Window, Test, Users_Management,Logs_Management ,Recipe_Selection, \
Barcode_Recipe_Selection
if "--vision" in sys.argv:
@@ -190,6 +191,8 @@ try:
self.main_window.about_a.triggered.connect(
lambda checked, selfie=weakref.ref(self): selfie().main_window.open_dialog(About()))
+ self.main_window.download_a.triggered.connect(
+ lambda checked, selfie=weakref.ref(self): selfie().main_window.open_dialog(Logs_Management()))
self.main_window.quit_a.triggered.connect(quit_app)
self.main_window.users_management_a.triggered.connect(
lambda checked, selfie=weakref.ref(self): selfie().main_window.open_dialog(Users_Management()))
diff --git a/src/ui/__init__.py b/src/ui/__init__.py
index b4b958b..8388ade 100644
--- a/src/ui/__init__.py
+++ b/src/ui/__init__.py
@@ -2,6 +2,7 @@ from .widget import Widget
from .window import Window
from .dialog import Dialog
from .about import About
+from .logs_management import Logs_Management
from .archive import Archive
from .barcodes_step_editor import Barcodes_Step_Editor
from .barcode_recipe_selection import Barcode_Recipe_Selection
diff --git a/src/ui/logs_management/__init__.py b/src/ui/logs_management/__init__.py
new file mode 100644
index 0000000..dd4009c
--- /dev/null
+++ b/src/ui/logs_management/__init__.py
@@ -0,0 +1 @@
+from .info import Logs_Management
diff --git a/src/ui/logs_management/info.py b/src/ui/logs_management/info.py
new file mode 100644
index 0000000..2a79f8f
--- /dev/null
+++ b/src/ui/logs_management/info.py
@@ -0,0 +1,69 @@
+import traceback
+
+from lib.db import log # Presumendo che esista un modulo per accedere alla tabella "log"
+from PyQt5.QtWidgets import QMessageBox, QTableWidget
+from ui.crud import Crud, Line_Edit_Cell_Widget
+from ui.widget import Widget
+
+
+class Logs_Management(Widget):
+ def __init__(self):
+ super().__init__()
+
+ class Info_Line_Edit_Cell_Widget(Line_Edit_Cell_Widget):
+ def render(self, data, row_number=None, crud=None):
+ super().render(data, row_number=row_number, crud=crud)
+
+ def parse(self, action=None, row_number=None, crud=None):
+ return self.text()
+
+ crud_aliases = {
+ "time": "Data",
+ "info_type": "Operazione",
+ "info": "Info",
+ }
+ self.crud = Crud(
+ "log",
+ display_name="LOG MANAGEMENT",
+ readonly=["id"],
+ select=list(crud_aliases.keys()),
+ fields_aliases=crud_aliases,
+ autocomplete={},
+ widget_classes={
+ "time": Info_Line_Edit_Cell_Widget,
+ "info_type": Info_Line_Edit_Cell_Widget,
+ "info": Info_Line_Edit_Cell_Widget,
+ },
+ row_filter=self.row_filter
+ )
+
+ self.layout().addWidget(self.crud, 0, 0, -1, -1)
+
+ # Adjust the column widths based on content
+ self.adjust_column_widths()
+
+ def adjust_column_widths(self):
+ """Adjust the widths of columns to fit their content."""
+ # Assuming self.crud has an attribute 'table' that is a QTableWidget or QTableView
+ if hasattr(self.crud, 'table') and isinstance(self.crud.table, (QTableWidget,)):
+ self.crud.table.resizeColumnsToContents()
+
+ def row_filter(self, row, row_number, crud):
+ try:
+ if row["info_type"] != "Download":
+ return False, None, False
+
+ log_entry = log.generate(
+ id=row["id"],
+ time=row["time"],
+ info_type=row["info_type"],
+ info=row["info"]
+ )
+ except AssertionError as e:
+ self.log.exception(traceback.format_exc())
+ self.crud.set_row_color(row_number, "red")
+ QMessageBox.critical(None, "Errore Salvataggio DB", f"Errore alla riga {row_number}:\n{str(e)}")
+ return False, None, True
+
+ row.update(log_entry)
+ return True, row, False
diff --git a/src/ui/logs_management/logs_management.ui b/src/ui/logs_management/logs_management.ui
new file mode 100644
index 0000000..9c4a9af
--- /dev/null
+++ b/src/ui/logs_management/logs_management.ui
@@ -0,0 +1,20 @@
+
+
+ Logs_Management
+
+
+
+ 0
+ 0
+ 94
+ 18
+
+
+
+ Logs Management
+
+
+
+
+
+
diff --git a/src/ui/main_window/main_window.ui b/src/ui/main_window/main_window.ui
index 73a6db4..d67b0ee 100644
--- a/src/ui/main_window/main_window.ui
+++ b/src/ui/main_window/main_window.ui
@@ -38,6 +38,7 @@
Informazioni
+