Skip to content

Commit 6fbd1eb

Browse files
author
Andrei Neagu
committed
added service count
1 parent 73db351 commit 6fbd1eb

File tree

1 file changed

+12
-5
lines changed
  • services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/api/frontend/routes

1 file changed

+12
-5
lines changed

services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/api/frontend/routes/_index.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from models_library.projects_nodes_io import NodeID
66
from nicegui import APIRouter, app, ui
77
from nicegui.element import Element
8+
from nicegui.elements.label import Label
89
from settings_library.utils_service import DEFAULT_FASTAPI_PORT
910

1011
from ....services.service_tracker import TrackedServiceModel, get_all_tracked_services
@@ -123,9 +124,12 @@ def _get_hash(items: list[tuple[NodeID, TrackedServiceModel]]) -> int:
123124

124125

125126
class CardUpdater:
126-
def __init__(self, parent_app: FastAPI, container: Element) -> None:
127+
def __init__(
128+
self, parent_app: FastAPI, container: Element, services_count_label: Label
129+
) -> None:
127130
self.parent_app = parent_app
128131
self.container = container
132+
self.services_count_label = services_count_label
129133
self.last_hash: int = _get_hash([])
130134

131135
async def update(self) -> None:
@@ -137,6 +141,7 @@ async def update(self) -> None:
137141
current_hash = _get_hash(tracked_items)
138142

139143
if self.last_hash != current_hash:
144+
self.services_count_label.set_text(f"{len(tracked_services)}")
140145
# Clear the current cards
141146
self.container.clear()
142147
for node_id, service in tracked_items:
@@ -148,13 +153,15 @@ async def update(self) -> None:
148153
@router.page("/")
149154
async def index():
150155
with base_page():
151-
152-
# Initial UI setup
153-
ui.label("Dynamic Item List")
156+
with ui.row().classes("gap-0"):
157+
ui.label("Total tracked services:")
158+
ui.label("").classes("w-1")
159+
with ui.label("0") as services_count_label:
160+
pass
154161

155162
card_container: Element = ui.row()
156163

157-
updater = CardUpdater(get_parent_app(app), card_container)
164+
updater = CardUpdater(get_parent_app(app), card_container, services_count_label)
158165

159166
# render cards when page is loaded
160167
await updater.update()

0 commit comments

Comments
 (0)