I can add tables

Refactoring DbEngine

Fixing unit tests

Fixing unit tests

Fixing unit tests

Refactored DbManager for datagrid

Improving front end performance

I can add new table

Fixed sidebar closing when clicking on it

Fix drag event rebinding, improve listener options, and add debug

Prevent duplicate drag event bindings with a dataset flag and ensure consistent scrollbar functionality. Change wheel event listener to passive mode for better performance. Refactor function naming for consistency, and add debug logs for event handling.

Refactor Datagrid bindings and default state handling.

Updated Javascript to conditionally rebind Datagrid on specific events. Improved Python components by handling empty DataFrame cases and removing redundant code. Revised default state initialization in settings for better handling of mutable fields.

Added Rowindex visualisation support

Working on Debugger with own implementation of JsonViewer

Working on JsonViewer.py

Fixed unit tests

Adding unit tests

I can fold and unfold

fixed unit tests

Adding css for debugger

Added tooltip management

Adding debugger functionalities

Refactor serializers and improve error handling in DB engine

Fixed error where tables were overwritten

I can display footer menu

Working on footer. Refactoring how heights are managed

Refactored scrollbars management

Working on footer menu

I can display footer menu + fixed unit tests

Fixed unit tests

Updated click management

I can display aggregations in footers

Added docker management

Refactor input handling and improve config defaults

Fixed scrollbars colors

Refactored tooltip management

Improved tooltip management

Improving FilterAll
This commit is contained in:
2025-05-11 18:27:32 +02:00
parent e1c10183eb
commit 66ea45f501
70 changed files with 2884 additions and 1258 deletions

View File

