Skip to content

Commit 9679145

Browse files
committed
check for served app before screenshot
1 parent f5d5d3c commit 9679145

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

NetworkDynamicsInspector/ext/ElectronExt.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ function NDI.get_electron_window()
5151
length(windows(app)) != 1 && @warn "App contains multiple windows"
5252
first(windows(app))
5353
end
54-
# check window size
55-
if NDI.CURRENT_DISPLAY[] isa NDI.ElectronDisp
56-
x, y = NDI.CURRENT_DISPLAY[].resolution
57-
try
58-
run(NDI.get_electron_app(),
59-
"BrowserWindow.fromId($(window.id)).setSize($x, $y)")
60-
catch e
61-
@warn "Could not resize window: $e"
62-
end
63-
end
6454

6555
return window
6656
end

NetworkDynamicsInspector/src/serving.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ function get_electron_window end
134134

135135
function save_electron_screenshot(path=joinpath(@__DIR__, "screenshot.png"), resize=true)
136136
sync()
137+
if isempty(run(get_electron_window(),
138+
"Array.from(document.querySelectorAll('.graphplot-col, .timeseries-col'))"))
139+
error("No content to screenshot!")
140+
end
137141
resize && _resize_electron_to_content()
138142

139143
path = isabspath(path) ? path : joinpath(pwd(), path)
@@ -173,9 +177,15 @@ function _resize_electron_to_content()
173177
"""
174178
y = run(window, js_max_h)
175179

176-
oldres = CURRENT_DISPLAY[].resolution
177-
resolution = (oldres[1], y)
178-
CURRENT_DISPLAY[] = ElectronDisp(; resolution)
179-
get_electron_window() # trigger resize
180+
# set size
181+
app = get_electron_app()
182+
resize_js = """
183+
{
184+
let window = BrowserWindow.fromId($(window.id));
185+
let size = window.getSize();
186+
window.setSize(size[0], $y);
187+
}
188+
"""
189+
run(app, resize_js)
180190
sleep(3)
181191
end

NetworkDynamicsInspector/src/widgets.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ function Bonito.jsrender(session::Session, toggle::ToggleSwitch)
593593
"transition" => "$(toggle.transition_time)s",
594594
"border-radius" => "$(toggle.height/2)px",
595595
),
596-
# CSS(":hover",
596+
CSS(":hover",
597597
# "background-color" => "#2196F3",
598-
# ),
598+
),
599599
CSS("::before",
600600
"position" => "absolute",
601601
"content" => "''",

docs/src/inspector.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ First, we need to define the system we want to inspect.
6161
end
6262

6363
sol = get_sol()
64+
nothing #hide
6465
```
6566

6667
Now that we have an `ODESolution` `sol`, we can call [`inspect`](@ref) to open the inspector GUI. The docstring provides several options to customize how the app is displayed.

0 commit comments

Comments
 (0)