Skip to content

Commit 6221778

Browse files
committed
clean up settings
1 parent 352004a commit 6221778

File tree

2 files changed

+31
-56
lines changed

2 files changed

+31
-56
lines changed

dashboard/components.py

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,92 +16,78 @@ def _create_controls(batch_name):
1616
"""
1717
state = get_state()
1818
settings_dropdown = DropDownNavContainer(
19-
NavHeaderLi("Chart Settings"),
19+
NavHeaderLi("Settings"),
2020
Li(
2121
DivLAligned(
22-
P("Small Charts", cls="text-sm font-medium"),
2322
Button(
24-
UkIcon("check" if state.small_charts else "x"),
23+
P("Small Charts", cls="text-sm font-medium"),
2524
hx_post=f"/batch/{batch_name}/toggle-size",
2625
hx_target="#main-content",
2726
cls=ButtonT.ghost,
2827
uk_tooltip="Toggle between compact and full-size chart views",
2928
),
30-
cls="flex items-center justify-between w-full px-4 py-2",
29+
cls="flex items-center justify-between w-full px-2 py-2",
3130
)
3231
),
3332
Li(
3433
DivLAligned(
35-
P("Two Columns", cls="text-sm font-medium"),
3634
Button(
37-
UkIcon("check" if state.two_columns else "x"),
35+
P("Two Columns", cls="text-sm font-medium"),
3836
hx_post=f"/batch/{batch_name}/toggle-columns",
3937
hx_target="#main-content",
4038
cls=ButtonT.ghost,
4139
uk_tooltip="Display charts in one or two columns",
4240
),
43-
cls="flex items-center justify-between w-full px-4 py-2",
41+
cls="flex items-center justify-between w-full px-2 py-2",
4442
)
4543
),
4644
Li(
4745
DivLAligned(
48-
P("Show Markers", cls="text-sm font-medium"),
4946
Button(
50-
UkIcon("check" if state.show_markers else "x"),
47+
P("Show Markers", cls="text-sm font-medium"),
5148
hx_post=f"/batch/{batch_name}/toggle-markers",
5249
hx_target="#main-content",
5350
cls=ButtonT.ghost,
5451
uk_tooltip="Show/hide data point markers on the charts",
5552
),
56-
cls="flex items-center justify-between w-full px-4 py-2",
53+
cls="flex items-center justify-between w-full px-2 py-2",
5754
)
5855
),
5956
Li(
6057
DivLAligned(
61-
P("Show Legend", cls="text-sm font-medium"),
6258
Button(
63-
UkIcon("check" if state.show_legend else "x"),
59+
P("Show Legend", cls="text-sm font-medium"),
6460
hx_post=f"/batch/{batch_name}/toggle-legend",
6561
hx_target="#main-content",
6662
cls=ButtonT.ghost,
67-
uk_tooltip="Display chart legends with metric details",
63+
uk_tooltip="Display chart legends",
6864
),
69-
cls="flex items-center justify-between w-full px-4 py-2",
65+
cls="flex items-center justify-between w-full px-2 py-2",
7066
)
7167
),
72-
NavDividerLi(),
7368
Li(
7469
DivLAligned(
75-
P("Dark Mode", cls="text-sm font-medium"),
7670
Button(
77-
UkIcon("check" if state.dark_mode else "x"),
78-
hx_post=f"/batch/{batch_name}/toggle-theme",
71+
P("Narrow Lines", cls="text-sm font-medium"),
72+
hx_post=f"/batch/{batch_name}/toggle-line-width",
7973
hx_target="#main-content",
8074
cls=ButtonT.ghost,
81-
uk_tooltip="Switch between light and dark color themes",
75+
uk_tooltip="Toggle between narrow and normal line thickness",
8276
),
83-
cls="flex items-center justify-between w-full px-4 py-2",
77+
cls="flex items-center justify-between w-full px-2 py-2",
8478
)
8579
),
80+
NavDividerLi(),
8681
Li(
8782
DivLAligned(
88-
P("Line Width", cls="text-sm font-medium"),
89-
Input(
90-
type="number",
91-
name="line_width",
92-
value=state.line_width,
93-
min=1,
94-
max=10,
95-
step=1,
96-
cls="uk-input uk-form-small",
97-
style="width: 60px;",
98-
hx_post=f"/batch/{batch_name}/update-line-width",
99-
hx_target="#charts-container",
100-
hx_trigger="change",
101-
hx_swap="innerHTML",
102-
uk_tooltip="Adjust the thickness of chart lines (1-10)",
83+
Button(
84+
P("Dark Mode", cls="text-sm font-medium"),
85+
hx_post=f"/batch/{batch_name}/toggle-theme",
86+
hx_target="#main-content",
87+
cls=ButtonT.ghost,
88+
uk_tooltip="Switch between light and dark color themes",
10389
),
104-
cls="flex items-center justify-between w-full px-4 py-2",
90+
cls="flex items-center justify-between w-full px-2 py-2",
10591
)
10692
),
10793
)

dashboard/routes.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -458,25 +458,14 @@ def post(batch_name: str, session=None):
458458
)
459459

460460

461-
@rt("/batch/{batch_name}/update-line-width")
462-
def post(batch_name: str, line_width: int = 2):
461+
@rt("/batch/{batch_name}/toggle-line-width")
462+
def post(batch_name: str, session=None):
463463
"""
464-
Update the line width for a given batch name.
464+
Toggle between narrow (1px) and normal (2px) line width.
465465
"""
466-
try:
467-
# Ensure line width is within valid range
468-
app.state.line_width = max(1, min(10, int(line_width)))
469-
app.state.chart_cache.clear() # Clear cache to regenerate charts
470-
471-
# Only regenerate the charts, maintaining the id and grid layout
472-
metric_stats = app.state.stats_cache[batch_name]
473-
return [
474-
*[
475-
ChartManager.create_chart_placeholder(
476-
stat["metric_name"], i, batch_name
477-
)
478-
for i, stat in enumerate(metric_stats)
479-
]
480-
]
481-
except ValueError:
482-
return "Invalid line width value"
466+
app.state.narrow_lines = not getattr(app.state, 'narrow_lines', False)
467+
app.state.line_width = 1 if app.state.narrow_lines else 2
468+
app.state.chart_cache.clear() # Clear cache to regenerate charts
469+
return get_batch_view(
470+
batch_name, session=session, initial_load=DEFAULT_LOAD_N_CHARTS
471+
)

0 commit comments

Comments
 (0)