@@ -1,42 +1,26 @@
# global layout
import logging.config
import requests
import yaml
from fasthtml.common import *
from assets.css import my_managing_tools_style
from auth.auth_manager import AuthManager
from components.DrawerLayoutOld import DrawerLayout as DrawerLayoutOld
from components.DrawerLayoutOld import Page
from components.addstuff.AddStuffApp import add_stuff_app
from components.addstuff.constants import ROUTE_ROOT as ADD_STUFF_ROUTE_ROOT
from components.datagrid.DataGrid import DATAGRID_PATH, datagrid_app
from components.datagrid_new.DataGridApp import datagrid_new_app
from components.datagrid_new.constants import ROUTE_ROOT as DATAGRID_NEW_ROUTE_ROOT
from components.debugger.DebuggerApp import debugger_app
from components.debugger.constants import ROUTE_ROOT as DEBUGGER_ROUTE_ROOT
from components.drawerlayout.DrawerLayoutApp import drawer_layout_app
from components.drawerlayout.components import DrawerLayout
from components.drawerlayout.components.DrawerLayout import DrawerLayout
from components.drawerlayout.constants import ROUTE_ROOT as DRAWER_LAYOUT_ROUTE_ROOT
from components.form.FormApp import form_app
from components.form.constants import ROUTE_ROOT as FORM_ROUTE_ROOT
from components.login.LoginApp import login_app
from components.login.components.Login import Login
from components.login.constants import ROUTE_ROOT as LOGIN_ROUTE_ROOT
from components.login.constants import Routes as LoginRoutes
from components.page_layout_new import page_layout_new, page_layout_lite
from components.register.RegisterApp import register_app
from components.register.components.Register import Register
from components.register.constants import ROUTE_ROOT as REGISTER_ROUTE_ROOT
from components.register.constants import Routes as RegisterRoutes
from components.tabs.TabsApp import tabs_app
from components.tabs.constants import ROUTE_ROOT as TABS_ROUTE_ROOT
from components.themecontroller.ThemeControllerApp import theme_controller_app
from components.themecontroller.constants import ROUTE_ROOT as THEME_CONTROLLER_ROUTE_ROOT
from constants import Routes
from core.dbengine import DbException
from core.instance_manager import NO_SESSION, NOT_LOGGED, InstanceManager
from core.instance_manager import InstanceManager
from core.settings_management import SettingsManager
from pages.admin_import_settings import AdminImportSettings, IMPORT_SETTINGS_PATH, import_settings_app
from pages.another_grid import get_datagrid2
@@ -52,59 +36,148 @@ with open('logging.yaml', 'r') as f:
# At the top of your script or module
logging.config.dictConfig(config)
logger = logging.getLogger("MainApp")
# daisy_ui_links_v4 = (
# Link(href="https://cdn.jsdelivr.net/npm/daisyui@latest/dist/full.min.css", rel="stylesheet", type="text/css"),
# Script(src="https://cdn.tailwindcss.com"),
# )
daisy_ui_links_v4 = (
Link(href="./assets/daisyui-4.12.10-full-min.css", rel="stylesheet", type="text/css"),
Script(src="./assets/tailwindcss.js"),
)
daisy_ui_links = (
links = [
# start with daisyui
Link(href="https://cdn.jsdelivr.net/npm/daisyui@5", rel="stylesheet", type="text/css"),
Link(href="https://cdn.jsdelivr.net/npm/daisyui@5/themes.css", rel="stylesheet", type="text/css"),
Script(src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"),
)
main_links = (Script(src="./assets/main.js"),
Link(rel="stylesheet", href="./assets/main.css", type="text/css"),)
drawer_layout = (Script(src="./components/drawerlayout/assets/DrawerLayout.js"),
Link(rel="stylesheet", href="./components/drawerlayout/assets/DrawerLayout.css"),)
datagridOld = (Script(src="./components/datagrid/DataGrid.js"),
Link(rel="stylesheet", href="./components/datagrid/DataGrid.css"))
drw_layout_old = (Script(src="./assets/DrawerLayout.js", defer=True),
Link(rel="stylesheet", href="./assets/DrawerLayout.css"))
datagrid = (Script(src="./components/datagrid_new/assets/Datagrid.js"),
Link(rel="stylesheet", href="./components/datagrid_new/assets/Datagrid.css"))
addstuff = (Script(src="./components/addstuff/assets/addstuff.js"),)
tabs = (Script(src="./components/tabs/assets/tabs.js"),
Link(rel="stylesheet", href="./components/tabs/assets/tabs.css"),)
debugger = (Script(type="module", src="./components/debugger/assets/Debugger.js"),)
routes = (
Mount(LOGIN_ROUTE_ROOT, login_app, name="login"),
Mount(REGISTER_ROUTE_ROOT, register_app, name="register"),
Mount(THEME_CONTROLLER_ROUTE_ROOT, theme_controller_app, name="theme_controller"),
Mount(DRAWER_LAYOUT_ROUTE_ROOT, drawer_layout_app, name="main"),
Mount(ADD_STUFF_ROUTE_ROOT, add_stuff_app, name="add_stuff"),
Mount(TABS_ROUTE_ROOT, tabs_app, name="tabs"),
Mount(FORM_ROUTE_ROOT, form_app, name="form"),
Mount(DATAGRID_NEW_ROUTE_ROOT, datagrid_new_app, name="datagrid_new"),
Mount(DEBUGGER_ROUTE_ROOT, debugger_app, name="debugger"),
# Old drawer layout
Script(src="./assets/DrawerLayout.js", defer=True),
Link(rel="stylesheet", href="./assets/DrawerLayout.css"),
# Old datagrid
Script(src="./components/datagrid/DataGrid.js"),
Link(rel="stylesheet", href="./components/datagrid/DataGrid.css"),
# add main
Script(src="./assets/main.js"),
Link(rel="stylesheet", href="./assets/main.css", type="text/css")
]
routes = []
def register_component(name, path, app_module_name):
def _get_fast_app(_module):
if app_module_name is None:
logger.debug(f" No app module defined for {_module.__name__}. Skipping fast app lookup.")
return None
for var_name in dir(_module):
if var_name.endswith('App'):
component_module = getattr(_module, var_name)
logger.debug(f" Found component module {component_module.__name__}")
for sub_var_name in dir(component_module):
if sub_var_name.endswith("_app"):
res = getattr(component_module, sub_var_name)
if isinstance(res, FastHTML):
logger.debug(f" Found FastHTML app component {sub_var_name}")
return res
raise ValueError(f" Cannot find app for component {name}")
def _get_route_root(_module):
if app_module_name is None:
logger.debug(f" No app module defined for {_module.__name__}. Skipping route root lookup.")
return None
constants_module = getattr(_module, "constants")
return getattr(constants_module, "ROUTE_ROOT")
def _get_links(_module):
# Get module file path and construct assets directory path
module_path = os.path.dirname(_module.__file__)
assets_path = os.path.join(module_path, 'assets')
if not os.path.exists(assets_path):
logger.debug(f" No 'assets' folder not found in module {_module.__name__}")
return None
# Find all CSS files in assets directory
files = []
for file in os.listdir(assets_path):
if file.endswith('.css'):
file_path = f'./{os.path.relpath(os.path.join(assets_path, file))}'
files.append(Link(rel="stylesheet", href=file_path, type="text/css"))
logger.debug(f" Found CSS file {file_path}")
elif file.endswith('.js'):
file_path = f'./{os.path.relpath(os.path.join(assets_path, file))}'
files.append(Script(src=file_path))
logger.debug(f" Found JS file {file_path}")
return files if files else None
try:
# Import the module dynamically
logger.debug(f"register_component {name=} {path=} {app_module_name=}")
module = __import__(path, fromlist=['*', app_module_name] if app_module_name else ['*'])
component_app = _get_fast_app(module)
component_route_root = _get_route_root(module)
component_links = _get_links(module)
if component_app is not None:
routes.append(Mount(component_route_root, component_app, name=name))
if component_links is not None:
links.extend(component_links)
except ImportError:
logging.error(f"Could not import module {path}")
def query_mistral(prompt):
"""Send a query to the Mistral model via Ollama API"""
ollama_host = os.environ.get('OLLAMA_HOST', 'http://localhost:11434')
response = requests.post(
f"{ollama_host}/api/generate",
json={
"model": "mistral",
"prompt": prompt,
"stream": False
}
)
return response.json()
register_component("login", "components.login", "LoginApp")
register_component("register", "components.register", "RegisterApp")
register_component("theme_controller", "components.themecontroller", "ThemeControllerApp")
register_component("main_layout", "components.drawerlayout", "DrawerLayoutApp")
register_component("tabs", "components.tabs", "TabsApp") # before repositories
register_component("repositories", "components.repositories", "RepositoriesApp")
register_component("add_stuff", "components.addstuff", None)
register_component("form", "components.form", "FormApp")
register_component("datagrid_new", "components.datagrid_new", "DataGridApp")
register_component("debugger", "components.debugger", "DebuggerApp")
routes.extend([
# old stuffs
Mount(f"/{BASIC_TEST_PATH}", basic_test_app, name="basic test"),
Mount(f"/{DATAGRID_PATH}", datagrid_app, name="datagrid"),
Mount(f"/{IMPORT_SETTINGS_PATH}", import_settings_app, name="import_settings"),
])
old_links = (
# daisy_ui_links_v4
Link(href="./assets/daisyui-4.12.10-full-min.css", rel="stylesheet", type="text/css"),
Script(src="./assets/tailwindcss.js"),
# datagridOld
Script(src="./components/datagrid/DataGrid.js"),
Link(rel="stylesheet", href="./components/datagrid/DataGrid.css"),
# drw_layout_old
Script(src="./assets/DrawerLayout.js", defer=True),
Link(rel="stylesheet", href="./assets/DrawerLayout.css")
)
@@ -133,18 +206,14 @@ bware = Beforeware(before, skip=[r'/favicon\.ico',
app, rt = fast_app(
before=bware,
hdrs=(daisy_ui_links,
main_links, my_managing_tools_style,
drawer_layout, addstuff,
tabs, debugger, datagrid),
hdrs=tuple(links),
live=True,
routes=routes,
routes=tuple(routes),
debug=True,
pico=False,
)
settings_manager = SettingsManager()
settings_manager.init_user(NO_SESSION, NOT_LOGGED)
import_settings = AdminImportSettings(settings_manager, None)
pages = [
@@ -181,7 +250,7 @@ def get(session):
@rt("/test")
def get(session):
return (Title("Another Project Management"),
datagridOld, drw_layout_old, daisy_ui_links_v4,
old_links,
Input(type='checkbox', value='light', cls='toggle theme-controller'),
DrawerLayoutOld(pages),)
@@ -219,4 +288,19 @@ def get(session):
return Titled("I like toast")
serve(port=5001)
if __name__ == "__main__":
# Start your application
print("Application starting...")
print("Checking if Mistral model is available...")
try:
requests.post(
f"{os.environ.get('OLLAMA_HOST', 'http://localhost:11434')}/api/pull",
json={"name": "mistral"}
)
print("Mistral model is ready")
except Exception as e:
print(f"Error pulling Mistral model: {e}")
serve(port=5001)