Skip to content

Commit 64ecfa3

Browse files
committed
Improved UI
1 parent ca4c2f2 commit 64ecfa3

1 file changed

Lines changed: 38 additions & 23 deletions

File tree

src/tdamapper/app.py

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
logger = logging.getLogger(__name__)
1818

1919

20+
GIT_REPO_URL = "https://github.com/lucasimi/tda-mapper-python"
21+
22+
ICON_URL = f"{GIT_REPO_URL}/raw/main/docs/source/logos/tda-mapper-logo-icon.png"
23+
24+
LOGO_URL = f"{GIT_REPO_URL}/raw/main/docs/source/logos/tda-mapper-logo-horizontal.png"
25+
26+
2027
LENS_IDENTITY = "Identity"
2128
LENS_PCA = "PCA"
2229
LENS_UMAP = "UMAP"
@@ -191,24 +198,26 @@ class App:
191198

192199
def __init__(self, storage):
193200
self.storage = storage
194-
with ui.row().classes("w-full h-screen overflow-hidden"):
195-
with ui.column().classes("w-80 h-full overflow-y-auto p-1"):
196-
with ui.card().classes("w-full"):
197-
self._init_file_upload()
198-
with ui.card().classes("w-full"):
199-
self._init_lens()
200-
with ui.card().classes("w-full"):
201-
self._init_cover()
202-
with ui.card().classes("w-full"):
203-
self._init_clustering()
204-
205-
ui.button(
206-
"Run Mapper",
207-
on_click=self.async_run_mapper,
208-
color="primary",
209-
).classes("w-full")
210-
211-
with ui.column().classes("flex-1 h-full overflow-hidden p-1"):
201+
with ui.row().classes("w-full h-screen overflow-hidden p-0 m-0"):
202+
with ui.column().classes("w-96 h-full p-1 m-0"):
203+
with ui.link(target=GIT_REPO_URL, new_tab=True).classes("w-full"):
204+
ui.image(LOGO_URL)
205+
with ui.column().classes("w-96 h-full overflow-y-auto p-1 m-0"):
206+
with ui.card().classes("w-full"):
207+
self._init_file_upload()
208+
with ui.card().classes("w-full"):
209+
self._init_lens()
210+
with ui.card().classes("w-full"):
211+
self._init_cover()
212+
with ui.card().classes("w-full"):
213+
self._init_clustering()
214+
215+
ui.button(
216+
"Run Mapper",
217+
on_click=self.async_run_mapper,
218+
color="primary",
219+
).classes("w-full")
220+
with ui.column().classes("flex-1 h-full overflow-hidden p-1 m-0"):
212221
self._init_plot()
213222

214223
def _init_file_upload(self):
@@ -370,7 +379,7 @@ def _init_clustering(self):
370379
)
371380

372381
def _init_plot(self):
373-
self.plot_container = ui.card().classes("w-full h-full p-1 overflow-hidden")
382+
self.plot_container = ui.card().classes("w-full h-full")
374383

375384
def get_mapper_config(self):
376385
return MapperConfig(
@@ -448,13 +457,20 @@ def load_file(self):
448457
df = self.storage.get("df")
449458
if df is not None:
450459
logger.info("Data loaded successfully.")
451-
ui.notify("File loaded successfully.", type="info")
460+
ui.notify("File loaded successfully.", type="positive")
452461
else:
453462
logger.warning("No data found. Please upload a file first.")
454463
ui.notify("No data found. Please upload a file first.", type="warning")
455464

456465
async def async_run_mapper(self):
457466
df = self.storage.get("df")
467+
if df is None or df.empty:
468+
logger.warning("No data found. Please upload a file first.")
469+
ui.notify("No data found. Please upload a file first.", type="warning")
470+
return
471+
ui.notify("Running Mapper...", type="info")
472+
with self.plot_container:
473+
ui.spinner(size="lg")
458474
mapper_config = self.get_mapper_config()
459475
mapper_fig = await run.cpu_bound(run_mapper, df, **asdict(mapper_config))
460476
mapper_fig.layout.width = None
@@ -463,13 +479,12 @@ async def async_run_mapper(self):
463479
self.plot_container.clear()
464480
with self.plot_container:
465481
logger.info("Displaying Mapper plot.")
466-
ui.plotly(mapper_fig).classes(
467-
"w-full h-full max-h-full max-w-full overflow-hidden"
468-
)
482+
ui.plotly(mapper_fig).classes("w-full h-full")
469483

470484

471485
@ui.page("/")
472486
def main():
487+
ui.query(".nicegui-content").classes("p-0")
473488
storage = app.storage.client
474489
App(storage=storage)
475490

0 commit comments

Comments
 (0)