Skip to content

Commit a9c04d0

Browse files
authored
Merge pull request #213 from JuliaDynamics/hw/inspector
fix half commented out css selector
2 parents de2b4c4 + 8dbd30f commit a9c04d0

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

NetworkDynamicsInspector/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NetworkDynamicsInspector"
22
uuid = "0a4713f2-d58f-43f2-b63b-1b5d5ee4e65a"
33
authors = ["Hans Würfel <git@wuerfel.io>"]
4-
version = "0.1.3"
4+
version = "0.1.4"
55

66
[deps]
77
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"

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/timeseries.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ function timeseries_card(app, key, session)
372372
# plot the thing
373373
onany(data, replot; update=true) do _dat, _
374374
task = @task begin
375+
while session.status == Bonito.UNINITIALIZED
376+
sleep(0.1)
377+
end
378+
if session.status == Bonito.CLOSED
379+
@debug "$key: Session closed, aborting plot"
380+
return
381+
end
375382
@debug "$key: Launch plot for valid_idxs[]"
376383
try
377384
empty!(ax)

NetworkDynamicsInspector/src/widgets.jl

Lines changed: 3 additions & 3 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",
597-
# "background-color" => "#2196F3",
598-
),
596+
# CSS(":hover",
597+
# "background-color" => "#2196F3",
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)