Skip to content

Commit 46fb5d0

Browse files
author
Andrei Neagu
committed
rename
1 parent da197d4 commit 46fb5d0

File tree

2 files changed

+39
-38
lines changed
  • services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/api/frontend/routes

2 files changed

+39
-38
lines changed

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

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ....services.service_tracker import TrackedServiceModel, get_all_tracked_services
1212
from ....services.service_tracker._models import SchedulerServiceState
1313
from .._utils import get_parent_app
14-
from . import marker_tags
14+
from . import markers
1515
from ._render_utils import base_page, get_iso_formatted_date
1616

1717
router = APIRouter()
@@ -49,7 +49,7 @@ def _render_service_details(node_id: NodeID, service: TrackedServiceModel) -> No
4949
),
5050
)
5151

52-
with ui.column().classes("gap-0").mark(marker_tags.INDEX_SERVICE_CARD):
52+
with ui.column().classes("gap-0").mark(markers.INDEX_SERVICE_CARD):
5353
for key, (widget, value) in dict_to_render.items():
5454
with ui.row(align_items="baseline"):
5555
ui.label(key).classes("font-bold")
@@ -63,51 +63,54 @@ def _render_service_details(node_id: NodeID, service: TrackedServiceModel) -> No
6363

6464

6565
def _render_buttons(node_id: NodeID, service: TrackedServiceModel) -> None:
66+
async def _display_confirm_dialog():
67+
with ui.dialog() as confirm_dialog, ui.card():
68+
confirm_dialog.mark(markers.INDEX_SERVICE_CARD_STOP_CONFIRM_DIALOG)
69+
70+
ui.markdown(f"Stop service **{node_id}**?")
71+
ui.label("The service will be stopped and its data will be saved.")
72+
with ui.row():
73+
ui.button(
74+
"Stop",
75+
color="red",
76+
on_click=lambda: confirm_dialog.submit("Stop"),
77+
)
78+
ui.button("No", on_click=lambda: confirm_dialog.submit("No")).mark(
79+
markers.INDEX_SERVICE_CARD_STOP_CONFIRM_DIALOG_NO_BUTTON
80+
)
81+
82+
click_result = await confirm_dialog
83+
84+
if click_result != "Stop":
85+
return
86+
87+
await httpx.AsyncClient(timeout=10).get(
88+
f"http://localhost:{DEFAULT_FASTAPI_PORT}/service/{node_id}:stop"
89+
)
90+
91+
ui.notify(
92+
f"Submitted stop request for {node_id}. Please give the service some time to stop!"
93+
)
94+
6695
with ui.button_group():
6796
ui.button(
6897
"Details",
6998
icon="source",
7099
on_click=lambda: ui.navigate.to(f"/service/{node_id}:details"),
71100
).tooltip("Display more information about what the scheduler is tracking").mark(
72-
marker_tags.INDEX_SERVICE_CARD_DETAILS_BUTTON
101+
markers.INDEX_SERVICE_CARD_DETAILS_BUTTON
73102
)
74103

75104
if service.current_state != SchedulerServiceState.RUNNING:
76105
return
77106

78-
async def display_confirm_dialog():
79-
with ui.dialog() as confirm_dialog, ui.card():
80-
confirm_dialog.mark(marker_tags.INDEX_SERVICE_CARD_STOP_CONFIRM_DIALOG)
81-
82-
ui.markdown(f"Stop service **{node_id}**?")
83-
ui.label("The service will be stopped and its data will be saved.")
84-
with ui.row():
85-
ui.button(
86-
"Stop",
87-
color="red",
88-
on_click=lambda: confirm_dialog.submit("Stop"),
89-
)
90-
ui.button("No", on_click=lambda: confirm_dialog.submit("No")).mark(
91-
marker_tags.INDEX_SERVICE_CARD_STOP_CONFIRM_DIALOG_NO_BUTTON
92-
)
93-
94-
click_result = await confirm_dialog
95-
96-
if click_result != "Stop":
97-
return
98-
99-
await httpx.AsyncClient(timeout=10).get(
100-
f"http://localhost:{DEFAULT_FASTAPI_PORT}/service/{node_id}:stop"
101-
)
102-
103-
ui.notify(
104-
f"Submitted stop request for {node_id}. Please give the service some time to stop!"
105-
)
106-
107107
ui.button(
108-
"Stop service", icon="stop", color="orange", on_click=display_confirm_dialog
108+
"Stop service",
109+
icon="stop",
110+
color="orange",
111+
on_click=_display_confirm_dialog,
109112
).tooltip("Stops the service and saves the data").mark(
110-
marker_tags.INDEX_SERVICE_CARD_STOP_BUTTON
113+
markers.INDEX_SERVICE_CARD_STOP_BUTTON
111114
)
112115

113116

@@ -166,12 +169,10 @@ async def update(self) -> None:
166169
async def index():
167170
with base_page():
168171
with ui.row().classes("gap-0"):
169-
ui.label("Total tracked services:").mark(
170-
marker_tags.INDEX_TOTAL_SERVICES_LABEL
171-
)
172+
ui.label("Total tracked services:").mark(markers.INDEX_TOTAL_SERVICES_LABEL)
172173
ui.label("").classes("w-1")
173174
with ui.label("0") as services_count_label:
174-
services_count_label.mark(marker_tags.INDEX_TOTAL_SERVICES_COUNT_LABEL)
175+
services_count_label.mark(markers.INDEX_TOTAL_SERVICES_COUNT_LABEL)
175176

176177
card_container: Element = ui.row()
177178

0 commit comments

Comments
 (0)